Пример #1
0
        public static void SellReturnedItem(FiscalItem fi)
        {
            cr.Execute(fi);
            fi.Quantity += ((SalesItem)fi.Clone()).VoidQuantity;
            matchingDocument.Items.Remove(fi);

            ListReturnedItems();
        }
Пример #2
0
        /// <summary>
        /// Add new fiscal item to document list.
        /// fiscal item: Void item or sales item.
        /// </summary>
        /// <param name="doc">
        /// Document list.
        /// </param>
        /// <param name="item">
        /// Item that will be added to document list.
        /// </param>
        public override void AddItem(SalesDocument doc, FiscalItem item)
        {
            Decimal newTotal = 0;

            if (item.TotalAmount >= 10000000)
            {
                throw new OverflowException(PosMessage.ITEM_TOTAL_AMOUNT_LIMIT_EXCEED_ERROR);
            }
            if (item.TotalAmount + doc.TotalAmount >= 100000000)
            {
                throw new OverflowException(PosMessage.DOCUMENT_TOTAL_AMOUNT_LIMIT_EXCEED_ERROR);
            }
            if (doc.ProductTotals.ContainsKey(item.Product))
            {
                newTotal = doc.ProductTotals[item.Product] + item.TotalAmount;
                if (newTotal < 0)
                {
                    throw new VoidException(PosMessage.VOID_AMOUNT_INVALID);
                }
                else if (newTotal == 0)
                {
                    doc.ProductTotals.Remove(item.Product);
                }
                else
                {
                    doc.ProductTotals[item.Product] += item.TotalAmount;
                }
            }
            else
            {
                if (item is VoidItem)
                {
                    throw new VoidException(PosMessage.CANNOT_VOID_NO_PROPER_SALE);
                }
                else
                {
                    doc.ProductTotals[item.Product] = item.TotalAmount;
                }
            }

            doc.Items.Add(item);
        }
Пример #3
0
        public override void LabelKey(int labelKey)
        {
            System.Collections.Generic.List <IProduct> sList = new System.Collections.Generic.List <IProduct>();
            if (cr.DataConnector.CurrentSettings.GetProgramOption(Setting.DefineBarcodeLabelKeys) == PosConfiguration.ON)
            {
                sList = cr.DataConnector.SearchProductByBarcode(Label.GetLabel(labelKey));
            }
            else
            {
                sList = cr.DataConnector.SearchProductByLabel(Label.GetLabel(labelKey));
            }

            if (sList.Count == 0)
            {
                cr.State = AlertCashier.Instance(new Error(new ProductNotFoundException()));
                return;
            }
            MenuList itemList = new MenuList();

            foreach (IProduct p in sList)
            {
                FiscalItem fi = (FiscalItem)cr.Item.Clone();
                fi.Product = p;
                itemList.Add(fi);
            }
            IDoubleEnumerator listEnumerator = (IDoubleEnumerator)itemList;

            if (itemList.Count == 1)
            {
                if (listEnumerator.MoveNext())
                {
                    cr.Execute(((FiscalItem)listEnumerator.Current).Product);
                }
            }
            else
            {
                cr.State = ListLabel.Instance(itemList,
                                              new ProcessSelectedItem <IProduct>(cr.Execute),
                                              labelKey);
            }
        }
Пример #4
0
        //public static IState Instance(IDoubleEnumerator ide, ProcessSelectedItem<Product> psi, int labelKey, int autoEnterMillis)
        //{
        //    ListLabel.labelKey = labelKey;
        //    ProcessSelected = psi;
        //    autoEnterMillis = autoEnterMillis;
        //    List.Instance(ide);
        //    return state;
        //}

        public override void LabelKey(int labelKey)
        {
            if (labelKey == ListLabel.labelKey)
            {
                base.DownArrow();
            }
            else
            {
                System.Collections.Generic.List <IProduct> sList = new System.Collections.Generic.List <IProduct>();
                if (CashRegister.DataConnector.CurrentSettings.GetProgramOption(Setting.DefineBarcodeLabelKeys) == PosConfiguration.ON)
                {
                    sList = CashRegister.DataConnector.SearchProductByBarcode(Label.GetLabel(labelKey));
                }
                else
                {
                    sList = CashRegister.DataConnector.SearchProductByLabel(Label.GetLabel(labelKey));
                }

                MenuList itemList = new MenuList();
                foreach (IProduct p in sList)
                {
                    FiscalItem si = (FiscalItem)CashRegister.Item.Clone();
                    si.Product = p;
                    itemList.Add(si);
                }

                if (itemList.IsEmpty)
                {
                    CashRegister.State = AlertCashier.Instance(new Error(new ProductNotFoundException()));
                }
                else
                {
                    CashRegister.State = ListLabel.Instance(itemList, ProcessSelected, labelKey);
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Add fiscal item to document list.
 /// </summary>
 /// <param name="doc">
 /// Current document list.
 /// </param>
 /// <param name="item">
 /// Item that will be added.
 /// </param>
 public override void AddItem(SalesDocument doc, FiscalItem item)
 {
     doc.State = DocumentOpen.Instance();
     doc.State.AddItem(doc, item);
 }
Пример #6
0
 /// <summary>
 /// After payment is started,document must be closed to sell or void new item.
 /// If cashier try to sell or void item,it does not permitted and alerted by the system to close sales.
 /// </summary>
 /// <param name="doc">
 /// Not used in this state.
 /// </param>
 /// <param name="item">
 /// Not used in this state.
 /// </param>
 /// <exception cref="SaleClosedException">
 /// Alerts cashier to close sales document in order to add new sales item.
 /// </exception>
 public override void AddItem(SalesDocument doc, FiscalItem item)
 {
     throw new SaleClosedException(String.Format("{0}\n{1}", PosMessage.RECEIVE_PAYMENT,
                                                 PosMessage.PROMPT_FINALIZE_SALE));
 }
Пример #7
0
 internal static void VoidSelectedItem(FiscalItem fi)
 {
     cr.Execute(new VoidItem(fi));
 }
Пример #8
0
        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));
            }
        }
Пример #9
0
 public virtual void AddItem(SalesDocument doc, FiscalItem item)
 {
 }