For calculating GST amount in Sales use the below logic.
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;
END;
Regards
Amit Sharma
linkedin.com/in/amit-sharma-94542440/
Press Yes if info is useful.