Esempio n. 1
0
        /**
         * Total order discount
         */
        public double EjWholeOrderDiscountTotal()
        {
            double total = 0;

            foreach (Object obj in ejArrayList)
            {
                EjLine ejLine = (EjLine)obj;


                if (ejLine.State == (int)EjLineStates.VOID_SALE || ejLine.State == (int)EjLineStates.VOID_ITEM || ejLine.State == (int)EjLineStates.PRICE_OVERRIDE)
                {
                    continue;
                }


                switch (ejLine.LineType)
                {
                case (int)EjLineType.PROMOTION:
                    EjPromotion ejPromo = ejLine as EjPromotion;
                    if (ejPromo.Promotion.PromotionType == (int)EjPromotionTypes.WHOLE_ORDER)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejPromo.Amount);
                    }
                    break;

                default:
                    break;
                }
            }
            return(Math.Round(total, 2));
        }
Esempio n. 2
0
        /**
         * Totals the current ej, exclueds surcharges, order discounts.
         */
        public double EjGrossTotal()
        {
            double total = 0;

            foreach (Object obj in ejArrayList)
            {
                EjLine ejLine = (EjLine)obj;

                if (ejLine.State != (int)EjLineStates.IN_PROGRESS)
                {
                    continue;
                }


                switch (ejLine.LineType)
                {
                case (int)EjLineType.ITEM:

                    TransItem transItem = ejLine.DataRecord() as TransItem;
                    if (transItem.State != (int)EjLineStates.VOID_ITEM)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    break;



                case (int)EjLineType.ITEM_LINK:
                    //	transItem = (TransItem) (context.currItem ().dataRecord ());
                    //	if (transItem.state () != TransItem.VOID)
                    //	{
                    //		total = context.posMath ().add (total, line.extAmount ());
                    //	}
                    break;

                case (int)EjLineType.PROMOTION:
                    EjPromotion ejPromotion = ejLine as EjPromotion;
                    //if (ejPromotion.Applied )
                    //{

                    if (ejPromotion.Promotion.PromotionType == (int)EjPromotionTypes.WHOLE_ORDER)
                    {
                        break;
                    }
                    if (ejPromotion.State == (int)EjLineStates.VOID_ITEM)
                    {
                        break;
                    }

                    total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    break;


                default:
                    break;
                }
            }

            return(Math.Round(total, 2));
        }
Esempio n. 3
0
 public void ReComputeWholeOrderDiscounts(EjItem ejitem)
 {
     if (PosContext.Instance.SaleMode != null)
     {
         ArrayList ejList = PosContext.Instance.CurrentEj.EjArrayList;
         foreach (object obj in ejList)
         {
             if (obj is EjPromotion)
             {
                 EjPromotion ejPromo = obj as EjPromotion;
                 if (ejPromo.LineNo == ejitem.LineNo)
                 {
                     if (ejPromo.Promotion.PromotionType == (int)EjPromotionTypes.WHOLE_ORDER)
                     {
                         ejPromo.ReCompute(ejitem);
                         return;
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
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;
            }
        }
Esempio n. 5
0
        /**
         * Sub-totals the current ej.
         */
        public double EjSubTotal()
        {
            double total = 0;

            foreach (Object obj in ejArrayList)
            {
                EjLine ejLine = (EjLine)obj;

                if (ejLine.State != (int)EjLineStates.IN_PROGRESS)
                {
                    continue;
                }


                switch (ejLine.LineType)
                {
                case (int)EjLineType.ITEM:

                    TransItem transItem = ejLine.DataRecord() as TransItem;
                    if (transItem.State != (int)EjLineStates.VOID_ITEM)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    break;

                case (int)EjLineType.SURCHARGE:

                    TransItem transItem1 = ejLine.DataRecord() as TransItem;
                    if (transItem1.State != (int)EjLineStates.VOID_ITEM)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    break;

                case (int)EjLineType.ITEM_LINK:
                    //	transItem = (TransItem) (context.currItem ().dataRecord ());
                    //	if (transItem.state () != TransItem.VOID)
                    //	{
                    //		total = context.posMath ().add (total, line.extAmount ());
                    //	}
                    break;

                case (int)EjLineType.PROMOTION:
                    EjPromotion ejPromotion = ejLine as EjPromotion;
                    //if (ejPromotion.Applied )
                    //{
                    if (ejPromotion.State != (int)EjLineStates.VOID_ITEM)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    //}
                    break;

                case (int)EjLineType.ACCOUNT:
                    EjReceiveOnAccount onAcc = ejLine as EjReceiveOnAccount;
                    total = PosContext.Instance.PosMath.Add(total, onAcc.TenderAmount);
                    break;


                default:
                    break;
                }
            }
            return(Math.Round(total, 2));
        }
Esempio n. 6
0
        public static Ej GetSuspendedEj(Transaction trans)
        {
            Ej transRecords = new Ej();

            transRecords.LineNo = 0;
            transRecords.SeqNo  = 0;


            //Do not load if not suspended
            if (trans.State == (int)Transaction.Status.SUSPEND)
            {
                trans.State = (int)(Transaction.Status.IN_PROGRESS);
                trans.UpdateState();
            }

            //Create a header
            EjHeader ejHeader = new EjHeader(trans);

            transRecords.EjAddReload(ejHeader);
            //Get items
            TransItem item = new TransItem();

            item.Trans_no        = trans.Trans_no;
            item.Organization_no = trans.Organization_no;
            item.Store_no        = trans.Store_no;
            item.Pos_no          = trans.Pos_no;

            DataSet   data = item.LoadByTransno();
            DataTable dt   = data.Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                TransItem transItem = new TransItem(dr);

                if (transItem.State == (int)EjLineStates.PRICE_OVERRIDE)
                {
                    continue;
                }
                if (transItem.State == (int)EjLineStates.VOID_ITEM)
                {
                    continue;
                }
                if (transItem.State == (int)EjLineStates.VOID_SALE)
                {
                    continue;
                }

                if (transItem.Line_no > transRecords.LineNo)
                {
                    transRecords.LineNo = transItem.Line_no;
                }
                if (transItem.Seq_no > transRecords.SeqNo)
                {
                    transRecords.SeqNo = transItem.Seq_no;
                }


                if (transItem.State == (int)EjLineStates.SUSPEND)
                {
                    transItem.State = (int)EjLineStates.IN_PROGRESS;
                    transItem.UpdateState();
                }

                if (transItem.Reason_code == (int)EjItemReasonCodes.NORMAL_ITEM)
                {
                    EjItem ejItem = new EjItem(transItem);

                    transRecords.EjAddReload(ejItem);
                }
                if (transItem.Reason_code == (int)EjItemReasonCodes.SURCHARGE)
                {
                    EjSurcharge ejSurcharge = new EjSurcharge(transItem);
                    transRecords.EjAddReload(ejSurcharge);
                }
            }


            //Get promotions
            try
            {
                TransPromotion promo = new  TransPromotion();
                promo.Trans_no        = trans.Trans_no;
                promo.Organization_no = trans.Organization_no;
                promo.Store_no        = trans.Store_no;
                promo.Pos_no          = trans.Pos_no;

                DataSet   data1 = promo.LoadAllByTransId();
                DataTable dt1   = data1.Tables[0];
                foreach (DataRow dr1 in dt1.Rows)
                {
                    TransPromotion transPromotion = new  TransPromotion(dr1);
                    if (transPromotion.Line_no > transRecords.LineNo)
                    {
                        transRecords.LineNo = transPromotion.Line_no;
                    }
                    if (transPromotion.Seq_no > transRecords.SeqNo)
                    {
                        transRecords.SeqNo = transPromotion.Seq_no;
                    }

                    if (transPromotion.State != (int)EjLineStates.VOID_ITEM)
                    {
                        transPromotion.State = (int)EjLineStates.IN_PROGRESS;
                        transPromotion.UpdateState();
                    }
                    EjPromotion ejPromotion = new EjPromotion(transPromotion);
                    transRecords.EjAddReload(ejPromotion);
                }
            }
            catch
            {
            }

            //Get Tax
            try
            {
                TransTax ttax = new  TransTax();
                ttax.Trans_no        = trans.Trans_no;
                ttax.Organization_no = trans.Organization_no;
                ttax.Store_no        = trans.Store_no;
                ttax.Pos_no          = trans.Pos_no;

                DataSet   data2 = ttax.LoadByTransid();
                DataTable dt2   = data2.Tables[0];
                foreach (DataRow dr2 in dt2.Rows)
                {
                    TransTax transTax = new TransTax(dr2);
                    EjTax    ejTax    = new EjTax(transTax);
                    transRecords.EjAddReload(ejTax);

                    if (transTax.Line_no > transRecords.LineNo)
                    {
                        transRecords.LineNo = transTax.Line_no;
                    }
                }
            }
            catch
            {
            }


            //Get Free Text
            try
            {
                TransText ttext = new TransText();
                ttext.Trans_no        = trans.Trans_no;
                ttext.Organization_no = trans.Organization_no;
                ttext.Store_no        = trans.Store_no;
                ttext.Pos_no          = trans.Pos_no;

                DataSet   data3 = ttext.LoadByTransNo();
                DataTable dt3   = data3.Tables[0];
                foreach (DataRow dr3 in dt3.Rows)
                {
                    if (ttext.Line_no > transRecords.LineNo)
                    {
                        transRecords.LineNo = ttext.Line_no;
                    }
                    if (ttext.Seq_no > transRecords.SeqNo)
                    {
                        transRecords.SeqNo = ttext.Seq_no;
                    }
                    TransText  transText = new TransText(dr3);
                    EjFreeText ejText    = new EjFreeText(transText);
                    transRecords.EjAddReload(ejText);
                }
            }
            catch
            {
            }

            try
            {
                //Get Sales person
                TransSalesPerson salesPerson = new TransSalesPerson();
                salesPerson.Organization_no = trans.Organization_no;
                salesPerson.Trans_no        = trans.Trans_no;
                salesPerson.Store_no        = trans.Store_no;
                salesPerson.Pos_no          = trans.Pos_no;
                DataSet   dataSalP = salesPerson.LoadByTransNo();
                DataTable dtSalP   = dataSalP.Tables[0];
                foreach (DataRow drSalP in dtSalP.Rows)
                {
                    TransSalesPerson transSp = new TransSalesPerson(drSalP);
                    EjSalesPerson    ejSalP  = new EjSalesPerson(transSp);
                    transRecords.EjAddReload(ejSalP);
                }
            }
            catch
            {
            }


            //Get Bank EJ
            try
            {
                //Get Sales person
                TransBank transBank = new  TransBank();
                transBank.Organization_no = trans.Organization_no;
                transBank.Pos_no          = trans.Pos_no;
                transBank.Store_no        = trans.Store_no;
                transBank.Trans_no        = trans.Trans_no;
                DataSet   dataTBank = transBank.LoadByTransid();
                DataTable dtTBank   = dataTBank.Tables[0];
                foreach (DataRow drTBank in dtTBank.Rows)
                {
                    TransBank tb     = new TransBank(drTBank);
                    EjBank    ejBank = new EjBank(tb);
                    transRecords.EjAddReload(ejBank);
                }
            }
            catch
            {
            }



            //Get Payments made
            try
            {
                TransTender tender = new TransTender();
                tender.Trans_no        = trans.Trans_no;
                tender.Organization_no = trans.Organization_no;
                tender.Store_no        = trans.Store_no;
                tender.Pos_no          = trans.Pos_no;


                DataSet   data1 = tender.LoadByTransid();
                DataTable dt1   = data1.Tables[0];
                foreach (DataRow dr1 in dt1.Rows)
                {
                    TransTender transTender = new TransTender(dr1);
                    EjTender    ejTender    = new  EjTender(transTender);
                    transRecords.EjAddReload(ejTender);
                }
            }
            catch
            {
            }



            transRecords.EjArrayList.Sort(new Ej());
            return(transRecords);
        }
Esempio n. 7
0
        public double EjTotal()
        {
            double total    = 0;
            bool   applyTax = true;

            foreach (Object obj in ejArrayList)
            {
                EjLine ejLine = (EjLine)obj;


                //if (ejLine.State != (int)EjLineStates.IN_PROGRESS) continue;


                switch (ejLine.LineType)
                {
                case (int)EjLineType.ITEM:

                    EjItem ejItem = (EjItem)ejLine;

                    // set apply tax flag
                    if (ejItem.TaxInclusive == 0)
                    {
                        applyTax = true;
                    }
                    else
                    {
                        applyTax = false;
                    }

                    TransItem transItem = (TransItem)ejLine.DataRecord();
                    if ((transItem.State != (int)EjLineStates.VOID_ITEM) && (transItem.State != (int)EjLineStates.PRICE_OVERRIDE))
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    break;

                case (int)EjLineType.SURCHARGE:

                    EjSurcharge ejSurcharge = (EjSurcharge)ejLine;

                    // set apply tax flag
                    if (ejSurcharge.TaxInclusive == 0)
                    {
                        applyTax = true;
                    }
                    else
                    {
                        applyTax = false;
                    }

                    TransItem transItem1 = (TransItem)ejLine.DataRecord();
                    if (transItem1.State != (int)EjLineStates.VOID_ITEM)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    break;


                case (int)EjLineType.ITEM_LINK:
                    //	transItem = (TransItem) (context.currItem ().dataRecord ());
                    //	if (transItem.state () != TransItem.VOID)
                    //	{
                    //		total = context.posMath ().add (total, line.extAmount ());
                    //	}
                    break;

                case (int)EjLineType.TAX:
                    EjTax tax = (EjTax)ejLine;

                    if (applyTax)
                    {
                        //	if (tax.taxRecord ().taxable () > 0.0)
                        //	{
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                        //	}
                    }
                    break;

                case (int)EjLineType.PROMOTION:
                    EjPromotion ejPromotion = ejLine as EjPromotion;
                    //if (ejPromotion.Applied )
                    //{
                    if (ejPromotion.State != (int)EjLineStates.VOID_ITEM)
                    {
                        total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);
                    }
                    //}
                    break;

                case (int)EjLineType.ACCOUNT:
                    EjReceiveOnAccount onAcc = ejLine as EjReceiveOnAccount;
                    total = PosContext.Instance.PosMath.Add(total, onAcc.TenderAmount);
                    break;

                default:
                    break;
                }
            }

            return(Math.Round(total, 2));
        }