/// <summary> /// /// </summary> /// /// <returns></returns> public Decimal[] GetTaxGroupAdjustments() { if (taxGroupAdjustments == null) { SalesDocument document = (SalesDocument)(this.Target); taxGroupAdjustments = new Decimal[Department.NUM_TAXGROUPS]; decimal productAdjustment, totalAdjustment = 0, maxAdjustment = 0; int maxAdjustedProduct = 0; foreach (int dep in document.TaxGroupTotals.Keys) { productAdjustment = Rounder.RoundDecimal(this.NetAmount * (document.TaxGroupTotals[dep] / this.adjustedTotal), 2, true); if (Math.Abs(productAdjustment) > Math.Abs(maxAdjustment)) { maxAdjustment = productAdjustment; maxAdjustedProduct = dep; } taxGroupAdjustments[dep] += productAdjustment; totalAdjustment += productAdjustment; } taxGroupAdjustments[maxAdjustedProduct] += this.NetAmount - totalAdjustment; } return(taxGroupAdjustments); }
public InventoryAssignmentModel(WorkEffortInventoryAssignment assignment) { this.PartId = assignment.InventoryItem.Part?.PartIdentification(); this.PartName = assignment.InventoryItem.Part?.Name; this.Quantity = assignment.DerivedBillableQuantity; this.UnitOfMeasure = assignment.InventoryItem.Part?.UnitOfMeasure?.Abbreviation?.ToUpperInvariant() ?? assignment.InventoryItem.Part?.UnitOfMeasure?.Name?.ToUpperInvariant() ?? "EA"; this.UnitSellingPrice = assignment.UnitSellingPrice.ToString("N2", new CultureInfo("nl-BE")); this.SellingPrice = Rounder.RoundDecimal(this.Quantity * assignment.UnitSellingPrice, 2).ToString("N2", new CultureInfo("nl-BE")); }
public PurchaseOrderItemAssignmentModel(WorkEffortPurchaseOrderItemAssignment assignment) { var purchaseOrderItem = assignment.PurchaseOrderItem; this.Name = purchaseOrderItem.Part?.Name ?? purchaseOrderItem.Description; this.Quantity = assignment.Quantity; this.UnitOfMeasure = purchaseOrderItem.Part?.UnitOfMeasure?.Abbreviation?.ToUpperInvariant() ?? purchaseOrderItem.Part?.UnitOfMeasure?.Name?.ToUpperInvariant() ?? "EA"; this.UnitSellingPrice = Rounder.RoundDecimal(assignment.UnitSellingPrice, 2).ToString("N2", new CultureInfo("nl-BE")); this.SellingPrice = Rounder.RoundDecimal(assignment.Quantity * assignment.UnitSellingPrice, 2).ToString("N2", new CultureInfo("nl-BE")); }
public static void PayByForeignCurrency(CurrencyPaymentInfo currency) { if (currency.Amount >= 10000000) { //Should probably be in document.pay cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.CURRENCY_LIMIT_EXCEEDED_PAYMENT_INVALID)); return; } currency.Amount = Rounder.RoundDecimal(currency.Amount * currency.ExchangeRate, 2, true); //cr.State = cr.Document.Pay(currency); cr.State = CalculateTotal(currency); }
public TimeEntryByBillingRateModel(IGrouping <decimal?, TimeEntry> @group) { var timeEntries = @group.ToArray(); var billingRate = @group.Key ?? 0.0m; var amountOfTime = timeEntries.Where(v => v.IsBillable).Sum(v => v.BillableAmountOfTime ?? v.AmountOfTime ?? 0.0m); var billingAmount = timeEntries.Where(v => v.IsBillable).Sum(v => v.BillingAmount); var cost = timeEntries.Sum(v => v.Cost); // Round this.BillingRate = Rounder.RoundDecimal(billingRate, 2).ToString("N2", new CultureInfo("nl-BE")); this.AmountOfTime = Rounder.RoundDecimal(amountOfTime, 2).ToString("N2", new CultureInfo("nl-BE")); this.BillingAmount = Rounder.RoundDecimal(billingAmount, 2).ToString("N2", new CultureInfo("nl-BE")); this.Cost = Rounder.RoundDecimal(cost, 2).ToString("N2", new CultureInfo("nl-BE")); }
public TimeEntryModel(TimeEntry timeEntry) { var frequency = timeEntry.TimeFrequency?.Abbreviation ?? timeEntry.TimeFrequency?.Name; this.AmountOfTime = Rounder.RoundDecimal(timeEntry.BillableAmountOfTime ?? timeEntry.AmountOfTime ?? 0.0m, 2); this.BillingRate = Rounder.RoundDecimal(timeEntry.BillingRate ?? 0.0m, 2).ToString("N2", new CultureInfo("nl-BE")); this.BillingAmount = Rounder.RoundDecimal(timeEntry.BillingAmount, 2).ToString("N2", new CultureInfo("nl-BE")); this.Cost = Rounder.RoundDecimal(timeEntry.Cost, 2).ToString("N2", new CultureInfo("nl-BE")); this.TimeFrequency = frequency?.ToUpperInvariant(); this.WorkerName = timeEntry.TimeSheetWhereTimeEntry?.Worker?.PartyName; this.WorkerId = timeEntry.TimeSheetWhereTimeEntry?.Worker?.FirstName; this.Description = timeEntry.Description; this.IsBillable = timeEntry.IsBillable == true; this.FromDate = timeEntry.FromDate.ToString("yyyy-MM-dd"); this.FromTime = timeEntry.FromDate.ToString("hh:mm:ss"); this.ThroughDate = timeEntry.ThroughDate?.ToString("yyyy-MM-dd"); this.ThroughTime = timeEntry.ThroughDate?.ToString("hh:mm:ss"); }
public InvoiceItemModel(PurchaseInvoiceItem item) { this.Part = item.Part?.Name; var description = item.Description; if (string.IsNullOrEmpty(this.Part) && description == null) { description = item.InvoiceItemType.Name; } this.Description = description?.Split('\n'); this.Quantity = item.Quantity; this.Price = Rounder.RoundDecimal(item.UnitPrice, 2).ToString("N2", new CultureInfo("nl-BE")); this.Amount = Rounder.RoundDecimal(item.TotalExVat, 2).ToString("N2", new CultureInfo("nl-BE")); this.Comment = item.Comment?.Split('\n'); this.SupplierProductId = item.Part?.SupplierOfferingsWherePart?.FirstOrDefault(v => v.Supplier.Equals(item.PurchaseInvoiceWherePurchaseInvoiceItem.BilledFrom))?.SupplierProductId; }
/// <summary> /// Adjust percent discount,discount,percent fee and fee transaction /// </summary> /// <param name="target"> /// The target that will be adjusted. /// </param> /// <param name="type"> /// Type of adjustment. /// </param> /// <param name="input"> /// Adjustment amount. /// </param> public Adjustment(IAdjustable target, AdjustmentType type, Decimal input) { this.method = type; input = Math.Round(input, 2); this.requestValue = input; this.adjustedObject = target; this.adjustedTotal = target.TotalAmount; createdTime = DateTime.Now; if (cr.CurrentCashier != null) { authorizingCashierId = cr.CurrentCashier.Id; } /* * 0.0001m added because of math.round bug * for example: Math.Round(0.145, 2) = 0.14 * but Math.Round(0.1451,2) = 0.15 */ switch (type) { case AdjustmentType.Discount: netAmount = -1m * input; break; case AdjustmentType.PercentDiscount: requestValue = Math.Round(input, 0); netAmount = (-1m) * Rounder.RoundDecimal((input / 100) * target.TotalAmount + 0.0001m, 2, true); break; case AdjustmentType.Fee: netAmount = input; break; case AdjustmentType.PercentFee: requestValue = Math.Round(input, 0); netAmount = Rounder.RoundDecimal((input / 100) * target.TotalAmount + 0.0001m, 2, true); break; } }
public OrderItemModel(SalesOrderItem item) { var currencyIsoCode = item.SalesOrderWhereSalesOrderItem.DerivedCurrency.IsoCode; this.Reference = item.InvoiceItemType?.Name; this.Product = item.Product?.Name; var description = item.Description; if (description != null) { description = Markdown.ToPlainText(description); } this.Description = description?.Split('\n'); this.Quantity = item.QuantityOrdered; // TODO: Where does the currency come from? this.Price = Rounder.RoundDecimal(item.UnitPrice, 2).ToString("N2", new CultureInfo("nl-BE")); this.Amount = Rounder.RoundDecimal(item.TotalExVat, 2).ToString("N2", new CultureInfo("nl-BE")); this.Comment = item.Comment?.Split('\n'); }
public static IState Pay(Decimal amount) { List <String> promotionRemark = new List <string>(); if (amount != 0) { if (paymentInfo is CurrencyPaymentInfo) { paymentInfo.Amount = Rounder.RoundDecimal(amount * ((CurrencyPaymentInfo)paymentInfo).ExchangeRate, 2, true); } else { paymentInfo.Amount = amount; } } if (paymentInfo.MinimumPayment > paymentInfo.Amount) { throw new OverflowException("ÖDEME MÝKTARI\nLÝMÝTÝN ALTINDA"); } if (paymentInfo.MaximumPayment < paymentInfo.Amount) { throw new OverflowException("ÖDEME MÝKTARI\nLÝMÝTÝN ÜZERÝNDE"); } //Payment on eft pos try { if ((paymentInfo is CreditPaymentInfo) && (cr.EftPos != null) && (((CreditPaymentInfo)paymentInfo).Credit.PayViaEft)) { IEftResponse response = cr.EftPos.Pay(paymentInfo.Amount, ((CreditPaymentInfo)paymentInfo).Installments); if (response.HasError) { throw new Exception("Exception occured when payment via EftPos."); } ((CreditPaymentInfo)paymentInfo).IsPaymentMade = true; ((CreditPaymentInfo)paymentInfo).Remark = response.CardNumber; } } catch (Exception) { return(cr.State = States.ConfirmPayment.Instance(PosMessage.ACCEPT_PAYMENT_OR_REPEAT_VIA_EFT, new StateInstance <Decimal>(ComplateCreditPayment), new StateInstance(cancelState), new StateInstance <Decimal>(Pay))); } // Add using points after confirm if (paymentInfo is CreditPaymentInfo && ((CreditPaymentInfo)paymentInfo).Credit.IsPointPayment) { long usingPoint = cr.Document.PriceToPoint(paymentInfo.Amount * -1); cr.Document.AddPoint(usingPoint); } // Add promo document if (!cr.Document.CanEmpty) { cr.Document.Append(promoDocument); promoDocument = null; } if (paymentInfo.Amount >= cr.Document.BalanceDue) { promoDocument = null; } if (cr.Document.Status != DocumentStatus.Paying && cr.Document.Remark != null) { foreach (String remark in cr.Document.Remark) { cr.Printer.PrintRemark(remark); } } return(cr.Document.Pay(paymentInfo)); }
public void ApplyPromotion() { decimal ratio = 0m; decimal lineDiscount = 0m, percDiscount = 0m; switch (base.LimitType) { case LimitType.Quantity: ratio = (int)(LineQuantity() / base.RequiredQuantity); lineDiscount = ratio * base.Discount; percDiscount = Rounder.RoundDecimal((TotalPercantageDiscount() / LineQuantity()) * (ratio * base.RequiredQuantity), 2, true); break; case LimitType.Amount: ratio = (TotalAmount() / base.RequiredAmount); lineDiscount = LineQuantity() * base.Discount; percDiscount = Rounder.RoundDecimal(TotalPercantageDiscount(), 2, true); break; default: ratio = LineQuantity(); lineDiscount = ratio * base.Discount; percDiscount = Rounder.RoundDecimal(TotalPercantageDiscount(), 2, true); break; } bool isPercentage = false; if (percDiscount > lineDiscount) { lineDiscount = percDiscount; isPercentage = true; } DataRow[] items = SoldItem.Instance().Select(String.Format("Plu = '{0}'", base.Id)); if (base.limitType != LimitType.Quantity && isPercentage) { foreach (DataRow rowItems in items) { rowItems["DiscountAmount"] = Rounder.RoundDecimal(((decimal)rowItems["Amount"] * base.PercentDiscount) / 100, 2, true); rowItems["PercentDiscount"] = base.PercentDiscount; } } else { decimal discItemQuantity = base.RequiredQuantity * ratio; decimal unitDisc = Rounder.RoundDecimal(lineDiscount / discItemQuantity, 2, true); decimal diff = lineDiscount - Rounder.RoundDecimal(unitDisc * discItemQuantity, 2, true); decimal amount = 0m; foreach (DataRow rowItems in items) { decimal lineDiscQuantity = (decimal)rowItems["Quantity"]; if (lineDiscQuantity <= 0) { continue; } int percRate = base.PercentDiscount; if ((decimal)rowItems["Quantity"] > discItemQuantity) { lineDiscQuantity = discItemQuantity; amount = (unitDisc * lineDiscQuantity) + diff; percRate = 0; } else { amount = (unitDisc * lineDiscQuantity) + diff; } diff = 0; discItemQuantity -= lineDiscQuantity; rowItems["DiscountAmount"] = (decimal)rowItems["DiscountAmount"] + amount; if (isPercentage) { rowItems["PercentDiscount"] = percRate; } if (discItemQuantity == 0) { break; } } } decimal appliedDisc = (decimal)SoldItem.Instance().Compute("Sum(DiscountAmount)", String.Format("Plu = '{0}'", base.Id)); pointEarned = (long)ratio * (base.Points + base.ExtraPoints); SoldItem.Instance().SetPromotion(this, appliedDisc + pointEarned > 0); }