I want to display IGST, CGST, SGST amounts and rates used in Indian Taxation on Project Invoice proposal Print Preview report. We can see these amounts from the Tax document option as shown in following picture:
These rates and amounts can be for a sales order, subscription or hour journal posted on a project.
There are codes available online to calculate GST rates and amounts on Purchase order or sales order confirmation and invoice. But I can’t find a way to calculate the same on Project Invoice Proposal.
Actually, I need this because I want to show these rates and amounts for each line on Print Preview report in action pane.
What tables does the report uses?
You can use \Classes\TaxBusinessService.
For reference, see \Classes\SalesInvoiceDP\initSalesInvoiceTmpWithProforma_IN
Finally I found the solution. It is the class ProjProposalTotals which provides methods for calculating tax for sales order, hour journal, subscription, on account transactions etc.
Below given is the code for getting CGST, IGST, SGST rates and amounts for each line on Project Invoice Proposal-
static void GetGSTRatesAmountsOnProjectProposal(Args _args)
{
ProjProposalTotals projProposalTotals;
ITaxableDocument taxableDocument;
ITaxDocumentComponentLineEnumerator lineEnumerator;
ITaxDocumentComponentLine componentLineObject;
ITaxDocument taxDocumentObject;
projProposalTotals = new ProjProposalTotals(ProjProposalJour::find('Your Proposal ID'));
taxableDocument = TaxableDocumentObject::construct(projProposalTotals.parmTaxableDocDescriptorRevenueSubTrans()); //Use for Subscription
//taxableDocument = TaxableDocumentObject::construct(projProposalTotals.parmTaxableDocDescriptorEmplTrans()); //Use for Hour journal
//taxableDocument = TaxableDocumentObject::construct(projProposalTotals.parmTaxableDocDescriptorItemSOTrans()); //Use for Sales order
//taxableDocument = TaxableDocumentObject::construct(projProposalTotals.parmTaxableDocumentDescriptorAccTrans()); //Use for On-account transaction
taxDocumentObject = TaxBusinessService::calculateTax(taxableDocument);
if (taxDocumentObject)
{
// Calculation of Tax amount for Tax type GST and Tax component SGST
lineEnumerator = taxDocumentObject.componentLines("GST","CGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
info(strFmt('%1', componentLineObject.getMeasure("Rate").value().value()*100));
info(strFmt('%1', componentLineObject.getMeasure("Tax Amount").value().value()));
}
lineEnumerator = taxDocumentObject.componentLines("GST","IGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
info(strFmt('%1', componentLineObject.getMeasure("Rate").value().value()*100));
info(strFmt('%1', componentLineObject.getMeasure("Tax Amount").value().value()));
}
lineEnumerator = taxDocumentObject.componentLines("GST","SGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
info(strFmt('%1', componentLineObject.getMeasure("Rate").value().value()*100));
info(strFmt('%1', componentLineObject.getMeasure("Tax Amount").value().value()));
}
}
}