AX2009 Recalculate Vendor Cash Disc
TL;DR: AX2009 Recalculate Vendor Cash Disc with X++
Description
With this job you can recalculate the cash disc amount in the vendor open transactions. You can change the query to filter different transactions.
AX2009 Job
static void down1_VendRecalcCashDisc(Args _args)
{
VendTransCashDisc ltabVendTransCashDisc;
VendTransOpen ltabVendTransOpen;
VendTrans ltabVendTrans;
VendInvoiceJour ltabVendInvoiceJour;
int i;
;
while select ltabVendTrans
where ltabVendTrans.CashDiscCode != ""
//&& (ltabVendTrans.AmountCur > 0.36 || ltabVendTrans.AmountCur < -0.36)
join ltabVendTransOpen
where ltabVendTransOpen.RefRecId == ltabVendTrans.RecId
notexists join ltabVendTransCashDisc
where ltabVendTransCashDisc.RefTableId == ltabVendTransOpen.TableId
&& ltabVendTransCashDisc.RefRecId == ltabVendTransOpen.RecId
&& ltabVendTransCashDisc.CashDiscAmount != 0
{
ltabVendInvoiceJour = VendInvoiceJour::findFromVendTrans(ltabVendTrans.Invoice, ltabVendTrans.TransDate, ltabVendTrans.AccountNum);
info(ltabVendTrans.AccountNum + " " + ltabVendTrans.Invoice + " " + ltabVendInvoiceJour.createdBy);
ltabVendTransCashDisc.calcCashDisc(ltabVendTrans.CurrencyCode, ltabVendTrans.AmountCur, ltabVendTrans.DueDate,
ltabVendTrans.DocumentDate ? ltabVendTrans.DocumentDate : ltabVendTrans.TransDate,
ltabVendTrans.CashDiscCode, ltabVendTransOpen.TableId, ltabVendTransOpen.RecId);
if (ltabVendTrans.AmountCur < -1 || ltabVendTrans.AmountCur > 1)
i++;
}
info(strfmt("Count of mutated entries: %1",i));
}
If you enjoyed this post, you might also enjoy:
- AX2009 Settle Customer Open Transcation
- AX2009 Cancel SalesOrder with empty SalesLine
- AX2009 Create picking list
- D365 F&O Replenishment Template Lines - set product queries by code
- AX2009 Restore deleted sales table without restoring sales line
- D365 F&O IOrganizationService for Dataverse
- D365 F&O Custom Work Types
MS Dynamics AX / D365 FO developer with experience in administration, developing new and adjusting the existing solutions in the Dynamics AX 2009, AX 2012, D365 FO. Ability to support all phases of implementation of project, starting with design, development, final deployment and administration. Responsible team member always looking for new challenges with experience from international projects in Austria, Germany and Switzerland. Experience in implementation of external service to MS Dynamcis AX / D365, like cash registers and warehouse automations. More about the author →