Thursday, October 22, 2009

AX 2009 Settlement of Invoice and Payments (AR)

AX 2009 settles Invoices and Payments by Customer account.

This is all high level btw so take it for what it is. It's not meant to be a end all be all of this. Just a good reference to understand how it all fits together.

The functionality for settling transactions can be done by looking at the Clicked method on the CustOpenTrans's Update Now button. It makes a call to CustTrans::settleTransacti(CustTable) where custTable is the customer that needs the settlements done.

A limitation of AX is to not allow the user to specifically point the marked payments/invoices to each other. It instead goes on a first in first out type settlement process based on the transactions that are marked. A modification would be needed for this functionality.

This is why the only thing that is needed is the customer table record. It will use the CustTable record's SpecTrans records for determining which records to try to settle (SpecTransRecId field).

Ultimately, all fun happens in the Class CustVendSettle's SettleNow method. This class is very large and does the actual 'settlement' logic.

As of AX 2009 SP1, this is how the method works:

1st parameter - The settling is done one company at a time

2nd parameter – The table Id of what we are settling (e.g. CustTable).

3rd parameter – The rec Id of what we are settling (e.g. CustTable record).

4th parameter – Boolean. Defaults to true. If true, handles the posting profile difference for the debit and credit transaction and also adjust tax on prepayment transactions. Value becomes negligible if the transaction is a prepayment (both Credit and Debit types).

Financial assistance: Invoices are Debits, Payments are Credits

The whole process will grab the first marked invoice (debit) transaction to settle based on what was marked. It will then grab the first marked payment (credit). When a transaction is marked through the open transaction editing form, it will create a specTrans record which ties to that customer and the respective open transaction. The specTrans record is grabbed based on three criteria:

  1. Company (SpecTrans.SpecCompany)
    1. Value is from 1st parameter of the settleNow method
  2. Table Id (SpecTrans.SpecTableId)
    1. Value is from 1st parameter of the settleNow method
  3. Rec Id (SpecTrans.SpecRecId)
    1. Value is from 1st parameter of the settleNow method

They link this record 1:1 to a record that has the same criteria on the table 'CustVendTransOpen'

It will grab the remaining debit amount from the open debit transaction.

The debit and credit records will only be processed if both the debit and credit side of things are not done (still open transactions to settle against). It will not process is there is a credit transaction left and not a debit. Both must be there.

This is where all the actual posting/financial fun happens. I am omitting it is there is a lot and this entry is not going into detail about that stuff. This is only about the processing of the marked transactions for settling at a high level.

After the process has determined that all of the transactions have marked against each other, it will process the transactions that still have a balance after the settlement. If the unsettled amount is under the set limit, under/over transactions are created.

The whole process ends by calling the method. It then deletes the SpecTrans records even though I think they are already gone at this point.

If you have questions or corrections, feel free to add them in the comments. Hope this helps out!


  1. Check this post for a more comprehensive explanation with code

  2. Thanks for posting on my blog. I don't advertise it at all so I'm glad you found this however you did. I apparently don't get notified when people post on things :-) Not sure how to fix that... Came across this post drinking a beer post client work...

    I would hesitate to say more comprehensive but I would definitely say supplemental and beneficial.

    I will definitely peruse your blog posts. Always great to connect with other AX people!

  3. Great knowledge, do anyone mind merely reference back to it online invoice app