Hi all,

I'm having a problem figuring out how to settle multiple payments against a 
particular invoice through X++ codes.

No problem when settling single payment against a particular invoice.

Below is my code for settling a payments.

while select ledgerJournalTrans order by recId desc
where ledgerJournalTrans.DocumentNum == localJournalTrans.DocumentNum
{
 custTransOpen = CustTransOpen::findRefId(CustTrans::findVoucherDate 
(ledgerJournalTrans.Voucher, ledgerJournalTrans.TransDate).RecId);

 //check correction payment
 amountSettled = abs(custTransOpen.AmountCur);

 //get amount
 if(ledgerJournalTrans.AmountCurCredit > 0)
   amountReceived = abs(ledgerJournalTrans.AmountCurCredit) *-1;

 if(ledgerJournalTrans.AmountCurDebit > 0)
   amountReceived = ledgerJournalTrans.AmountCurDebit;

 //create settlement based on custTransOpen
 specification = Specification::construct(SpecType::OffsetVoucher, 
localJournalTrans.TableId, localJournalTrans.RecId);

 specification.create(custTransOpen.TableId, custTransOpen.RecId, 
amountReceived, localJournalTrans.CurrencyCode, NoYes::Yes);
}

Can anybody point me to the right direction and/or sample codes? 
Im using AX4.
Thanks.





Reply via email to