public void Init(EjItem item, Promotion promotion) { this.item = item; this.promo = promotion; this.amount = 0; this.quantity = 0; this.lineNo = item.LineNo; }
/** How to initialize */ public void Init(EjItem item, Promotion promotion) { this.item = item; this.promo = promotion; this.amount = 0; this.quantity = 0; this.desc = promo.PromotionString + " " + promo.PromotionDval1 + "%"; this.lineNo = item.LineNo; }
public override void Engage(int val) { //MessageBox.Show("*** Discount ***" + keyValue.ToString()); //Check if employee role is authorized to this event if (!PosContext.Instance.Employee.RolesEventNames.Contains("Discount")) { PosError posError = new PosError(PosErrorCode.INSUFFICIENT_USER_AUTHORITY); posError.Engage(0); return; } // if ( PosContext.Instance.CurrentEj != null && PosContext.Instance.CurrentEj.Seq_no > 0 ) //{ // PosError posError = new PosError(PosErrorCode.PROMOTION_NOT_APPLICABLE); // posError.Engage(0); // return; //} int keyValue = val; //(int) PosContext.Instance.PosKeyValue; Promotion pro = new Promotion(); pro.PromotionNo = keyValue; pro.Organization_no = PosSettings.Default.Organization; pro.Load(); if (pro.PromotionType == (int)EjPromotionTypes.WHOLE_ORDER) { PosContext.Instance.SaleMode = pro; //Apply promotion for current Ej object[] currentEj = new Object[PosContext.Instance.CurrentEj.EjArrayList.Count]; PosContext.Instance.CurrentEj.EjArrayList.CopyTo(currentEj); foreach (object obj in currentEj) { if (obj is EjItem) { EjItem ejItem = obj as EjItem; if ((ejItem.TransItem.State == (int)EjLineStates.VOID_ITEM) || ejItem.TransItem.State == (int)EjLineStates.PRICE_OVERRIDE) { continue; } EjPromotion ejPromo1 = new EjPromotion(PosContext.Instance.SaleMode, ejItem); ejPromo1.SKU = ejItem.SKU; ejPromo1.Engage(0); } } } else { EjPromotion ejPromo1 = new EjPromotion(pro, PosContext.Instance.CurrentEjItem); ejPromo1.SKU = PosContext.Instance.CurrentEjItem.SKU; ejPromo1.Engage(0); } }
public void Init(EjItem item, Promotion promotion) { this.item = item; this.promotion = promotion; //this.amount = 0; //this.quantity = 0; if (trxNo != PosContext.Instance.TrxNo) { trxNo = PosContext.Instance.TrxNo; //apply_count = 0; } this.lineNo = item.LineNo; }
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; } } }
public void ReComputeWholeOrderDiscounts(EjItem ejitem) { if (PosContext.Instance.SaleMode != null) { ArrayList ejList = PosContext.Instance.CurrentEj.EjArrayList; foreach (object obj in ejList) { if (obj is EjPromotion) { EjPromotion ejPromo = obj as EjPromotion; if (ejPromo.LineNo == ejitem.LineNo) { if (ejPromo.Promotion.PromotionType == (int)EjPromotionTypes.WHOLE_ORDER) { ejPromo.ReCompute(ejitem); return; } } } } } }
public ItemList(EjItem ejItem, Ej ej) { _count = 0; foreach (Object obj in ej.EjArrayList) { EjLine ejLine = obj as EjLine; if ((ejLine is EjItem) && ejLine.Equals(ejItem)) { if (nextitem) { break; } nextitem = true; this.Add(ejLine); continue; // Get the next ejLine } // Ignore other EjItems in the array list if (!nextitem) { continue; } if (ejLine is EjPromotion) { this.Add(ejLine); } if (ejLine is EjTax) { this.Add(ejLine); } } }
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; } }
/*public string PromptText * { * get * { * return promptText; * } * set * { * promptText= value; * } * }*/ #endregion /** * Customized for event type on top of stack * - PosError, pop the next event and update dialogs. * - If there is input line data, (i.e. user is in the * middle inputing a number, remove the last number. * - else, clear input, pops the stack and update dialogs. */ public override void Engage(int keyValue) { Logger.Info( this.GetType().FullName, this.GetType().FullName + "Key value:" + PosContext.Instance.InputLine.ToString(), PosSettings.Default.Debug ); // MessageBox.Show("*** ClearKey ***"); //PosContext.Instance.InputLine = ""; //PosContext.Instance.Operprompt.Update(this); PosContext.Instance.PosPrompt.EnableInput(); PosEvent posEventCurrent = PosEventStack.Instance.Peek() as PosEvent; // Clear the error event, update dialogs and return if (posEventCurrent is PosError) { PosEventStack.Instance.PopEvent(); PosEvent posEventNext = PosEventStack.Instance.Peek() as PosEvent; if (posEventNext is FinishTransaction) { PosEventStack.Instance.NextEvent(); } if (posEventNext is LogOn) { LogOn logOn = posEventNext as LogOn; PosContext.Instance.Operprompt.Update(this); logOn.States().PushState((int)LogonStates.EnterUser); PosEventStack.Instance.NextEvent(); return; } if (posEventNext is SelectTable) { PosContext.Instance.CurrentPosDisplay.UnloadTableSelect(); PosContext.Instance.HomeGUI(); } PosContext.Instance.ClearInput(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.ClearProcessed(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is UnLock) { return; } if (posEventCurrent is FinishTransaction) { PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is CloseCashDrawer) { PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is PromptPrintReceipt) { // get rid of this event and continue PosContext.Instance.ClearInput(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.PopEvent(); PosEventStack.Instance.NextEvent(); return; } // If this is a finish trans then the user wants to // cancel the current tender, clean up the operator // reciept, remove the tender ej and continue. if (posEventCurrent is FinishTransaction) { PosContext.Instance.Receipt.ClearLine(); PosContext.Instance.ClearInput(); //PosContext.Instance.CurrentEj.RemoveCurrLine(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is EjItem) { EjItem ejItem = posEventCurrent as EjItem; if (ejItem.DialogStep != EjItem.ITEM_FINAL) { ejItem.States().PopState(); ejItem.States().PushState(EjItem.ITEM_CLEAR); PosEventStack.Instance.NextEvent(); } return; } if (posEventCurrent is EjLine) { PosContext.Instance.ClearInput(); //PosContext.Instance.CurrentEj.RemoveCurrLine (); PosContext.Instance.HomeGUI(); PosEventStack.Instance.ClearPending(); PosContext.Instance.EnableKeys(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is LogOn) { PosContext.Instance.ClearInput(); LogOn logOn = posEventCurrent as LogOn; logOn.ResetState(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is RegisterOpen) { // if ( (PosContext.Instance.CurrentEj.TransHeader.State == (int) Transaction.Status.COMPLETE) || // (PosContext.Instance.CurrentEj.TransHeader.State == (int) Transaction.Status.VOIDED) ) // { // PosContext.Instance.Receipt.ClearLine(); // } PosContext.Instance.HomeGUI(); PosContext.Instance.EnableKeys(); PosContext.Instance.Operprompt.Update(this); PosContext.Instance.Receipt.Update(this); } if (posEventCurrent is TerminalReport) { PosContext.Instance.HomeGUI(); PosContext.Instance.EnableKeys(); PosContext.Instance.Operprompt.Update(this); PosContext.Instance.Receipt.Update(this); } if (posEventCurrent is SelectTable) { PosContext.Instance.HomeGUI(); PosContext.Instance.CurrentPosDisplay.UnloadTableSelect(); PosContext.Instance.Operprompt.Update(this); PosContext.Instance.Receipt.Update(this); } if (posEventCurrent is PosNumberDialog) { PosNumberDialog dialog = posEventCurrent as PosNumberDialog; PosContext.Instance.EnableKeys(); dialog.Clear(); if (PosContext.Instance.Input() > 0) { PosContext.Instance.ClearInput(); PosContext.Instance.Operprompt.Update(dialog); } else { PosContext.Instance.ClearInput(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.ClearProcessed(); PosEventStack.Instance.NextEvent(); } } else { PosContext.Instance.HomeGUI(); PosContext.Instance.ClearInput(); PosEventStack.Instance.ClearPending(); // PosEventStack.Instance.ClearPending(); PosEventStack.Instance.NextEvent(); } return; }
/** Event logic is implemented here */ public override void Engage(int keyValue) { Item item = new Item(); item.Organization_no = PosSettings.Default.Organization; // if (keyValue > 0) // { // item.Plu = keyValue; // item.LoadByPLU(); // // } // else // { if (PosContext.Instance.InputLine.Length == 0 && PosContext.Instance.ItemLookupDevice.SelectedItem().Length > 0) { item.Sku = PosContext.Instance.ItemLookupDevice.SelectedItem(); item.LoadBySKU(); } else { if (PosContext.Instance.InputLine.Length <= maxPluLength) { try { item.Plu = PosContext.Instance.InputLine.Trim(); item.LoadByPLU(); } catch (System.FormatException e) { //Could be SKU item.Sku = PosContext.Instance.InputLine; item.LoadBySKU(); } } if (item.Short_Desc == null) { try { item.Sku = PosContext.Instance.InputLine; item.LoadBySKU(); } catch { } } } // } if (item.Short_Desc != null) { try { EjItem ejItem = new EjItem(item); //ejItem.Engage(0); ejItem.States().PushState((int)EjItemStates.ENTER_QTY); PosEventStack.Instance.PushEvent(ejItem); // PosEventStack.Instance.Dump(); PosEventStack.Instance.NextEvent(); } catch (Exception e) { MessageBox.Show(e.StackTrace.ToString()); } } else { PosError posError = new PosError(PosErrorCode.INVALID_INPUT); posError.Engage(0); } PosContext.Instance.InputLine = ""; PosContext.Instance.ClearInput(); }
public void Update(EjItem ejItem) { int state = ejItem.States().PeekState(); StringBuilder strDisplay = new StringBuilder(prompt.MessageWidth); // for (int i = 0; i < prompt.MessageWidth; i++) // { // strDisplay.Append(" "); // } switch (state) { case (int)EjItemStates.ENTER_QTY: // strDisplay.Append("Item : "); strDisplay.Append(ejItem.Item.Short_Desc + " "); prompt.MessageText = strDisplay.ToString(); //ejItem.Item.Short_Desc +" "+ " ? " + ejItem.Item.Shipping_uom + " ? $"; break; case (int)EjItemStates.ENTER_AMOUNT: strDisplay.Append(ejItem.Item.Short_Desc + " "); strDisplay.Append(string.Format("{0:###########0.00}", ejItem.Quantity) + " " + ejItem.Item.Shipping_uom); prompt.MessageText = strDisplay.ToString(); //ejItem.Item.Short_Desc + " " + string.Format("{0:###########0.00}", ejItem.Quantity) +ejItem.Item.Shipping_uom + " X " + " ?$"; break; case (int)EjItemStates.ITEM_FINAL: prompt.MessageText = ""; //ejItem.Item.Short_Desc + " " + ejItem.Quantity.ToString() + string.Format("{0:###########0.00}", ejItem.Amount); prompt.EndInputAnimation(); break; defaut: prompt.MessageText = ""; break; } if (state != (int)EjItemStates.ITEM_FINAL) { if (prompt != null) { this.prompt.PromptText = ejItem.PromptText; // this.posDisplay.MessageText = ""; prompt.InputText = ""; prompt.StartInputAnimation(); } return; } prompt.PromptText = ejItem.PromptText; prompt.InputText = ""; // posDisplay.MessageText = ejItem.Quantity.ToString()+ " * " + // ejItem.Desc +" "+ string.Format( "{0:###########0.00}", ejItem.Amount); if (PosHardware.Instance.LineDisplay != null) { PosHardware.Instance.LineDisplay.Clear(); PosHardware.Instance.LineDisplay.SetText(ejItem.Desc, 0, 0); //Item price string itemPrice = string.Format("{0:#########0.00}", ejItem.Amount); int col = PosHardware.Instance.LineDisplay.PromptWidth() - itemPrice.Length - 1; PosHardware.Instance.LineDisplay.SetText(itemPrice, 1, col); //Total string total = string.Format("{0:<#########0.00>}", PosContext.Instance.CurrentEj.EjSubTotal());; PosHardware.Instance.LineDisplay.SetText(total, 1, 0); } }