示例#1
0
        public override void Engage(int keyValue)
        {
            // Created trans Header just before the first item
            if (PosContext.Instance.CurrentEj == null || PosContext.Instance.CurrentEj.SeqNo == 0)
            {
                new StartTransaction().Engage(0);
                return;
            }


            if (this.item == null)
            {
                return;
            }

            if (this.transItem == null)
            {
                this.transItem            = new TransItem();
                transItem.Trans_no        = PosContext.Instance.TrxNo;
                transItem.Organization_no = PosSettings.Default.Organization;
                transItem.Store_no        = PosSettings.Default.Store;
                transItem.Pos_no          = PosSettings.Default.Station;
                transItem.Sku_link        = " ";
                transItem.Sku             = item.Sku;
                transItem.Item_desc       = item.Short_Desc;
            }
            transItem.Quantity    = this.qty; //PosContext.Instance.Quantity == 0 ? 1 : PosContext.Instance.Quantity;
            transItem.Amount      = amount;   //item.Amount;
            transItem.Ext_amount  = (float)Math.Round(amount * this.qty, 2);
            transItem.Ext_amount  = PosContext.Instance.PosMath.Mult(transItem.Ext_amount, PosContext.Instance.Sign);
            transItem.Tax_exempt  = item.Tax_Exempt;
            transItem.Tax_incl    = item.Tax_Inclusive;
            transItem.State       = (int)EjLineStates.IN_PROGRESS;
            transItem.Reason_code = (int)EjItemReasonCodes.NORMAL_ITEM;
            transItem.Seq_no      = PosContext.Instance.CurrentEj.SeqNo + 1;
            transItem.Line_no     = PosContext.Instance.CurrentEj.LineNo + 1;

            PosContext.Instance.Receipt.Update(this);



            // double amount = item.Amount;

            // PosContext.Instance.CurrentEjItem = this;



            switch (this.PeekState())
            {
            case ENTER_QTY:
            case QTY_ERROR:

                if (this.item.Def_quantity == 0)
                {
                    PosContext.Instance.ClearInput();
                    this.PromptText = PosContext.Instance.Parameters.getParam("EnterQuantity");
                    PosContext.Instance.Operprompt.Update(this);
                    //Wait for the Enter key after input amount
                    this.PopState();
                    this.States().PushState(GET_QTY);
                    PosContext.Instance.DisableKeys();
                    PosContext.Beep(500, 50);
                    return;
                }
                else
                {
                    // Complet ej
                    this.PopState();
                    this.qty = item.Def_quantity;
                    this.States().PushState(ENTER_AMOUNT);
                    PosEventStack.Instance.NextEvent();
                }

                break;

            case GET_QTY:

                this.PopState();
                this.qty = PosContext.Instance.PosMath.GetAmount(PosContext.Instance.InputDouble());
                PosContext.Instance.ClearInput();

                if (this.qty == 0)
                {
                    this.States().PushState(QTY_ERROR);
                    PosContext.Beep(500, 50);
                }
                else
                {
                    this.PromptText = PosContext.Instance.Parameters.getParam("RegOpen");
                    PosContext.Instance.Operprompt.Update(this);
                    this.States().PushState(ENTER_AMOUNT);
                }
                PosEventStack.Instance.NextEvent();
                break;


            case ENTER_AMOUNT:
            case AMOUNT_ERROR:

                if (this.item.Pricing_Opt == (int)EclipsePos.Data.PricingOptions.Counter_pricing)
                {
                    PosContext.Instance.ClearInput();
                    this.PromptText = PosContext.Instance.Parameters.getParam("PromptItemPrice");
                    PosContext.Instance.Operprompt.Update(this);

                    //Wait for the Enter key after after input amount
                    this.PopState();
                    this.States().PushState(GET_AMOUNT);
                    PosContext.Beep(500, 50);
                    return;
                }
                else
                {
                    // Complet ej
                    this.PopState();
                    amount = item.Amount;
                    this.States().PushState(ITEM_FINAL);
                    PosEventStack.Instance.NextEvent();
                }

                break;

            case GET_AMOUNT:

                this.PopState();
                amount = PosContext.Instance.PosMath.GetAmount(PosContext.Instance.InputDouble());
                PosContext.Instance.ClearInput();

                if (amount == 0)
                {
                    this.States().PushState(AMOUNT_ERROR);
                    PosContext.Beep(500, 50);
                }
                else
                {
                    this.PromptText = PosContext.Instance.Parameters.getParam("RegOpen");
                    PosContext.Instance.Operprompt.Update(this);
                    this.States().PushState(ITEM_FINAL);
                }
                PosEventStack.Instance.NextEvent();
                break;

            case ITEM_CLEAR:
                PosContext.Instance.Receipt.Update(this);
                PosContext.Instance.CurrentEjItem = null;
                PosContext.Instance.Operprompt.Update(this);
                PosContext.Instance.Quantity = 0;
                this.States().Clear();
                PosEventStack.Instance.ClearPending();
                PosContext.Instance.EnableKeys();
                PosEventStack.Instance.NextEvent();

                break;

            case ITEM_FINAL:


                if (this.transItem == null)
                {
                    this.transItem = new TransItem();
                }

                /*
                 * transItem.Trans_no = PosContext.Instance.TrxNo;
                 * transItem.Organization_no = PosSettings.Default.Organization;
                 * transItem.Store_no = PosSettings.Default.Store;
                 * transItem.Pos_no = PosSettings.Default.Station;
                 * transItem.Sku_link = " ";
                 * transItem.Sku = item.Sku;
                 * transItem.Item_desc = item.Short_Desc;
                 * transItem.Quantity = this.qty; //PosContext.Instance.Quantity == 0 ? 1 : PosContext.Instance.Quantity;
                 * transItem.Amount = amount; //item.Amount;
                 * transItem.Ext_amount = (float)Math.Round(amount * this.qty, 2);
                 * transItem.Ext_amount = PosContext.Instance.PosMath.Mult(transItem.Ext_amount, PosContext.Instance.Sign);
                 * transItem.Tax_exempt = item.Tax_Exempt;
                 * transItem.Tax_incl = item.Tax_Inclusive;
                 * transItem.State = (int)EjLineStates.IN_PROGRESS;
                 * transItem.Reason_code = (int)EjItemReasonCodes.NORMAL_ITEM;
                 * */

                PosContext.Instance.CurrentEjItem = this;

                PosContext.Instance.CurrentEj.EjAdd(this);
                transItem.Seq_no  = PosContext.Instance.CurrentEj.SeqNo;
                transItem.Line_no = PosContext.Instance.CurrentEj.LineNo;

                // if not traning mode
                if (!PosContext.Instance.Training)
                {
                    transItem.Add();
                }

                if (!(item.Tax_Exempt == 1))
                {
                    try
                    {
                        string    taxGroupId = item.Tax_group_id;
                        TaxGroup  taxGroup   = (TaxGroup)PosContext.Instance.Config.TaxGroups[taxGroupId];
                        ArrayList taxes      = taxGroup.Taxes;
                        foreach (Object obj in taxes)
                        {
                            Tax   tax   = (Tax)obj;
                            EjTax ejTax = new EjTax(tax, this);
                            ejTax.Engage(0);
                            appliedTaxes.Add(ejTax);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Error("EjItem.cs", e.ToString());
                    }
                }



                //	Print the item at this point, discounts are printed in any modifiers
                PosContext.Instance.Receipt.Update(this);

                // add any modifiers that we find.

                if (PosContext.Instance.SaleMode != null)
                {
                    EjPromotion ejPromo1 = new EjPromotion(PosContext.Instance.SaleMode, this);
                    ejPromo1.SKU = item.Sku;
                    ejPromo1.Engage(0);
                }


                if (this.Item.Promotions() != null)
                {      // now apply promos attached to the item
                    foreach (object obj in this.Item.Promotions())
                    {
                        Promotion promo2 = obj as Promotion;

                        // the modifier is applied in the EjPromotion constructor
                        EjPromotion ejPromo2 = new EjPromotion(promo2, this);
                        ejPromo2.SKU = item.Sku;
                        ejPromo2.Engage(0);
                    }
                }

                //Re - Compute whole order discount
                this.ReComputeWholeOrderDiscounts();

                // Re - Compute surcharge if necessary
                this.ReComputeSurchrge();

                // Display item details in Customer display after any discount
                PosContext.Instance.Operprompt.Update(this);
                PosContext.Instance.Quantity = 0;


                this.States().Clear();
                PosEventStack.Instance.ClearPending();
                PosContext.Instance.EnableKeys();
                PosEventStack.Instance.NextEvent();


                break;
            }
        }
示例#2
0
        public override void Engage(int keyVal)
        {
            if (this.surcharge == null)
            {
                return;
            }


            // Created trans Header just before the first item
            if (PosContext.Instance.CurrentEj == null || PosContext.Instance.CurrentEj.SeqNo == 0)
            {
                new StartTransaction().Engage(0);
                return;
            }

            this.States().Clear();
            PosEventStack.Instance.ClearPending();

            if (this.transItem == null)
            {
                this.transItem = new TransItem();
            }

            // double amount = item.Amount;
            transItem.Trans_no        = PosContext.Instance.TrxNo;
            transItem.Organization_no = PosSettings.Default.Organization;
            transItem.Store_no        = PosSettings.Default.Store;
            transItem.Pos_no          = PosSettings.Default.Station;
            transItem.Sku_link        = " ";
            transItem.Sku             = surcharge.Surcharge_code; //item.Sku;
            transItem.Item_desc       = surcharge.Surcharge_desc; //item.Short_Desc;
            transItem.Quantity        = 1;

            //Initialize Amt
            amount = 0;

            //Amt based on purcentage
            if (surcharge.Method == 0)
            {
                double percent = surcharge.Amount / 100;
                this.amount = PosContext.Instance.PosMath.Mult(PosContext.Instance.CurrentEj.EjSaleTotal(), percent);
                this.Method = 0;
            }
            // Amt based on Fixed sum
            if (surcharge.Method == 1)
            {
                this.amount = surcharge.Amount;
                this.Method = 1;
            }

            transItem.Amount     = amount; //item.Amount;
            transItem.Ext_amount = (float)Math.Round(amount * transItem.Quantity, 2);
            //  transItem.Ext_amount = PosContext.Instance.PosMath.Mult(transItem.Ext_amount, PosContext.Instance.Sign);
            transItem.Tax_exempt  = surcharge.Tax_exempt;
            transItem.Tax_incl    = surcharge.Tax_inclusive;
            transItem.State       = (int)EjLineStates.IN_PROGRESS;
            transItem.Reason_code = (int)EjItemReasonCodes.SURCHARGE;

            // PosContext.Instance.CurrentEjItem = this;

            PosContext.Instance.CurrentEj.EjAdd(this);
            transItem.Seq_no  = PosContext.Instance.CurrentEj.SeqNo;
            transItem.Line_no = PosContext.Instance.CurrentEj.LineNo;

            // if not traning mode
            if (!PosContext.Instance.Training)
            {
                transItem.Add();
            }

            if (!(surcharge.Tax_exempt == 1))
            {
                try
                {
                    string    taxGroupId = surcharge.Tax_group_id;
                    TaxGroup  taxGroup   = (TaxGroup)PosContext.Instance.Config.TaxGroups[taxGroupId];
                    ArrayList taxes      = taxGroup.Taxes;
                    foreach (Object obj in taxes)
                    {
                        Tax   tax   = (Tax)obj;
                        EjTax ejTax = new EjTax(tax, this);
                        ejTax.Engage(0);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("EjItem.cs", e.ToString());
                }
            }



            //	Print the item at this point, discounts are printed in any modifiers
            this.ReCompute = false;
            PosContext.Instance.Receipt.Update(this);

            // add any modifiers that we find.



            // Display item details in Customer display after any discount
            PosContext.Instance.Operprompt.Update(this);
            PosContext.Instance.Quantity = 0;

            // PosEventStack.Instance.NextEvent();
        }