コード例 #1
0
ファイル: TransItemFactory.cs プロジェクト: hkiaipc/yh
 /// <summary>
 /// 
 /// </summary>
 /// <param deviceType="nm"></param>
 /// <returns></returns>
 public static TransItem Create(NameMap nm, FromDBI fromDBI, ToDBIForPs toDBI)
 {
     TransItem item = new TransItem();
     item.FromDevice = CreateFromDevice(nm.FromName, fromDBI, nm.TotalHeight);
     item.ToDevice = CreateToDevice(nm.ToName, toDBI, nm.Elvation);
     return item;
 }
コード例 #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));
        }
コード例 #3
0
ファイル: StorageManager.cs プロジェクト: vlung/Citicenter
        private TransItem WriteStorageContext(StorageContext storageContext)
        {
            // write the context to disk
            List <int> usedPages   = null;
            TransItem  contextData = new TransItem();

            // write the page table
            if (null != storageContext.PageTable)
            {
                contextData.PageTableStartPage =
                    storageContext.PageTable.WritePageTableData(
                        this.dataFile, this.pageManager, out usedPages);
                usedPages = storageContext.PageTable.GetStoragePages();
                contextData.StoragePageList.AddRange(usedPages);
            }

            // write the resource index
            if (null != storageContext.ResourceIndex)
            {
                contextData.ResourceIndexStartPage =
                    storageContext.ResourceIndex.WriteIndexData(
                        this.dataFile, this.pageManager, out usedPages);
                usedPages = storageContext.ResourceIndex.GetStoragePages();
                contextData.StoragePageList.AddRange(usedPages);
            }

            // write the reservation index
            if (null != storageContext.ReservationIndex)
            {
                contextData.ReservationIndexStartPage =
                    storageContext.ReservationIndex.WriteIndexData(
                        this.dataFile, this.pageManager, out usedPages);
                usedPages = storageContext.ReservationIndex.GetStoragePages();
                contextData.StoragePageList.AddRange(usedPages);
            }

            // write allocated page list
            if (null != storageContext.AllocatedPageList)
            {
                ListWriter <int> writer = new ListWriter <int>();
                writer.WriteList(
                    this.dataFile, this.pageManager, storageContext.AllocatedPageList, out usedPages);
                contextData.AllocatedPageListStartPage = usedPages[0];
                contextData.StoragePageList.AddRange(usedPages);
            }

            // write freed page list
            if (null != storageContext.FreedPageList)
            {
                ListWriter <int> writer = new ListWriter <int>();
                writer.WriteList(
                    this.dataFile, this.pageManager, storageContext.FreedPageList, out usedPages);
                contextData.FreedPageListStartPage = usedPages[0];
                contextData.StoragePageList.AddRange(usedPages);
            }

            return(contextData);
        }
コード例 #4
0
        /// <summary>
        /// Adds a transaction data to the list.
        /// </summary>
        /// <param name="contextData">transaction data</param>
        public void Add(TransItem contextData)
        {
            if (this.contextTable.ContainsKey(contextData.Transaction))
            {
                throw new InvalidOperationException();
            }

            this.contextTable.Add(contextData.Transaction, contextData);
        }
コード例 #5
0
        /// <summary>
        /// Adds a transaction data to the list.
        /// </summary>
        /// <param name="contextData">transaction data</param>
        public void Add(TransItem contextData)
        {
            if (this.contextTable.ContainsKey(contextData.Transaction))
            {
                throw new InvalidOperationException();
            }

            this.contextTable.Add(contextData.Transaction, contextData);
        }
コード例 #6
0
ファイル: EjSurcharge.cs プロジェクト: naushard/EclipsePOS
 public EjSurcharge(TransItem trans)
 {
     this.transItem = trans;
     this.LineType  = (int)EjLineType.SURCHARGE;
     this.surcharge = new Surcharge();
     this.surcharge.Organization_no = PosSettings.Default.Organization;
     this.surcharge.Surcharge_code  = transItem.Sku;
     this.surcharge.LoadBySurchargeCode();
     this.Method = this.surcharge.Method;
 }
 void PM_OnSerializeToDbTransItemInElement(XmlStringWriter writer, TransItem item)
 {
     /*
      * if (item is TransPayment)
      * {
      *  TransPayment transaction = item as TransPayment;
      *  string propina = (10 * BL.CurrentTransaction.Total / 100).ToString();
      *  writer.WriteField("propina", propina);
      * }
      */
 }
コード例 #8
0
        /// <summary>
        /// Removes the transaction data from the list.
        /// </summary>
        /// <param name="context">transaction id</param>
        /// <returns>the item we just removed from the list</returns>
        public TransItem Remove(Transaction context)
        {
            TransItem item = null;

            if (!this.contextTable.TryGetValue(context, out item))
            {
                return(null);
            }
            this.contextTable.Remove(context);

            return(item);
        }
コード例 #9
0
ファイル: StorageManager.cs プロジェクト: vlung/Citicenter
        // implements the abort of a transaction
        private void aAbort(Transaction context)
        {
            lock (ManagerLock)
            {
                List <int>     oldStorageContextPages = new List <int>();
                StorageContext storageContext         = null;
                if (this.activeContextMap.TryGetValue(context, out storageContext))
                {
                    // found transaction in active transactions list
                    this.activeContextMap.Remove(context);
                }
                else
                {
                    TransItem contextData = this.preparedContextMap.Remove(context);
                    if (null == contextData)
                    {
                        // transaction must already have been commited or aborted
                        // nothing to do
                        return;
                    }

                    // found transaction in prepared transaction list
                    oldStorageContextPages = contextData.StoragePageList;
                    storageContext         = contextData.TransactionData;
                    if (null == storageContext)
                    {
                        storageContext = ReadStorageContext(contextData, out oldStorageContextPages);
                    }
                }

                DBHdr dbRoot = this.ReadDBRoot();
                if (null == dbRoot)
                {
                    throw new Exception();
                }

                // write the updated prepared transaction list
                List <int> oldPrepedContextMapPages = null;
                dbRoot.PrepedTransactions = this.preparedContextMap.WriteTransactionTableData(
                    this.dataFile, this.pageManager, out oldPrepedContextMapPages);

                // update the page manager
                this.pageManager.SetFreePages(oldStorageContextPages);
                this.pageManager.SetFreePages(oldPrepedContextMapPages);
                this.pageManager.SetFreePages(storageContext.AllocatedPageList);
                dbRoot.PageManager = this.pageManager.WritePageManagerData(
                    this.dataFile);

                this.WriteDBRoot(dbRoot);
                this.dataFile.Flush(true);
            }
        }
コード例 #10
0
ファイル: EjItem.cs プロジェクト: naushard/EclipsePOS
        public EjItem(TransItem transItem)
        {
            this.transItem = transItem;
            this.LineType  = (int)EjLineType.ITEM;
            Item item1 = new Item();

            item1.Sku             = transItem.Sku;
            item1.Organization_no = PosSettings.Default.Organization;
            item1.LoadBySKU();
            this.Item = item1;
            //this.transItem.State = 1;
            this.qty = transItem.Quantity;
            this.States().PushState(LOAD_FROM_EJ);
        }
コード例 #11
0
ファイル: StorageManager.cs プロジェクト: vlung/Citicenter
        // prepares a transaction for commit by serialializing the data to disk
        private void aPrepare(Transaction context)
        {
            lock (ManagerLock)
            {
                if (this.preparedContextMap.Contains(context))
                {
                    // transaction already prepared for commit
                    // nothing to do
                    return;
                }

                StorageContext storageContext = null;
                if (!this.activeContextMap.TryGetValue(context, out storageContext))
                {
                    // oops ... we don't know anything about this transaction
                    // something must have gone wrong
                    throw new Exception();
                }
                this.activeContextMap.Remove(context);

                // add the new item to the table
                TransItem contextData = WriteStorageContext(storageContext);
                contextData.Transaction     = context;
                contextData.TransactionData = storageContext;
                this.preparedContextMap.Add(contextData);

                // update the DB root for the free list page and
                // commited transaction list
                DBHdr dbRoot = this.ReadDBRoot();
                if (null == dbRoot)
                {
                    throw new InvalidDataException();
                }

                // write the prepared transactions table
                List <int> oldContextMapPages = null;
                dbRoot.PrepedTransactions = this.preparedContextMap.WriteTransactionTableData(
                    this.dataFile, this.pageManager, out oldContextMapPages);

                // write the page manager
                this.pageManager.SetFreePages(oldContextMapPages);
                dbRoot.PageManager = this.pageManager.WritePageManagerData(
                    this.dataFile);

                this.WriteDBRoot(dbRoot);
                this.dataFile.Flush(true);
            }
        }
コード例 #12
0
ファイル: ChangeQuantity.cs プロジェクト: naushard/EclipsePOS
        public void EffectChangeQuantity(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.Quantity = this.newQuantity;

                        transItem.Ext_amount = PosContext.Instance.PosMath.Mult(transItem.Amount, this.newQuantity);
                        transItem.Ext_amount = PosContext.Instance.PosMath.Mult(transItem.Ext_amount, PosContext.Instance.Sign);

                        transItem.UpdateAmounts();

                        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;
                }
            }
        }
        void PM_OnSerializeToPrinterTransItemInElement(XmlStringWriter writer, TransItem item)
        {
            //throw new NotImplementedException();
            if (item is Transaction)
            {
                Transaction transaction = item as Transaction;
                string      foliosii    = transaction.GetCustomField("bes_folio_num").ToString();
                writer.WriteField("folionum", foliosii);

                string webserviceChileSignature = transaction.GetCustomField("webservice_bes_signature").ToString();
                writer.WriteField("dte_firma", webserviceChileSignature);

                string nombreTipoDocumento = transaction.GetCustomField("tipo_documento").ToString();
                writer.WriteField("tipodoc", nombreTipoDocumento);
            }
        }
        //GRABA EN DB
        void PM_OnSerializeToDbTransItemInElement(XmlStringWriter writer, TransItem item)
        {
            //throw new NotImplementedException();
            if (item is Transaction)
            {
                Transaction transaction = item as Transaction;
                string      webserviceChileSignature = transaction.GetCustomField("webservice_bes_signature").ToString();
                writer.WriteField("dte_firma", webserviceChileSignature);

                //webservice_bes_folionum
                string webserviceChileFolioNUM = transaction.GetCustomField("webservice_bes_folionum").ToString();
                writer.WriteField("bes_folio_num", webserviceChileFolioNUM);

                string doctypeBES = transaction.GetCustomField("dte_doc_type").ToString();
                writer.WriteField("doc_type", doctypeBES);
            }
        }//FINISH PM_OnSerializeToDbTransItemInElement
コード例 #15
0
        public override void Perform()
        {
            try
            {
                TransItem.ExecuteTranslate(_PluginConfigName);
            }
            catch (Exception ex)
            {
                string             BadTlogLocation = TransItem.PluginConfig.GetValue("BadTlogLocation");
                System.IO.FileInfo file            = new System.IO.FileInfo(TransItem.SourceFile);
                System.IO.File.Move(TransItem.SourceFile, BadTlogLocation + "\\" + file.Name);

                if (_ExceptHandler != null)
                {
                    _ExceptHandler.Invoke(ex.GetType().GetProperties(), ex);
                }
            }
        }
コード例 #16
0
//		public void  RemoveCurrLine()
//		{
//			if (this.EjArrayList.Count > 0 )
//			{
//				this.EjArrayList.RemoveAt(this.ejArrayList.Count-1);
//
//			}
//		}


        /*  public EjLine GetCurrentLine()
         * {
         *    if (this.EjArrayList.Count > 0)
         *    {
         *        return this.EjArrayList[this.ejArrayList.Count - 1] as EjLine;
         *
         *    }
         *
         *    return null;
         *
         * }
         * */


        public double EjQtyTotal()
        {
            double total = 0;

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

                if (ejLine.LineType == (int)EjLineType.ITEM)
                {
                    TransItem transItem = ejLine.DataRecord() as TransItem;
                    if (transItem.State != (int)EjLineStates.VOID_ITEM)
                    {
                        //total = PosContext.Instance.PosMath.Add(total, ejLine.Quantity);
                        total++;
                    }
                }
            }
            return(total);
        }
コード例 #17
0
ファイル: StorageManager.cs プロジェクト: vlung/Citicenter
        // commits a transaction
        private void aCommit(Transaction context)
        {
            lock (ManagerLock)
            {
                TransItem contextData = this.preparedContextMap.Remove(context);
                if (null == contextData)
                {
                    // transaction must already have been commited or aborted
                    // nothing to do
                    return;
                }

                List <int>     oldStorageContextPages = contextData.StoragePageList;
                StorageContext storageContext         = contextData.TransactionData;
                if (null == storageContext)
                {
                    storageContext = ReadStorageContext(contextData, out oldStorageContextPages);
                }

                // read in the DB root
                DBHdr dbRoot = this.ReadDBRoot();
                if (null == dbRoot)
                {
                    throw new InvalidDataException();
                }

                // merge page table
                storageContext.PageTable.ReadPageTableData(
                    this.dataFile, dbRoot.PageTable);
                storageContext.PageTable.ClearDirtyFlags();

                // merge resource index
                storageContext.ResourceIndex.ReadIndexData(
                    this.dataFile, dbRoot.ResourceIndex);
                storageContext.ResourceIndex.ClearDirtyFlags();

                // merge reservation index
                storageContext.ReservationIndex.ReadIndexData(
                    this.dataFile, dbRoot.ReservationIndex);
                storageContext.ReservationIndex.ClearDirtyFlags();

                // write the page table
                List <int> oldPageTablePages = null;
                dbRoot.PageTable = storageContext.PageTable.WritePageTableData(
                    this.dataFile, this.pageManager, out oldPageTablePages);

                // write the resource index
                List <int> oldResourceIndexPages = null;
                dbRoot.ResourceIndex = storageContext.ResourceIndex.WriteIndexData(
                    this.dataFile, this.pageManager, out oldResourceIndexPages);

                // write the reservation index
                List <int> oldReservationIndexPages = null;
                dbRoot.ReservationIndex = storageContext.ReservationIndex.WriteIndexData(
                    this.dataFile, this.pageManager, out oldReservationIndexPages);

                // write the updated prepared transaction list
                List <int> oldPrepedContextMapPages = null;
                dbRoot.PrepedTransactions = this.preparedContextMap.WriteTransactionTableData(
                    this.dataFile, this.pageManager, out oldPrepedContextMapPages);

                // update the page manager
                this.pageManager.SetFreePages(oldStorageContextPages);
                this.pageManager.SetFreePages(oldPageTablePages);
                this.pageManager.SetFreePages(oldResourceIndexPages);
                this.pageManager.SetFreePages(oldReservationIndexPages);
                this.pageManager.SetFreePages(oldPrepedContextMapPages);
                this.pageManager.SetFreePages(storageContext.FreedPageList);
                dbRoot.PageManager = this.pageManager.WritePageManagerData(
                    this.dataFile);

                this.WriteDBRoot(dbRoot);
                this.dataFile.Flush(true);
            }
        }
コード例 #18
0
ファイル: MergeOrder.cs プロジェクト: naushard/EclipsePOS
        private void ProcessEjLine(EjLine ejLine)
        {
            switch (ejLine.LineType)
            {
            case (int)EjLineType.TRANS_HEADER:

                break;

            case (int)EjLineType.ITEM:

                EjItem ejItemFrom = ejLine as EjItem;

                TransItem 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             = ejItemFrom.TransItem.Sku;
                transItem.Item_desc       = ejItemFrom.TransItem.Item_desc;
                transItem.Quantity        = ejItemFrom.TransItem.Quantity;
                transItem.Amount          = ejItemFrom.TransItem.Amount;
                transItem.Ext_amount      = ejItemFrom.TransItem.Ext_amount;
                transItem.Tax_exempt      = ejItemFrom.TransItem.Tax_exempt;
                transItem.Tax_incl        = ejItemFrom.TransItem.Tax_incl;
                transItem.State           = (int)EjLineStates.IN_PROGRESS;
                transItem.Reason_code     = (int)EjItemReasonCodes.NORMAL_ITEM;
                EjItem ejItem = new EjItem(transItem);

                PosContext.Instance.CurrentEjItem = ejItem;

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

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

                PosContext.Instance.Receipt.Update(ejItem);
                break;

            case (int)EjLineType.PROMOTION:

                EjPromotion fromPromotion = ejLine as EjPromotion;

                TransPromotion transPromotion = new  TransPromotion();

                transPromotion.Trans_no        = PosContext.Instance.TrxNo;
                transPromotion.Organization_no = PosSettings.Default.Organization;
                transPromotion.Store_no        = PosSettings.Default.Store;
                transPromotion.Pos_no          = PosSettings.Default.Station;
                transPromotion.PromotionNo     = fromPromotion.Promotion.PromotionNo;

                transPromotion.PromotionAmount   = fromPromotion.Amount;
                transPromotion.PromotionQuantity = fromPromotion.Quantity;     //PosContext.Instance.Quantity;
                transPromotion.ReasonCode        = 0;
                transPromotion.PromotionData     = " ";
                transPromotion.PromotionDesc     = fromPromotion.Desc;
                transPromotion.State             = (int)EjLineStates.IN_PROGRESS;

                EjPromotion ejPromotion = new EjPromotion(transPromotion);

                PosContext.Instance.CurrentEj.EjAdd(ejPromotion);
                transPromotion.Seq_no  = PosContext.Instance.CurrentEj.SeqNo;
                transPromotion.Line_no = PosContext.Instance.CurrentEj.LineNo;

                // if not training mode
                if (!PosContext.Instance.Training)
                {
                    transPromotion.Add();
                }
                PosContext.Instance.Receipt.Update(ejPromotion);

                break;

            case (int)EjLineType.TAX:

                EjTax    fromTax      = ejLine as EjTax;
                TransTax fromTransTax = (TransTax)fromTax.DataRecord();

                TransTax transTax = new TransTax();
                transTax.Trans_no        = PosContext.Instance.TrxNo;
                transTax.Organization_no = PosSettings.Default.Organization;
                transTax.Store_no        = PosSettings.Default.Store;
                transTax.Pos_no          = PosSettings.Default.Station;
                transTax.SeqNo           = PosContext.Instance.CurrentEj.SeqNo;
                transTax.Line_no         = PosContext.Instance.CurrentEj.LineNo;
                transTax.TaxId           = fromTransTax.TaxId;
                transTax.TaxDesc         = fromTransTax.TaxDesc;
                transTax.Rate            = fromTransTax.Rate;
                transTax.State           = (int)EjLineStates.IN_PROGRESS;
                transTax.TaxAmount       = fromTransTax.TaxAmount;
                transTax.TaxableAmount   = fromTransTax.TaxableAmount;

                //If not training mode
                if (!PosContext.Instance.Training)
                {
                    transTax.Add();
                }

                EjTax ejTax = new EjTax(transTax);
                PosContext.Instance.CurrentEj.EjAdd(ejTax);



                break;

            case (int)EjLineType.TENDER:

                break;

            case (int)EjLineType.BANK:
                //		Update( (EjBank)pEvent );
                break;

            case (int)EjLineType.ACCOUNT:
                break;

            case (int)EjLineType.ALT_CURRENCY_TENDER:

                break;

            case (int)EjLineType.CHECK_TENDER:

                break;

            case (int)EjLineType.DEBIT_TENDER:

                break;

            case (int)EjLineType.CC_TENDER:

                break;

            case (int)EjLineType.COUPON:
                //		Update ((EjCoupon) pEvent );
                break;

            case (int)EjLineType.FREE_TEXT:

                break;

            case (int)EjLineType.SURCHARGE:

                break;

            default:
                //	Log.warning ("Unhandled ej type in Receipt " + line.toString ());
                break;
            }
        }
コード例 #19
0
ファイル: EjSurcharge.cs プロジェクト: naushard/EclipsePOS
        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();
        }
コード例 #20
0
ファイル: NForX.cs プロジェクト: naushard/EclipsePOS
        public void Apply()
        {
            applied = false;
            int applyCount = 0;

            totalDiscount = 0;
            double itemAmount = item.Amount;

            if (itemAmount < 0.0)
            {
                itemAmount *= -1.0;
            }

            Ej ej = PosContext.Instance.CurrentEj;

            foreach (Object obj in ej.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 (item.SKU.Equals(transItem.Sku))
                    {
                        applyCount = applyCount + (int)transItem.Quantity;
                    }
                    break;


                case (int)EjLineType.PROMOTION:
                    EjPromotion ejPromotion = ejLine as EjPromotion;
                    if (this.item.SKU.Equals(ejPromotion.SKU))
                    {
                        applyCount = applyCount - (int)ejPromotion.Quantity;
                    }

                    break;


                default:
                    break;
                }
            }

            //Remaining Qty to apply the promotion
            if (applyCount >= promotion.PromotionVal1)
            {
                //Actual price
                double promoPrice = promotion.PromotionDval1 / promotion.PromotionVal1;
                // Discount for on
                double discount = item.Amount - promoPrice;
                //caluclate N
                this.promoQty = applyCount - (int)applyCount % promotion.PromotionVal1;


                totalDiscount = PosContext.Instance.PosMath.Mult(this.promoQty, discount);
                // totalDiscount = PosContext.Instance.PosMath.Negate(totalDiscount);
                this.applied = true;
            }
        }
コード例 #21
0
ファイル: StorageManager.cs プロジェクト: vlung/Citicenter
        private StorageContext ReadStorageContext(TransItem contextData, out List <int> oldStorageContextPages)
        {
            // allocate the storage page list
            oldStorageContextPages = new List <int>();

            // look for the context in the map
            StorageContext storageContext = new StorageContext();

            // read in the page table
            if (TransItem.NotStored != contextData.PageTableStartPage)
            {
                storageContext.PageTable.ReadPageTableData(
                    this.dataFile, contextData.PageTableStartPage);
                oldStorageContextPages.AddRange(
                    storageContext.PageTable.GetStoragePages());
            }

            // read in the resource index
            if (TransItem.NotStored != contextData.ResourceIndexStartPage)
            {
                storageContext.ResourceIndex.ReadIndexData(
                    this.dataFile, contextData.ResourceIndexStartPage);
                oldStorageContextPages.AddRange(
                    storageContext.ResourceIndex.GetStoragePages());
            }

            // read in the reservation index
            if (TransItem.NotStored != contextData.ReservationIndexStartPage)
            {
                storageContext.ReservationIndex.ReadIndexData(
                    this.dataFile, contextData.ReservationIndexStartPage);
                oldStorageContextPages.AddRange(
                    storageContext.ReservationIndex.GetStoragePages());
            }

            // read in the allocated page list
            if (TransItem.NotStored != contextData.AllocatedPageListStartPage)
            {
                List <int> usedPages = null;
                List <int> data      = null;

                ListReader <int> reader = new ListReader <int>();
                reader.ReadList(this.dataFile, contextData.AllocatedPageListStartPage, out data, out usedPages);

                storageContext.AllocatedPageList = data;
                oldStorageContextPages.AddRange(usedPages);
            }

            // read in the freed page list
            if (TransItem.NotStored != contextData.FreedPageListStartPage)
            {
                List <int> usedPages = null;
                List <int> data      = null;

                ListReader <int> reader = new ListReader <int>();
                reader.ReadList(this.dataFile, contextData.FreedPageListStartPage, out data, out usedPages);

                storageContext.FreedPageList = data;
                oldStorageContextPages.AddRange(usedPages);
            }

            return(storageContext);
        }
コード例 #22
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));
        }
コード例 #23
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);
        }
コード例 #24
0
        private void VoidLine(int lineNumber)
        {
            ArrayList ejList = PosContext.Instance.CurrentEj.EjArrayList;

            foreach (object obj in ejList)
            {
                EjLine ejLine = obj as EjLine;
                if (ejLine.LineNo != lineNumber)
                {
                    continue;
                }
                switch (ejLine.LineType)
                {
                case (int)EjLineType.ITEM:

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

                    if (transItem.State != (int)EjLineStates.VOID_ITEM)
                    {      // already voided?
                        transItem.State = (int)EjLineStates.VOID_ITEM;
                        transItem.UpdateState();
                        PosContext.Instance.Receipt.Update((EjItem)ejLine);
                    }
                    break;

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

                case (int)EjLineType.PROMOTION:
                    TransPromotion itemPromo = (TransPromotion)ejLine.DataRecord();
                    if (itemPromo.State != (int)EjLineStates.VOID_ITEM)
                    {      // already voided?
                        itemPromo.State = (int)EjLineStates.VOID_ITEM;
                        itemPromo.UpdateState();

                        if (itemPromo.PromotionType == (int)EjPromotionTypes.WHOLE_ORDER)
                        {
                            PosContext.Instance.SaleMode = null;
                        }
                        PosContext.Instance.Receipt.Update((EjPromotion)ejLine);
                    }
                    //  itemPromo.PromotionAmount = 0;
                    break;

                case (int)EjLineType.TAX:
                    TransTax itemTax = ejLine.DataRecord() as TransTax;

                    itemTax.State = (int)EjLineStates.VOID_ITEM;
                    itemTax.UpdateState();
                    ///	itemTax.TaxAmount = 0.0;
                    //  itemTax.TaxableAmount = 0.0;
                    // ejLine.ExtAmount = 0;
                    // ejLine.TaxAmount = 0;
                    // ejLine.Amount = 0;
                    PosContext.Instance.Receipt.Update((EjTax)ejLine);
                    break;

                case (int)EjLineType.SURCHARGE:
                    TransItem transSurcharge = (TransItem)ejLine.DataRecord();

                    if (transSurcharge.State != (int)EjLineStates.VOID_ITEM)
                    {      // already voided?
                        transSurcharge.State = (int)EjLineStates.VOID_ITEM;
                        transSurcharge.UpdateState();
                        PosContext.Instance.Receipt.Update((EjSurcharge)ejLine);
                    }

                    break;
                }
            }
        }
コード例 #25
0
        private void VoidCurrentItem()
        {
            ItemList itemList = new ItemList(PosContext.Instance.CurrentEjItem, PosContext.Instance.CurrentEj);

            for (int i = 0; i < itemList.Count; i++)
            {
                Object obj    = itemList[i];
                EjLine ejLine = (EjLine)obj;

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

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

                    if (transItem.State != (int)EjLineStates.VOID_ITEM)
                    {      // already voided?
                        transItem.State = (int)EjLineStates.VOID_ITEM;
                        transItem.UpdateState();
                        PosContext.Instance.Receipt.Update((EjItem)ejLine);
                    }
                    break;

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

                case (int)EjLineType.PROMOTION:
                    TransPromotion itemPromo = (TransPromotion)ejLine.DataRecord();
                    if (itemPromo.State != (int)EjLineStates.VOID_ITEM)
                    {      // already voided?
                        itemPromo.State = (int)EjLineStates.VOID_ITEM;
                        itemPromo.UpdateState();
                        PosContext.Instance.Receipt.Update((EjPromotion)ejLine);
                    }
                    //  itemPromo.PromotionAmount = 0;
                    break;

                case (int)EjLineType.TAX:
                    TransTax itemTax = ejLine.DataRecord() as TransTax;

                    itemTax.State = (int)EjLineStates.VOID_ITEM;
                    itemTax.UpdateState();
                    ///	itemTax.TaxAmount = 0.0;
                    //  itemTax.TaxableAmount = 0.0;
                    // ejLine.ExtAmount = 0;
                    // ejLine.TaxAmount = 0;
                    // ejLine.Amount = 0;
                    PosContext.Instance.Receipt.Update((EjTax)ejLine);
                    break;

                case (int)EjLineType.SURCHARGE:
                    TransItem transSurcharge = (TransItem)ejLine.DataRecord();

                    if (transSurcharge.State != (int)EjLineStates.VOID_ITEM)
                    {      // already voided?
                        transSurcharge.State = (int)EjLineStates.VOID_ITEM;
                        transSurcharge.UpdateState();
                        PosContext.Instance.Receipt.Update((EjSurcharge)ejLine);
                    }

                    break;
                }
            }
        }
コード例 #26
0
ファイル: EjItem.cs プロジェクト: naushard/EclipsePOS
        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;
            }
        }
コード例 #27
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));
        }
コード例 #28
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;
                }
            }
        }