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));

computed column in Dataentity

synatx:-    public static server str methodname()   {       str purchid=SysComputedColumn::returnField(dataentityviewstr(Dataentityname),d...