Calculate markup trans for Sales order including Tax
static Amount calculateMarkupTrans(SalesId _salesId)
{
AmountCur markupAmount,headermarkupamt,linemarkupamt,totTaxAmountCur,lineamount;
MarkupTrans markupTrans;
CurrencyExchangeHelper curCurrencyExchangeHelper;
SalesTable salesTable = SalesTable::find(_salesId);
SalesLine salesLine;
SalesTotals salestotals;
container cont;
// Code to calculate total tax for sales order inlucing charges tax-->
salesTotals = SalesTotals::construct(salesTable, SalesUpdate::All);
salesTotals.calc();
cont = salesTotals.displayFieldsCurrency(salesTotals.currencyCode());
totTaxAmountCur = conpeek(cont, TradeTotals::posTaxTotal());
// Code to calculate total tax for sales order inlucing charges tax<--
// Code to calculate total Charge for sales order header-->
while select markupTrans
where markupTrans.TransTableId == salesTable.TableId
&&markupTrans.TransRecId == salesTable.RecId
{
markupAmount = markupTrans.Value;
if (markupTrans.CurrencyCode != salesTable.CurrencyCode)
{
// To automatically conver amount Markup::calcMarkupAmount can be used
curCurrencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::primaryLedger(CompanyInfo::findDataArea(markupTrans.company()).RecId), systemDateGet());
markupAmount = curCurrencyExchangeHelper.calculateAccountingToTransaction(salesTable.CurrencyCode, markupAmount, true);
}
headermarkupamt =headermarkupamt+markupAmount;
}
// Code to calculate total Charge for sales order header <--
// Code to calculate total Charge for sales order lines-->
while select salesLine
where salesLine.SalesId == salesTable.SalesId
{
while select markupTrans
where markupTrans.TransTableId == salesLine.TableId
&&markupTrans.TransRecId == salesLine.RecId
{
markupAmount = Markup::calcTrans(markupTrans, salesLine.SalesQty, salesLine.LineAmount);
if (markupTrans.CurrencyCode != salesTable.CurrencyCode)
{
// To automatically conver amount Markup::calcMarkupAmount can be used
curCurrencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::primaryLedger(CompanyInfo::findDataArea(markupTrans.company()).RecId), systemDateGet());
markupAmount = curCurrencyExchangeHelper.calculateAccountingToTransaction(salesTable.CurrencyCode, markupAmount, true);
}
linemarkupamt = linemarkupamt+markupAmount;
}
}
// Code to calculate total Charge for sales order lines<--
markupAmount = linemarkupamt+headermarkupamt;//Sum both line and Header Charges for Sales order
// Calculate Charge lines tax if we get tax > 0 for sales order-->
if(salesTable.InclTax == noyes::No && totTaxAmountCur >0)// Calculate Charge lines tax if we get tax > 0 for sales order
{
TaxGroupHeading taxgroup;
TaxGroupData taxgroupdata;
select * from taxgroupdata
where taxgroupdata.TaxGroup == salesTable.TaxGroup;
real taxpercent =taxgroupdata.ShowTaxValue();
markupAmount =markupAmount+(markupAmount*taxgroupdata.ShowTaxValue())/100;//Add tax amount to Charge lines when Salestable Includetax field is set to no.
}
// Calculate Charge lines tax if we get tax > 0 for sales order-->
return markupAmount;
}
Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks
ReplyDelete