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:
unknown
2011-08-23 12:40:05 +05:30
parent 226cc30057
commit 831ec37cda
28 changed files with 625 additions and 286 deletions

View 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)
{ }
}
}

View File

@ -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]
});
}

View File

@ -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;
}
}
}

View File

@ -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);

View File

@ -0,0 +1,36 @@
using System;
using System.Reflection;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
namespace Tanshu.Accounts.Conventions
{
public class PropertyAccessConvention : IPropertyConvention
{
public void Apply(IPropertyInstance instance)
{
var entityType = instance.EntityType;
var camelCaseUnderscoreName = ConvertToCamelCaseUnderscore(instance.Name);
// Default is to use property setter, so only modify mapping
// if there is a backing field
if (HasField(entityType, camelCaseUnderscoreName))
instance.Access.CamelCaseField(CamelCasePrefix.Underscore);
}
private static string ConvertToCamelCaseUnderscore(string propertyName)
{
return "_" + propertyName[0].ToString().ToLower() + propertyName.Substring(1);
}
private static bool HasField(Type type, string fieldName)
{
var backingField = type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
return backingField != null;
}
}
}

View File

@ -59,7 +59,7 @@ namespace Tanshu.Accounts.Repository
c.Add<NotNullConvention>();
c.Add<FormulaConvention>();
c.Add<InverseConvention>();
//c.Add<AllowNullConvention>();
c.Add<PropertyAccessConvention>();
c.Add<EnumConvention>();
});

View File

@ -84,6 +84,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BusinessLayer\CheckoutBI.cs" />
<Compile Include="BusinessLayer\ReprintBI.cs" />
<Compile Include="BusinessLayer\FluentBasicBaseBI.cs" />
<Compile Include="BusinessLayer\VoucherSettlementBI.cs" />
<Compile Include="BusinessLayer\FluentGenericBaseBI.cs" />
@ -95,6 +96,7 @@
<Compile Include="Fluent\CascadeConvention.cs" />
<Compile Include="Fluent\InverseConvention.cs" />
<Compile Include="Fluent\FormulaConvention.cs" />
<Compile Include="Fluent\PropertyAccessConvention.cs" />
<Compile Include="Fluent\UniqueConvention.cs" />
<Compile Include="Fluent\NotNullConvention.cs" />
<Compile Include="Lifetime\Session.cs" />