D365/AX7: Customer Settlement Using X++ Code

Requirement

Customer Settlement of Invoice (Debit) and Payment (Credit) Using X++ Code.

Sample Code

[code language=”cpp”]

CUSTTABLE originator = CustTable::find(‘CAHM-1066’);
CustVendOpenTransManager SettleManager;
Custtransopen custtransopenfrom, custtransopento;
;
SettleManager = custVendOpenTransManager::construct(originator);

//finding debit amount record
select firstonly1 custtransopenfrom
where custtransopenfrom.AccountNum == originator.AccountNum
&& custtransopenfrom.RefRecId == 5637165579;

//finding credit amount record
select firstonly1 custtransopento
where custtransopento.AccountNum == originator.AccountNum
&& custtransopento.RefRecId == 5637172326;

SettleManager.updateTransMarked(custtransopenfrom, true);
SettleManager.updateSettleAmount(custtransopenfrom, 1); // settling with amount value 1
SettleManager.updateTransMarked(custtransopento, true);
SettleManager.updateSettleAmount(custtransopento, -1); // settling with amount value -1
SettleManager.settleMarkedTrans();
[/code]

Leave a Reply