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 :
Small and medium business | Business Central, N...
Suggested Answer

Unable to calculate GST on sales Invoice

(0) ShareShare
ReportReport
Posted on by 12
Dear Team,
I have written below code to create sales invoice in business central but GST is not calculate on sales invoice.When i create same invoice manually then its calculating Gst.Can anyone suggest
 
procedure CreateSalesInvoice()
    var
        GLSetup: Record /General Ledger Setup/;
    begin
        GLSetup.Get();
        SalesNReceivableSetup.Get();
        SalesHeaderRec.Reset();
        SalesHeaderRec.SetRange(/External Document No./, SalesStaging.InvoiceNo);
        if not SalesHeaderRec.FindFirst() then begin
            SalesHeader.Init();
            SalesHeader./Document Type/ := SalesHeader./Document Type/::Invoice;
            SalesHeader.Validate(/Document Type/);
            SalesHeader./No./ := NoSeriesMngt.GetNextNo(SalesNReceivableSetup./Invoice Nos./, WORKDATE, TRUE);
            SalesHeader.Validate(/No./);
            SalesHeader./External Document No./ := SalesStaging.InvoiceNo;
            SalesHeader.Validate(/External Document No./);
            //To get Sell-To customer No++
            CustomerRec.Reset();
            CustomerRec.SetRange(ClientID, SalesStaging./Client ID/);
            if SalesStaging./Application Type/ <> '' then
                CustomerRec.SetRange(/Application Type/, SalesStaging./Application Type/);
            if CustomerRec.FindFirst() then begin
                SalesHeader./Sell-to Customer No./ := CustomerRec./No./;
                SalesHeader.Validate(/Sell-to Customer No./);
            end;
            //--
             if SalesNReceivableSetup./Ho Location/ <> '' then begin
                SalesHeader./Location Code/ := SalesNReceivableSetup./Ho Location/;
                SalesHeader.Validate(/Location Code/);
            end;
            if SalesStaging.PaymentTerms <> '' then begin
                SalesHeader./Payment Terms Code/ := SalesStaging.PaymentTerms;
                SalesHeader.Validate(/Payment Terms Code/);
            end;
            SalesHeader./Sell-to Address/ := SalesStaging.Address;
            SalesHeader.Validate(/Sell-to Address/);
            SalesHeader./Posting Date/ := SalesStaging.Createddate;
            SalesHeader.Validate(/Posting Date/);
            if (GLSetup./LCY Code/ <> SalesStaging.Curency) then begin
                SalesHeader./Currency Code/ := SalesStaging.Curency;
                SalesHeader.Validate(/Currency Code/);
            end;
            SalesHeader.Insert();
            SalesLine.Init();
            SalesLine./Document Type/ := SalesLine./Document Type/::Invoice;
            SalesLine.Validate(/Document Type/);
            SalesLine./Sell-to Customer No./ := SalesHeader./Sell-to Customer No./;
            SalesLine.Validate(/Sell-to Customer No./);
            SalesLine./Document No./ := SalesHeader./No./;
            SalesLine.Validate(/Document No./);
            SalesLine./Line No./ := 10000;
            SalesLine.Validate(/Line No./);
            SalesLine.Type := SalesLine.Type::/G/L Account/;
            SalesLine.Validate(Type);
            SalesLine./No./ := CustomerRec./Sales Account/);
            SalesLine.Validate(/No./);
            SalesLine.Quantity := SalesStaging.Completes;
            SalesLine.Validate(Quantity);
            SalesLine./Unit Price/ := SalesStaging.Cpi;
            SalesLine.Validate(/Unit Price/);
            SalesLine./Shortcut Dimension 2 Code/ := SalesStaging.Marketid;
            SalesLine.Validate(/Shortcut Dimension 2 Code/);
            SalesLine./GST Group Code/ := SalesStaging./GST Group Code/;
            SalesLine.Validate(/GST Group Code/);
            SalesLine./HSN/SAC Code/ := SalesStaging./HSN Code/;
            SalesLine.Validate(/HSN/SAC Code/);
            SalesLine.Insert();
            SalesLine.Validate(Quantity, SalesLine.Quantity);
            SalesLine.Modify();
    
I have the same question (0)
  • Suggested answer
    Gerardo Rentería García Profile Picture
    25,709 Most Valuable Professional on at
    Hi
    Maybe this can help you and give you some hints
    Best Regards
    Gerardo

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,717 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 995 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 628 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans