Version: AX2012 R3
Pending vendor invoice is created through X++ from PO.
Below tables were used:
vendInvoiceInfoTable
vendInvoiceInfoSubTable
vendInvoiceInfoLine
VAT is calculated.
User will provide the VAT amount to override the calculated amount.
We can usually use ledgerJournalEngine.CorrectTaxamount() etc for journals but how to re-calculate or override the VAT amount using X++ for pending vendor invoice?
Thanks,
*This post is locked for comments
I have the same question (0)I have used below code to override the calculated VAT amount.
TaxAmountCur taxAmount;
TaxRegulation taxRegulation;
Tax tax;
PurchTotals purchTotals;
if (taxAmount > 0 || taxAmount < 0) // TaxAmount is provided in the CSV file.
{
// totals are only needed if price includes tax
purchTotals = PurchTotals::newParmTable(vendInvoiceInfoTable,
PurchUpdate::All,
AccountOrder::None,
vendInvoiceInfoTable.ParmId,
vendInvoiceInfoTable.PurchId,
vendInvoiceInfoTable.Ordering);
purchTotals.calc(false, false, true);
tax = purchTotals.tax();
taxRegulation = TaxRegulation::newTaxRegulation(tax, null, tableName2id("VendInvoiceTable"),vendInvoiceInfoTable.RecId);
taxRegulation.allocateAmount(taxAmount);
taxRegulation.saveTaxRegulation();
}
Syed Haris Shah
9
Mea_
4
Rahul Shah
2