Example #1
0
 public EjTax(Tax t, EjSurcharge i)
 {
     this.taxRecord   = t;
     this.ejSurcharge = i;
     this.useAltTax   = false;
     this.LineType    = (int)EjLineType.TAX;
     this.item        = null;
 }
Example #2
0
        public void ReComputeSurchrge()
        {
            ArrayList ejList = PosContext.Instance.CurrentEj.EjArrayList;

            foreach (object obj in ejList)
            {
                if (obj is EjSurcharge)
                {
                    EjSurcharge ejSur = obj as EjSurcharge;
                    if (ejSur.Method == 0)
                    {
                        ejSur.ReApplySurcharge();
                    }
                }
            }
        }
Example #3
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);
        }
Example #4
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));
        }