/// <summary> /// Shows document subtotal to cashier. /// Two types: /// First: If customer autho. adjustment is active;show document subtotal wtih the discounted value. /// Second: If customer autho is not active; show only discounted value. /// </summary> /// <returns> ///Document state:DocumentOpen,DocumentSubtotal or DocumentPayment. ///</returns> public static DocumentState Instance() { if (cr.Document.IsEmpty) { return(state); } String strMessage = String.Format("{0}\n{1:C}", PosMessage.SUBTOTAL, new Number(cr.Document.BalanceDue)); if (cr.Document.Status == DocumentStatus.Active) { PromotionDocument doc = new PromotionDocument(cr.Document, null, PromotionType.Document); if (doc.HasAdjustment) { strMessage = DisplayAdapter.AmountPairFormat(PosMessage.SUBTOTAL, cr.Document.BalanceDue, PosMessage.DISCOUNTED, doc.BalanceDue); DisplayAdapter.Both.Show(strMessage); return(state); } } DisplayAdapter.Both.Show(strMessage); if (!(cr.Document.State is DocumentPaying || cr.Document.State is DocumentSubTotal)) { bool hardcopy = cr.DataConnector.CurrentSettings.GetProgramOption(Setting.PrintSubtTotal) == PosConfiguration.ON; cr.Printer.PrintSubTotal(cr.Document, hardcopy); } DisplayAdapter.Customer.Show("{0}\n{1:C}", PosMessage.SUBTOTAL, new Number(cr.Document.BalanceDue)); return(state); }
private static IState CalculateTotal(PaymentInfo pInfo) { paymentInfo = pInfo; Decimal balanceDue = 0; if (!(cr.Document.CanEmpty)) { PaymentInfo currentPaymentInfo = paymentInfo.Clone(); if (currentPaymentInfo.Amount == 0) { currentPaymentInfo.Amount = cr.Document.BalanceDue; } promoDocument = new PromotionDocument(cr.Document, currentPaymentInfo, PromotionType.Document); if (promoDocument.HasAdjustment) { balanceDue = promoDocument.BalanceDue; } else { balanceDue = cr.Document.BalanceDue; } if (!(cr.State is PaymentAfterTotalAdjustment)) { cancelState = States.Start.Instance; } } else { balanceDue = cr.Document.BalanceDue; } // Ýf payment is point payment, dont gain point so clear it if (paymentInfo is CreditPaymentInfo && ((CreditPaymentInfo)paymentInfo).Credit.IsPointPayment) { if (promoDocument != null && promoDocument.Points != null && promoDocument.Points.Count > 0) { promoDocument.Points.Clear(); } // And if point payment amount bigger than balanceDue, fix it if (paymentInfo.Amount > balanceDue) { paymentInfo.Amount = balanceDue; } } if (paymentInfo.Amount == 0) { if (paymentInfo is CurrencyPaymentInfo) { decimal dec = Math.Round(balanceDue / ((CurrencyPaymentInfo)paymentInfo).ExchangeRate, 2); paymentInfo.Amount = Math.Round(dec * ((CurrencyPaymentInfo)paymentInfo).ExchangeRate, 2); //paymentInfo.Amount = Math.Truncate(100 * (dec * ((CurrencyPaymentInfo)paymentInfo).ExchangeRate)) / 100; } else { paymentInfo.Amount = balanceDue; } } //TODO This crap should be in HYDisplay DisplayAdapter.Customer.Show(PosMessage.SUBTOTAL, balanceDue); return(cr.State = States.ConfirmPayment.Instance(DisplayAdapter.AmountPairFormat(PosMessage.TOTAL, balanceDue, paymentInfo.ToString(), paymentInfo.Amount), new StateInstance <Decimal>(Pay), new StateInstance(cancelState))); }