Removed Code and BaseCode from Products
Management form almost fixed. Error testing now.
This commit is contained in:
@ -4,13 +4,17 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Windows.Forms;
|
||||
using Tanshu.Accounts.Repository;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Tanshu.Accounts.Management
|
||||
{
|
||||
public partial class ManagementForm : Form
|
||||
{
|
||||
Stopwatch _stopwatch;
|
||||
Stopwatch _totalStopwatch;
|
||||
public ManagementForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -22,12 +26,21 @@ namespace Tanshu.Accounts.Management
|
||||
dtpFinish.Value = DateTime.Today;
|
||||
}
|
||||
|
||||
#region Go
|
||||
private void btnGo_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtStatus.Text = "";
|
||||
btnGo.Enabled = false;
|
||||
_stopwatch = Stopwatch.StartNew();
|
||||
_totalStopwatch = Stopwatch.StartNew();
|
||||
bwGo.RunWorkerAsync();
|
||||
}
|
||||
private void DoGo(BackgroundWorker worker)
|
||||
{
|
||||
var currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var beer = Path.Combine(currentDirectory, "beer.csv");
|
||||
var sale = Path.Combine(currentDirectory, "sale.csv");
|
||||
var credit = Path.Combine(currentDirectory, "credit.csv");
|
||||
var beer = Path.Combine(currentDirectory, "beer.json");
|
||||
var sale = Path.Combine(currentDirectory, "sale.json");
|
||||
var credit = Path.Combine(currentDirectory, "credit.json");
|
||||
var error = string.Empty;
|
||||
if (!File.Exists(beer))
|
||||
error += "Beer not found! ";
|
||||
@ -49,246 +62,138 @@ namespace Tanshu.Accounts.Management
|
||||
var info = string.Empty;
|
||||
foreach (var item in saleDates)
|
||||
{
|
||||
var startDate = item.StartDate;
|
||||
var finishDate = item.FinishDate;
|
||||
Debug.WriteLine("Starting on " + startDate.ToShortDateString() + " to " + finishDate.ToShortDateString());
|
||||
ProcessData(true, startDate, finishDate, item.Sale15 + item.Sale25);
|
||||
Debug.WriteLine("Starting beer");
|
||||
ProcessBeer(beerDates, startDate, finishDate);
|
||||
Debug.WriteLine("Starting sale");
|
||||
info += ProcessSale(item, creditDates);
|
||||
Debug.WriteLine("Starting cleanup");
|
||||
ProcessData(false, startDate, finishDate, item.Sale15 + item.Sale25);
|
||||
Debug.WriteLine("Cleanup done");
|
||||
}
|
||||
MessageBox.Show(info);
|
||||
btnGo.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region Get Data
|
||||
protected class SaleData
|
||||
{
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime FinishDate { get; set; }
|
||||
public decimal Sale125 { get; set; }
|
||||
public decimal Sale25 { get; set; }
|
||||
public decimal Sale15 { get; set; }
|
||||
public decimal Sale0 { get; set; }
|
||||
}
|
||||
private IEnumerable<SaleData> GetSale(string sale)
|
||||
{
|
||||
IFormatProvider culture = new CultureInfo("en-US", true);
|
||||
var startDate = dtpStart.Value.Date;
|
||||
var finishDate = dtpFinish.Value.Date;
|
||||
|
||||
var dates = new List<SaleData>();
|
||||
using (var reader = new StreamReader(File.OpenRead(sale)))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
var values = line.Split(',');
|
||||
if (values.Length != 6)
|
||||
var startDate = item.SDate.Value;
|
||||
var finishDate = item.FDate.Value;
|
||||
var sDate = startDate.AddHours(7);
|
||||
var fDate = finishDate.AddDays(1).AddHours(7);
|
||||
Console.WriteLine("Starting on " + startDate.ToShortDateString() + " to " + finishDate.ToShortDateString());
|
||||
int count = 0;
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
MessageBox.Show("Error reading line: " + line);
|
||||
continue;
|
||||
worker.ReportProgress(++count, "Deleting Voids");
|
||||
bi.DeleteVoid(sDate, fDate);
|
||||
worker.ReportProgress(++count, "Deleting Staff");
|
||||
bi.MoveStaffToNc(sDate, fDate);
|
||||
worker.ReportProgress(++count, "Clearing Modifiers");
|
||||
bi.ClearModifiers(sDate, fDate);
|
||||
worker.ReportProgress(++count, "Combining Kots");
|
||||
bi.CombineKots(sDate, fDate);
|
||||
worker.ReportProgress(++count, "Removing Blank Kots");
|
||||
bi.RemoveBlankKots(sDate, fDate);
|
||||
worker.ReportProgress(++count, "Starting beer");
|
||||
foreach (var beerDate in beerDates)
|
||||
{
|
||||
if (beerDate.bDate < startDate || beerDate.bDate > finishDate)
|
||||
continue;
|
||||
var stDt = beerDate.bDate.Value.AddHours(7);
|
||||
var fiDt = stDt.AddDays(1);
|
||||
worker.ReportProgress(++count, "Setting beer for " + stDt.ToShortDateString());
|
||||
bi.SetBeer(stDt, fiDt, beerDate.Quantity);
|
||||
}
|
||||
bi.MoveToNc(sDate, fDate, item.Sale.Where(x => x.IsLiq).Sum(x => x.Amount) / .75M); // Do not put all in NC this will allow for about 25% discount on the rest of non nc liqour
|
||||
worker.ReportProgress(++count, "Starting sale");
|
||||
foreach (var saleItem in item.Sale)
|
||||
{
|
||||
worker.ReportProgress(++count, "Setting sale for " + saleItem.Rate.ToString());
|
||||
if (saleItem.IsLiq)
|
||||
bi.SetSaleDiscount(saleItem.Rate, saleItem.Amount, sDate, fDate);
|
||||
else
|
||||
bi.SetSaleQuantity(saleItem.Rate, saleItem.Amount, sDate, fDate);
|
||||
}
|
||||
worker.ReportProgress(++count, "Removing Blank Kots");
|
||||
bi.RemoveBlankKots(sDate, fDate);
|
||||
worker.ReportProgress(++count, "Starting cleanup");
|
||||
bi.SetPayments(sDate, fDate);
|
||||
bi.SaveChanges();
|
||||
}
|
||||
DateTime dateStart;
|
||||
DateTime dateFinish;
|
||||
if (!DateTime.TryParseExact(values[0], "dd-MM-yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out dateStart))
|
||||
continue;
|
||||
if (!DateTime.TryParseExact(values[1], "dd-MM-yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out dateFinish))
|
||||
continue;
|
||||
if (dateFinish.Date < startDate.Date || dateStart.Date > finishDate.Date)
|
||||
continue;
|
||||
dates.Add(new SaleData
|
||||
{
|
||||
StartDate = dateStart,
|
||||
FinishDate = dateFinish,
|
||||
Sale125 = TryConvert(values[2]),
|
||||
Sale25 = TryConvert(values[3]),
|
||||
Sale15 = TryConvert(values[4]),
|
||||
Sale0 = TryConvert(values[5])
|
||||
});
|
||||
worker.ReportProgress(++count, "Cleanup done");
|
||||
}
|
||||
}
|
||||
return dates;
|
||||
}
|
||||
private Dictionary<DateTime, decimal> GetCredit(string credit)
|
||||
private void bwGo_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
|
||||
{
|
||||
IFormatProvider culture = new CultureInfo("en-US", true);
|
||||
var startDate = dtpStart.Value.Date.AddHours(7);
|
||||
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
||||
|
||||
var dates = new Dictionary<DateTime, decimal>();
|
||||
using (var reader = new StreamReader(File.OpenRead(credit)))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
var values = line.Split(',');
|
||||
if (values.Length != 2)
|
||||
{
|
||||
MessageBox.Show("Error reading line: " + line);
|
||||
continue;
|
||||
}
|
||||
DateTime dateOut;
|
||||
if (!DateTime.TryParseExact(values[0], "dd/MM/yyyy", culture, DateTimeStyles.NoCurrentDateDefault, out dateOut))
|
||||
continue;
|
||||
if (dateOut.Date < startDate.Date || dateOut.Date >= finishDate.Date)
|
||||
continue;
|
||||
var amount = TryConvert(values[1]);
|
||||
if (!dates.ContainsKey(dateOut))
|
||||
dates.Add(dateOut, amount);
|
||||
}
|
||||
}
|
||||
return dates;
|
||||
DoGo(sender as BackgroundWorker);
|
||||
}
|
||||
private Dictionary<DateTime, decimal> GetBeer(string beer)
|
||||
private void bwGo_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
|
||||
{
|
||||
IFormatProvider culture = new CultureInfo("en-US", true);
|
||||
var startDate = dtpStart.Value.Date.AddHours(7);
|
||||
var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(7);
|
||||
|
||||
var dates = new Dictionary<DateTime, decimal>();
|
||||
using (var reader = new StreamReader(File.OpenRead(beer)))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
var values = line.Split(',');
|
||||
DateTime dateOut;
|
||||
if (!DateTime.TryParseExact(values[0], "dd-MMM-yy", culture, DateTimeStyles.NoCurrentDateDefault, out dateOut))
|
||||
continue;
|
||||
if (dateOut.Date < startDate.Date || dateOut.Date >= finishDate.Date)
|
||||
continue;
|
||||
decimal amount = 0;
|
||||
if (values.Length > 1) // Dark - Location 1, Basecode 1
|
||||
amount += TryConvert(values[1]);
|
||||
if (values.Length > 2) // Wheat - Location 2, Basecode 2
|
||||
amount += TryConvert(values[2]);
|
||||
if (values.Length > 3) // Light - Location 3, Basecode 4
|
||||
amount += TryConvert(values[3]);
|
||||
if (values.Length > 4) // Premium - Location 4, Basecode 3
|
||||
amount += TryConvert(values[4]);
|
||||
dates.Add(dateOut, amount);
|
||||
}
|
||||
}
|
||||
return dates;
|
||||
var time = (_stopwatch.ElapsedMilliseconds / 1000).ToString() + "s / " + (_totalStopwatch.ElapsedMilliseconds / 1000).ToString() + "s";
|
||||
_stopwatch.Reset();
|
||||
_stopwatch.Start();
|
||||
txtStatus.Text = (string)e.UserState + " " + time + " \r\n" + txtStatus.Text;
|
||||
}
|
||||
private void bwGo_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
txtStatus.Text += "Done !!!";
|
||||
_stopwatch.Stop();
|
||||
_totalStopwatch.Stop();
|
||||
btnGo.Enabled = true;
|
||||
}
|
||||
#endregion
|
||||
private static void ProcessData(bool opening, DateTime startIn, DateTime finishIn, decimal liqTarget)
|
||||
|
||||
#region Get Data
|
||||
private IList<SaleJson> GetSale(string sale)
|
||||
{
|
||||
var startDate = startIn.AddHours(7);
|
||||
var finishDate = finishIn.AddDays(1).AddHours(7);
|
||||
if (opening)
|
||||
var startDate = dtpStart.Value.Date;
|
||||
var finishDate = dtpFinish.Value.Date;
|
||||
var fileContents = new StreamReader(File.OpenRead(sale)).ReadToEnd();
|
||||
JavaScriptSerializer jss = new JavaScriptSerializer();
|
||||
var data = jss.Deserialize<IList<SaleJson>>(fileContents);
|
||||
IList<SaleJson> list = new List<SaleJson>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.DeleteVoid(startDate, finishDate);
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.DeleteStaff(startDate, finishDate);
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.ClearModifiers(startDate, finishDate);
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.CombineKots(startDate, finishDate);
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.RemoveBlankKots(startDate, finishDate);
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.MoveNc(startDate, finishDate, liqTarget);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.SetPayments(startDate, finishDate);
|
||||
}
|
||||
if (!item.SDate.HasValue || !item.FDate.HasValue)
|
||||
continue;
|
||||
if (item.FDate.Value.Date < startDate.Date || item.SDate.Value.Date > finishDate.Date)
|
||||
continue;
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void ProcessBeer(Dictionary<DateTime, decimal> dates, DateTime startIn, DateTime finishIn)
|
||||
private IList<CreditJson> GetCredit(string credit)
|
||||
{
|
||||
using (var bi = new ManagementBI())
|
||||
var startDate = dtpStart.Value.Date;
|
||||
var finishDate = dtpFinish.Value.Date;
|
||||
var fileContents = new StreamReader(File.OpenRead(credit)).ReadToEnd();
|
||||
JavaScriptSerializer jss = new JavaScriptSerializer();
|
||||
var data = jss.Deserialize<IList<CreditJson>>(fileContents);
|
||||
IList<CreditJson> list = new List<CreditJson>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
var info = string.Empty;
|
||||
foreach (var item in dates)
|
||||
{
|
||||
if (item.Key < startIn || item.Key > finishIn)
|
||||
continue;
|
||||
var stDt = item.Key.AddHours(7);
|
||||
var fiDt = stDt.AddDays(1);
|
||||
var original = bi.GetQuantity(stDt, fiDt);
|
||||
if (original < item.Value)
|
||||
{
|
||||
info += "Original for " + item.Key.ToString() + " is " + original.ToString() + " desired is " + item.Value.ToString() + "\r\n";
|
||||
}
|
||||
else if (original == item.Value)
|
||||
{
|
||||
info += item.Key.ToString() + " is " + original.ToString() + " matches!" + "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
bi.SetQuantity(stDt, fiDt, item.Value);
|
||||
}
|
||||
}
|
||||
if (!item.CDate.HasValue)
|
||||
continue;
|
||||
if (item.CDate.Value.Date < startDate.Date || item.CDate.Value.Date > finishDate.Date)
|
||||
continue;
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static string ProcessSale(SaleData item, Dictionary<DateTime, decimal> creditDates)
|
||||
private IList<BeerJson> GetBeer(string beer)
|
||||
{
|
||||
var info = string.Empty;
|
||||
var startDate = item.StartDate.AddHours(7);
|
||||
var finishDate = item.FinishDate.AddHours(7).AddDays(1);
|
||||
var creditInfo = creditDates.Where(x => x.Key >= item.StartDate && x.Key <= item.FinishDate).ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
info += "From " + startDate.ToShortDateString() + " to " + finishDate.ToShortDateString() + "\r\n";
|
||||
|
||||
using (var bi = new ManagementBI())
|
||||
var startDate = dtpStart.Value.Date;
|
||||
var finishDate = dtpFinish.Value.Date;
|
||||
var fileContents = new StreamReader(File.OpenRead(beer)).ReadToEnd();
|
||||
JavaScriptSerializer jss = new JavaScriptSerializer();
|
||||
var data = jss.Deserialize<IList<BeerJson>>(fileContents);
|
||||
IList<BeerJson> list = new List<BeerJson>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
info += "25%\t" + bi.GetFood(.26250M, startDate, finishDate) + "\t";
|
||||
var ret = bi.SetLiq(.26250M, item.Sale25, startDate, finishDate);
|
||||
info += ret + "\t" + item.Sale25.ToString() + "\r\n";
|
||||
if (!item.bDate.HasValue)
|
||||
continue;
|
||||
if (item.bDate.Value.Date < startDate.Date || item.bDate.Value.Date > finishDate.Date)
|
||||
continue;
|
||||
list.Add(item);
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
info += "15%\t" + bi.GetFood(.1575M, startDate, finishDate) + "\t";
|
||||
var ret = bi.SetLiq(.1575M, item.Sale15, startDate, finishDate);
|
||||
info += ret + "\t" + item.Sale15.ToString() + "\r\n";
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
info += "12.5%\t" + bi.GetFood(.13125M, startDate, finishDate) + "\t";
|
||||
var ret = bi.SetFood(.13125M, item.Sale125, startDate, finishDate);
|
||||
info += ret + "\t" + item.Sale125.ToString() + "\r\n";
|
||||
}
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
info += "0%\t" + bi.GetFood(0M, startDate, finishDate) + "\t";
|
||||
var ret = bi.SetFood(0M, item.Sale0, startDate, finishDate);
|
||||
info += ret + "\t" + item.Sale0.ToString() + "\r\n";
|
||||
}
|
||||
return info;
|
||||
return list;
|
||||
}
|
||||
|
||||
private static decimal TryConvert(string amount)
|
||||
{
|
||||
decimal result = 0;
|
||||
decimal.TryParse(amount, out result);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Tally
|
||||
private void btnTally_Click(object sender, EventArgs e)
|
||||
{
|
||||
var startDate = dtpStart.Value.Date;
|
||||
@ -331,49 +236,27 @@ namespace Tanshu.Accounts.Management
|
||||
var cash = 0M;
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
var sale = Math.Round(bi.GetFood(.26250M, currentStart, currentFinish));
|
||||
var vat = 0M;
|
||||
if (sale != 0)
|
||||
var saleAndVat = bi.GetSaleAndVat(currentStart, currentFinish);
|
||||
foreach (var item in saleAndVat)
|
||||
{
|
||||
cash += sale;
|
||||
voucher += GetLedger("Sale @ 25 %", sale.ToString("#0.00"));
|
||||
vat = Math.Round(bi.GetVat(.26250M, currentStart, currentFinish));
|
||||
cash += vat;
|
||||
voucher += GetLedger("Output Vat @ 25%", vat.ToString("#0.00"));
|
||||
if (item.Net == 0)
|
||||
throw new ArgumentException();
|
||||
cash += Math.Round(item.Net);
|
||||
var rate = item.Rate * 100 / 1.05M;
|
||||
voucher += GetLedger(string.Format("Sale @ {0:#} %", rate), item.Net.ToString("#0.00"));
|
||||
var vat = Math.Round(item.Vat);
|
||||
if (vat != 0)
|
||||
{
|
||||
cash += vat;
|
||||
voucher += GetLedger(string.Format("Output Vat @ {0:#}%", rate), vat.ToString("#0.00"));
|
||||
}
|
||||
}
|
||||
|
||||
sale = Math.Round(bi.GetFood(.1575M, currentStart, currentFinish));
|
||||
if (sale != 0)
|
||||
var st = Math.Round(bi.GetServiceTax(currentStart, currentFinish));
|
||||
if (st != 0)
|
||||
{
|
||||
cash += sale;
|
||||
voucher += GetLedger("Sale @ 15%", sale.ToString("#0.00"));
|
||||
vat = Math.Round(bi.GetVat(.1575M, currentStart, currentFinish));
|
||||
cash += vat;
|
||||
voucher += GetLedger("Output Vat @ 15%", vat.ToString("#0.00"));
|
||||
}
|
||||
|
||||
sale = Math.Round(bi.GetFood(.13125M, currentStart, currentFinish));
|
||||
if (sale != 0)
|
||||
{
|
||||
cash += sale;
|
||||
voucher += GetLedger("Sale 12.5%", sale.ToString("#0.00"));
|
||||
vat = Math.Round(bi.GetVat(.13125M, currentStart, currentFinish));
|
||||
cash += vat;
|
||||
voucher += GetLedger("Output Vat 12.5%", vat.ToString("#0.00"));
|
||||
}
|
||||
|
||||
sale = Math.Round(bi.GetFood(0M, currentStart, currentFinish));
|
||||
if (sale != 0)
|
||||
{
|
||||
cash += sale;
|
||||
voucher += GetLedger("Sale Tax Free", sale.ToString("#0.00"));
|
||||
}
|
||||
|
||||
vat = Math.Round(bi.GetServiceTax(currentStart, currentFinish));
|
||||
if (vat != 0)
|
||||
{
|
||||
cash += vat;
|
||||
voucher += GetLedger("Central Service Tax@3.708%", vat.ToString("#0.00"));
|
||||
cash += st;
|
||||
voucher += GetLedger("Central Service Tax", st.ToString("#0.00"));
|
||||
}
|
||||
|
||||
if (cash != 0)
|
||||
@ -488,51 +371,87 @@ namespace Tanshu.Accounts.Management
|
||||
#endregion
|
||||
return string.Format(template, ledgername, isDeemedPositive, isPartyLedger, amount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void btnFinalSanction_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
bi.FinalSanction(dtpStart.Value.Date.AddHours(7), dtpFinish.Value.Date.AddDays(1).AddHours(7));
|
||||
bi.UpdateBillID(dtpStart.Value.Date.AddHours(7), dtpFinish.Value.Date.AddDays(1).AddHours(7));
|
||||
bi.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel
|
||||
private void btnExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
btnExcel.Enabled = false;
|
||||
var startDate = dtpStart.Value.Date;
|
||||
var finishDate = dtpFinish.Value.Date;
|
||||
var sheet = "Date\t Bill Start\t Bill Final\t Sale 0%\t Sale 12.5%\t Sale 15%\t Sale 25%\t Vat 12.5%\t Vat 15%\t Vat 25%\t Service Tax\n";
|
||||
|
||||
for (var date = startDate; date <= finishDate; date = date.AddDays(1))
|
||||
{
|
||||
sheet += GetExcel(date);
|
||||
}
|
||||
var sheet = GetExcel(startDate, finishDate);
|
||||
Clipboard.SetText(sheet, TextDataFormat.Text);
|
||||
btnExcel.Enabled = true;
|
||||
}
|
||||
private static string GetExcel(DateTime date)
|
||||
private static string GetExcel(DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
var info = new List<ExcelInfo>();
|
||||
var rates = new List<decimal>();
|
||||
using (var bi = new ManagementBI())
|
||||
{
|
||||
var currentStart = date.AddHours(7);
|
||||
var currentFinish = date.AddDays(1).AddHours(7);
|
||||
var cash = bi.GetFirstBill(date);
|
||||
if (cash == "")
|
||||
return "";
|
||||
cash = string.Format("{0:dd-MMM-yyyy}\t'{1}\t'{2}\t", date, cash, bi.GetLastBill(date));
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(0M, currentStart, currentFinish)));
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(.13125M, currentStart, currentFinish)));
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(.1575M, currentStart, currentFinish)));
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetFood(.2625M, currentStart, currentFinish)));
|
||||
for (var date = startDate; date <= finishDate; date = date.AddDays(1))
|
||||
{
|
||||
var currentStart = date.AddHours(7);
|
||||
var currentFinish = date.AddDays(1).AddHours(7);
|
||||
var bills = bi.GetMinMaxBills(currentStart, currentFinish);
|
||||
if (bills == null)
|
||||
continue;
|
||||
var saleList = bi.GetSaleAndVat(currentStart, currentFinish);
|
||||
var serviceTax = bi.GetServiceTax(currentStart, currentFinish);
|
||||
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetVat(.13125M, currentStart, currentFinish)));
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetVat(.1575M, currentStart, currentFinish)));
|
||||
cash += string.Format("{0:#0}\t", Math.Round(bi.GetVat(.2625M, currentStart, currentFinish)));
|
||||
var ei = new ExcelInfo()
|
||||
{
|
||||
Date = date,
|
||||
StartBill = bi.FullBillID(bills.StartBill, Tanshu.Accounts.Entities.VoucherType.Regular),
|
||||
FinishBill = bi.FullBillID(bills.FinishBill, Tanshu.Accounts.Entities.VoucherType.Regular),
|
||||
SaleAndVat = new Dictionary<decimal, SaleInfo>(),
|
||||
ServiceTax = serviceTax
|
||||
};
|
||||
foreach (var item in saleList)
|
||||
{
|
||||
if (!rates.Contains(item.Rate))
|
||||
rates.Add(item.Rate);
|
||||
ei.SaleAndVat.Add(item.Rate, item);
|
||||
}
|
||||
info.Add(ei);
|
||||
}
|
||||
|
||||
cash += string.Format("{0:#0}\n", Math.Round(bi.GetServiceTax(currentStart, currentFinish)));
|
||||
return cash;
|
||||
rates.Sort();
|
||||
|
||||
var sheet = "Date\tBill Start\tBill Final\t";
|
||||
|
||||
foreach (var item in rates)
|
||||
{
|
||||
sheet += string.Format("Sale {0:#0.00}%\tVat {0:#0.00}%\t", item * 100);
|
||||
}
|
||||
sheet += "Service Tax\n";
|
||||
|
||||
foreach (var item in info)
|
||||
{
|
||||
sheet += string.Format("{0:dd-MMM-yyyy}\t'{1}\t'{2}\t", item.Date, item.StartBill, item.FinishBill);
|
||||
foreach (var rate in rates)
|
||||
{
|
||||
if (item.SaleAndVat.ContainsKey(rate))
|
||||
sheet += string.Format("{0:#0}\t{1:#0}\t", Math.Round(item.SaleAndVat[rate].Net), Math.Round(item.SaleAndVat[rate].Vat));
|
||||
else
|
||||
sheet += "0\t0\t";
|
||||
}
|
||||
sheet += string.Format("{0:#0}\n", Math.Round(item.ServiceTax));
|
||||
|
||||
}
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@
|
||||
this.btnTally = new System.Windows.Forms.Button();
|
||||
this.btnFinalSanction = new System.Windows.Forms.Button();
|
||||
this.btnExcel = new System.Windows.Forms.Button();
|
||||
this.bwGo = new System.ComponentModel.BackgroundWorker();
|
||||
this.txtStatus = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dtpFinish
|
||||
@ -66,10 +68,9 @@
|
||||
//
|
||||
// btnGo
|
||||
//
|
||||
this.btnGo.Enabled = false;
|
||||
this.btnGo.Location = new System.Drawing.Point(12, 207);
|
||||
this.btnGo.Name = "btnGo";
|
||||
this.btnGo.Size = new System.Drawing.Size(150, 23);
|
||||
this.btnGo.Size = new System.Drawing.Size(113, 23);
|
||||
this.btnGo.TabIndex = 24;
|
||||
this.btnGo.Text = "Go";
|
||||
this.btnGo.UseVisualStyleBackColor = true;
|
||||
@ -77,9 +78,9 @@
|
||||
//
|
||||
// btnTally
|
||||
//
|
||||
this.btnTally.Location = new System.Drawing.Point(168, 207);
|
||||
this.btnTally.Location = new System.Drawing.Point(145, 207);
|
||||
this.btnTally.Name = "btnTally";
|
||||
this.btnTally.Size = new System.Drawing.Size(150, 23);
|
||||
this.btnTally.Size = new System.Drawing.Size(113, 23);
|
||||
this.btnTally.TabIndex = 25;
|
||||
this.btnTally.Text = "Tally";
|
||||
this.btnTally.UseVisualStyleBackColor = true;
|
||||
@ -89,7 +90,7 @@
|
||||
//
|
||||
this.btnFinalSanction.Location = new System.Drawing.Point(12, 178);
|
||||
this.btnFinalSanction.Name = "btnFinalSanction";
|
||||
this.btnFinalSanction.Size = new System.Drawing.Size(150, 23);
|
||||
this.btnFinalSanction.Size = new System.Drawing.Size(113, 23);
|
||||
this.btnFinalSanction.TabIndex = 26;
|
||||
this.btnFinalSanction.Text = "Final Sanction";
|
||||
this.btnFinalSanction.UseVisualStyleBackColor = true;
|
||||
@ -97,19 +98,38 @@
|
||||
//
|
||||
// btnExcel
|
||||
//
|
||||
this.btnExcel.Location = new System.Drawing.Point(168, 178);
|
||||
this.btnExcel.Location = new System.Drawing.Point(145, 178);
|
||||
this.btnExcel.Name = "btnExcel";
|
||||
this.btnExcel.Size = new System.Drawing.Size(150, 23);
|
||||
this.btnExcel.Size = new System.Drawing.Size(113, 23);
|
||||
this.btnExcel.TabIndex = 27;
|
||||
this.btnExcel.Text = "Excel";
|
||||
this.btnExcel.UseVisualStyleBackColor = true;
|
||||
this.btnExcel.Click += new System.EventHandler(this.btnExcel_Click);
|
||||
//
|
||||
// bwGo
|
||||
//
|
||||
this.bwGo.WorkerReportsProgress = true;
|
||||
this.bwGo.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bwGo_DoWork);
|
||||
this.bwGo.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bwGo_RunWorkerCompleted);
|
||||
this.bwGo.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bwGo_ProgressChanged);
|
||||
//
|
||||
// txtStatus
|
||||
//
|
||||
this.txtStatus.AcceptsReturn = true;
|
||||
this.txtStatus.Location = new System.Drawing.Point(12, 38);
|
||||
this.txtStatus.Multiline = true;
|
||||
this.txtStatus.Name = "txtStatus";
|
||||
this.txtStatus.ReadOnly = true;
|
||||
this.txtStatus.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtStatus.Size = new System.Drawing.Size(246, 134);
|
||||
this.txtStatus.TabIndex = 28;
|
||||
//
|
||||
// ManagementForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(359, 242);
|
||||
this.ClientSize = new System.Drawing.Size(270, 242);
|
||||
this.Controls.Add(this.txtStatus);
|
||||
this.Controls.Add(this.btnExcel);
|
||||
this.Controls.Add(this.btnFinalSanction);
|
||||
this.Controls.Add(this.btnTally);
|
||||
@ -136,5 +156,7 @@
|
||||
private System.Windows.Forms.Button btnTally;
|
||||
private System.Windows.Forms.Button btnFinalSanction;
|
||||
private System.Windows.Forms.Button btnExcel;
|
||||
private System.ComponentModel.BackgroundWorker bwGo;
|
||||
private System.Windows.Forms.TextBox txtStatus;
|
||||
}
|
||||
}
|
||||
@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="bwGo.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user