Exemple #1
0
            private static RoundingUnitAndMethod GetRoundingUnitAndMethod(RequestContext context, string currencyCode, bool useSalesRounding)
            {
                GetCurrencyByCodeDataRequest dataRequest = new GetCurrencyByCodeDataRequest(currencyCode, new ColumnSet());
                var currency = context.Execute <SingleEntityDataServiceResponse <Currency> >(dataRequest).Entity;

                decimal        roundingUnit   = Rounding.DefaultRoundingValue;
                RoundingMethod roundingMethod = RoundingMethod.Nearest;

                if (currency != null)
                {
                    roundingUnit = useSalesRounding ? currency.RoundOffSales : currency.RoundOffPrice;
                    if (roundingUnit == decimal.Zero)
                    {
                        roundingUnit = Rounding.DefaultRoundingValue;
                    }

                    int roundoffType = useSalesRounding ? currency.RoundOffTypeSales : currency.RoundOffTypePrice;
                    roundingMethod = Rounding.ConvertRoundOffTypeToRoundingMethod(roundoffType);
                }
                else
                {
                    NetTracer.Warning("No currency found for currency code {0}. Falling back to default rounding value ({1}).", currencyCode, Rounding.DefaultRoundingValue);
                }

                return(new RoundingUnitAndMethod(roundingUnit, roundingMethod));
            }
Exemple #2
0
            private SingleEntityDataServiceResponse <Currency> GetCurrencyByCode(GetCurrencyByCodeDataRequest request)
            {
                CurrencyDataManager manager = this.GetDataManagerInstance(request.RequestContext);

                Currency currency = manager.GetCurrencyByCode(request.CurrencyCode, request.Columns);

                return(new SingleEntityDataServiceResponse <Currency>(currency));
            }