Sales Order Payments - Cash Book Rcts change  Topic is solved

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

Sales Order Payments - Cash Book Rcts change

Postby DannyC » Fri Jul 22, 2016 2:31 pm

Hi,

When a sales order payment is created, Jwia automatically creates a Cash Book Receipts batch in the background.
I need to change the bank account on the created cash book receipt.
I can't work out how to do it.

The bank account change will be based on the sales order branch/division, so a different back acct for each division.
It would also mean a new batch (on the same day) would need to be created for different divisions.

Can you point me in the right direction?

Cheers

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

Re: Sales Order Payments - Cash Book Rcts change  Topic is solved

Postby Mike.Sheen » Sun Jul 31, 2016 2:33 pm

Hi Danny,

In the payment processing part of the code, we do the following:

Code: Select all
For Each payment As Payment In SalesOrderPayments
                RaiseEvent PaymentProcessingStart(Me, payment)

                If payment.Processed = False AndAlso payment.ProcessPayment Then
                    If SystemSettings.UsePaymentTypeBankAccounts Then
                        BankAccount = payment.PaymentType.LedgerAccount
                    Else
                        If SystemSettings.ChildDebtorsUseChildGLAccounts OrElse Debtor.ParentDebtor.DebtorID = "" Then
                            BankAccount = Debtor.LedgerDebtorSourcedReceipts
                        Else
                            BankAccount = Debtor.ParentDebtor.LedgerDebtorSourcedReceipts
                        End If
                    End If


So, you can add a handler for the PaymentProcessingStart event and in there set the Debtor.LedgerDebtorSourcedReceipts or payment.PaymentType.LedgerAccount (depending on how your UsePaymentTypeBankAccounts system setting is set) account by doing a Read on that entity - and then our payment processing code will use that account.

For example - after adding the "Sales Order Entry" to the business logic tab of your plugin, use the following code:

Code: Select all
Public Class BusinessLogicPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaBusinessLogicPlugin

    Public Overrides Function InitializeLifetimeService() As Object
        ' returning null here will prevent the lease manager
        ' from deleting the Object.
        Return Nothing
    End Function

    Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = JiwaBusinessLogic
      AddHandler salesOrder.PaymentProcessingStart, AddressOf PaymentProcessingStart
    End Sub
   
   Private Sub PaymentProcessingStart(SalesOrder As JiwaSales.SalesOrder.SalesOrder, Payment As JiwaSales.SalesOrder.Payment)
      If SalesOrder.Branch.Description = "Perth" Then
         ' Override the bank account
         If SalesOrder.SystemSettings.UsePaymentTypeBankAccounts Then
            If SalesOrder.SystemSettings.ChildDebtorsUseChildGLAccounts OrElse SalesOrder.Debtor.ParentDebtor.DebtorID = "" Then
               SalesOrder.Debtor.LedgerDebtorSourcedReceipts.ReadRecordFromAccountNo("1000-000-01")
            Else               
               SalesOrder.Debtor.ParentDebtor.LedgerDebtorSourcedReceipts.ReadRecordFromAccountNo("1000-000-01")
            End If
         Else
            payment.PaymentType.LedgerAccount.ReadRecordFromAccountNo("1000-000-01")
         End If
      End If
   End Sub

End Class


Let us know if that works for you.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Sales Order Payments - Cash Book Rcts change

Postby indikad » Tue Aug 30, 2016 5:06 pm

Hi Mike,

I have taken this project over from Danny.
have tried the code you supplied and cannot get it to work - not sure if its running too as the debug msgbox too does not pop up
( is it because its on the Business Logic plugin ?)
see my code below - only difference is the gl code and the message box.
can you advise pls ? What we want is the Bank Legder code to change - ( under the description field on header on a Cash Book receipt )
thanks.
Code: Select all
 Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
'      If TypeOf JiwaBusinessLogic Is JiwaSales.SalesOrder.SalesOrder
'         Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = JiwaBusinessLogic
'            AddHandler salesOrder.PaymentProcessingStart, AddressOf PaymentProcessingStart   
'      End If
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = JiwaBusinessLogic
      AddHandler salesOrder.PaymentProcessingStart, AddressOf PaymentProcessingStart
    End Sub
   Private Sub PaymentProcessingStart(SalesOrder As JiwaSales.SalesOrder.SalesOrder, Payment As JiwaSales.SalesOrder.Payment)
      msgbox (" att_Bakery_CashBookReceiptDefaultGL  - at work ")
      If SalesOrder.Branch.Description = "Perth" Then
         ' Override the bank account
         If SalesOrder.SystemSettings.UsePaymentTypeBankAccounts Then
            If SalesOrder.SystemSettings.ChildDebtorsUseChildGLAccounts OrElse SalesOrder.Debtor.ParentDebtor.DebtorID = "" Then
               SalesOrder.Debtor.LedgerDebtorSourcedReceipts.ReadRecordFromAccountNo("1200-200-00")
            Else               
               SalesOrder.Debtor.ParentDebtor.LedgerDebtorSourcedReceipts.ReadRecordFromAccountNo("1200-200-00")
            End If
         Else
            payment.PaymentType.LedgerAccount.ReadRecordFromAccountNo("1200-200-00")
         End If
      End If
   End Sub
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Sales Order Payments - Cash Book Rcts change

Postby indikad » Mon Jan 23, 2017 9:38 am

attn Mike - Just trying to get attention to my reply above. Could you advise pls ?
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Sales Order Payments - Cash Book Rcts change

Postby Mike.Sheen » Mon Jan 23, 2017 9:48 am

Instead of a messagebox, put in a System.Diagnostics.Debugger.Launch() to determine if your code is actually running. Messageboxes will still display if invoked in business logic - but you've got to be mindful that there won't always be a user to display the messagebox to (e.g.: services).

If the debugger does not launch, then the PaymentProcessingStart event is not being raised by the sales order processing - which would occur if there were no payments on the sales order - there are payments on the sales order, right?

I missed your question because this was marked as answered after a few weeks of inactivity after I responded - Danny should have marked this topic as unanswered, or responded!
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Sales Order Payments - Cash Book Rcts change

Postby indikad » Mon Jan 23, 2017 10:11 am

Thanks Mike. I will follow your recommendations.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 0 guests