When a payment is made or received toward an invoice, either on the vendor side or on the customer side, the transactions have to settle against each other in order to close the transaction. Obviously, the standard functionality in AX lets the users take care of this in a very neat way using the payment journal form where they can enter the payment into AX and mark the invoices to settle the payment against, as shown in the following screenshot:
However, you might find yourself creating an integration that should take care of this automatically and then it would be nice to know how to do this using AX, right?
Ok, so let's assume that a payment has been registered by the customer account shown in the form shown previosly (3001), but the settlement hasn't been done yet and it is our task to write the code that takes care of it:
The following code should then do the trick:
static void settlePayment(Args _args) { CustTable custTable; CustTrans invCustTrans, payCustTrans...