Get tax codes for charge line/purchase order line/invoice line

X++ to go through tax codes:

    PurchTotals             purchTotals;
    TaxPurch                taxPurch;
    TmpTaxWorkTrans         tmpTaxWorkTrans;
    VendInvoiceInfoTable    vendInvoiceInfoTable;
    MarkupTrans             markupTrans;

    // Invoice
    purchTotals = PurchTotals::newParmTable(
                vendInvoiceInfoTable,
                PurchUpdate::All,
                AccountOrder::None,
                vendInvoiceInfoTable.ParmId,
                '',
                vendInvoiceInfoTable.Ordering);
    purchTotals.calc();
    taxPurch = purchTotals.tax();

    // PO
    taxPurch = PurchTotals::getTax(purchTable);


  
    taxPurch.showTaxesSourceSingleLine(markupTrans.TableId, markupTrans.RecId, true); // markupTrans could be also PurchLine, VendInvoiceInfoLine
    tmpTaxWorkTrans = taxPurch.tmpTaxWorkTrans();

    while select tmpTaxWorkTrans
            where   tmpTaxWorkTrans.SourceRecId     == markupTrans.RecId
                 && tmpTaxWorkTrans.SourceTableId   == markupTrans.TableId
    {
        info(strFmt("code: %1, amount %2", tmpTaxWorkTrans.TaxCode, tmpTaxWorkTrans.TaxAmount));
    }



Support The Author

 If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.

Buy Me a Coffee

Post a Comment


All Comments


No comments. Be the first one to comment on this post.

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own "buy me a coffee" link.
Join us.

Blog Tags