Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

How to update Actual Tax amount in Sales Order programmatically ?

(0) ShareShare
ReportReport
Posted on by 592
Hi all,
 
This is about Sales Order question, specifically on Actual tax amount. I'm trying to programmatically update actual tax amount during Sales Order creation which also create by code.
 
I'm using this part of code :
 
            SalesTotals salesTotals     = SalesTotals::construct(salesTable,SalesUpdate::All);
            salesTotals.calc();
                
            if (!CustParameters::find().EnableSingleLineTaxAdjustment)   // need this parameter activated
            {
                throw Error(/@TaxEnableSalesOrderSingleLineAdjustment:EnableSingleLineTaxAdjustment/);
            }
            TaxRegulationDetail taxRegulation = TaxRegulation::newTaxRegulation(salesTotals.tax());
            TaxRegulationDetail taxRegulationDetail = taxRegulation as TaxRegulationDetail;
            TmpTaxRegulation    tmpTaxRegulationDetail = taxRegulationDetail.tmpTaxRegulationDetail();
 
            select tmpTaxRegulationDetail
                where tmpTaxRegulationDetail.SourceRecId            == salesLine.RecId
                    && tmpTaxRegulationDetail.SourceTableId         == tableNum(SalesLine)
                    && tmpTaxRegulationDetail.TaxAdjustmentType     == TaxAdjustmentType::Detail
                    && tmpTaxRegulationDetail.OverrideCalculatedTax == NoYes::No;
            if (tmpTaxRegulationDetail && tmpTaxRegulationDetail.SourceRegulateAmountCur != <myActualTaxAmount> )
            {
                taxRegulation.updateTaxRegulationAmount(tmpTaxRegulationDetail, <myActualTaxAmount>, true);
                taxRegulation.saveTaxRegulation();
            }
 
My question now, does this Actual Tax Amount sign should follow the sign of the sales amount or not ?
Or is the amount should be the opposite sign of the sales amount ?
 
When posting invoice I have discrepancy which looking at the message it looks like it is because the sign is not correct, or even it is actually not reflected by the actual amount.
 
Thanks,
 
 
 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans