2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using System.Windows.Forms;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
using Tanshu.Accounts.Entities.Auth;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using Tanshu.Accounts.Repository;
|
2011-04-11 12:55:45 +00:00
|
|
|
|
using System.Diagnostics;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Print
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
internal enum Align
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Left = 1,
|
|
|
|
|
Centre = 2,
|
|
|
|
|
Right = 4
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Thermal
|
|
|
|
|
{
|
|
|
|
|
private const string DrawLine = "\n\r------------------------------------------";
|
|
|
|
|
private const string DrawEqual = "\n\r==========================================";
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
private static string DesignKot(Voucher trans, string kotCode, IEnumerable<Inventory> billItems, int copyNumber)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var waiter = trans.Waiter;
|
|
|
|
|
var billText = "\n\r" + FormatText("KOT / BOT", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText(string.Format("Copy No. {0}", copyNumber), 42, false, Align.Centre);
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
billText += string.Format("\n\rKOT ID : {0,-7}/{1,-7} {2:dd-MMM-yyyy HH:mm}", trans.KotID, kotCode,
|
|
|
|
|
trans.Date);
|
|
|
|
|
billText += string.Format("\n\rTable No.: {0} / {1}", trans.TableID, waiter.Name);
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
billText += "\n\r Qty. x Name ";
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
foreach (var item in billItems)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += string.Format("\n\r{0,6:#,##0.00} x {1,-33}", item.Quantity, Name(item.Product));
|
|
|
|
|
foreach (var mod in item.InventoryModifier)
|
|
|
|
|
billText += string.Format("\n\r --- {0,-32}", mod.Modifier.Name);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += DrawLine;
|
|
|
|
|
if (trans.Narration != "")
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + FormatText(trans.Narration, 42, false, Align.Centre);
|
|
|
|
|
billText += DrawLine;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return billText;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
private static string DesignBill(Voucher trans)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var list = new Dictionary<int, Inventory>();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
foreach (var kot in trans.Kots)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in kot.Inventories)
|
|
|
|
|
{
|
|
|
|
|
if (list.ContainsKey(item.Product.ProductID))
|
|
|
|
|
list[item.Product.ProductID].Quantity += item.Quantity;
|
|
|
|
|
else
|
|
|
|
|
list.Add(item.Product.ProductID, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var cashier = trans.User;
|
|
|
|
|
var waiter = trans.Waiter;
|
|
|
|
|
var customer = trans.Customer;
|
|
|
|
|
var billNo = trans.BillID.Substring(trans.BillID.IndexOf("-") + 1);
|
|
|
|
|
var billText = "";
|
|
|
|
|
billText = "\n\r" + FormatText("Hops n Grains", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("The Microbrewery", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("SCO 358, Sector 9, Panchkula", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("A Unit of Peitho Foods Pvt. Ltd.", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("TIN: 06592507323", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("Retail Invoice", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
billText += "\n\r" + "Bill No: " + FormatText(billNo, 13, false, Align.Centre) +
|
|
|
|
|
string.Format("{0:dd-MMM-yyyy HH:mm:ss}", trans.Date);
|
|
|
|
|
billText += "\n\r" + "Table No.: " + trans.TableID;
|
|
|
|
|
billText += "\n\r" + "------------------------------------------";
|
|
|
|
|
billText += "\n\r" + "Qty. Particulars Price Amount";
|
|
|
|
|
billText += "\n\r" + "------------------------------------------";
|
2011-02-18 16:54:48 +00:00
|
|
|
|
foreach (var item in list.Values)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (item.Quantity == 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (Math.Round((item.Rate * (1 + item.Tax)), 0) == 1)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + " ";
|
|
|
|
|
billText += FormatText(Name(item.Product), 22, false, Align.Left) + " ";
|
|
|
|
|
billText += " ";
|
|
|
|
|
billText += FormatBillNum(item.Rate * item.Quantity, 6);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + FormatBillNum(item.Quantity, 5) + " ";
|
|
|
|
|
billText += FormatText(Name(item.Product), 22, false, Align.Left) + " ";
|
|
|
|
|
billText += FormatBillNum(item.Rate, 6) + " ";
|
|
|
|
|
billText += FormatBillNum(item.Rate * item.Quantity, 6);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + "------------------------------------------";
|
2011-02-18 16:54:48 +00:00
|
|
|
|
decimal amount;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
amount = Net(list.Values);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (amount != 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + FormatText("Net : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
amount = Discount(list.Values);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (amount != 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + FormatText("Discount : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
amount = ServiceCharge(list.Values);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (amount != 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + FormatText("Service Charge : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
|
|
|
|
|
// Begin Service Tax and VAT Hack
|
|
|
|
|
decimal st = 0;
|
|
|
|
|
amount = list.Values.Where(x => x.Tax == 0.14741M).Sum(item => item.Quantity * item.Rate * (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 @ 12.5% + 5% Sur. : ", 33, false, Align.Right) +
|
|
|
|
|
FormatBillNum(amount, 9);
|
|
|
|
|
|
|
|
|
|
amount = list.Values.Where(x => x.Tax == 0.26673M).Sum(item => item.Quantity * item.Rate * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax);
|
|
|
|
|
st += amount * 0.105316973M;
|
|
|
|
|
amount = amount * (1 - 0.105316973M);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (amount != 0)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
billText += "\n\r" + FormatText("VAT @ 25% + 5% Sur. : ", 33, false, Align.Right) +
|
2011-03-11 18:49:48 +00:00
|
|
|
|
FormatBillNum(amount, 9);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
if (st != 0)
|
|
|
|
|
billText += "\n\r" + FormatText("Cental Govt. ST : ", 33, false, Align.Right) +
|
|
|
|
|
FormatBillNum(st, 9);
|
|
|
|
|
//// Original
|
|
|
|
|
//amount = Tax(list.Values);
|
|
|
|
|
//if (amount != 0)
|
|
|
|
|
// billText += "\n\r" + FormatText("VAT (incl. surcharge) : ", 33, false, Align.Right) +
|
|
|
|
|
// FormatBillNum(amount, 9);
|
|
|
|
|
|
|
|
|
|
// End Service Tax and VAT Hack
|
|
|
|
|
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
amount = Amount(list.Values);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (amount != 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += string.Format("\n\r Final Amount : {0,9:#,##0.00;(#,##0.00);0}",
|
|
|
|
|
Math.Round(amount, 0));
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += DrawLine;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
if (trans.Narration != "")
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + FormatText(trans.Narration, 42, false, Align.Centre);
|
|
|
|
|
billText += DrawLine;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
if (customer.CustomerID != 1)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + customer.Name;
|
|
|
|
|
billText += string.Format("\n\r{0}\n\r{1}", customer.Phone, customer.Address);
|
|
|
|
|
billText += DrawLine;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += "\n\r" + "Cashier : " + cashier.Name + " / " + waiter.Name;
|
|
|
|
|
billText += "\n\r" + "Call: 0172-4026666, 8054923853, 8054923856";
|
|
|
|
|
return billText;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
private static decimal Amount(IEnumerable<Inventory> list)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return list.Sum(item => item.Quantity * item.Rate * (1 - item.Discount) * (1 + item.ServiceCharge) * (1 + item.Tax));
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
private static decimal Tax(IEnumerable<Inventory> list)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return list.Sum(item => item.Quantity * item.Rate * (1 - item.Discount) * (1 + item.ServiceCharge) * item.Tax);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
private static decimal ServiceCharge(IEnumerable<Inventory> list)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return list.Sum(item => item.Quantity * item.Rate * (1 - item.Discount) * item.ServiceCharge);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
private static decimal Discount(IEnumerable<Inventory> list)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return list.Sum(item => item.Quantity * item.Rate * item.Discount);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
private static decimal Net(IEnumerable<Inventory> list)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return list.Sum(item => item.Quantity * item.Rate);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
private static string Name(Product product)
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return string.IsNullOrEmpty(product.Units)
|
|
|
|
|
? product.Name
|
|
|
|
|
: string.Format("{0} ({1})", product.Name, product.Units);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
private static string FormatText(string inputString, int width, Boolean multiline, Align alignment)
|
|
|
|
|
{
|
|
|
|
|
if ((multiline) && (inputString.Length > width))
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var newString = "";
|
|
|
|
|
var lines = Convert.ToInt32(Math.Floor(Convert.ToDecimal(inputString.Length / width)));
|
|
|
|
|
for (var i = 0; i < lines; i++)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
newString += inputString.Substring(i * width, width) + "\n\r";
|
|
|
|
|
newString += FormatText(inputString.Substring(lines * width), width, multiline, alignment);
|
|
|
|
|
return newString;
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (inputString.Length > width)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
return inputString.Substring(0, width);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (alignment == Align.None)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
return inputString;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (alignment == Align.Left)
|
|
|
|
|
return string.Format("{0,-" + width + "}", inputString);
|
|
|
|
|
if (alignment == Align.Centre)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
int left;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
left = Convert.ToInt32(Math.Ceiling(Convert.ToDouble((width - inputString.Length) / 2))) +
|
|
|
|
|
inputString.Length;
|
|
|
|
|
inputString = string.Format("{0,-" + left + "}", inputString);
|
|
|
|
|
return string.Format("{0," + width + "}", inputString);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (alignment == Align.Right)
|
|
|
|
|
return string.Format("{0," + width + "}", inputString);
|
|
|
|
|
return inputString;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
private static string FormatBillNum(decimal amount, int length)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var temp = String.Format("{0:#,##0.00;(#,##0.00);0}", amount);
|
|
|
|
|
return string.Format("{0," + length + "}", temp);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
private static bool PrintRaw(PrintLocation printer, string text, string documentName)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-04 19:30:55 +00:00
|
|
|
|
#if (DEBUG)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
MessageBox.Show(text);
|
2011-02-04 19:30:55 +00:00
|
|
|
|
return true;
|
|
|
|
|
#else
|
2010-03-02 17:56:21 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2011-03-12 11:42:02 +00:00
|
|
|
|
text += printer.CutCode;
|
|
|
|
|
if (!RawPrinterHelper.PrintString(printer.Printer, documentName, text, new[] { ';' }))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
GC.Collect();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
MessageBox.Show("Error in PrintRAW Function. Please Report immediately");
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2011-02-04 19:30:55 +00:00
|
|
|
|
#endif
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
public static Boolean PrintAdvance(string user, string advance, string narration)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var billText = "\n\r" + FormatText("Hops n Grains", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("The Microbrewery", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("SCO 358, Sector 9, Panchkula", 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("A Unit of Peitho Foods Pvt. Ltd.", 42, false, Align.Centre);
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
billText += "\n\r" +
|
|
|
|
|
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
|
|
|
|
billText += "\n\r" + FormatText("Received Rs. " + advance + " as advance.", 42, false, Align.Centre);
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
if (narration != "") billText += "\n\r" + FormatText(narration, 42, false, Align.Centre);
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
billText += "\n\r" + FormatText("Thanking you " + user, 42, false, Align.Left);
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
billText += "Signed" + "\n\r";
|
|
|
|
|
billText += "\n\r";
|
|
|
|
|
PrintRaw(PrintLocationBI.BasePrinter, billText, "Advance for " + user);
|
|
|
|
|
return PrintRaw(PrintLocationBI.BasePrinter, billText, "Advance for " + user);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-17 14:55:43 +00:00
|
|
|
|
public static Boolean PrintClosing(CheckoutBI details)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var billText = FormatText(string.Format("{0} Checkout By {1}", details.Cashier.Name, details.Manager), 42,
|
|
|
|
|
false, Align.Centre);
|
|
|
|
|
billText += string.Format("\n\r{0:dd-MMM-yy} To {1:dd-MMM-yy} @ {2:dd-MMM-yyyy HH:mm}",
|
|
|
|
|
details.StartDate, details.FinishDate, DateTime.Now);
|
|
|
|
|
billText += DrawLine;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
//BillText += string.Format("\n\rOpening : {0,26:#,##0.00}", details.Opening);
|
|
|
|
|
//BillText += string.Format("\n\rReceipts : {0,26:#,##0.00}", details.Receipts);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += string.Format("\n\rAdvance Rcv. : {0,26:#,##0.00}", details.AdvanceReceipts);
|
|
|
|
|
billText += string.Format("\n\rCC Receipts : {0,26:#,##0.00}", details.CcReceipts);
|
|
|
|
|
billText += string.Format("\n\rNC Amount : {0,26:#,##0.00}", details.NcReceipts);
|
|
|
|
|
billText += string.Format("\n\rBTC Amount : {0,26:#,##0.00}", details.BtcReceipts);
|
2011-04-11 12:55:45 +00:00
|
|
|
|
billText += string.Format("\n\rCash Amount : {0,26:#,##0.00}", details.CashReceipts);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += string.Format("\n\rAdvance Adj. : {0,26:#,##0.00}", details.AdvanceAdjusted);
|
2011-02-09 12:03:22 +00:00
|
|
|
|
//BillText += string.Format("\n\rPayments : {0,26:#,##0.00}", details.CashPayments);
|
|
|
|
|
//BillText += string.Format("\n\rAddl. Voids : {0,26:#,##0.00}", details.AdditionalVoids);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += string.Format("\n\rVoids in Sys. : {0,26:#,##0.00}", details.VoidsInSystem);
|
|
|
|
|
billText += string.Format("\n\rDiscounts : {0,26:#,##0.00}", details.Discount);
|
|
|
|
|
billText += string.Format("\n\rPending Bills : {0,26:#,##0.00}", details.PendingBills);
|
2011-04-11 12:55:45 +00:00
|
|
|
|
billText += string.Format("\n\rNet Sales : {0,26:#,##0.00}", details.CashReceipts);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += string.Format("\n\rClosing Bal. : {0,26:#,##0.00}", details.ClosingBalance);
|
|
|
|
|
billText += string.Format("\n\rCash Dep. : {0,26:#,##0.00}", details.CashDeposited);
|
|
|
|
|
billText += DrawLine;
|
|
|
|
|
billText += string.Format("\n\rOld Pending : {0,26:#,##0.00}", details.OldPending);
|
|
|
|
|
billText += string.Format("\n\rOld Receipts : {0,26:#,##0.00}", details.OldReceipts);
|
|
|
|
|
billText += string.Format("\n\rOld Voided : {0,26:#,##0.00}", details.OldVoided);
|
|
|
|
|
billText += DrawEqual;
|
|
|
|
|
billText += "\n\r" + FormatText(details.Status, 42, false, Align.Centre);
|
|
|
|
|
billText += DrawEqual;
|
|
|
|
|
billText += string.Format("\n\rActive Cashiers : {0}", details.Cashiers);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
if (details.PendingString.Length > 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += details.PendingString;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (details.CcString.Length > 0)
|
|
|
|
|
billText += details.CcString;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (details.NcString.Length > 0)
|
|
|
|
|
billText += details.NcString;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
if (details.BtcString.Length > 0)
|
|
|
|
|
billText += details.BtcString;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
if (details.VoidsString.Length > 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += details.VoidsString;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
if (details.PaymentString.Length > 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += details.PaymentString;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
if (details.DiscountString.Length > 0)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
billText += details.DiscountString;
|
|
|
|
|
return PrintRaw(PrintLocationBI.BasePrinter, billText, "Closing");
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 18:49:48 +00:00
|
|
|
|
public static string FormatPrintNum(string inputString)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
return inputString == "" ? "0.00" : FormatText(inputString, 24, false, Align.Right);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
//return FormatText(FormatNumber(InputString.Trim, 2, TriState.UseDefault, TriState.True, TriState.True), 24, False, Align.Right);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public static void PrintBill(int voucherID)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-04-11 12:55:45 +00:00
|
|
|
|
var voucher = VoucherBI.Get(voucherID);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
PrintRaw(PrintLocationBI.BasePrinter, DesignBill(voucher), "Bill");
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public static void PrintKot(int voucherID, int kotID)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-04-11 12:55:45 +00:00
|
|
|
|
var stopwatch = new Stopwatch();
|
|
|
|
|
stopwatch.Start();
|
|
|
|
|
var voucher = VoucherBI.Get(voucherID);
|
2011-03-11 18:49:48 +00:00
|
|
|
|
var dict = new Dictionary<PrintLocation, List<Inventory>>();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
foreach (var item in voucher.Kots.Where(x => x.KotID == kotID))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-02-18 16:54:48 +00:00
|
|
|
|
foreach (var inventory in item.Inventories)
|
2011-01-17 14:55:43 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var type = inventory.Product.ProductGroup.ProductGroupID;
|
2011-01-17 14:55:43 +00:00
|
|
|
|
var printer = PrintLocationBI.KotPrinter(type);
|
|
|
|
|
if (!dict.ContainsKey(printer))
|
|
|
|
|
{
|
2011-02-18 16:54:48 +00:00
|
|
|
|
dict.Add(printer, new List<Inventory>());
|
2011-01-17 14:55:43 +00:00
|
|
|
|
}
|
2011-02-18 16:54:48 +00:00
|
|
|
|
dict[printer].Add(inventory);
|
2011-01-17 14:55:43 +00:00
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-04-11 12:55:45 +00:00
|
|
|
|
stopwatch.Stop();
|
2011-06-23 12:47:48 +00:00
|
|
|
|
Trace.TraceWarning("kot and printers built in {0} ms", stopwatch.ElapsedMilliseconds);
|
2011-04-11 12:55:45 +00:00
|
|
|
|
stopwatch.Reset();
|
2011-01-17 14:55:43 +00:00
|
|
|
|
foreach (var item in dict)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
for (var i = 0; i < item.Key.Copies; i++)
|
2011-01-17 14:55:43 +00:00
|
|
|
|
{
|
2011-04-11 12:55:45 +00:00
|
|
|
|
stopwatch.Start();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
PrintRaw(item.Key,
|
|
|
|
|
DesignKot(voucher, voucher.Kots.Where(x => x.KotID == kotID).Single().Code, item.Value, i),
|
|
|
|
|
"KOT");
|
2011-04-11 12:55:45 +00:00
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
Trace.TraceWarning("kot designed and printed in {0} ms", stopwatch.ElapsedMilliseconds);
|
|
|
|
|
stopwatch.Reset();
|
2011-01-17 14:55:43 +00:00
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
|
|
|
|
#region Print Cash Total
|
|
|
|
|
|
|
|
|
|
public static Boolean PrintCash(Dictionary<int, int> amount, string user)
|
|
|
|
|
{
|
|
|
|
|
string printText;
|
|
|
|
|
int total = 0;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
printText = FormatText(user, 42, false, Align.Centre);
|
|
|
|
|
printText += DrawLine;
|
|
|
|
|
printText += "\n\r" +
|
|
|
|
|
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
|
|
|
|
foreach (int key in amount.Keys.OrderByDescending(k => k))
|
|
|
|
|
{
|
|
|
|
|
printText += CashLine(amount, key);
|
|
|
|
|
total += amount[key] * key;
|
|
|
|
|
}
|
|
|
|
|
printText += "\n\r" + DrawEqual;
|
|
|
|
|
printText += string.Format("\n\r Total = {0,10:#,##0}", total);
|
|
|
|
|
printText += DrawLine;
|
|
|
|
|
return PrintRaw(PrintLocationBI.BasePrinter, printText, "Closing/Opening for " + user);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Boolean PrintSale(string user, IList<SalesAnalysis> det, DateTime startDate, DateTime endDate)
|
|
|
|
|
{
|
|
|
|
|
string printText;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
printText = FormatText(user, 42, false, Align.Centre);
|
|
|
|
|
printText += DrawLine;
|
|
|
|
|
printText += "\n\r" +
|
|
|
|
|
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
|
|
|
|
printText += "\n\r" +
|
|
|
|
|
FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42,
|
|
|
|
|
false, Align.Centre);
|
|
|
|
|
printText += DrawLine;
|
|
|
|
|
foreach (SalesAnalysis d in det)
|
|
|
|
|
{
|
|
|
|
|
printText += string.Format("\n\r {0,-22} {1,9:#,##0}", d.GroupType, d.Amount);
|
|
|
|
|
}
|
|
|
|
|
printText += DrawEqual;
|
|
|
|
|
return PrintRaw(PrintLocationBI.BasePrinter, printText, "Sale Detail " + user);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Boolean PrintSale(string user, IList<SalesAnalysisDetail> list, DateTime startDate,
|
|
|
|
|
DateTime endDate)
|
|
|
|
|
{
|
|
|
|
|
var printText = FormatText(user, 42, false, Align.Centre);
|
|
|
|
|
printText += DrawLine;
|
|
|
|
|
printText += "\n\r" +
|
|
|
|
|
FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
|
|
|
|
printText += "\n\r" +
|
|
|
|
|
FormatText(string.Format("{0:dd-MMM-yyyy} to {1:dd-MMM-yyyy}", startDate, endDate), 42,
|
|
|
|
|
false, Align.Centre);
|
|
|
|
|
printText += DrawLine;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
printText += string.Format("\n\r{0,-22} {1,9:#,##0.00} {2,9:#,##0.00}", item.Product, item.Sale,
|
|
|
|
|
item.NC);
|
|
|
|
|
}
|
|
|
|
|
printText += DrawEqual;
|
|
|
|
|
return PrintRaw(PrintLocationBI.BasePrinter, printText, "Sale Detail " + user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string CashLine(IDictionary<int, int> amount, int key)
|
|
|
|
|
{
|
|
|
|
|
return amount.ContainsKey(key) ? string.Format("\n\r{0,5:#,##0} x {1,10:#,##0} = {2,10:#,##0}", key, amount[key], key * amount[key]) : string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|