Hi TestBot,
1) Issue
- Requirement to calculate GST (India) for a custom ISV table/form in D365 Finance using SAC/HSN code
- Standard GST calculation works only for standard modules (Sales, Purchase, Free text invoice, etc.)
- Custom tables do not automatically trigger tax calculation
- Need to integrate tax engine logic into custom process
- Expectation is to reuse standard tax/GST framework instead of building logic from scratch
2) Reason
- The limitation is caused by GST calculation in D365 being tightly integrated with the Tax engine framework (Taxable document model)
- Standard GST calculation is triggered through document frameworks such as SalesLine, PurchLine, LedgerJournalTrans, etc.
- A required structure such as TaxableDocument, TaxIntegration, and TaxBusinessService is not present in custom tables by default
- This leads to a situation where tax engine cannot identify the custom transaction and therefore does not calculate GST
- This can happen because SAC/HSN-based tax calculation depends on tax setup, tax groups, item groups, and document metadata which must be explicitly provided to the engine
3) Resolution
- Use the standard Tax engine framework instead of manual GST calculation
Step 1: Identify required tax inputs
- SAC/HSN code (from your custom line table)
- Tax group
- Item sales tax group
- Currency and amount
- Date and company context
Step 2: Use TaxableDocument framework
- Create a custom TaxableDocument implementation for your table
- Map your custom fields (amount, SAC/HSN, quantities) to tax engine fields
Example concept:
- Extend or mimic classes used in: SalesLine → TaxableDocument, PurchLine → TaxableDocument
Step 3: Call TaxBusinessService
- Use standard tax calculation service:
- Code example (simplified):
TaxableDocumentObject taxableDocument;
TaxBusinessService taxBusinessService;
TaxDocument taxDocument;
taxableDocument = YourCustomTaxableDocument::construct(_yourCustomTableBuffer);
taxBusinessService = TaxBusinessService::construct();
taxDocument = taxBusinessService.calculateTax(taxableDocument);
Step 4: Read calculated GST
- Loop through taxDocument lines:
TaxDocumentComponentLine componentLine;
while select componentLine
where componentLine.TaxDocument == taxDocument.RecId
{
info(strFmt("Tax Amount: %1", componentLine.TaxAmount));
}
Step 5: Ensure setup is correct
- SAC/HSN code must be linked to:
- Item sales tax group
- Tax group
- GST components (CGST, SGST, IGST)
- Check Tax setup:
- Tax > Setup > Sales tax
- India GST feature must be enabled
Step 6: Alternative quick approach (if full framework is too heavy)
- Reuse an existing table (like PurchLine or SalesLine)
- Temporarily simulate your data into that buffer
- Call tax calculation
- Extract result
- Not ideal but faster for ISV scenarios
Key considerations
- Do not manually calculate GST rates
- Always use tax engine to ensure:
- Compliance
- Future updates
- Localization correctness
Common pitfalls
- Missing tax group or item tax group
- SAC/HSN not linked in tax setup
- Not using TaxableDocument structure
- Trying to calculate GST only via percentage logic
Best practice
- Treat your custom table like a standard document line
- Plug into Tax engine via TaxableDocument
- Keep logic reusable and aligned with Microsoft framework
Key takeaway
- GST calculation in D365 Finance is not standalone logic
- It is driven by the Tax engine and TaxableDocument framework
- To support custom tables you must integrate with this framework instead of bypassing it
For a more detailed answer, please provide more information.
Rg,
Alexander
*Due to the complex and different possibilities of deploying Dynamics 365 I highly recommend not to setup the application without some expert/partner or support. (For more information contact me under anassl@inno-solutions.info or visit www.inno-solutions.de)
*The Information comes directly from the manufacturer or provider and are validated (not guaranteed) up to date of creation of the posting.
References:
- Microsoft Licensing Guide
- Microsoft Doc`s/Learn