using System; using System.Collections.Generic; using System.Linq; using Tanshu.Accounts.Entities; using Tanshu.Common.Helpers; namespace Tanshu.Accounts.Print { public static partial class Thermal { private static string DesignBill(Voucher voucher, IDictionary list) { var billText = ""; billText += Header(voucher); billText += Products(voucher, list); decimal amount; amount = Net(list.Values); if (amount != 0) billText += "\n\r" + FormatText("Net : ", 33, Align.Right) + FormatBillNum(amount, 9); amount = HappyHourDiscount(list.Values); if (amount != 0) billText += "\n\r" + FormatText("Happy Hour Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); amount = Discount(list.Values); if (amount != 0) billText += "\n\r" + FormatText("Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); amount = ServiceCharge(list.Values); if (amount != 0) billText += "\n\r" + FormatText("Service Charge : ", 33, Align.Right) + FormatBillNum(amount, 9); // Begin Service Tax and VAT Hack decimal st = 0; amount = list.Values.Where(x => x.Tax == 0.14741M).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax); st = amount * 0.190564292M; amount = amount * (1 - 0.190564292M); if (amount != 0) billText += "\n\r" + FormatText("VAT on Food : ", 33, Align.Right) + FormatBillNum(amount, 9); amount = list.Values.Where(x => x.Tax == 0.26673M).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax); st += amount * 0.105316973M; amount = amount * (1 - 0.105316973M); if (amount != 0) billText += "\n\r" + FormatText("VAT on Liqour : ", 33, Align.Right) + FormatBillNum(amount, 9); if (st != 0) billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, Align.Right) + FormatBillNum(st, 9); //// Original //amount = Tax(list.Values); //if (amount != 0) // billText += "\n\r" + FormatText("VAT (incl. surcharge) : ", 33, Align.Right) + // FormatBillNum(amount, 9); // End Service Tax and VAT Hack amount = Amount(list.Values); if (amount != 0) billText += string.Format("\n\r{0,33}{1,9:#,##0.00;(#,##0.00);0}", "Final Amount : ", Math.Round(amount, 0)); billText += DrawLine; if (voucher.VoucherType == VoucherType.NoCharge || voucher.VoucherType == VoucherType.Staff) { billText += "\n\r" + "THIS IS NOT A BILL - DON'T PAY".Center42(); billText += DrawLine; } if (voucher.Narration != "") { billText += "\n\r" + FormatText(voucher.Narration, 42, Align.Centre); billText += DrawLine; } if (voucher.Customer.CustomerID != 1) { billText += "\n\r" + voucher.Customer.Name; billText += string.Format("\n\r{0}\n\r{1}", voucher.Customer.Phone, voucher.Customer.Address); billText += DrawLine; } billText += "\n\r" + "Cashier : " + voucher.User.Name + " / " + voucher.Waiter.Name; billText += "\n\r" + "Call: 0172-4026666, 8054923853, 8054923856"; return billText; } private static string Products(Voucher voucher, IDictionary list) { var billNo = voucher.BillID.Substring(voucher.BillID.IndexOf("-") + 1); var billText = ""; billText += "\n\r" + string.Format("Bill No: {0,-12} {1:dd-MMM-yyyy HH:mm:ss}", billNo, voucher.Date); billText += "\n\r" + "Table No.: " + voucher.TableID; billText += "\n\r" + "------------------------------------------"; billText += "\n\r" + "Qty. Particulars Price Amount"; billText += "\n\r" + "------------------------------------------"; foreach (var item in list.Values.Where(item => item.Quantity != 0)) { billText += "\n\r" + FormatBillNum(item.Quantity, 5) + " "; billText += FormatText(Name(item.Product), 22, Align.Left) + " "; billText += FormatBillNum(item.FullPrice, 6) + " "; billText += FormatBillNum(item.FullPrice * item.Quantity, 6); } billText += "\n\r" + "------------------------------------------"; return billText; } private static string Header(Voucher voucher) { var billText = ""; billText += "\n\r" + "Hops n Grains".Center42(); billText += "\n\r" + "The Microbrewery".Center42(); billText += "\n\r" + "SCO 358, Sector 9, Panchkula".Center42(); billText += "\n\r" + "A Unit of Peitho Foods Pvt. Ltd.".Center42(); billText += "\n\r" + "TIN: 06592507323".Center42(); switch (voucher.VoucherType) { case VoucherType.Regular: billText += "\n\r" + "Retail Invoice".Center42(); billText += "\n\r"; break; case VoucherType.NoCharge: billText += "\n\r" + "NO CHARGE - THIS IS NOT A BILL - DON'T PAY".Center42(); billText += "\n\r"; break; case VoucherType.TakeAway: billText += "\n\r" + "Retail Invoice (Delivery)".Center42(); billText += "\n\r"; break; case VoucherType.Staff: billText += "\n\r" + "STAFF CONSUMPTION -- THIS IS NOT A BILL".Center42(); billText += "\n\r"; break; } return billText; } } }