Beispiel #1
0
        /**
         * Totals the tender amounts.
         */
        public double EjTotalTender()
        {
            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.CC_TENDER:
                case (int)EjLineType.CHECK_TENDER:
                case (int)EjLineType.ALT_CURRENCY_TENDER:
                case (int)EjLineType.COUPON:
                case (int)EjLineType.DEBIT_TENDER:
                case (int)EjLineType.GIFT_CERT_TENDER:
                case (int)EjLineType.TENDER:

                    EjTax ejTax = ejLine as EjTax;
                    total = PosContext.Instance.PosMath.Add(total, ejLine.ExtAmount);

                    break;

                default:
                    break;
                }
            }

            return(Math.Round(total, 2));
        }
Beispiel #2
0
        /**
         * Totals tax records
         */
        public double EjTaxTotal()
        {
            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.TAX:
                    EjTax ejTax = ejLine as EjTax;
                    total = PosContext.Instance.PosMath.Add(total, ejTax.ExtAmount);
                    break;

                default:
                    break;
                }
            }
            return(Math.Round(total, 2));
        }
Beispiel #3
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;
            }
        }
Beispiel #4
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();
        }
Beispiel #5
0
        public void ChangePrice(int lineNumber)
        {
            object[] ejList = PosContext.Instance.CurrentEj.EjArrayList.ToArray();
            foreach (object obj in ejList)
            {
                EjLine ejLine = obj as EjLine;
                if (ejLine.LineNo != lineNumber)
                {
                    continue;
                }
                switch (ejLine.LineType)
                {
                case (int)EjLineType.ITEM:

                    this.ejItem = ejLine as EjItem;

                    this.transItem = (TransItem)ejLine.DataRecord();

                    if (transItem.State != (int)EjLineStates.VOID_ITEM)
                    {
                        //transItem = PosContext.Instance.CurrentEjItem.TransItem;


                        //Create a price oveeride audit ( New line )
                        EclipsePos.Data.TransItem transItemAudit = new TransItem();
                        transItemAudit.Trans_no        = transItem.Trans_no;
                        transItemAudit.Organization_no = transItem.Organization_no;
                        transItemAudit.Store_no        = transItem.Store_no;
                        transItemAudit.Pos_no          = transItem.Pos_no;
                        transItemAudit.Sku_link        = transItem.Sku_link;
                        transItemAudit.Sku             = transItem.Sku;
                        transItemAudit.Item_desc       = transItem.Item_desc;
                        transItemAudit.Quantity        = transItem.Quantity;

                        transItemAudit.Amount     = transItem.Amount;
                        transItemAudit.Ext_amount = transItem.Ext_amount;     //PosContext.Instance.PosMath.Mult(transItem.Quantity, changedTransItem.Amount);
                        transItemAudit.State      = (int)EjLineStates.PRICE_OVERRIDE;



                        transItemAudit.Tax_exempt = transItem.Tax_exempt;
                        transItemAudit.Tax_incl   = transItem.Tax_incl;
                        transItemAudit.State      = (int)EjLineStates.PRICE_OVERRIDE;

                        EjItem ejItem = new EjItem(transItemAudit);

                        // Add to Ej to set the seq no and line no's
                        PosContext.Instance.CurrentEj.EjAdd(ejItem);

                        transItemAudit.Line_no = PosContext.Instance.CurrentEj.LineNo;
                        transItemAudit.Seq_no  = PosContext.Instance.CurrentEj.SeqNo;

                        transItemAudit.Add();



                        //Now change the current line to reflect the price change
                        transItem.Amount = newAmount;

                        transItem.Ext_amount = PosContext.Instance.PosMath.Mult(transItem.Quantity, newAmount);
                        transItem.Ext_amount = PosContext.Instance.PosMath.Mult(transItem.Ext_amount, PosContext.Instance.Sign);

                        transItem.UpdateAmounts();

                        this.ejItem.Desc = "*" + ejItem.Desc;
                        PosContext.Instance.Operprompt.Update(this.ejItem);
                        PosContext.Instance.Receipt.Update(this);
                    }
                    break;

                case (int)EjLineType.ITEM_LINK:
                    //	TransItemLink itemLink = (TransItemLink) line.dataRecord ();
                    //	itemLink.setAmount (0.0);
                    break;



                case (int)EjLineType.TAX:
                    EjTax itemTax = (EjTax)ejLine as EjTax;
                    //itemTax.ApplyTax();


                    break;
                }
            }
        }
Beispiel #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);
        }
Beispiel #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));
        }