public static async void Print(OrderVM order) { await Application.Current.Dispatcher.BeginInvoke(new Action(() => { var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); var store = GConfig.POS_Setup; var h = order._orderHeader; bool IsDiscountSelected = false; decimal dServiceFee; decimal dTax; if (h.dOrderAmtDue > 0 || order.Discount > 0) { IsDiscountSelected = true; } dTax = BaseAppUI.Properties.Settings.Default.Tax1_State + BaseAppUI.Properties.Settings.Default.Tax2_Village; var varTax1 = ((order.TaxSubtotal) * BaseAppUI.Properties.Settings.Default.Tax1_State / dTax).ToString("C", culture); var varTax2 = ((order.TaxSubtotal) * BaseAppUI.Properties.Settings.Default.Tax2_Village / dTax).ToString("C", culture); if (h.dOrderServiceFee != null) { dServiceFee = (decimal)(h.dOrderServiceFee); } else { dServiceFee = 0; } ReceiptModel model = new ReceiptModel() { StoreName = store.vCorpName, Address1 = Properties.Settings.Default.BusinessAddress1, Address2 = Properties.Settings.Default.BusinessAddress2, Date = DateTime.Now.ToString("MMMM dd, yyyy", culture), Time = DateTime.Now.ToString("h:mm tt", culture), Phone = Properties.Settings.Default.BusinessTel, CustomerName = order.CustomerName, ReceiptNo = order.OrderNumber.ToString() + " -- " + h.vOrderType, PaymentType = order.PaymentType, PaymentRef = h.vOrderPaymentRef, Authorization = "Authorization " + h.vApprovalCode, TaxSubtotal = order.TaxSubtotal.ToString("C", culture), Tax1 = varTax1.ToString(), Tax2 = varTax2.ToString(), Tax1Label = "Tax 1 (" + BaseAppUI.Properties.Settings.Default.Tax1_State + "%)", Tax2Label = "Tax 2 (" + BaseAppUI.Properties.Settings.Default.Tax2_Village + "%)", TaxText = "Tax 1 (" + varTax1.ToString() + ") + Tax 2 (" + varTax2.ToString() + ")", Subtotal = order.Subtotal.ToString("C", culture), Total = order.AllTotal.ToString("C", culture), GratuityLabel = "Gratuity (" + BaseAppUI.Properties.Settings.Default.ServiceFee + "%)", Gratuity = "$" + dServiceFee.ToString("#.00"), GratuitySelected = order.ServiceFeeIsSelected, DiscountLabel = "Discount", DiscountAmt = "(" + order.Discount.ToString("C", culture) + ")", DiscountSelected = IsDiscountSelected, // Tips = new List<TipLine> //{ // new TipLine{Title="15% (Tip $20.25, Total $155.55)"}, // new TipLine{Title="20% (Tip $27.00, Total $162.00)"}, // new TipLine{Title="25% (Tip $33.75, Total $168.75)"} //} }; model.Lines = new List <ReceiptLine>(); foreach (var line in order.OrderLines) { string title = null; if (line.Quantity < 2) { title = line.ItemName; } else { title = string.Format("{0} x {1}", line.ItemName, line.Quantity); } var rline = new ReceiptLine { Title = title, Amount = line.Total.ToString("C", culture) }; model.Lines.Add(rline); } _printmodel(model); })); }
public static async void Print(OrderVM order) { await Task.Factory.StartNew(() => { Application.Current.Dispatcher.BeginInvoke(new Action(() => { var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); var store = GConfig.POS_Setup; var h = order._orderHeader; decimal dServiceFee = 0; bool IsDiscountSelected = false; decimal dTax; dTax = BaseAppUI.Properties.Settings.Default.Tax1_State + BaseAppUI.Properties.Settings.Default.Tax2_Village; var varTax1 = ((order.TaxSubtotal) * BaseAppUI.Properties.Settings.Default.Tax1_State / dTax).ToString("C", culture); var varTax2 = ((order.TaxSubtotal) * BaseAppUI.Properties.Settings.Default.Tax2_Village / dTax).ToString("C", culture); if (h.dOrderAmtDue > 0 || order.Discount > 0) { IsDiscountSelected = true; } if (h.dOrderServiceFee != null) { dServiceFee = (decimal)(h.dOrderServiceFee); } else { dServiceFee = 0; } ReceiptModel model = new ReceiptModel() { StoreName = store.vCorpName, Address1 = Properties.Settings.Default.BusinessAddress1, Address2 = Properties.Settings.Default.BusinessAddress2, Date = DateTime.Now.ToString("MMMM dd, yyyy", culture), Time = DateTime.Now.ToString("h:mm tt", culture), Phone = Properties.Settings.Default.BusinessTel, CustomerName = order.CustomerName, ReceiptNo = order.OrderNumber.ToString() + " -- " + h.vOrderType, PaymentType = order.PaymentType, PaymentRef = h.vOrderPaymentRef, Authorization = "Authorization " + h.vApprovalCode, TaxSubtotal = order.TaxSubtotal.ToString("C", culture), Tax1 = varTax1.ToString(), Tax2 = varTax2.ToString(), Tax1Label = "Tax 1 (" + BaseAppUI.Properties.Settings.Default.Tax1_State + "%)", Tax2Label = "Tax 2 (" + BaseAppUI.Properties.Settings.Default.Tax2_Village + "%)", TaxText = "Tax 1 (" + varTax1.ToString() + ") + Tax 2 (" + varTax2.ToString() + ")", Subtotal = order.Subtotal.ToString("C", culture), Total = order.AllTotal.ToString("C", culture), GratuityLabel = "Gratuity (" + BaseAppUI.Properties.Settings.Default.ServiceFee + "%)", Gratuity = "$" + dServiceFee.ToString("#,#.00"), GratuitySelected = order.ServiceFeeIsSelected, DiscountLabel = "Discount", DiscountAmt = "(" + order.Discount.ToString("C", culture) + ")", DiscountSelected = IsDiscountSelected, // Tips = new List<TipLine> //{ // new TipLine{Title="15% (Tip $20.25, Total $155.55)"}, // new TipLine{Title="20% (Tip $27.00, Total $162.00)"}, // new TipLine{Title="25% (Tip $33.75, Total $168.75)"} //} }; model.Lines = new List <ReceiptLine>(); foreach (var line in order.OrderLines) { string title = null; if (line.Quantity < 2) { title = line.ItemName; } else { title = string.Format("{0} x {1}", line.ItemName, line.Quantity); } var rline = new ReceiptLine { Title = title, Amount = line.Total.ToString("C", culture), Comments = line.Comments }; model.Lines.Add(rline); } if (h.iSplitCount.HasValue) { model.HasSplit = true; // var splits = Model.SplitPaymentInfo.FromText(h.vSplitPayment); var splits = h.vSplitPayment.Split(new string[] { ";" }, StringSplitOptions.None); model.Splits = new List <SplitLine>(); //foreach (var split in splits) //{ // model.Splits.Add(new SplitLine // { // Title = split[Model.SplitPaymentInfoFlags.id], // Amount = decimal.Parse(split[Model.SplitPaymentInfoFlags.amount]).ToString("C", culture), // Type = string.Format("({0})", split[Model.SplitPaymentInfoFlags.type]) // }); //} foreach (var split in splits) { var parts = split.Split(new string[] { "," }, StringSplitOptions.None); model.Splits.Add(new SplitLine { //0 paymenttype //1 cardnumber //2 amount //3 splitname Amount = decimal.Parse(parts[2]).ToString("C", culture), Title = string.Format("{0} / {1}", parts[3], h.iSplitCount.Value) }); } } Printmodel(model); })); }); }