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 amount = SplitTax(list.Values, .13125M); if (amount != 0) billText += "\n\r" + FormatText("VAT on Food : ", 33, Align.Right) + FormatBillNum(amount, 9); amount = SplitTax(list.Values, .1575M); if (amount != 0) billText += "\n\r" + FormatText("VAT on Liqour : ", 33, Align.Right) + FormatBillNum(amount, 9); amount = ServiceTax(list.Values); if (amount != 0) billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, Align.Right) + FormatBillNum(amount, 9); 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(); billText += "\n\r" + "Service Tax: AAFCP5097GSD001".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; } } }