public EjTax(Tax t, EjSurcharge i) { this.taxRecord = t; this.ejSurcharge = i; this.useAltTax = false; this.LineType = (int)EjLineType.TAX; this.item = null; }
public void ReCompute(EjItem ejItem1) { this.Modifier = null; try { this.Modifier = Assembly.GetExecutingAssembly().CreateInstance(promotion.PromotionClass) as PosItemModifier; } catch (Exception e) { Logger.Error("EjPromotion.cs", e.ToString()); } if (this.Modifier != null) { this.Modifier.Init(ejItem1, this.Promotion); this.Modifier.Apply(); if (this.Modifier.Applied) { this.transPromotion.PromotionAmount = this.Modifier.Amount; this.transPromotion.UpdatePromotionAmount(); } if (ejItem1 != null) { foreach (EjTax itemTax in ejItem1.Taxes) { itemTax.PromotionAmount += this.TransPromotion.PromotionAmount; itemTax.ApplyTax(); if (!PosContext.Instance.Training) { itemTax.Save(); } } } PosContext.Instance.Receipt.Update(this); } }
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 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; } } }
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); }
public void Complete(int state) { if (PosContext.Instance.Training) { this.Clear(); return; } foreach (Object obj in ejArrayList) { EjLine ejLine = (EjLine)obj; if (ejLine.State != (int)EjLineStates.IN_PROGRESS) { continue; } // ejLine.State = state; switch (ejLine.LineType) { case (int)EjLineType.TRANS_HEADER: EjHeader ejHeader = (EjHeader)ejLine; if (!ejHeader.UpdateState(state)) { MessageBox.Show("Error :- Unable to complete UpdateState-Ej"); } break; case (int)EjLineType.ITEM: ejLine.UpdateTotals(); EjItem ejItem = ejLine as EjItem; ejItem.SaveState((EjLineStates)state); if (state == (int)Transaction.Status.COMPLETE) { ejItem.UpdateStock(); } break; case (int)EjLineType.PROMOTION: case (int)EjLineType.BANK: case (int)EjLineType.TENDER: case (int)EjLineType.CHECK_TENDER: case (int)EjLineType.CC_TENDER: case (int)EjLineType.GIFT_CERT_TENDER: case (int)EjLineType.DEBIT_TENDER: case (int)EjLineType.ALT_CURRENCY_TENDER: case (int)EjLineType.COUPON: case (int)EjLineType.ACCOUNT: case (int)EjLineType.TAX: case (int)EjLineType.SURCHARGE: ejLine.UpdateTotals(); break; case (int)EjLineType.TOTAL: break; default: break; } // es01-26/11/08 if (!ejLine.Save()) // es01-26/11/08 { // es01-26/11/08 MessageBox.Show("Error :- Unable to save Ej"); // es01-26/11/08 } } //EjHeader ejHeader = (EjHeader)ejArrayList[0]; //if (!ejHeader.UpdateState(state)) //{ // MessageBox.Show("Error :- Unable to complete UpdateState-Ej"); //} this.Clear(); }
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)); }
public EjPromotion(Promotion pro, EjItem item) { this.promotion = pro; this.LineType = (int)EjLineType.PROMOTION; this.ejItem = item; }