web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Issue with overriding sales tax on Free text invoice for single sales tax code

(5) ShareShare
ReportReport
Posted on by 27
Hi,
 
I am trying to override sales tax on a free text invoice. FTI has two lines - with same sales tax and Item sales tax groups(hence picking only one sales tax code).
I am writing the logic in extension to CustInvoiceCalcTax_Table.calcTax() method as below:
 
 
The issue is its not overriding the sales tax amount (115.00 in my case) and still using the standard calculation using the sales tax code.
 
Couple of options I tried:
 
1) Used taxRegulation.allocateAmount(115.00)
2) Tried updating TmpTaxWorkTrans.SourceRegulateAmountCur values for the records to the tax amounts to be overridden with.
3) Tried updating TmpTaxRegulation.SourceRegulateAmountCur and TmpTaxRegulation.OverrideCalculatesSalesTax to 'Yes'.
 
This is a very urgent issue - tried to debug standard code but no luck.
 
Any help is much appreciated!!
 
thanks,
Padmaja
Categories:
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    304,708 Super User 2026 Season 1 on at
    Hi Padmaja,
     
    Can you share the full code of the class you created? What do you mean by "I am writing overwrite login in extension"? What is "login"? You can't just overwrite methods, it is extending it. If the method is a CoC handler, where do you have the next() call? 
     
    When debugging, have you included standard models to the library for debugging? Is the debugger hitting your code?
  • Padmaja Akella Profile Picture
    27 on at
    Hi André,
     
    Apologies, that was a typo. I meant tax overriding logic. I have written CoC for calcTax method .Debugger is hitting this code.

    Below is the full code of CoC I have written.
     
    /// <summary>
    /// <c>DLW_CustInvoiceCalcTax_T_Extension</c> extends the logic of <c>CustInvoiceCalcTax_Table</c> ensuring new tax calc logic is executed.
    /// </summary>
    [ExtensionOf(classStr(CustInvoiceCalcTax_Table))]
    final class  DLW_CustInvoiceCalcTax_T_Extension
    {
        /// <summary>
        /// Method to calculate tax.
        /// </summary>
        /// <param name = "_balance">Tax amount buffer.</param>
        /// <returns>
        ///     return tax amount.
        /// </returns>
        TaxAmountCur calcTax(AmountCur _balance)
        {
            CustInvoiceTable            custInvoiceTable;
            CustInvoiceline             custInvoiceline;
            CustInvoiceCalcTax_Table    custInvoiceCalcTax;
            TaxRegulation               taxRegulation;
            TmpTaxRegulation            tmpTaxRegulationBuffer;
            TmpTaxWorkTrans             tmpTaxWorkTransBuffer;
            TaxFreeInvoice              taxFreeInvoice;
            TaxAmountCur                taxAmountCur;
            TaxCalculation              taxCalculation;
     
            taxAmountCur = next calcTax(_balance);
     
            custInvoiceTable = this.parmCustInvoiceTable();
            
            select firstonly custInvoiceline
                where custInvoiceline.ParentRecId == custInvoiceTable.RecId
                && custInvoiceline.DLW_TaxAmount != 0;
            if (custInvoiceline)
            {
                ttsbegin;
     
                custInvoiceCalcTax = new CustInvoiceCalcTax_Table(custInvoiceTable);
                taxFreeInvoice = new TaxFreeInvoice(custInvoiceCalcTax, true, true, true);
                taxFreeInvoice.calcTax();
     
                taxRegulation           = TaxRegulation::newTaxRegulation(taxFreeInvoice);
                tmpTaxRegulationBuffer  = taxRegulation.tmpTaxRegulation();
                tmpTaxWorkTransBuffer   = taxRegulation.tmpTaxWorkTrans();
     
                // Inject override logic
                taxRegulation.updateTaxRegulationAmount(tmpTaxRegulationBuffer,115.00,true);
                taxRegulation.saveTaxRegulation();
                ttscommit;
            }
            
            return TaxAmountCur;
        }
    }
     
     
    thanks,
    Padmaja
  • Suggested answer
    Padmaja Akella Profile Picture
    27 on at
    Hi All,
     
    Just in case anyone coming across such issue, we have resolved the issue by using allocateAmount() rather than saveTaxRegulation().
     
    thanks,
    Padmaja

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 593 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 543

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans