public override void Engage(int keyValue) { switch (this.States().PeekState()) { case ENTER_LINE_NUMBER: PosContext.Instance.ClearInput(); this.PromptText = PosContext.Instance.Parameters.getParam("PromptEnterLineNumber"); this.PopState(); this.PushState(GET_LINE_NUMBER); PosContext.Instance.Operprompt.Update(this); break; case GET_LINE_NUMBER: this.lineNumber = PosContext.Instance.Input(); PosContext.Instance.ClearInput(); PosContext.Instance.Operprompt.Clear(); this.PopState(); if (this.lineNumber > 0 && this.lineNumber <= PosContext.Instance.CurrentEj.LineNo) { this.PushState(ENTER_QUANTITY); } else { this.PushState(ENTER_LINE_NUMBER); PosContext.Beep(500, 50); } PosEventStack.Instance.NextEvent(); break; case ENTER_QUANTITY: PosContext.Instance.ClearInput(); this.PromptText = PosContext.Instance.Parameters.getParam("EnterQuantity"); PosContext.Instance.Operprompt.Update(this); //Wait for the Enter key after after input amount this.PopState(); this.States().PushState(GET_QUANTITY); PosContext.Beep(500, 50); break; case GET_QUANTITY: this.PopState(); this.newQuantity = PosContext.Instance.PosMath.GetAmount(PosContext.Instance.InputDouble()); PosContext.Instance.ClearInput(); this.States().PushState(ITEM_FINAL); PosEventStack.Instance.NextEvent(); break; case ITEM_FINAL: this.EffectChangeQuantity(this.lineNumber); this.ReComputeWholeOrderDiscounts(this.ejItem); this.ReComputeSurchrge(); this.States().Clear(); PosEventStack.Instance.NextEvent(); break; } }
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; } }
/** * Void the last item in the ej. Logic also * sets any related ej record amounts to 0, * but doesn't remove them. */ public override void Engage(int keyValue) { //Check if employee role is authorized to this event if (!PosContext.Instance.Employee.RolesEventNames.Contains("VoidItemLine")) { PosError posError = new PosError(PosErrorCode.INSUFFICIENT_USER_AUTHORITY); posError.Engage(0); return; } // if in a middle of a dialog just return // if (!(PosEventStack.Instance.CurrentPosEvent() is EclipsePos.Apps.PosEvents.RegisterOpen)) // { // PosEventStack.Instance.PushEvent(new PosError(PosErrorCode.ERROR_EVENT)); // PosEventStack.Instance.NextEvent(); // return; // } // If tried to void without any sales, just return // if (PosContext.Instance.CurrentEj == null) return; switch (this.States().PeekState()) { case VOID_ITEM: this.PopState(); this.PushState(ENTER_LINE_NUMBER); PosEventStack.Instance.NextEvent(); break; case ENTER_LINE_NUMBER: PosContext.Instance.ClearInput(); this.PromptText = PosContext.Instance.Parameters.getParam("PromptEnterLineNumber"); this.PopState(); this.PushState(GET_LINE_NUMBER); PosContext.Instance.Operprompt.Update(this); break; case GET_LINE_NUMBER: this.lineNumber = PosContext.Instance.Input(); PosContext.Instance.ClearInput(); PosContext.Instance.Operprompt.Clear(); this.PopState(); if (this.lineNumber > 0 && this.lineNumber <= PosContext.Instance.CurrentEj.LineNo) { this.PushState(COMPLETE_ITEM_VOID); } else { this.PushState(ENTER_LINE_NUMBER); PosContext.Beep(500, 50); } PosEventStack.Instance.NextEvent(); break; case COMPLETE_ITEM_VOID: // this.ProcessItemVoid(this.lineNumber); this.VoidLine(this.lineNumber); this.States().Clear(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.NextEvent(); break; } }