Sales order doing somthing before printing  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Sales order doing somthing before printing

Postby DannyC » Tue Jul 28, 2015 4:46 pm

Hi,

I want to fire a plugin before printing - it will check the Alt Account No of the debtor and based on the value, do stuff.

My question is fairly simple. I cannot seem to get the AltAccountNo to display. I have a msgbox just to confirm, but it is showing a blank even though I know the debtor has an altAccountno. I have
Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaApplication.IJiwaForm)
      AddHandler salesOrderForm.SalesOrder.Printing, AddressOf SOPrinting
    End Sub
   
   Private Sub SOPrinting (sender As Object, e As System.eventargs, ByRef Report As JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast( sender , JiwaSales.SalesOrder.SalesOrder)
      msgbox(salesorder.Debtor.AltAccountNo)
      msgbox(Report.DocumentType)
      If salesorder.Debtor.AltAccountNo = "PROFORMA" Then
         MessageBox.Show("PROFORMA CUSTOMER")
      End If
   End Sub   

Is there some trick to getting the AltAccountNo?

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Sales order doing somthing before printing  Topic is solved

Postby Scott.Pearce » Tue Aug 18, 2015 3:57 pm

It looks like the debtor entity used by the sales order object is in fact inherited from Entities.Debtor.Debtor with an overridden ReadRecord that does *not* read the AltAccountNo for you. You should read the AltAccountNo yourself. Here's the easiest way:

Code: Select all
Dim myDebtorEntity As New JiwaApplication.Entities.Debtor.Debtor
myDebtorEntity.ReadRecord(salesOrder.Debtor.RecID)
msgbox(myDebtorEntity.AltAccountNo)


See that I'm declaring my own variable of type JiwaApplication.Entities.Debtor.Debtor as opposed to type JiwaSales.SalesOrder.Debtor? Then I read using the *proper* debtor entity, feeding the RecID from the sales order overridden debtor entity (which doesn't have the all data we want).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 2 guests