Feature: Added a Tax Management form and a beer consumption report.
Chore: Fixed some Form_Load function names as they were copied from old forms and were not neat. Feature: Management BI Improved and should be pretty much solid by now.
This commit is contained in:
@ -766,7 +766,7 @@ and v.VoucherType = :regular";
|
||||
//Increase Sales
|
||||
if (inv.Inv.IsHappyHour)
|
||||
IncreaseLiqourUsingHappyHour(s, inv, c);
|
||||
else if (inv.Inv.Discount > .10M)
|
||||
else if (inv.Inv.Discount > 0)
|
||||
IncreaseLiqourUsingDiscount(s, inv, c);
|
||||
|
||||
}
|
||||
@ -778,6 +778,49 @@ and v.VoucherType = :regular";
|
||||
}
|
||||
}
|
||||
|
||||
public void IncreaseLiqIfLess(IList<SaleDetailJson> sale, DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
var rand = new Random();
|
||||
const string query = @"
|
||||
select v.Date, i
|
||||
from Voucher v
|
||||
inner join v.Kots k
|
||||
inner join k.Inventories i
|
||||
where v.Date >= :startDate and v.Date <= :finishDate
|
||||
and v.VoucherType = :regular";
|
||||
var list = _session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate.AddHours(7))
|
||||
.SetParameter("finishDate", finishDate.AddDays(1).AddHours(7))
|
||||
.SetParameter("regular", VoucherType.Regular)
|
||||
.List<object[]>();
|
||||
List<InvDate> inventories = new List<InvDate>();
|
||||
foreach (var item in Randomize(list))
|
||||
{
|
||||
inventories.Add(new InvDate()
|
||||
{
|
||||
Date = ((DateTime)item[0]).AddHours(-7).Date,
|
||||
Inv = (Inventory)item[1]
|
||||
});
|
||||
}
|
||||
foreach (var inv in inventories)
|
||||
{
|
||||
var s = sale.SingleOrDefault(x => x.Rate == inv.Inv.VatRate);
|
||||
if (s == null) // Temp ignore and move on
|
||||
continue;
|
||||
//throw new ArgumentException("Unknown type of vat rate encountered");
|
||||
if (Math.Abs(s.Amount) < 10)
|
||||
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
|
||||
if (s.IsLiq)
|
||||
continue; //Move on if we have to reduce and we do not have credit sale margin
|
||||
//Increase Sales
|
||||
IncreaseLiqourUsingPrice(s, inv);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void IncreaseFood(SaleDetailJson s, InvDate inv, CreditJson c)
|
||||
{
|
||||
//Increase Sales
|
||||
@ -874,6 +917,23 @@ and v.VoucherType = :regular";
|
||||
s.Amount += inv.Inv.Net;
|
||||
c.Amount += inv.Inv.Amount;
|
||||
}
|
||||
private void IncreaseLiqourUsingPrice(SaleDetailJson s, InvDate inv)
|
||||
{
|
||||
//decimal price;
|
||||
//if (s.Amount * -1 > inv.Inv.Quantity * inv.Inv.EffectivePrice)
|
||||
// discount = 0;
|
||||
//else
|
||||
// discount = inv.Inv.Discount + Math.Round(s.Amount / (inv.Inv.Quantity * inv.Inv.EffectivePrice), 2);
|
||||
|
||||
//const string query = @"update Inventory i set Discount = :discount where i.InventoryID = :inventoryID";
|
||||
//_session.CreateQuery(query)
|
||||
// .SetParameter("discount", discount)
|
||||
// .SetParameter("inventoryID", inv.Inv.InventoryID)
|
||||
// .ExecuteUpdate();
|
||||
//inv.Inv.Discount = 1 - (inv.Inv.Discount - discount);
|
||||
//s.Amount += inv.Inv.Net;
|
||||
//c.Amount += inv.Inv.Amount;
|
||||
}
|
||||
private void DecreaseLiqour(Random r, SaleDetailJson s, InvDate inv, CreditJson c)
|
||||
{
|
||||
var min = Math.Max(Convert.ToInt32(inv.Inv.Discount * 100) + 1, 10);
|
||||
|
||||
@ -12,6 +12,44 @@ namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
public class ReportsBI
|
||||
{
|
||||
public IList<BeerConsumptionDetail> BeerConsumption(DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
startDate = startDate.Date.AddHours(6);
|
||||
finishDate = finishDate.Date.AddDays(1).AddHours(5);
|
||||
if (finishDate <= startDate)
|
||||
return new List<BeerConsumptionDetail>();
|
||||
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
const string query = @"
|
||||
select v.Date, p.ProductID, p.Name, Sum(i.Quantity * p.Quantity)
|
||||
from Voucher v
|
||||
inner join v.Kots k
|
||||
inner join k.Inventories i
|
||||
inner join i.Product p
|
||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
|
||||
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
|
||||
and vs.Settled in (:cash, :creditCard, :billToCompany, :staff, :noCharge))
|
||||
group by v.Date, p.ProductID, p.Name
|
||||
order by v.Date, p.ProductID, p.Name
|
||||
";
|
||||
var list = session
|
||||
.CreateQuery(query)
|
||||
.SetParameter("startDate", startDate)
|
||||
.SetParameter("finishDate", finishDate)
|
||||
.SetParameter("cash", SettleOption.Cash)
|
||||
.SetParameter("creditCard", SettleOption.CreditCard)
|
||||
.SetParameter("billToCompany", SettleOption.BillToCompany)
|
||||
.SetParameter("staff", SettleOption.Staff)
|
||||
.SetParameter("noCharge", SettleOption.NoCharge)
|
||||
.List<object[]>();
|
||||
var outList = new List<BeerConsumptionDetail>();
|
||||
foreach (var item in list)
|
||||
if ((decimal)item[3] != 0)
|
||||
outList.Add(new BeerConsumptionDetail() { Date = (DateTime)item[0], ProductID = (Guid)item[1], Name = (string)item[2], Quantity = (decimal)item[3] });
|
||||
return outList;
|
||||
}
|
||||
}
|
||||
public IList<SalesAnalysisDetail> SaleQuantity(DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
startDate = startDate.Date.AddHours(6);
|
||||
|
||||
Reference in New Issue
Block a user