Example #1
0
        public AccountRoundingService(IRounding rounder, IPrecisionProvider precisionProvider, string currency)
        {
            if (rounder == null)
            {
                throw new ArgumentNullException(nameof(rounder));
            }

            if (precisionProvider == null)
            {
                throw new ArgumentNullException(nameof(precisionProvider));
            }

            if (currency == null)
            {
                throw new ArgumentNullException(nameof(currency));
            }


            this.rounder           = rounder;
            this.precisionProvider = precisionProvider;

            if (currency.Length > 0)
            {
                this.precision = precisionProvider.GetCurrencyPrecision(currency);
            }
        }
Example #2
0
        /// <summary>
        /// Format the Price/Amount text for display
        /// </summary>
        /// <param name="subcodeTable"></param>
        private static void FormatDisplayText(DataTable subcodeTable)
        {
            // Set DisplayPrice
            subcodeTable.Columns.Add(new DataColumn("PRICE", typeof(string)));

            string    normalPrice  = LSRetailPosis.ApplicationLocalizer.Language.Translate(60009);
            string    displayPrice = string.Empty;
            IRounding rounding     = InfoCodes.InternalApplication.Services.Rounding;

            foreach (DataRow row in subcodeTable.Rows)
            {
                decimal amount = (decimal)row["AMOUNTPERCENT"];
                switch ((LSRetailPosis.POSProcesses.PriceTypeEnum)row["PRICETYPE"])
                {
                case LSRetailPosis.POSProcesses.PriceTypeEnum.FromItem:
                    displayPrice = normalPrice;
                    break;

                case LSRetailPosis.POSProcesses.PriceTypeEnum.Price:
                    displayPrice = rounding.RoundForDisplay(amount, ApplicationSettings.Terminal.StoreCurrency, true, true);
                    break;

                case LSRetailPosis.POSProcesses.PriceTypeEnum.Percent:
                    displayPrice = string.Format("{0}%", rounding.Round(amount, false));
                    break;

                default:
                    displayPrice = string.Empty;
                    break;
                }

                row["PRICE"] = displayPrice;
            }
        }
        private void SetQuickAmountButtons(decimal quickButtonAmount)
        {
            amtGiftCardAmounts.LocalCurrencyCode = ApplicationSettings.Terminal.StoreCurrency;
            amtGiftCardAmounts.UsedCurrencyCode  = ApplicationSettings.Terminal.StoreCurrency;

            IRounding rounding = GiftCard.InternalApplication.Services.Rounding;

            amtGiftCardAmounts.SoldLocalAmount     = rounding.RoundAmount(quickButtonAmount, ApplicationSettings.Terminal.StoreId, this.controller.TenderInfo.TenderID.ToString());
            amtGiftCardAmounts.ForeignCurrencyMode = false;

            amtGiftCardAmounts.HighestOptionAmount = this.controller.TenderInfo.MaximumAmountAllowed;
            amtGiftCardAmounts.LowesetOptionAmount = this.controller.TenderInfo.MinimumAmountAllowed;

            amtGiftCardAmounts.ViewOption = AmountViewer.ViewOptions.ExcactAmountOnly;

            amtGiftCardAmounts.SetButtons();
        }
Example #4
0
        public AccountRoundingService(IRounding rounder, IPrecisionProvider precisionProvider, string currency)
        {
            if (rounder == null)
                throw new ArgumentNullException(nameof(rounder));

            if (precisionProvider == null)
                throw new ArgumentNullException(nameof(precisionProvider));

            if (currency == null)
                throw new ArgumentNullException(nameof(currency));


            this.rounder = rounder;
            this.precisionProvider = precisionProvider;

            if (currency.Length > 0)
                this.precision = precisionProvider.GetCurrencyPrecision(currency);
        }
Example #5
0
        /// <summary>
        /// Round tax code amounts at the Tax Group level
        /// </summary>
        /// <param name="lineItem"></param>
        /// <param name="taxGroup"></param>
        private static void RoundTaxGroup(BaseSaleItem lineItem, string taxGroup)
        {
            if (lineItem.TaxLines.Count > 0)
            {
                decimal roundedAmount = decimal.Zero;
                decimal roundedSum    = decimal.Zero;
                decimal rawSum        = decimal.Zero;
                decimal diff          = decimal.Zero;

                IRounding rounding      = TaxService.Tax.InternalApplication.Services.Rounding;
                string    storeCurrency = ApplicationSettings.Terminal.StoreCurrency;

                // Sum up raw and rounded tax amounts
                foreach (ITaxItem taxLine in lineItem.TaxLines.Where(t => (!t.Exempt) && string.Equals(taxGroup, t.TaxGroup)))
                {
                    // Accumulate rounded and unrounded/raw amounts.  Tax.Amount is the raw value.
                    roundedAmount = rounding.Round(taxLine.Amount, storeCurrency, true, 1);
                    rawSum       += taxLine.Amount;
                    roundedSum   += roundedAmount;

                    // Set Tax.Amount to the rounded amount
                    taxLine.Amount = roundedAmount;

                    // Compute the difference between the sums.
                    // If we have accumulated enough extra decimals to cause raw to round up, then we'll see a difference.
                    diff = rounding.Round(rawSum, storeCurrency, true, 1) - roundedSum;

                    // Apply the difference against the current line
                    if (diff != decimal.Zero)
                    {
                        taxLine.Amount += diff;
                        roundedSum     += diff;
                    }
                }
            }
        }
Example #6
0
 public void SetProductRounding(IRounding newproductRounding)
 {
     productRounding = newproductRounding;
 }
Example #7
0
 public Tax(decimal rate, IRounding rounding)
 {
     this._rate = rate;
     this._rounding = rounding;
 }
Example #8
0
 public BusinessLogic(IRounding rounding)
 {
     _rounding = rounding;
 }
 private TraderFoods404CalculatorSplitPrice(CurrencyField splitPrice, NumberField forQuantity, IRounding rounding)
 {
     _splitPrice  = splitPrice;
     _forQuantity = forQuantity;
     _rounding    = rounding;
 }
Example #10
0
 public Tax(decimal rate, IRounding rounding)
 {
     this._rate     = rate;
     this._rounding = rounding;
 }