/// <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); }
public static IState Instance(String message, StateInstance <PromotionDocument> returnConfirmWithObject, StateInstance <PromotionDocument> returnCancelWithObject, PromotionDocument doc) { ReturnConfirmWithObject = returnConfirmWithObject; ReturnCancelWithObject = returnCancelWithObject; document = doc; DisplayAdapter.Cashier.Show(message); return(state); }
private void ClearEventsLog() { if (cr.State == state) { return; } ReturnConfirmWithObject = null; ReturnCancelWithObject = null; ReturnCancel = null; ReturnConfirm = null; document = null; }
public override void Pay(CurrencyPaymentInfo info) { paymentInfo = info; MenuList tempCurrencies = CurrencyPaymentInfo.GetCurrencies(); MenuList currencies = new MenuList(); foreach (CurrencyPaymentInfo cpi in tempCurrencies) { CurrencyPaymentInfo currency = (CurrencyPaymentInfo)cpi.Clone(); currency.Amount = input.ToDecimal(); currencies.Add(currency); } paymentInfo.Amount = 0; input = new Number(); promoDocument = null; cr.State = ListCurrencies.Instance(currencies, new ProcessSelectedItem <CurrencyPaymentInfo>(PayByForeignCurrency)); }
public static IState ComplateCreditPayment() { if (cr.Document.Status != DocumentStatus.Paying) { //First payment 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 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)); }
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))); }