//For Sales Order
while select * from projProposalJour where projProposalJour.ProposalId == proposalId
join projProposalItem where projProposalItem.ProposalId == projProposalJour.ProposalId
join projProposalItemDetail where projProposalItemDetail.ProposalRefRecId == projProposalItem.RecId
{
LineTmp.clear();
LineTmp.Sunb_Description = projProposalItem.Txt;
LineTmp.LineAmount = projProposalItemDetail.LineAmount;
TotalLineAmt += LineTmp.LineAmount;
LineTmp.QTY = projProposalItem.Qty();
LineTmp.SalesPrice = projProposalItemDetail.SalesPrice;
// Find SalesLine to get HSN/SAC
select firstonly salesLine
where salesLine.ProjTransId == projProposalItem.ProjTransId;
transTaxInformation = TransTaxInformationHelper::findOrCreateTransTaxInformation(salesLine.TableId, salesLine.RecId);
select firstonly hsnCodeTable
where hsnCodeTable.RecId == transTaxInformation.HSNCodeTable;
if (hsnCodeTable)
{
hsn = hsnCodeTable.Code;
}
else
{
hsn = HSNCodeTable_IN::find(inventTable.HSNCodeTable_IN).Code;
}
select firstonly serviceAccountingCodeTable_IN
where serviceAccountingCodeTable_IN.RecId == transTaxInformation.ServiceAccountingCodeTable;
if (serviceAccountingCodeTable_IN)
{
sac = serviceAccountingCodeTable_IN.SAC;
}
else
{
sac = ServiceAccountingCodeTable_IN::find(inventTable.ServiceAccountingCodeTable_IN).SAC;
}
LineTmp.Sunb_HSN_SAC = hsn + sac;
// ---------------- TAX CALCULATION ----------------
if (projProposalJour.CurrencyId == 'INR')
{
projProposalTotals = new ProjProposalTotals(projProposalJour);
taxableDocument = TaxableDocumentObject::construct(projProposalTotals.parmTaxableDocDescriptorItemSOTrans());
taxDocumentObject = TaxBusinessService::calculateTax(taxableDocument);
if (taxDocumentObject)
{
// IGST
lineEnumerator = taxDocumentObject.componentLines("GST","IGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
real TaxValue = componentLineObject.getMeasure("Rate").value().value();
real TaxableAmount = componentLineObject.getMeasure("Base Amount").value().value();
real TaxAmount = (TaxableAmount * TaxValue * 100) / 100;
if (TaxableAmount == LineTmp.LineAmount)
{
LineTmp.IGST = abs(TaxAmount);
IGST += LineTmp.IGST;
LineTmp.Sunb_TaxRate = TaxValue;
}
}
// SGST
lineEnumerator = taxDocumentObject.componentLines("GST","SGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
real TaxValue = componentLineObject.getMeasure("Rate").value().value();
real TaxableAmount = componentLineObject.getMeasure("Base Amount").value().value();
real TaxAmount = (TaxableAmount * TaxValue * 100) / 100;
if (TaxableAmount == LineTmp.LineAmount)
{
LineTmp.SGST = abs(TaxAmount);
SGST += LineTmp.SGST;
LineTmp.Sunb_TaxRate = TaxValue;
}
}
// CGST
lineEnumerator = taxDocumentObject.componentLines("GST","CGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
real TaxValue = componentLineObject.getMeasure("Rate").value().value();
real TaxableAmount = componentLineObject.getMeasure("Base Amount").value().value();
real TaxAmount = (TaxableAmount * TaxValue * 100) / 100;
if (TaxableAmount == LineTmp.LineAmount)
{
LineTmp.CGST = abs(TaxAmount);
CGST += LineTmp.CGST;
LineTmp.Sunb_TaxRate = TaxValue;
}
}
}
}
TotalGst = SGST + CGST + IGST;
// ---------------- MARKUP CHARGES START----------------
while select markuptranspro
where markuptranspro.TransRecId == salesLine.RecId
{
ChargesTmp.clear();
ChargesTmp.Charges_Description = markuptranspro.Txt;
ChargesTmp.Charges_TaxableAmount = markuptranspro.Value; //markuptranspro.Value;
TotalChrgesTaxAmt += ChargesTmp.Charges_TaxableAmount;
//hsn charges code
// Find SalesLine to get HSN/SAC
select firstonly salesLine
where salesLine.ProjTransId == projProposalItem.ProjTransId;
transTaxInformation = TransTaxInformationHelper::findOrCreateTransTaxInformation(salesLine.TableId, salesLine.RecId);
select firstonly hsnCodeTable
where hsnCodeTable.RecId == transTaxInformation.HSNCodeTable;
if (hsnCodeTable)
{
hsn = hsnCodeTable.Code;
}
else
{
hsn = HSNCodeTable_IN::find(inventTable.HSNCodeTable_IN).Code;
}
select firstonly serviceAccountingCodeTable_IN
where serviceAccountingCodeTable_IN.RecId == transTaxInformation.ServiceAccountingCodeTable;
if (serviceAccountingCodeTable_IN)
{
sac = serviceAccountingCodeTable_IN.SAC;
}
else
{
sac = ServiceAccountingCodeTable_IN::find(inventTable.ServiceAccountingCodeTable_IN).SAC;
}
ChargesTmp.Sunb_HSN_SAC = hsn + sac;
// ---------------- CHARGES TAX CALCULATION ----------------
if (projProposalJour.CurrencyId == 'INR')
{
projProposalTotals = new ProjProposalTotals(projProposalJour);
taxableDocument = TaxableDocumentObject::construct(projProposalTotals.parmTaxableDocDescriptorItemSOTrans());
taxDocumentObject = TaxBusinessService::calculateTax(taxableDocument);
if (taxDocumentObject)
{
// IGST
lineEnumerator = taxDocumentObject.componentLines("GST","IGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
real TaxValue = componentLineObject.getMeasure("Rate").value().value();
real TaxableAmount = componentLineObject.getMeasure("Base Amount").value().value();
real TaxAmount = (TaxableAmount * TaxValue * 100) / 100;
if (TaxableAmount == ChargesTmp.Charges_TaxableAmount)
{
ChargesTmp.Charges_IGST = abs(TaxAmount);
ChargesIGST += ChargesTmp.Charges_IGST;
ChargesTmp.Charges_TaxRate = TaxValue;
}
}
// SGST
lineEnumerator = taxDocumentObject.componentLines("GST","SGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
real TaxValue = componentLineObject.getMeasure("Rate").value().value();
real TaxableAmount = componentLineObject.getMeasure("Base Amount").value().value();
real TaxAmount = (TaxableAmount * TaxValue * 100) / 100;
if (TaxableAmount == ChargesTmp.Charges_TaxableAmount)
{
ChargesTmp.Charges_SGST = abs(TaxAmount);
ChargesSGST += ChargesTmp.Charges_SGST;
ChargesTmp.Charges_TaxRate = TaxValue;
}
}
// CGST
lineEnumerator = taxDocumentObject.componentLines("GST","CGST");
while (lineEnumerator.moveNext())
{
componentLineObject = lineEnumerator.current();
real TaxValue = componentLineObject.getMeasure("Rate").value().value();
real TaxableAmount = componentLineObject.getMeasure("Base Amount").value().value();
real TaxAmount = (TaxableAmount * TaxValue * 100) / 100;
if (TaxableAmount == ChargesTmp.Charges_TaxableAmount)
{
ChargesTmp.Charges_CGST = abs(TaxAmount);
ChargesCGST += ChargesTmp.Charges_CGST;
ChargesTmp.Charges_TaxRate = TaxValue;
}
}
}
TotalCharges = ChargesIGST + ChargesCGST + ChargesSGST + TotalChrgesTaxAmt;
ChargesTmp.insert();
}
}
// ---------------- MARKUP CHARGES END ----------------
TotalAmount = TotalGst + TotalLineAmt + TotalCharges;
if (projProposalJour.CurrencyId == 'INR')
{
//LineTmp.Sunb_TotalInWords = Sunb_NumToWord1::numeralsToTxt_IN(TotalAmount);
LineTmp.Sunb_TotalInWords = Sunb_NumToWord1::numeralsToTxt_MultiCurrency(TotalAmount, 'INR');
}
LineTmp.insert();
LineTmp.clear();
}