/// <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; } }
/// <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; } } } }