Stop Jiwa firing VerifyPayments()  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Stop Jiwa firing VerifyPayments()

Postby DannyC » Tue Jan 17, 2023 12:37 pm

I have a client who wants to set up cash debtors and just display a warning if payments on the sales order don't meet the history total when processing.
Just a warning, with a yes/no to proceed if they want to.

At the moment the VerifyPayments() routine runs so , if a cash account is set up, and the system setting AllowSalesOrderSaveForCashOnlyDebtors is true, then it displays the message from VerifyPayments and the exception stops processing.

So I want to remove Jiwa's VerifyPayments and roll my own.

Best way of doing that?
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Stop Jiwa firing VerifyPayments()

Postby Mike.Sheen » Tue Jan 17, 2023 3:58 pm

DannyC wrote:So I want to remove Jiwa's VerifyPayments and roll my own.

Best way of doing that?


I've logged DEV-9746 to improve the event so you can via plugin signal you don't want the built-in validation performed.

In the meantime you will need to trick the system by setting the SalesOrder.Debtor.IsCashOnly to false temporarily (after preserving existig value) in a handler for VerifyPaymentsStart, and the set it back to what it was in VerifyPaymentsEnd. This will cause the built-in validation to be skipped.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Stop Jiwa firing VerifyPayments()  Topic is solved

Postby SBarnes » Tue Jan 17, 2023 3:59 pm

Below is the code for verify payments, given there is clearly a verify payment start event and verify payments end event, why not simply set AllowSalesOrderSaveForCashOnlyDebtors to true in the start and then in the end event do your own code and reset the setting.

I haven't tested it but it should work.


Code: Select all
Public Sub VerifyPayments()
            OnVerifyPaymentsStart()

            If _CreditNote = False AndAlso _Debtor.IsCashOnly Then
                If (_IsProcessing) OrElse (_IsProcessing = False AndAlso SystemSettings.AllowSalesOrderSaveForCashOnlyDebtors = False) Then
                    Dim freightAmount = SalesOrderHistorys((SelectedHistoryNo)).CartageCharge1.IncGSTAmount + SalesOrderHistorys((SelectedHistoryNo)).CartageCharge2.IncGSTAmount + SalesOrderHistorys((SelectedHistoryNo)).CartageCharge3.IncGSTAmount
                    If SalesOrderPayments.TotalPayments < (SalesOrderLines.OrderedIncGSTTotal + freightAmount) Then
                        Throw New JiwaApplication.Exceptions.CreditTermsViolationException(String.Format("'{0}' is a cash only customer - you must ensure the invoice is fully paid before continuing.", _Debtor.AccountNoDashName))
                    End If
                End If
            End If

            OnVerifyPaymentsEnd()
        End Sub
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Stop Jiwa firing VerifyPayments()

Postby Mike.Sheen » Tue Jan 17, 2023 4:01 pm

SBarnes wrote:why not simply set AllowSalesOrderSaveForCashOnlyDebtors to true in the start and then in the end event do your own code reset the setting.


That's even better than setting SalesOrder.Debtor.IsCashOnly as I suggested.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 30 guests

cron