Automatic mark a Settlement Transactions on a Payment Journal in AX 2012

Do you know that you can mark the transactions to settle in a journal in an automatic way?

In this post we will explain how to do just that, for this we are going to create a job in AX and we will add the following lines of code:

imagen1

First we will add the variables for the header and the lines of the payment journal. As we can see we hace a manager, the LedgerJournalTrans, the VendTransOpen, the AxLedgerJournalTable and the AxLedgerJournalTrans. We also initialize the vendTransOpen with the recId of the open transaction we want to settle.

imagen2

Now we initialize the AxLedgerJournalTable class, we set the journal name and the journal type, all of this for the header of the journal. Finally we save the header.

imagen3

Now we will create the line for the journal, but this time we will initialize the AxLedgerJournalTrans class, we will set some parameters for example the journal number, the date, the due date, the account type, the ledger dimensions that will be the structure of the Main Account, etc.

imagen4

Now we will check the transaction line we want to settle, for this we initialize the contruct method of the CustVendOpenTransManager with our current journal and we update the marked trans using the initialized manager.

imagen5

Now we will get the total of the marked transactions, for this we are using the SpecTransManager and the method getTotalSettleAmountForSpecReference, and we set the parameters needed for this method such as the company, the table id, the  recId, the currencycode,  the date and the exchange rate.

imagen6

Finally we wil save the data we set previously, take note of the ttsbegin and ttscommit in our code, this must be done because this will check the health of our transaction. We set the table for update, and we set the amount and the voucher to be settled, finally we run the update method, and as we can see below,  the transaction is marked as shown:

imagen7

  • Andesoft International

    by EI

  • http://allaboutax.blogspot.co.in Mehul Thacker

    Awesome work man…
    It saved my tons of time!! :-)

  • Pam

    Hej, thats nice. Will it work for AX 2009 with some minor alterations maybe?

  • dArc

    Hi Andesoft,

    how to settle the market transaction from the code?

    Thx & Regards,
    dArc

  • subash sam

    Hi,I am getting an error in UpdateTransMarked method like “Unable to cast ‘CustVendTransOpen’ to ‘VendTransOpen’ “. Actually I am sending an ‘vendTransOpen’ table buffer only.

  • https://goo.gl/YJW7ol

    My children were needing CA UCSF 756-020Z this month and were told about a web service with a huge forms library . If you are wanting CA UCSF 756-020Z too , here’s