I want to add 4 new methods to Standard class "CurrencyExchangeHelper" . I already tried by getting error "Error Chain of command method must contain one next call." I have allready checked some posted questions but didn't get it could you please tell me how to do it below are 4 methods
public static Amount roundWithRuleTypeCurrencyTable(Amount _amount, Currency _currency, CurrencyRoundingRuleType _currencyRoundingRuleType)
{
Amount result;
if (_amount == 0)
{
return 0;
}
switch (_currencyRoundingRuleType)
{
case CurrencyRoundingRuleType::Amount:
result = CurrencyExchangeHelper::roundWithRule(
_amount,
_currency.RoundingPrecision,
RoundOffType::Ordinary);
break;
case CurrencyRoundingRuleType::Price:
result = CurrencyExchangeHelper::roundWithRule(
_amount,
_currency.RoundOffPrice,
_currency.RoundOffTypePrice);
break;
case CurrencyRoundingRuleType::PurchaseOrder:
result = CurrencyExchangeHelper::roundWithRule(
_amount,
_currency.RoundOffPurch,
_currency.RoundOffTypePurch);
break;
case CurrencyRoundingRuleType::SalesOrder:
result = CurrencyExchangeHelper::roundWithRule(
_amount,
_currency.RoundOffSales,
_currency.RoundOffTypeSales);
break;
// <GJP>
case CurrencyRoundingRuleType::AssetDep_JP:
result = CurrencyExchangeHelper::roundWithRule(
_amount,
_currency.RoundOffAssetDep_JP,
_currency.RoundOffTypeAssetDep_JP);
break;
// </GJP>
default:
throw error(Error::wrongUseOfFunction(funcname()));
}
return result;
}
2
public static Amount roundWithRuleType(Amount _amount, CurrencyCode _currency, CurrencyRoundingRuleType _currencyRoundingRuleType)
{
Currency currency;
if (_amount == 0)
{
return 0;
}
if (_currency)
{
currency = Currency::find(_currency);
}
else
{
currency = Currency::find(Ledger::accountingCurrency());
}
return CurrencyExchangeHelper::roundWithRuleTypeCurrencyTable(_amount, currency, _currencyRoundingRuleType);
}
3
public static Amount roundWithRule(Amount _amount, RoundOff _roundOffAmount, RoundOffType _roundOffType)
{
RoundOff roundOffAmountLoc = _roundOffAmount;
Amount result;
if (_amount == 0)
{
return 0;
}
switch (_roundOffType)
{
case RoundOffType::Ordinary:
if (!roundOffAmountLoc)
{
roundOffAmountLoc = 0.01;
}
result = round(_amount, roundOffAmountLoc);
break;
case RoundOffType::RoundDown:
if (!roundOffAmountLoc)
{
roundOffAmountLoc = 1.0;
}
// round to zero since from a financial standpoint that's what
// we mean by rounding down
result = roundZero(_amount, roundOffAmountLoc);
break;
case RoundOffType::RoundUp:
if (!roundOffAmountLoc)
{
roundOffAmountLoc = 1.0;
}
if (_amount >= 0)
{
result = roundUp(_amount, roundOffAmountLoc);
}
else
{
result = roundDown(_amount, roundOffAmountLoc);
}
break;
default:
throw error(Error::wrongUseOfFunction(funcname()));
}
return result;
}
4
public static Amount round(Amount _amount, CurrencyCode _currency)
{
return CurrencyExchangeHelper::roundWithRuleType(
_amount,
_currency,
CurrencyRoundingRuleType::Amount);
}