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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

CGST, SGST, IGST and total with GST for sales invoice report

(0) ShareShare
ReportReport
Posted on by 76

I'm working in India localization for Business Central. I'm looking for CGST, SGST, IGST and total with GST values for my sales invoice report. If i opened my sales invoice page, i can able to see tax information factbox showing CGST, SGST values, but i'm unable to get those values to my report through report extension. I want to know from where we have to take CGST, SGST, IGST and total with GST values. Also how to write a code in AL to show CGST, SGST and IGST depending upon interstate/intrastate? how in report CGST, SGST and IGST values gets changed when we changed the currency and inter/intrastate?

...pastedimage1661247761873v3.png 

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    Thanks.

  • Verified answer
    Amit Baru Profile Picture
    3,037 on at

    Hi,

    Please read this logic and write code in your extension.

    Clear(CGSTTotalAmount);
                        Clear(SGSTTotalAmount);
                        Clear(IGSTTotalAmount);
                        Clear(TotalInvoiceValue);
                        DetailedGSTLedgerEntry.RESET;
                        DetailedGSTLedgerEntry.SETCURRENTKEY("GST Component Code");
                        DetailedGSTLedgerEntry.SETRANGE("Document No.", "No.");
                        //DetailedGSTLedgerEntry.SETRANGE("Document Line No.", "Line No.");
                        DetailedGSTLedgerEntry.SETRANGE("Entry Type", DetailedGSTLedgerEntry."Entry Type"::"Initial Entry");
                        IF DetailedGSTLedgerEntry.FINDSET THEN BEGIN
                            REPEAT
                                IF DetailedGSTLedgerEntry."GST Component Code" = 'CGST' THEN BEGIN
                                    CGSTTotalAmount += -DetailedGSTLedgerEntry."GST Amount";
                                    //TotalGSTLinePercemntage += DetailedGSTLedgerEntry."GST %";
                                END;
                                IF DetailedGSTLedgerEntry."GST Component Code" = 'IGST' THEN BEGIN
                                    IGSTTotalAmount += -DetailedGSTLedgerEntry."GST Amount";
                                    //TotalGSTLinePercemntage += DetailedGSTLedgerEntry."GST %";
                                END;
                                IF DetailedGSTLedgerEntry."GST Component Code" = 'SGST' THEN BEGIN
                                    SGSTTotalAmount += -DetailedGSTLedgerEntry."GST Amount";
                                    //TotalGSTLinePercemntage += DetailedGSTLedgerEntry."GST %";
                                END;
                            UNTIL DetailedGSTLedgerEntry.NEXT = 0;
    For More information-->
    Regards
    Amit Sharma
    Press Yes button for verified reply
  • Revathi.T Profile Picture
    76 on at

    I have used the above code in my page extension using OnAfterGetRecord trigger because i got error when i used Clear, now it runs successfully and opened in BC, But when i used the CGST, SGST and IGST fields from the table extension to report extension, All values are showing as 0.00. Following are the codes with table extension, page extension and report extension. where i made mistake? how to get values to the report?

    tableextension 50126 requiredfieldstableheaderext extends "Sales Header"

    {

       fields

       {        

           field(50012; PO_Number1; Code[100])

           {

               Caption = 'PO Number';

               DataClassification = CustomerContent;

           }

       }

    }

    tableextension 50127 requiredfieldstableext extends "Sales Line"

    {

       fields

       {

           field(50001; Activity; Code[500])

           {

               Caption = 'Activity';

               DataClassification = CustomerContent;

           }

           field(50002; "Gross Amount"; Decimal)

           {

               Caption = 'Gross Amount';

               DataClassification = CustomerContent;

           }

           field(50003; "CGST"; Decimal)

           {

               Caption = 'CGST';

               DataClassification = CustomerContent;

           }

           field(50004; "SGST"; Decimal)

           {

               Caption = 'SGST';

               DataClassification = CustomerContent;

           }

           field(50013; "IGST"; Decimal)

           {

               Caption = 'IGST';

               DataClassification = CustomerContent;

           }

           field(50005; "Total"; Decimal)

           {

               Caption = 'Total';

               DataClassification = CustomerContent;

           }

           field(50014; "Total with IGST"; Decimal)

           {

               Caption = 'Total with IGST';

               DataClassification = CustomerContent;

           }        

           field(50011; TAX; Code[100])

           {

               Caption = 'TAX';

               DataClassification = CustomerContent;

           }

           field(50015; "S.No."; Integer)

           {

               Caption = 'S.No.';

               DataClassification = CustomerContent;

           }

       }    

    }

    pageextension 50126 requiredfieldspageheaderext extends "Sales Invoice"

    {

       layout

       {

           addafter("Due Date")

           {            

               field(PO_Number; Rec.PO_Number1)

               {

                   ApplicationArea = All;

               }

           }

       }

    }

    pageextension 50127 requiredfieldspageext extends "Sales Invoice Subform"

    {

       layout

       {

           addbefore(Description)

           {

               field(Activity; Rec.Activity)

               {

                   ApplicationArea = All;

               }

           }

           addbefore("GST Assessable Value (LCY)")

           {

               field(TAX; Rec.TAX)

               {

                   ApplicationArea = All;

               }

           }

       }

       var

           recDetailedGstLedgEnt: Record "Detailed GST Ledger Entry";

           gIgstPer: Decimal;

           gCgstPer: Decimal;

           gSgstPer: Decimal;

       Trigger OnafterGetRecord()

       Begin

           recDetailedGstLedgEnt.RESET;

           recDetailedGstLedgEnt.SetCurrentKey("GST Component Code");

           recDetailedGstLedgEnt.SETRANGE("Document No.", Rec."Document No.");

           recDetailedGstLedgEnt.SETRANGE("Document Line No.", Rec."Line No.");

           recDetailedGstLedgEnt.SetRange("Entry Type", recDetailedGstLedgEnt."Entry Type"::"Initial Entry");

           IF recDetailedGstLedgEnt.FINDSET THEN begin

               repeat

                   IF recDetailedGstLedgEnt."GST Component Code" = 'IGST' THEN BEGIN

                       Rec.IGST += -recDetailedGstLedgEnt."GST Amount";

                       gIgstPer += recDetailedGstLedgEnt."GST %";

                   END;

                   IF recDetailedGstLedgEnt."GST Component Code" = 'CGST' THEN BEGIN

                       Rec.CGST += -recDetailedGstLedgEnt."GST Amount";

                       gCgstPer += recDetailedGstLedgEnt."GST %";

                   END;

                   IF recDetailedGstLedgEnt."GST Component Code" = 'SGST' THEN BEGIN

                       Rec.SGST += -recDetailedGstLedgEnt."GST Amount";

                       gSgstPer += recDetailedGstLedgEnt."GST %";

                   END;

               Until recDetailedGstLedgEnt.Next = 0;

           end;

       End;

    }

    reportextension 50127 requirefieldsext extends "Standard Sales - Draft Invoice"

    {

       WordLayout = './StandardSalesDraftInvoice.docx';

       dataset

       {

           add(Header)

           {            

               column(PO_Number1; PO_Number1)

               {

               }

           }

           add(Line)

           {

               column(Activity; Activity)

               {

               }            

               column(UNIT; "Unit of Measure")

               {

               }

               column(QTY; Quantity)

               {

               }

               column(RATE; "Unit Price")

               {

               }

               column(AMOUNT; "Line Amount")

               {

               }

               column(Gross_Amount; "Gross Amount")

               {

               }

               column(CGST; "CGST")

               {

               }

               column(SGST; "SGST")

               {

               }

               column(IGST; "IGST")

               {

               }

               column(Total; "Total")

               {

               }

               column("TotalwithIGST"; "Total with IGST")

               {

               }

               column("TAX"; TAX)

               {

               }

               column(No_; "No.")

               {

               }

               column(HSN_SAC_Code_; "HSN/SAC Code")

               {

               }

               column("SNo"; "S.No.")

               {

               }

           }

       }

    }

  • Lakshmanan.R Profile Picture
    137 on at

    Dear Revathi.T,

    Have you met your requirement on this, with the above code..? If yes, please share the proper code for achieving that.

    If not, please share your GL Setup Screenshots.

    Thanks & Regards,

    Lakshmanan R

  • Revathi.T Profile Picture
    76 on at
    [deleted]
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Thanks for the update.

  • Revathi.T Profile Picture
    76 on at

    dataitem("Sales invoice Line"; "Sales Invoice Line")

               {

                   DataItemLink = "Document No." = field("No.");

                   DataItemLinkReference = Header;

                   DataItemTableView = sorting("Document No.");

                   column(HSN_SAC_Code_; "HSN/SAC Code") { }

                   column(CGSTAmount; CGSTAmount) { }

                   column(SGSTAmount; SGSTAmount) { }

                   column(IGSTAmount; IGSTAmount) { }

                   column(TotalGST; TotalGST) { }

                   column(TotalAmountwithGST_; TotalAmountwithGST) { }

                   column(GSTpercent; GSTpercentage) { }

                   column(SGSTpercent; SGSTpercentage) { }

                   column(IGSTpercent; IGSTpercentage) { }

                   trigger OnAfterGetRecord()

                   var

                       DGST: Record "Detailed GST Ledger Entry";

                       Salesinvline: Record "Sales Invoice line";

                       TotalAmountwithoutGST: Decimal;

                   begin

                       DGST.Reset();

                       DGST.SetRange("Document No.", CurrReport.Header."No.");

                       TotalGST := 0;

                       CGSTAmount := 0;

                       SGSTAmount := 0;

                       IGSTAmount := 0;

                       TotalAmountwithoutGST := CurrReport.Header.Amount;

                       if DGST.FindFirst() then

                           repeat

                               TotalGST += -DGST."GST Amount";

                               if DGST."GST Component Code" = 'CGST' then begin

                                   CGSTAmount += -DGST."GST Amount";

                                   GSTpercentage := DGST."GST %";

                               end;

                               if DGST."GST Component Code" = 'SGST' then begin

                                   SGSTAmount += -DGST."GST Amount";

                                   SGSTpercentage := DGST."GST %";

                               end;

                               if DGST."GST Component Code" = 'IGST' then begin

                                   IGSTAmount += -DGST."GST Amount";

                                   IGSTpercentage := DGST."GST %";

                               end;

                           until DGST.Next() = 0

                       else begin

                           TotalGST := 0;

                           CGSTAmount := 0;

                           SGSTAmount := 0;

                           IGSTAmount := 0;

                           GSTpercentage := 0;

                           SGSTpercentage := 0;

                           IGSTpercentage := 0;

                       end;

                       TotalAmountwithGST := TotalAmountwithoutGST + TotalGST;

                   end;

               }

    Previously i made mistake by linking "Sales Line" and "Detailed Gst Ledger Entry", i couldn't able to get values in my report. Later i tried linking "Sales Invoice Line" and "Detailed GST Ledger Entry", and also i used CurrReport.Header."No." . This time i can able to get current line values from Detailed GST Ledger Entry. The Above Code is perfect. Now i can able to get all cgst, igst and sgst values in my standard sales invoice report. Thank you all for your suggestions and responses. your responses helped me a lot to get solutions quicker.

  • Lakshmanan.R Profile Picture
    137 on at

    Dear Revathi.T,

     Thanks for your response ,but I'm not able to find the mentioned table "Detailed GST Ledger Entry". Could you please tell me where would I find the above mentioned table.?

  • Revathi.T Profile Picture
    76 on at

    Hi Lakshmanan.R,

    You can simply type "Detailed GST Ledger Entry" in search bar.

  • Revathi.T Profile Picture
    76 on at

    Or the other way, Go to Posted Sales Invoice, Select "Find Entries" in Home Tab, you can able to "Detailed GST Ledger Entry"

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans