Wednesday, October 22, 2025

Get salestax amount of each individual purchline

 Scenario:- In this post we see how we can get salestax amount of a purchline from purchase order

code:-

PurchTable purchTable =PurchTable::find('00000400');
PurchTotals purchTotals = PurchTotals::newPurchTable(purchTable);
purchTotals.calc();
TmpTaxWorkTrans tmpTaxWorkTrans;
tmpTaxWorkTrans.setTmpData(purchTotals.tax().tmpTaxWorkTrans());

real salestax;

while select * from tmpTaxWorkTrans
     where tmpTaxWorkTrans.SourceRecId == Pass Purchlinerecid
{
     // Process the tax information for the specific line
     salestax+=tmpTaxWorkTrans.TaxAmount;
}

info(strfmt("SalesTaxamount:-%1",salestax));
---------------------------------------------------------------------------------------------------------------------

Scenario:- In this post we see how we can get salestax amount of a pendingvendor invoice without po
note:-actually this code works for both

code:-

VendInvoiceInfoTable vendInvoiceInfoTable= VendInvoiceInfoTable::findRecId(5637973306);
PurchTotals purchTotals = PurchTotals::newParmTable(vendInvoiceInfoTable,PurchUpdate::All,vendInvoiceInfoTable.ParmId,
             '',
             vendInvoiceInfoTable.Ordering,
             PurchTotalsCachingMethod::Reuse);

 

purchTotals.calc();

AmountCur taxAmount = purchTotals.taxTotal();
Info(strFmt("Subtotal: %1", taxAmount));

No comments:

Post a Comment

Custom services in d365fo

 In this blog we see how to develop custom services in d365fo Mainly we need to develop 1) Request class 2) Response class  3) service class...