public override void Void() { if (cr.Document.Adjustments == null || cr.Document.Adjustments.Length == 0 || cr.Document.Payments.Count > 0) { base.Void(); return; } cr.Document.UndoAdjustment(true); cr.State = Selling.Instance(); }
public static IState Instance(String message) { if (cr.Document.Status == DocumentStatus.Paying) { return(Payment.Continue()); } if (!message.Equals(String.Empty)) { DisplayAdapter.Cashier.Show(message); } //Turn off satis var led DisplayAdapter.Cashier.LedOff(Leds.Sale); //Turn off customer led if (cr.Document.Customer == null) { DisplayAdapter.Cashier.LedOff(Leds.Customer); } return(cr.Document.IsEmpty ? state : Selling.Instance()); }
public static IState Instance() { if (cr.Printer == null) { Chassis.RestartProgram(false); } if (cr.CurrentCashier == null || cr.CurrentManager == null) { return(Login.Instance()); } if (cr.Document.Status == DocumentStatus.Paying) { return(Payment.Continue()); } if (cr.Document.State == DocumentPaying.Instance()) { return(Payment.Continue()); } if (cr.Document.Adjustments.Length != 0) { decimal total = 0; for (int adj = 0; adj < cr.Document.Adjustments.Length; adj++) { total += cr.Document.Adjustments[adj].NetAmount; } if (total != 0) { return(Payment.Continue()); } } cr.Document.State = DocumentOpen.Instance(); //Turn off satis var led if (cr.Document.IsEmpty) { DisplayAdapter.Cashier.LedOff(Leds.Sale); } //Turn off customer led if (cr.Document.Customer == null) { DisplayAdapter.Cashier.LedOff(Leds.Customer); } //Show main menu to cashier and customer //check name if length bigger-smaller than 14 String name = cr.CurrentCashier.Name; if (name.Length > 14) { name = name.Substring(0, 14); } System.Threading.Thread.Sleep(100); DisplayAdapter.Cashier.Show(cashierMsg, cr.Document.Name, DateTime.Now, name); DisplayAdapter.Customer.Show(PosMessage.WELCOME); cr.Printer.ClearDisplay(); if (cr.Item != null) { cr.Item.Reset(); } if (cr.Item is VoidItem) { cr.Item = new SalesItem(); } Payment.ResetPayment(); #if ORDER if (!cr.Document.IsEmpty && cr.Document.ReturnReason == "WAITING_FOR_PAYMENT") { /*DisplayAdapter.Cashier.Show("ÖDEME BEKLENİYOR.."); * System.Threading.Thread.Sleep(2000); * return Selling.CloseOrder();*/ // Çıkış için document iptal edilebilir, çıkış fonk VoidLastOrder eklenebilir cr.Document.ReturnReason = null; return(States.AlertCashier.Instance(new Confirm(PosMessage.WAITING_PAYMENT, new StateInstance(Selling.CloseOrder)))); } else if (!cr.Document.IsEmpty) { return(Selling.Instance()); } else { return(state); } #else return(cr.Document.IsEmpty ? state : Selling.Instance()); #endif }
private static IState OnContinue() { DisplayAdapter.Cashier.Show(PosMessage.CONTINUE_SELLING); return(Selling.Instance()); }
public override void Correction() { if (cr.Document.LastItem == null) { throw new NoCorrectionException(); } try { if (cr.Document.LastItem.Adjustments == null || cr.Document.LastItem.Adjustments.Count == 0) { if (cr.Document.LastItem is VoidItem) { throw new CmdSequenceException(); } cr.Printer.Correct(cr.Document.LastItem); FiscalItem voidItem = new VoidItem(cr.Document.LastItem); ((SalesItem)cr.Document.LastItem).VoidQuantity = cr.Document.LastItem.Quantity; ((SalesItem)cr.Document.LastItem).VoidAmount = cr.Document.LastItem.TotalAmount; cr.Document.AddItem(voidItem, true); DisplayAdapter.Both.ShowVoid(voidItem); return; } FiscalItem fi = cr.Document.LastItem; Adjustment lastAdjustment = fi.Adjustments[fi.Adjustments.Count - 1]; if (lastAdjustment.IsCorrection) { throw new CmdSequenceException(); } Adjustment adjustment = null; AdjustmentType adjType = lastAdjustment.NetAmount > 0 ? AdjustmentType.Discount : AdjustmentType.Fee; if (cr.Document.State is DocumentOpen) { adjustment = new Adjustment(cr.Document.LastItem, adjType, Math.Abs(lastAdjustment.NetAmount)); adjustment.IsCorrection = true; if (!(cr.Document.CanAdjust(adjustment))) { cr.State = States.AlertCashier.Instance(new Error(new AdjustmentLimitException(adjustment.Label))); return; } IPrinterResponse printerReponse = cr.Printer.Correct(lastAdjustment); cr.Document.LastItem.Adjust(adjustment); DisplayAdapter.Both.ShowCorrect(adjustment, false); cr.State = Selling.Instance(); } if (cr.Document.State is DocumentSubTotal) { throw new CmdSequenceException(); } } catch (CmdSequenceException) { cr.State = AlertCashier.Instance(new Error(new NoCorrectionException())); } catch (NoAdjustmentException ae) { AlertCashier.Instance(new Error(ae)); } }
public override void Adjust(AdjustmentType method) { if (input.ToString().Length < input.Length || Str.Contains(input.ToString(), ',')) { if (method == AdjustmentType.PercentDiscount) { method = AdjustmentType.Discount; } else if (method == AdjustmentType.PercentFee) { method = AdjustmentType.Fee; } } if (cr.Document.IsEmpty) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.NO_SALE_INVALID_ACTION)); return; } /* * //Check whether cashier has authorization or not. * if (input.ToDecimal() == 100) * { * if (method == AdjustmentType.PercentDiscount) * { * input = new Number(cr.Document.State is DocumentOpen ? cr.Document.LastItem.TotalAmount : cr.Document.BalanceDue); * method = AdjustmentType.Discount; * } * if (method == AdjustmentType.PercentFee) * { * input = new Number(cr.Document.State is DocumentOpen ? cr.Document.LastItem.TotalAmount : cr.Document.BalanceDue); * method = AdjustmentType.Fee; * } * } */ if (method == AdjustmentType.PercentDiscount || method == AdjustmentType.Discount) { //check whether cashier has percentDiscount or discount. if (!cr.IsAuthorisedFor(Authorizations.Discount)) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.INSUFFICIENT_ACCESS_LEVEL)); return; } } else if (method == AdjustmentType.PercentFee || method == AdjustmentType.Fee) { //check whether cashier has percentFee or fee. if (!cr.IsAuthorisedFor(Authorizations.Fee)) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.INSUFFICIENT_ACCESS_LEVEL)); return; } } //Deny if percentFee or percentDiscount is not integer. if (method == AdjustmentType.PercentDiscount || method == AdjustmentType.PercentFee) { if (input.Decimals > 0) { cr.State = AlertCashier.Instance(new Confirm(PosMessage.DNEY_PERCENTDISCOUNT)); return; } if (input.Length > 2) { cr.State = AlertCashier.Instance(new Confirm(PosMessage.DNEY_PERCENT_OVER_AMOUNT)); return; } } Adjustment adjustment = null; try { if (cr.Document.State is DocumentOpen) { if (cr.Document.LastItem.Adjustments.Count > 0 && !cr.Document.LastItem.Adjustments[cr.Document.LastItem.Adjustments.Count - 1].IsCorrection) { cr.State = States.AlertCashier.Instance(new Confirm("DAHA ÖNCE ÜRÜNE\nÝND/ART YAPILMIÞ")); return; } if (cr.Document.LastItem is VoidItem) { cr.State = States.AlertCashier.Instance(new Confirm("ÜRÜN ÝPTALÝNE\nÝND/ART YAPILAMAZ")); return; } if (input.ToDecimal() < 0.01m) { cr.State = States.AlertCashier.Instance(new Confirm("MÝN ÝND/ART TUTARI\n0,01")); return; } adjustment = new Adjustment(cr.Document.LastItem, method, input.ToDecimal()); if (!(cr.CurrentCashier.IsAuthorisedFor(adjustment) && cr.Document.CanAdjust(adjustment))) { cr.State = States.AlertCashier.Instance(new Confirm(String.Format("{0} {1}", adjustment.Label, PosMessage.INSUFFICIENT_LIMIT))); return; } if (method == AdjustmentType.PercentFee && input.ToDecimal() > 99) { adjustment = new Adjustment(cr.Document.LastItem, AdjustmentType.Fee, adjustment.NetAmount); } cr.Printer.Print(adjustment); cr.Document.LastItem.Adjust(adjustment); //TODO - if printerresponse is OK DisplayAdapter.Both.Show(adjustment); cr.State = Selling.Instance(); } else if (cr.Document.State is DocumentSubTotal) { adjustment = new Adjustment(cr.Document, method, input.ToDecimal()); if (!(cr.CurrentCashier.IsAuthorisedFor(adjustment) && cr.Document.CanAdjust(adjustment))) { cr.State = States.AlertCashier.Instance(new Confirm(String.Format("{0} {1}", adjustment.Label, PosMessage.INSUFFICIENT_LIMIT))); return; } cr.Printer.Print(adjustment); cr.Document.Adjust(adjustment); DisplayAdapter.Both.Show(adjustment); cr.State = States.PaymentAfterTotalAdjustment.Instance(adjustment); cr.Document.State = DocumentPaying.Instance(); } } catch (CmdSequenceException) { String adj = (method == AdjustmentType.Discount || method == AdjustmentType.PercentDiscount) ? PosMessage.DISCOUNT : PosMessage.FEE; cr.State = AlertCashier.Instance(new Confirm(String.Format("ARATOPLAM ONCESINE\n{0} GECERSIZ", adj))); } catch (ReceiptLimitExceededException) { //Sales document is a receipt which needs to be //converted to an invoice Invoice invoice = new Invoice(cr.Document); if (adjustment.Target is SalesItem) { invoice.LastItem.Adjust(adjustment); } if (!cr.Printer.CanPrint(invoice)) { throw new ReceiptLimitExceededException(); } MenuList docTypes = new MenuList(); docTypes.Add(new MenuLabel(PosMessage.TRANSFER_DOCUMENT + "\n" + PosMessage.INVOICE, invoice)); cr.State = States.ListDocument.Instance(docTypes, new ProcessSelectedItem <SalesDocument>(cr.ChangeDocumentType)); DisplayAdapter.Cashier.Show(PosMessage.RECEIPT_LIMIT_EXCEEDED_TRANSFER_DOCUMENT); } finally { input.Clear(); } }