Friday, May 8, 2026

Get or set adjust tax calculated amount using TAXDOCUMENT framework (Tax calculation service) in D365FO

 //Get or adjust tax calculation using TAXDOCUMENT framework (Tax calculation service)

TaxRegulation taxRegulationDetail;

TmpTaxRegulation  tmpTaxRegulationDetail;

SalesTotals salesTotals;


salesTotals = SalesTotals::construct(SalesTable::find(salesLineParentPOl.SalesId), SalesUpdate::All);

salesTotals.calc();


taxRegulationDetail = TaxRegulation::newTaxRegulation(salesTotals.tax());

tmpTaxRegulationDetail.setTmpData(taxRegulationDetail.tmpTaxRegulation()); // Get all current tax by order wise


//Get this buffer "tmpTaxRegulationDetail" to get all tax related data

//To adjust

TaxTable    taxTable;

select firstonly tmpTaxRegulationDetail

    where tmpTaxRegulationDetail.TaxCode

    join taxTable

        where taxTable.TaxCode == 'SAN_IPI';

if(tmpTaxRegulationDetail)

{

    taxRegulationDetail.updateTaxRegulationAmount(tmpTaxRegulationDetail, (<Updated tax amount after adjustment>), true); // to adjust use this call to do

    taxRegulationDetail.saveTaxRegulation(); //

}

Monday, May 4, 2026

Get Vendor & Warehouse primary address using query

 --Vendor default primary address

Select  vt.AccountNum, vt.Party, vt.RecId, lpd.RECID, dpl.LOCATION, lpd.ADDRESS from VENDTABLE vt

join DirPartyLocation dpl on dpl.Party = vt.Party

join LogisticsPostalAddress lpd on dpl.LOCATION = lpd.LOCATION

where vt.DataAreaId = 'usrt' and dpl.ISPRIMARY =1 and lpd.VALIDTO = '2154-12-31 23:59:59.000'


--Warehouse default primary address

Select  it.InventLocationId, it.INVENTSITEID, it.RecId, lpd.RECID,  lpd.ADDRESS

from INVENTLOCATION it

join InventLocationLogisticsLocation illl on illl.INVENTLOCATION = it.RECID

join LogisticsPostalAddress lpd on lpd.LOCATION = illl.LOCATION

where it.DataAreaId = 'usrt' --and dpl.ISPRIMARY =1 

and illl.IsPostalAddress =1 and illl.IsPrimary =1 and lpd.VALIDTO = '2154-12-31 23:59:59.000'


Get or set adjust tax calculated amount using TAXDOCUMENT framework (Tax calculation service) in D365FO

 //Get or adjust tax calculation using TAXDOCUMENT framework (Tax calculation service) TaxRegulation taxRegulationDetail; TmpTaxRegulation  ...