Fix: Sale Detail Report would not show the proper NC as it did not check of the product was Happy Hour and at times would overwrite the wrong value

Feature: Modifier form now resizes the buttons so that if there are more modifiers than can fit on the screen, the button size will reduce to a degree
Feature: The Final Sanction is also a background worker and reports progress.
This commit is contained in:
tanshu
2016-12-03 12:08:47 +05:30
parent 68388705f1
commit 3d3c21b853
6 changed files with 155 additions and 68 deletions

View File

@ -5,6 +5,7 @@ using System.Globalization;
using System.Linq;
using NHibernate;
using Tanshu.Accounts.Entities;
using System.ComponentModel;
namespace Tanshu.Accounts.Repository
{
@ -386,7 +387,7 @@ where vs.Voucher.VoucherID = :voucherID and (
_session.Insert(new VoucherSettlement() { Voucher = new Voucher() { VoucherID = item.Key }, Amount = -1 * (amount + roundoff), Settled = settlementType });
}
}
public void UpdateBillID(DateTime startDate, DateTime finishDate)
public void UpdateBillID(DateTime startDate, DateTime finishDate, BackgroundWorker bw)
{
var query = @"
select MAX(v.BillID)
@ -404,13 +405,13 @@ where v.Date < :startDate and v.Void = false and v.VoucherType in (:regular, :ta
.Where(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false && (x.VoucherType == VoucherType.Regular || x.VoucherType == VoucherType.TakeAway))
.OrderBy(x => x.Date).Asc
.List();
var count = " of" + list.Count.ToString();
var count = " of " + list.Count.ToString();
var i = 0;
foreach (var voucher in list)
{
i++;
if (i % 20 == 0)
Console.WriteLine("Loop " + i.ToString() + count);
bw.ReportProgress(0, "Loop " + i.ToString() + count);
if (voucher.BillID != newID)
{
var update = _session.CreateSQLQuery("exec UpdateBillID ?,?");
@ -420,26 +421,31 @@ where v.Date < :startDate and v.Void = false and v.VoucherType in (:regular, :ta
}
newID = GetNewID(newID);
}
}
query = @"
select coalesce(v.BillID + 1, 1)
public void UpdateOtherBillID(DateTime startDate, DateTime finishDate, VoucherType vt, BackgroundWorker bw)
{
var query = @"
select MAX(v.BillID)
from Voucher v
where v.Date < :startDate and v.Void = false and v.VoucherType = :nc
order by v.Date desc
";
lastBill = _session
where v.Date < :startDate and v.Void = false and v.VoucherType = :vt";
var lastBill = _session
.CreateQuery(query)
.SetParameter("startDate", startDate)
.SetParameter("nc", VoucherType.NoCharge)
.SetMaxResults(1)
.SetParameter("vt", vt)
.UniqueResult();
newID = (int)lastBill;
list = _session.QueryOver<Voucher>()
.Where(x => x.Date >= startDate && x.Date <= finishDate && x.VoucherType == VoucherType.NoCharge && x.Void == false)
var newID = lastBill == null ? 1 : (int)lastBill + 1;
var list = _session.QueryOver<Voucher>()
.Where(x => x.Date >= startDate && x.Date <= finishDate && x.Void == false && x.VoucherType == vt)
.OrderBy(x => x.Date).Asc
.List();
var count = " of " + list.Count.ToString();
var i = 0;
foreach (var voucher in list)
{
i++;
if (i % 20 == 0)
bw.ReportProgress(0, "Loop " + i.ToString() + count);
if (voucher.BillID != newID)
{
var update = _session.CreateSQLQuery("exec UpdateBillID ?,?");
@ -450,7 +456,6 @@ order by v.Date desc
newID += 1;
}
}
private static int GetNewID(int lastBill)
{
lastBill += 1;
@ -740,11 +745,11 @@ and v.VoucherType = :regular";
continue;
//throw new ArgumentException("Unknown type of vat rate encountered");
if (c == null) // Means no credit card for the day
c = new CreditJson() { _date = inv.Date.ToString("dd-MMM-yyyy"), Amount = 0 };
c = new CreditJson() { _date = inv.Date.ToString("dd-MMM-yyyy"), Amount = s.Amount };
// throw new ArgumentException("Unknown date encountered");
if (Math.Abs(s.Amount) < 10)
if (Math.Abs(s.Amount) < 1)
continue; // Close enough for now
if (s.Amount > 0 && c.Amount < 10)
if (s.Amount > 0 && c.Amount <= 0)
continue; //Move on if we have to reduce and we do not have credit sale margin
if (!s.IsLiq) //Food
{
@ -772,7 +777,8 @@ and v.VoucherType = :regular";
}
else
{
DecreaseLiqour(rand, s, inv, c);
if (inv.Inv.Quantity != 0 && inv.Inv.EffectivePrice != 0)
DecreaseLiqour(rand, s, inv, c);
}
}
}
@ -809,7 +815,7 @@ and v.VoucherType = :regular";
if (s == null) // Temp ignore and move on
continue;
//throw new ArgumentException("Unknown type of vat rate encountered");
if (Math.Abs(s.Amount) < 10)
if (Math.Abs(s.Amount) < 2)
continue; // Close enough for now
if (s.Amount >= 0)
continue; //Move on if we have to reduce and we do not have credit sale margin
@ -999,6 +1005,8 @@ and p.Quantity != 0";
inventories.Add(inventoryID, new object[] { productID, inventoryQuantity, productQuantity });
}
var left = GetBeer(startDate, finishDate) - quantity;
if (left < 0)
Console.Write("Beer was already negative");
foreach (var item in inventories)
{
if (left <= 0)