Step 3: Exploring the MYOB Acumatica Source Code

In this step, you will explore the source code of the Invoices (SO303000) and Payments and Applications (AR302000) forms of MYOB Acumatica. You will explore the code of these forms to learn the field names and methods you need to use in order to determine where and when to fire the event that triggers the transition from the PendingPayment state to the ReadyForAssignment state.

Learning Field Names

To determine whether an invoice has been prepaid and whether the event that triggers the transition from the PendingPayment state to the ReadyForAssignment state should be fired, you need to calculate the percentage of the invoice amount that has been prepaid.

To calculate this percentage, you need the outstanding amount of the invoice and the original amount of the invoice. These values are displayed in the Balance and Amount boxes, respectively, of the Invoices (SO303000) form. Thus, to calculate the percentage, you should learn the field names of these boxes by doing the following:
  1. In MYOB Acumatica, open the Invoices form.
  2. To open the Element Inspector for the Balance box, press Ctrl + Alt and click the box.

    In the Element Properties dialog box, which opens, notice that the Balance box is defined by the CuryDocBal field of the ARInvoice data access class.

  3. To open the Element Inspector for the Amount box, press Ctrl + Alt and click the box.
    In the Element Properties dialog box, which opens, notice that the Amount box is defined by the CuryOrigDocAmt field of the ARInvoice data access class.
    Tip: If you do not see the Amount box on the form, you need to select the Validate Document Totals on Entry check box on the Accounts Receivable Preferences(AR101000) form, open or refresh the Invoices form, and then perform this instruction.

Exploring the Source Code of the Release Method

To fire the event that triggers the transition from the PendingPayment to ReadyForAssignment state, you need to first override the method where the outstanding amount of the invoice (which you just explored) is calculated and updated. This recalculation is performed on release of the prepayment that is applied to an invoice. Thus, to find the method to override, you need to explore the code of the action that is associated with the Release button on the Payments and Applications (AR302000) form.

If you explore the code of the Release button (as described in Step 3: Exploring and Debugging the Code), you can notice that the amounts of the invoice, including the CuryDocBal field value, are recalculated in the UpdateBalances method of the ARReleaseProcess class. To make sure this is the right method to override, add a breakpoint to the UpdateBalances method, run the application in debug mode, and trace how the CuryDocBal value is changed in the method.

As a result of this debugging, you can see that UpdateBalances is the method that you should override to calculate the prepaid percentage of the invoice and to fire the event that triggers the transition from the PendingPayment state to the ReadyForAssignment state.