static void exchangeRate(Args _args)
{
ExchangeRateHelper exchangeRateHelper;
TransDate transdate;
CurrencyCode currencycode = "USD";
CurrencyExchangeRate ex1,ex2;
transdate = mkDate(16,11,2016);
exchangeRateHelper = exchangeRateHelper::newExchangeDate(Ledger::current(),currencycode,transdate);
ex1 = exchangeRateHelper.getExchangeRate1();
ex2 = exchangeRateHelper.getExchangeRate2();
info(strFmt("%1 - %2",ex1,ex2));
}
{
ExchangeRateHelper exchangeRateHelper;
TransDate transdate;
CurrencyCode currencycode = "USD";
CurrencyExchangeRate ex1,ex2;
transdate = mkDate(16,11,2016);
exchangeRateHelper = exchangeRateHelper::newExchangeDate(Ledger::current(),currencycode,transdate);
ex1 = exchangeRateHelper.getExchangeRate1();
ex2 = exchangeRateHelper.getExchangeRate2();
info(strFmt("%1 - %2",ex1,ex2));
}
public real
balanceInINR()
{
ExchRate
exchRate_abc,exchRates_IN;
ExchangeRate
exchangeratetab;
ExchangeRateCurrencyPair
exchangeratecurrecypair;
real s,p,BalanceINR;
if(Curext()
!= "HMIN")
{
s =
amountCurOpen;//CustTrans.RemainAmountMST();//tmpAccountSum.Balance01;
select validtimestate(exchRateDate)
exchangeratetab order by ValidFrom desc
where exchangeratetab.ValidFrom <=
exchRateDate
join
exchangeratecurrecypair where
exchangeratecurrecypair.RecId ==
exchangeRatetab.ExchangeRateCurrencyPair
&& exchangeratecurrecypair.FromCurrencyCode ==
CompanyInfo::standardCurrency()
&&
exchangeratecurrecypair.ToCurrencyCode
== "INR";
if(exchangeratetab.RecId)
{
exchRate_abc = exchangeratetab.ExchangeRate/100;
}
else
{
select validtimestate(exchRateDate)
exchangeratetab order by ValidFrom desc
where exchangeratetab.ValidFrom <=
exchRateDate
join exchangeratecurrecypair where exchangeratecurrecypair.RecId == exchangeRatetab.ExchangeRateCurrencyPair
&& exchangeratecurrecypair.FromCurrencyCode == "INR"
&& exchangeratecurrecypair.ToCurrencyCode == CompanyInfo::standardCurrency();//CompanyInfo::findByCompany_IN(companyDomainList.companyId).HM_standardCurrency()
;
if(exchangeratetab.RecId)
{
exchRate_abc = exchangeratetab.ExchangeRate/100;
}
}
BalanceINR = s*exchRate_abc ;
return s*exchRate_abc;
}
else
{
if(custtrans.CurrencyCode == "INR")
{
BalanceINR = amountCurOpen;//CustTrans.RemainAmountMST();//tmpAccountSum.Balance01;
}
else
{
select validtimestate(exchRateDate)
exchangeratetab order by ValidFrom desc
where exchangeratetab.ValidFrom <=
exchRateDate
join exchangeratecurrecypair where exchangeratecurrecypair.RecId == exchangeRatetab.ExchangeRateCurrencyPair
&&
exchangeratecurrecypair.FromCurrencyCode == custtrans.currencycode
&&
exchangeratecurrecypair.ToCurrencyCode
== "INR";
if(exchangeratetab.RecId)
{
exchRates_IN =exchangeratetab.ExchangeRate/100;
//BalanceINR =
/*tmpAccountSum.Balance01Cur*/CustTrans.RemainAmountCur()
*exchRates_IN;//commented by raj
BalanceINR = amountCurOpen*exchRates_IN;
}
else
{
select
validtimestate(exchRateDate) exchangeratetab order
by ValidFrom desc
where exchangeratetab.ValidFrom <=
exchRateDate
join exchangeratecurrecypair where exchangeratecurrecypair.RecId ==
exchangeRatetab.ExchangeRateCurrencyPair
&&
exchangeratecurrecypair.FromCurrencyCode == "INR"
&&
exchangeratecurrecypair.ToCurrencyCode
== custtrans.currencycode;
exchRates_IN =exchangeratetab.ExchangeRate/100;
//BalanceINR =
/*tmpAccountSum.Balance01Cur*/CustTrans.RemainAmountCur()
*exchRates_IN;//commented by raj
BalanceINR = amountCurOpen *exchRates_IN;
}
}
return BalanceINR;
}
}
public real
balanceInUSD()
{
ExchangeRate
exchangeratetab;
ExchangeRateCurrencyPair
exchangeratecurrecypair;
ExchRate
exchRate_abc,exchRate_usd,exchRates1;
real s
,TestBalance,BalanceInUSD ;
// ExchRates
exchRatesz,ExchRates;
if(custtrans.CurrencyCode != "USD")
{
exchRate_usd =1;
select validtimestate(exchRateDate) exchangeratetab order
by ValidFrom desc
where exchangeratetab.ValidFrom <=
exchRateDate
join exchangeratecurrecypair where exchangeratecurrecypair.RecId ==
exchangeRatetab.ExchangeRateCurrencyPair
&& exchangeratecurrecypair.FromCurrencyCode ==
custtrans.currencycode
&& exchangeratecurrecypair.ToCurrencyCode == "USD";
if(exchangeratetab.RecId)
{
exchRate_usd = (exchangeratetab.ExchangeRate/100);
}
else
{
exchangeratetab.clear();
exchangeratecurrecypair.clear();
select
validtimestate(exchRateDate) exchangeratetab order
by ValidFrom desc
where exchangeratetab.ValidFrom <=
exchRateDate
join exchangeratecurrecypair where exchangeratecurrecypair.RecId == exchangeRatetab.ExchangeRateCurrencyPair
&& exchangeratecurrecypair.FromCurrencyCode == "USD"
&& exchangeratecurrecypair.ToCurrencyCode ==
custtrans.currencycode;
if(exchangeratetab.RecId)
{
exchRate_usd = (exchangeratetab.ExchangeRate/100);
return
amountCurOpen/exchRate_usd;//CustTrans.RemainAmountCur()/exchRate_usd;
}
else
{
exchRate_usd = 0;
}
}
if(custTransOpenPerDateTmp.HM_BalanceInINR !=0)
{
BalanceInUSD = amountCurOpen*exchRate_usd;//CustTrans.RemainAmountCur()*exchRate_usd;
//CustTrans.RemainAmountCur()*exchRate_usd;//BalanceINR/exchRate_usd;
}
else
{
BalanceInUSD = 0;
}
}
else if(custTrans.CurrencyCode
== "USD")
{
BalanceInUSD = amountCurOpen;//CustTrans.RemainAmountCur();/*tmpAccountSum.Balance01Cur*/
}
return balanceInUSD;
}
No comments:
Post a Comment