public override void Engage(int val) { if (!(PosContext.Instance.Parameters.getParam("ApplyRoundingToCashTender") == "TRUE")) { PosEventStack.Instance.NextEvent(); return; } int keyValue = 0; try { keyValue = int.Parse(PosContext.Instance.Parameters.getParam("AutoRoundDownPromotionNo")); //999; } catch (Exception e) { PosEventStack.Instance.NextEvent(); return; } Promotion pro = new Promotion(); pro.PromotionNo = keyValue; pro.Organization_no = PosSettings.Default.Organization; pro.Load(); EjPromotion ejPromo1 = new EjPromotion(pro, PosContext.Instance.CurrentEjItem); ejPromo1.SKU = PosContext.Instance.CurrentEjItem.SKU; ejPromo1.Engage(0); PosEventStack.Instance.NextEvent(); }
private bool LoadEj(int transNo) { //PrintJobQueue.Instance.Clear(); Transaction trans = new Transaction(transNo); trans.Organization_no = PosSettings.Default.Organization; trans.Store_no = PosSettings.Default.Store; trans.Pos_no = PosSettings.Default.Station; // trans.State = (int)Transaction.Status.SUSPEND; trans.Load(); if (trans.Trans_no != 0) { // was this a suspended transaction? PosContext.Instance.CurrentEj = Ej.GetSuspendedEj(trans); PosContext.Instance.TransactionType = trans.Trans_type; PosContext.Instance.TableName = trans.Table_name; if (PosContext.Instance.CurrentEj.EjArrayList.Count > 0) { // finally make sure there are records PosContext.Instance.TableName = trans.Table_name; PosContext.Instance.TrxNo = trans.Trans_no; trans.State = (int)Transaction.Status.IN_PROGRESS; foreach (Object obj in PosContext.Instance.CurrentEj.EjArrayList) { EjLine line = (EjLine)obj; if (line is EjPromotion) { EjPromotion ejPromo = line as EjPromotion; if (ejPromo.LineType == (int)EjPromotionTypes.WHOLE_ORDER) { PosContext.Instance.SaleMode = ejPromo.Promotion; } } PosContext.Instance.Receipt.Update(line); } } if (trans.Customer_tax_id.Length > 0) { EclipsePos.Data.Customer cus = new EclipsePos.Data.Customer(); cus.Organization_no = PosSettings.Default.Organization; cus.Tax_id = trans.Customer_tax_id; cus.LoadByTaxID(); EjCustomer ejCus = new EjCustomer(cus); PosContext.Instance.Receipt.Update(ejCus); PosContext.Instance.EjCustomer = ejCus; } return(true); } else { return(false); } }
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 Update(EjPromotion pEvent) { prompt = PosContext.Instance.PosPrompt; if (prompt != null) { prompt.PromptText = pEvent.PromptText; posDisplay.MessageText = ""; prompt.InputText = ""; } }
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 override void Engage(int keyValue) { //MessageBox.Show("*** Item markdown ***" + keyValue.ToString() ); //if there are no items in the invoice error out if (PosContext.Instance.CurrentEj == null || PosContext.Instance.CurrentEj.SeqNo == 0) { PosError posError = new PosError(PosErrorCode.ITEM_DISCOUNT_NOT_APPLICABLE); posError.Engage(0); return; } Promotion promo = new Promotion(); // int keyValue = (int) PosContext.Instance.PosKeyValue; promo.PromotionNo = keyValue; promo.Organization_no = PosSettings.Default.Organization; promo.Load(); if (promo.PromotionClass != null) { EjPromotion ejPromo = new EjPromotion(promo, PosContext.Instance.CurrentEjItem); ejPromo.Engage(0); } // PosEventStack.Instance.NextEvent(); }
public override void Engage(int keyValue) { //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.SeqNo == 0) { PosError posError = new PosError(PosErrorCode.ITEM_DISCOUNT_NOT_APPLICABLE); posError.Engage(0); return; } switch (this.States().PeekState()) { case ENTER_AMOUNT: PosContext.Instance.ClearInput(); this.PromptText = PosContext.Instance.Parameters.getParam("EnterDiscountAmount"); PosContext.Instance.Operprompt.Update(this); this.PopState(); this.PushState(GET_AMOUNT); break; case GET_AMOUNT: this.discountAmt = PosContext.Instance.Input(); // PosContext.Instance.ClearInput(); // PosContext.Instance.Operprompt.Clear(); this.PopState(); this.States().PushState(APPLY_DISCOUNT); PosEventStack.Instance.NextEvent(); break; case APPLY_DISCOUNT: Promotion promo = new Promotion(); // int keyValue = (int) PosContext.Instance.PosKeyValue; promo.PromotionNo = 0; promo.Organization_no = PosSettings.Default.Organization; promo.PromotionType = 1; promo.PromotionVal1 = 1; promo.PromotionString = "Discount"; promo.PromotionClass = "EclipsePos.Apps.Operators.GetDiscountFromInput"; EjPromotion ejPromo = new EjPromotion(promo, PosContext.Instance.CurrentEjItem); ejPromo.Engage(0); this.States().Clear(); PosContext.Instance.ClearInput(); PosContext.Instance.Operprompt.Clear(); break; } }
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 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; } }