Reprint and Printed bill editing logged.
Printed bill can no longer be changed, any changes voids the bill and prints a new one. Added option to Split Bill. Kot printed with right time. Numerous bug fixes.
This commit is contained in:
23
Tanshu.Accounts.Repository/BusinessLayer/ReprintBI.cs
Normal file
23
Tanshu.Accounts.Repository/BusinessLayer/ReprintBI.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using NHibernate;
|
||||
using Tanshu.Accounts.Entities;
|
||||
|
||||
|
||||
namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
public class ReprintBI : FluentGenericBase<Reprint>
|
||||
{
|
||||
public ReprintBI()
|
||||
: base()
|
||||
{ }
|
||||
public ReprintBI(bool beginTransaction)
|
||||
: base(beginTransaction)
|
||||
{ }
|
||||
public ReprintBI(ISession session)
|
||||
: base(session)
|
||||
{ }
|
||||
public ReprintBI(ISession session, bool beginTransaction)
|
||||
: base(session, beginTransaction)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ order by g.GroupType
|
||||
using (var session = SessionManager.Session)
|
||||
{
|
||||
const string query = @"
|
||||
select v.Date, v.BillID, s.Settled, s.Amount
|
||||
select v.Date, v.BillID, s.Settled, s.Amount, v.Void, v.VoidReason
|
||||
from Voucher v
|
||||
inner join v.Settlements s
|
||||
where v.Date >= :startDate and v.Date <= :finishDate
|
||||
@ -134,11 +134,14 @@ order by v.BillID, s.Settled
|
||||
var outList = new List<BillDetail>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var settlement = ((SettleOption)item[2]).Display();
|
||||
if ((bool)item[4])
|
||||
settlement = string.Format("Void: {0}", (string)item[5]);
|
||||
outList.Add(new BillDetail()
|
||||
{
|
||||
Date = (DateTime)item[0],
|
||||
BillID = (string)item[1],
|
||||
Settlement = ((SettleOption)item[2]).Display(),
|
||||
Settlement = settlement,
|
||||
Amount = (decimal)item[3]
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NHibernate.Criterion;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using Tanshu.Common.Helpers;
|
||||
using NHibernate;
|
||||
using System.Linq;
|
||||
|
||||
@ -27,11 +28,11 @@ namespace Tanshu.Accounts.Repository
|
||||
public int? Insert(Voucher voucher)
|
||||
{
|
||||
var dt = DbValues.Date;
|
||||
voucher.CreationDate = dt;
|
||||
voucher.LastEditDate = dt;
|
||||
voucher.Date = dt;
|
||||
voucher.KotID = DbValues.KotID;
|
||||
voucher.BillID = voucher.Printed ? DbValues.BillID : voucher.KotID;
|
||||
voucher.SetValue(VoucherFields.CreationDate, dt);
|
||||
voucher.SetValue(VoucherFields.LastEditDate, dt);
|
||||
voucher.SetValue(VoucherFields.Date, dt);
|
||||
voucher.SetValue(VoucherFields.KotID, DbValues.KotID);
|
||||
voucher.SetValue(VoucherFields.BillID, voucher.Printed ? DbValues.BillID : voucher.KotID);
|
||||
Kot addedKot = null;
|
||||
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
|
||||
{
|
||||
@ -47,7 +48,6 @@ namespace Tanshu.Accounts.Repository
|
||||
Session.Save(voucher);
|
||||
return addedKot == null ? (int?)null : addedKot.KotID;
|
||||
}
|
||||
|
||||
public void Delete(int voucherID)
|
||||
{
|
||||
var voucher = Session.Get<Voucher>(voucherID);
|
||||
@ -55,18 +55,16 @@ namespace Tanshu.Accounts.Repository
|
||||
using (var ft = new FoodTableBI(Session, false))
|
||||
ft.UpdateStatus(voucher.TableID, voucherID, null);
|
||||
}
|
||||
|
||||
public int? Update(Voucher voucher)
|
||||
{
|
||||
var dt = DbValues.Date;
|
||||
voucher.LastEditDate = dt;
|
||||
voucher.SetValue(VoucherFields.LastEditDate, dt);
|
||||
if (voucher.Date == null)
|
||||
{
|
||||
voucher.Date = dt;
|
||||
voucher.BillID = DbValues.BillID;
|
||||
voucher.SetValue(VoucherFields.Date, dt);
|
||||
voucher.SetValue(VoucherFields.BillID, DbValues.BillID );
|
||||
}
|
||||
if (!voucher.Printed)
|
||||
voucher.Date = dt;
|
||||
|
||||
Kot addedKot = null;
|
||||
foreach (var item in voucher.Kots.Where(item => item.KotID == 0))
|
||||
{
|
||||
@ -80,10 +78,7 @@ namespace Tanshu.Accounts.Repository
|
||||
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
||||
VoucherSettlementBI.UpdateSettlements(voucher.Settlements, amount);
|
||||
Session.Update(voucher);
|
||||
if (addedKot == null)
|
||||
return null;
|
||||
else
|
||||
return addedKot.KotID;
|
||||
return addedKot == null ? (int?) null : addedKot.KotID;
|
||||
}
|
||||
|
||||
public Voucher Get(int voucherID)
|
||||
@ -109,7 +104,6 @@ namespace Tanshu.Accounts.Repository
|
||||
NHibernateUtil.Initialize(item);
|
||||
return voucher;
|
||||
}
|
||||
|
||||
public Voucher Get(string billID)
|
||||
{
|
||||
var voucher = Session.CreateCriteria<Voucher>()
|
||||
@ -141,5 +135,6 @@ namespace Tanshu.Accounts.Repository
|
||||
Session.Update(voucher);
|
||||
return voucher.VoucherID;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ using Tanshu.Accounts.Entities;
|
||||
using Tanshu.Accounts.Entities.Auth;
|
||||
using NHibernate;
|
||||
using System.Linq;
|
||||
using Tanshu.Common.Helpers;
|
||||
|
||||
namespace Tanshu.Accounts.Repository
|
||||
{
|
||||
@ -71,7 +72,7 @@ namespace Tanshu.Accounts.Repository
|
||||
var amount = -1 * voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
||||
UpdateSettlements(voucher.Settlements, amount);
|
||||
voucher.User = user;
|
||||
voucher.LastEditDate = DbValues.Date;
|
||||
voucher.SetValue(VoucherFields.LastEditDate, DbValues.Date);
|
||||
Session.Update(voucher);
|
||||
using (var ft = new FoodTableBI(Session, false))
|
||||
ft.TableSettled(voucher);
|
||||
|
||||
Reference in New Issue
Block a user