Important! : Need to update to new schema using SQL Scripts

Important! : This version will not work.  It is pre-alpha and saved in case of catastrophic failure
Refactor: Remove dependency on Fluent Nhibernate.
Refactor: All Primary keys are now Guids.
Refactor: Class Mappings changed from AutoMap to Explicit Mappings.
Breakage: All Cascading is now disabled and entities must be explicitly saved/updated/deleted
Breakage: Auto Commiting is now off and "SaveChanges()" needs to be called on all BIs.
Refactor: Changed the pattern where all relevant db code for an operation is basically in the same function.
Chore: Removed Advance and Payments options.
This commit is contained in:
tanshu 2014-10-12 15:11:45 +05:30
parent 36dd81bc6f
commit 69617949bd
148 changed files with 2556 additions and 61995 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -1,40 +0,0 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>NHibernate.ByteCode.Castle</name>
</assembly>
<members>
<member name="T:NHibernate.ByteCode.Castle.LazyInitializer">
<summary>
A <see cref="T:NHibernate.Proxy.ILazyInitializer"/> for use with the Castle Dynamic Class Generator.
</summary>
</member>
<member name="M:NHibernate.ByteCode.Castle.LazyInitializer.#ctor(System.String,System.Type,System.Object,System.Reflection.MethodInfo,System.Reflection.MethodInfo,NHibernate.Type.IAbstractComponentType,NHibernate.Engine.ISessionImplementor)">
<summary>
Initializes a new <see cref="T:NHibernate.ByteCode.Castle.LazyInitializer"/> object.
</summary>
<param name="entityName"></param>
<param name="persistentClass">The Class to Proxy.</param>
<param name="id">The Id of the Object we are Proxying.</param>
<param name="getIdentifierMethod"></param>
<param name="setIdentifierMethod"></param>
<param name="componentIdType"></param>
<param name="session">The ISession this Proxy is in.</param>
</member>
<member name="M:NHibernate.ByteCode.Castle.LazyInitializer.Intercept(Castle.DynamicProxy.IInvocation)">
<summary>
Invoke the actual Property/Method using the Proxy or instantiate the actual
object and use it when the Proxy can't handle the method.
</summary>
<param name="invocation">The <see cref="T:Castle.DynamicProxy.IInvocation"/> from the generated Castle.DynamicProxy.</param>
</member>
<member name="M:NHibernate.ByteCode.Castle.ProxyFactory.GetProxy(System.Object,NHibernate.Engine.ISessionImplementor)">
<summary>
Build a proxy using the Castle.DynamicProxy library.
</summary>
<param name="id">The value for the Id.</param>
<param name="session">The Session the proxy is in.</param>
<returns>A fully built <c>INHibernateProxy</c>.</returns>
</member>
</members>
</doc>

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,131 @@
USE Gets;
BEGIN TRANSACTION
ALTER TABLE Entities_Waiters ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_FoodTables ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Customers ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Auth_Groups ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Modifiers ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Auth_Roles ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_ProductGroups ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Taxes ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Auth_Users ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Vouchers ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Kots ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Products ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Inventories ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_InventoryModifiers ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Auth_RoleGroups ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Auth_UserGroups ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_ProductGroupModifiers ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_PrintLocations ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_Reprints ADD ID uniqueidentifier not null DEFAULT newid();
ALTER TABLE Entities_VoucherSettlements ADD ID uniqueidentifier not null DEFAULT newid();
COMMIT
BEGIN TRANSACTION
UPDATE Entities_Customers SET ID = '2C716F4B-0736-429A-AD51-610D7C47CB5E' WHERE CustomerID = 1;
UPDATE Entities_Waiters SET ID = '3ECB3BCE-CBBA-461C-BC16-5823FC075AAA' WHERE WaiterID = 1;
COMMIT
USE Sales
BEGIN TRANSACTION
INSERT INTO Waiters (WaiterID, Name)
SELECT ID, Name from Gets.dbo.Entities_Waiters;
INSERT INTO Customers (CustomerID, Name, Address, Important, Phone, Remarks)
SELECT ID, Name, Address, Important, Phone, Remarks from Gets.dbo.Entities_Customers;
INSERT INTO Auth_Groups (GroupID, Name)
SELECT ID, Name from Gets.dbo.Auth_Groups;
INSERT INTO Modifiers (ModifierID, Name, ShowInBill, Price)
SELECT ID, Name, 0, 0 from Gets.dbo.Entities_Modifiers;
INSERT INTO Auth_Roles (RoleID, Name)
SELECT ID, Name from Gets.dbo.Auth_Roles;
INSERT INTO ProductGroups (ProductGroupID, Name, DiscountLimit, IsModifierCompulsory, Discontinued, SortOrder, GroupType)
SELECT ID, Name, DiscountLimit, IsModifierCompulsory, Discontinued, SortOrder, GroupType from Gets.dbo.Entities_ProductGroups;
INSERT INTO Taxes (TaxID, Name, Rate)
SELECT ID, Name, Rate from Gets.dbo.Entities_Taxes;
INSERT INTO Auth_Users (UserID, Name, MsrString, Password, LockedOut)
SELECT ID, Name, MsrString, Password, LockedOut from Gets.dbo.Auth_Users;
INSERT INTO Vouchers (VoucherID, Date, Pax, UserID, CreationDate, LastEditDate, BillID, TableID, WaiterID, CustomerID, Narration, Void, VoidReason, Printed, VoucherType, KotID)
SELECT ID, Date, Pax,
(SELECT u.ID FROM Gets.dbo.Auth_Users u WHERE u.UserID = v.UserID),
CreationDate, LastEditDate, BillID, TableID,
(SELECT w.ID FROM Gets.dbo.Entities_Waiters w WHERE w.WaiterID = v.WaiterID),
(SELECT c.ID FROM Gets.dbo.Entities_Customers c WHERE c.CustomerID = v.CustomerID),
Narration, Void, VoidReason, Printed, VoucherType, KotID
from Gets.dbo.Entities_Vouchers as V;
INSERT INTO Kots (KotID, VoucherID, Code, TableID, Printed, Date, UserID)
SELECT ID,
(SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = k.VoucherID),
Code, TableID, Printed, Date,
(SELECT u.ID FROM Gets.dbo.Auth_Users u WHERE u.UserID = k.UserID)
from Gets.dbo.Entities_Kots AS k;
INSERT INTO Products (ProductID, Code, Name, Units, ProductGroupID, VatID, ServiceTaxID, ServiceCharge, IsScTaxable, Price, FullPrice, Discontinued, SortOrder, BaseCode, Quantity)
SELECT ID, Code, Name, Units,
(SELECT pg.ID FROM Gets.dbo.Entities_ProductGroups pg WHERE pg.ProductGroupID = p.ProductGroupID),
(SELECT vat.ID FROM Gets.dbo.Entities_Taxes vat WHERE vat.TaxID = p.VatID),
(SELECT st.ID FROM Gets.dbo.Entities_Taxes st WHERE st.TaxID = p.ServiceTaxID),
ServiceCharge, IsScTaxable, Price, FullPrice, Discontinued, SortOrder, BaseCode, Quantity
from Gets.dbo.Entities_Products AS p;
INSERT INTO Inventories (InventoryID, KotID, ProductID, Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTaxRate, VatRate, ServiceTaxID, VatID, Discount)
SELECT ID,
(SELECT k.ID FROM Gets.dbo.Entities_Kots k WHERE k.KotID = i.KotID),
(SELECT p.ID FROM Gets.dbo.Entities_Products p WHERE p.ProductID = i.ProductID),
Quantity, Price, FullPrice, ServiceCharge, IsScTaxable, ServiceTax, Vat,
(SELECT s.ID FROM Gets.dbo.Entities_Taxes s WHERE s.Rate = i.ServiceTax),
(SELECT v.ID FROM Gets.dbo.Entities_Taxes v WHERE v.Rate = i.Vat),
Discount
from Gets.dbo.Entities_Inventories as i;
INSERT INTO InventoryModifiers (InventoryModifierID, InventoryID, ModifierID)
SELECT ID,
(SELECT i.ID FROM Gets.dbo.Entities_Inventories i WHERE i.InventoryID = im.InventoryID),
(SELECT m.ID FROM Gets.dbo.Entities_Modifiers m WHERE m.ModifierID = im.ModifierID)
from Gets.dbo.Entities_InventoryModifiers as im;
INSERT INTO Auth_RoleGroups (RoleGroupID, RoleID, GroupID)
SELECT ID,
(SELECT r.ID FROM Gets.dbo.Auth_Roles r WHERE r.RoleID = rg.RoleID),
(SELECT g.ID FROM Gets.dbo.Auth_Groups g WHERE g.GroupID = rg.GroupID)
from Gets.dbo.Auth_RoleGroups as rg;
INSERT INTO Auth_UserGroups (UserGroupID, UserID, GroupID)
SELECT ID,
(SELECT u.ID FROM Gets.dbo.Auth_Users u WHERE u.UserID = ug.UserID),
(SELECT g.ID FROM Gets.dbo.Auth_Groups g WHERE g.GroupID = ug.GroupID)
from Gets.dbo.Auth_UserGroups as ug;
INSERT INTO ProductGroupModifiers (ProductGroupModifierID, ProductGroupID, ModifierID, ShowAutomatically)
SELECT ID,
(SELECT pg.ID FROM Gets.dbo.Entities_ProductGroups pg WHERE pg.ProductGroupID = pgm.ProductGroupID),
(SELECT m.ID FROM Gets.dbo.Entities_Modifiers m WHERE m.ModifierID = pgm.ModifierID),
ShowAutomatically
from Gets.dbo.Entities_ProductGroupModifiers as pgm;
INSERT INTO PrintLocations (PrintLocationID, ProductGroupID, Location, Printer, Copies, CutCode)
SELECT ID,
(SELECT pg.ID FROM Gets.dbo.Entities_ProductGroups pg WHERE pg.ProductGroupID = pl.ProductGroupID),
Location, Printer, Copies, CutCode
from Gets.dbo.Entities_PrintLocations as pl;
INSERT INTO Reprints (ReprintID, UserID, Date, VoucherID)
SELECT ID,
(SELECT u.ID FROM Gets.dbo.Auth_Users u WHERE u.UserID = r.UserID),
Date,
(SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = r.VoucherID)
from Gets.dbo.Entities_Reprints as r;
INSERT INTO VoucherSettlements (VoucherSettlementID, VoucherID, Settled, Amount)
SELECT ID,
(SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = s.VoucherID),
Settled, Amount
from Gets.dbo.Entities_VoucherSettlements as s;
INSERT INTO FoodTables (FoodTableID, Name, Location, Status, VoucherID, SortOrder)
SELECT ID, Name, Location, Status,
(SELECT v.ID FROM Gets.dbo.Entities_Vouchers v WHERE v.VoucherID = ft.VoucherID),
FoodTableID
from Gets.dbo.Entities_FoodTables as ft;
COMMIT

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tanshu.Accounts.Contracts
{
public sealed class Constants
{
public static Guid CASH_CUSTOMER
{
get
{
return new Guid("2C716F4B-0736-429A-AD51-610D7C47CB5E");
}
}
public static Guid WAITER
{
get
{
return new Guid("3ECB3BCE-CBBA-461C-BC16-5823FC075AAA");
}
}
}
}

View File

@ -6,14 +6,14 @@ namespace Tanshu.Accounts.Contracts
{
public class BillItemValue
{
public int ProductID { get; set; }
public Guid ProductID { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public decimal FullPrice { get; set; }
public decimal Quantity { get; set; }
private decimal _discount;
public Product Product { get; private set; }
public bool IsKot { get; private set; }
public decimal Discount
{
get { return _discount; }
@ -29,25 +29,27 @@ namespace Tanshu.Accounts.Contracts
public bool IsScTaxable { get; set; }
public decimal ServiceTax { get; set; }
public Tax ServiceTax { get; set; }
public decimal ServiceTaxRate { get; set; }
public decimal ServiceTaxAmount
{
get
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * ServiceTax;
return Quantity * Price * (1 - Discount) * ServiceTax;
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * ServiceTaxRate;
return Quantity * Price * (1 - Discount) * ServiceTaxRate;
}
}
public decimal Vat { get; set; }
public Tax Vat { get; set; }
public decimal VatRate { get; set; }
public decimal VatAmount
{
get
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * Vat;
return Quantity * Price * (1 - Discount) * Vat;
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * VatRate;
return Quantity * Price * (1 - Discount) * VatRate;
}
}
@ -83,8 +85,8 @@ namespace Tanshu.Accounts.Contracts
get
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTax + Vat);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTax + Vat);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTaxRate + VatRate);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTaxRate + VatRate);
}
}
@ -125,25 +127,28 @@ namespace Tanshu.Accounts.Contracts
Price = product.Price;
FullPrice = product.FullPrice;
IsScTaxable = product.IsScTaxable;
ServiceTax = product.ServiceTax.Rate;
Vat = product.Vat.Rate;
ServiceTax = product.ServiceTax;
Vat = product.Vat;
ServiceTaxRate = product.ServiceTax.Rate;
VatRate = product.Vat.Rate;
ServiceCharge = product.ServiceCharge;
Discount = 0;
Printed = false;
IsKot = false;
}
}
public BillItemValue()
{
Product = null;
ProductID = 0;
ProductID = Guid.Empty;
Discount = 0;
Name = "== New Kot ==";
Price = 0;
FullPrice = 0;
Printed = true;
Quantity = 0;
Vat = -1;
ServiceCharge = 0;
IsKot = true;
}
public BillItemValue(Kot kot)
@ -156,8 +161,8 @@ namespace Tanshu.Accounts.Contracts
FullPrice = 0;
Printed = true;
Quantity = 0;
Vat = -1;
ServiceCharge = 0;
IsKot = true;
}
}

View File

@ -11,71 +11,28 @@ namespace Tanshu.Accounts.Contracts
}
public class BillItemKey
{
private BillItemKey(int productID, int kotID, BillItemType billItemType)
private BillItemKey(Guid productID, Guid kotID, BillItemType billItemType)
{
if (kotID < 0)
throw new ArgumentException("KotID Cannot be Negative");
if (productID < 0)
throw new ArgumentException("ProductID Cannot be Negative");
BillItemType = billItemType;
ProductID = productID;
KotID = kotID;
}
public BillItemKey(int kotID)
: this(0, kotID, BillItemType.Kot)
public BillItemKey(Guid kotID)
: this(Guid.Empty, kotID, BillItemType.Kot)
{ }
public BillItemKey(int productID, int kotID)
public BillItemKey(Guid productID, Guid kotID)
: this(productID, kotID, BillItemType.Product)
{ }
private int _productID;
public int ProductID
private Guid _productID;
public Guid ProductID
{
get { return BillItemType == BillItemType.Product ? _productID : 0; }
private set { _productID = BillItemType == BillItemType.Product ? value : 0; }
get { return BillItemType == BillItemType.Product ? _productID : Guid.Empty; }
private set { _productID = BillItemType == BillItemType.Product ? value : Guid.Empty; }
}
public int KotID { get; private set; }
public Guid KotID { get; private set; }
public BillItemType BillItemType { get; private set; }
public override int GetHashCode()
{
return BillItemType == BillItemType.Product ?
ProductID.GetHashCode() ^ KotID.GetHashCode() ^ BillItemType.GetHashCode()
: KotID.GetHashCode() ^ BillItemType.GetHashCode(); ;
}
public override bool Equals(object obj)
{
if (obj is BillItemKey)
return (this == (BillItemKey)obj);
else
return false;
}
public override string ToString()
{
return string.Format("{0} - {1}", ProductID, KotID);
}
public static bool operator ==(BillItemKey a, BillItemKey b)
{
if (object.ReferenceEquals(null, a))
return object.ReferenceEquals(null, b);
if (!(a is BillItemKey))
return false;
if (!(b is BillItemKey))
return false;
if (a.BillItemType != b.BillItemType)
return false;
return a.BillItemType == BillItemType.Product ?
a.ProductID == b.ProductID && a.KotID == b.KotID && a.BillItemType == b.BillItemType
: a.KotID == b.KotID && a.BillItemType == b.BillItemType;
}
public static bool operator !=(BillItemKey a, BillItemKey b)
{
return !(a == b);
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
namespace Tanshu.Accounts.Contracts
{

View File

@ -1,6 +1,5 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
namespace Tanshu.Accounts.Contracts
{

View File

@ -1,6 +1,5 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
namespace Tanshu.Accounts.Contracts
{

View File

@ -1,18 +0,0 @@
using System;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.Entities
{
public class Advance
{
public virtual int AdvanceID { get; private set; }
public virtual decimal Amount { get; set; }
public virtual string Narration { get; set; }
[NotNull]
public virtual User CashierIn { get; set; }
public virtual DateTime DateIn { get; set; }
public virtual User CashierOut { get; set; }
public virtual DateTime? DateOut { get; set; }
}
}

View File

@ -1,15 +1,15 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities.Auth
{
public class Group
{
public virtual int GroupID { get; set; }
[NotNull, Unique]
public virtual Guid GroupID { get; set; }
public virtual string Name { get; set; }
public virtual IList<RoleGroup> RoleGroups { get; set; }
public virtual IList<UserGroup> UserGroups { get; set; }
@ -19,4 +19,18 @@ namespace Tanshu.Accounts.Entities.Auth
UserGroups = new List<UserGroup>();
}
}
public class GroupMap : ClassMapping<Group>
{
public GroupMap()
{
Table("Auth_Groups");
Schema("dbo");
Lazy(true);
Id(x => x.GroupID, map => map.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Bag(x => x.RoleGroups, colmap => { colmap.Key(x => x.Column("GroupID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
Bag(x => x.UserGroups, colmap => { colmap.Key(x => x.Column("GroupID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}

View File

@ -1,21 +1,34 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities.Auth
{
public class Role
{
public virtual int RoleID { get; set; }
[NotNull, Unique]
public virtual Guid RoleID { get; set; }
public virtual string Name { get; set; }
public virtual IList<RoleGroup> Groups { get; set; }
public Role()
{
Groups = new List<RoleGroup>();
}
}
public class RoleMap : ClassMapping<Role>
{
public RoleMap()
{
Table("Auth_Roles");
Schema("dbo");
Lazy(true);
Id(x => x.RoleID, map => map.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Bag(x => x.Groups, colmap => { colmap.Key(x => x.Column("RoleID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}

View File

@ -1,16 +1,40 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities.Auth
{
public class RoleGroup
{
public virtual int RoleGroupID { get; set; }
[NotNull]
public virtual Guid RoleGroupID { get; set; }
public virtual Role Role { get; set; }
[NotNull]
public virtual Group Group { get; set; }
}
public class RoleGroupMap : ClassMapping<RoleGroup>
{
public RoleGroupMap()
{
Table("Auth_RoleGroups");
Schema("dbo");
Lazy(true);
Id(x => x.RoleGroupID, map => map.Generator(Generators.GuidComb));
ManyToOne(x => x.Role, map =>
{
map.Column("RoleID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.Group, map =>
{
map.Column("GroupID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
}
}
}

View File

@ -1,22 +1,48 @@
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using System;
using System.Collections.Generic;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
namespace Tanshu.Accounts.Entities.Auth
{
public class User
{
public virtual int UserID { get; set; }
[Unique] [NotNull]
public virtual Guid UserID { get; set; }
public virtual string Name { get; set; }
public virtual string MsrString { get; set; }
[NotNull]
public virtual string Password { get; set; }
[NotNull]
public virtual bool LockedOut { get; set; }
public virtual IList<UserGroup> UserGroups { get; set; }
public virtual IList<Kot> Kots { get; set; }
public virtual IList<Reprint> Reprints { get; set; }
public virtual IList<Voucher> Vouchers { get; set; }
public User()
{
UserGroups = new List<UserGroup>();
Kots = new List<Kot>();
Reprints = new List<Reprint>();
Vouchers = new List<Voucher>();
}
}
public class UserMap : ClassMapping<User>
{
public UserMap()
{
Table("Auth_Users");
Schema("dbo");
Lazy(true);
Id(x => x.UserID, m => m.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Property(x => x.MsrString);
Property(x => x.Password, m => m.NotNullable(true));
Property(x => x.LockedOut, m => m.NotNullable(true));
Bag(x => x.UserGroups, colmap => { colmap.Key(x => x.Column("UserID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
Bag(x => x.Kots, colmap => { colmap.Key(x => x.Column("UserID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
Bag(x => x.Reprints, colmap => { colmap.Key(x => x.Column("UserID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
Bag(x => x.Vouchers, colmap => { colmap.Key(x => x.Column("UserID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}

View File

@ -1,16 +1,41 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
using System.Collections.Generic;
namespace Tanshu.Accounts.Entities.Auth
{
public class UserGroup
{
public virtual int UserGroupID { get; set; }
[NotNull]
public virtual Guid UserGroupID { get; set; }
public virtual User User { get; set; }
[NotNull]
public virtual Group Group { get; set; }
}
public class UserGroupMap : ClassMapping<UserGroup>
{
public UserGroupMap()
{
Table("Auth_UserGroups");
Schema("dbo");
Lazy(true);
Id(x => x.UserGroupID, map => map.Generator(Generators.GuidComb));
ManyToOne(x => x.User, map =>
{
map.Column("UserID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.Group, map =>
{
map.Column("GroupID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
}
}
}

View File

@ -1,13 +1,33 @@
namespace Tanshu.Accounts.Entities
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
using System.Collections.Generic;
using System;
namespace Tanshu.Accounts.Entities
{
public class Customer
{
public virtual int CustomerID { get; set; }
public virtual int Code { get; set; }
public virtual Guid CustomerID { get; set; }
public virtual string Name { get; set; }
public virtual string Address { get; set; }
public virtual bool Important { get; set; }
public virtual string Phone { get; set; }
public virtual string Remarks { get; set; }
public virtual IList<Voucher> Vouchers { get; set; }
}
public class CustomerMap : ClassMapping<Customer>
{
public CustomerMap()
{
Table("Customers");
Schema("dbo");
Lazy(true);
Id(x => x.CustomerID, map => map.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Property(x => x.Address);
Property(x => x.Important);
Property(x => x.Phone);
Property(x => x.Remarks);
Bag(x => x.Vouchers, colmap => { colmap.Key(x => x.Column("CustomerID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}

View File

@ -1,11 +1,30 @@
namespace Tanshu.Accounts.Entities
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
using System;
namespace Tanshu.Accounts.Entities
{
public class FoodTable
{
public virtual int FoodTableID { get; set; }
public virtual Guid FoodTableID { get; set; }
public virtual string Name { get; set; }
public virtual string Location { get; set; }
public virtual string Status { get; set; }
public virtual int VoucherID { get; set; }
public virtual int SortOrder { get; set; }
public virtual Guid? VoucherID { get; set; }
}
public class FoodTableMap : ClassMapping<FoodTable>
{
public FoodTableMap()
{
Table("FoodTables");
Schema("dbo");
Lazy(true);
Id(x => x.FoodTableID, map => map.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Property(x => x.Location);
Property(x => x.Status);
Property(x => x.VoucherID);
Property(x => x.SortOrder);
}
}
}

View File

@ -1,5 +1,9 @@
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
using System;
using System.ComponentModel;
namespace Tanshu.Accounts.Entities
{
@ -7,41 +11,82 @@ namespace Tanshu.Accounts.Entities
{
public Inventory()
{
// ReSharper disable DoNotCallOverridableMethodsInConstructor
InventoryModifier = new List<InventoryModifier>();
// ReSharper restore DoNotCallOverridableMethodsInConstructor
}
public virtual int InventoryID { get; set; }
[NotNull]
public virtual Guid InventoryID { get; set; }
public virtual Kot Kot { get; set; }
[NotNull]
public virtual Product Product { get; set; }
public virtual decimal Quantity { get; set; }
public virtual decimal Price { get; set; }
public virtual decimal FullPrice { get; set; }
public virtual decimal ServiceCharge { get; set; }
public virtual bool IsScTaxable { get; set; }
public virtual decimal ServiceTax { get; set; }
public virtual decimal Vat { get; set; }
public virtual decimal ServiceTaxRate { get; set; }
public virtual decimal VatRate { get; set; }
public virtual Tax ServiceTax { get; set; }
public virtual Tax Vat { get; set; }
public virtual decimal Discount { get; set; }
[Cascade]
public virtual IList<InventoryModifier> InventoryModifier { get; set; }
[Formula(Formula = "CASE WHEN IsScTaxable = 1 THEN Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTax + Vat) ELSE Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTax + Vat) END")]
public virtual decimal Amount
{
get
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTax + Vat);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTax + Vat);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTaxRate + VatRate);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTaxRate + VatRate);
}
private set { }
set { }
}
}
public class InventoryMap : ClassMapping<Inventory>
{
public InventoryMap()
{
Table("Inventories");
Schema("dbo");
Lazy(true);
Id(x => x.InventoryID, m => m.Generator(Generators.GuidComb));
Property(x => x.Quantity, map => map.NotNullable(true));
Property(x => x.Price, map => map.NotNullable(true));
Property(x => x.FullPrice, map => map.NotNullable(true));
Property(x => x.ServiceTaxRate, map => map.NotNullable(true));
Property(x => x.VatRate, map => map.NotNullable(true));
Property(x => x.Discount, map => map.NotNullable(true));
Property(x => x.ServiceCharge, map => map.NotNullable(true));
Property(x => x.IsScTaxable, map => map.NotNullable(true));
Property(x => x.Amount, map =>
{
map.Formula("CASE WHEN IsScTaxable = 1 THEN Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTaxRate + VatRate) ELSE Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTaxRate + VatRate) END");
});
ManyToOne(x => x.ServiceTax, map =>
{
map.Column("ServiceTaxID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.Vat, map =>
{
map.Column("VatID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.Kot, map =>
{
map.Column("KotID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.Product, map =>
{
map.Column("ProductID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
Bag(x => x.InventoryModifier, colmap => { colmap.Key(x => x.Column("InventoryID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}

View File

@ -1,16 +1,41 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities
{
public class InventoryModifier
{
public virtual int InventoryModifierID { get; set; }
[NotNull]
public virtual Guid InventoryModifierID { get; set; }
public virtual Inventory Inventory { get; set; }
[NotNull]
public virtual Modifier Modifier { get; set; }
}
public class InventoryModifierMap : ClassMapping<InventoryModifier>
{
public InventoryModifierMap()
{
Table("InventoryModifiers");
Schema("dbo");
Lazy(true);
Id(x => x.InventoryModifierID, map => map.Generator(Generators.GuidComb));
ManyToOne(x => x.Inventory, map =>
{
map.Column("InventoryID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.Modifier, map =>
{
map.Column("ModifierID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
}
}
}

View File

@ -1,28 +1,57 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using Tanshu.Accounts.Entities.Auth;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities
{
public class Kot
{
public virtual int KotID { get; set; }
public virtual Voucher Voucher { get; set; }
public virtual string Code { get; set; }
public virtual string TableID { get; set; }
public virtual bool Printed { get; set; }
public virtual DateTime Date { get; set; }
[NotNull]
public virtual User User { get; set; }
[Cascade]
public virtual IList<Inventory> Inventories { get; set; }
public Kot()
{
Inventories = new List<Inventory>();
Printed = false;
}
public virtual Guid KotID { get; set; }
public virtual Voucher Voucher { get; set; }
public virtual string Code { get; set; }
public virtual string TableID { get; set; }
public virtual bool Printed { get; set; }
public virtual DateTime Date { get; set; }
public virtual User User { get; set; }
public virtual IList<Inventory> Inventories { get; set; }
}
public class KotMap : ClassMapping<Kot>
{
public KotMap()
{
Table("Kots");
Schema("dbo");
Lazy(true);
Id(x => x.KotID, map => map.Generator(Generators.GuidComb));
Property(x => x.Code, map => { map.NotNullable(true); map.Unique(true); });
Property(x => x.TableID, map => map.NotNullable(true));
Property(x => x.Printed, map => map.NotNullable(true));
Property(x => x.Date, map => map.NotNullable(true));
ManyToOne(x => x.Voucher, map =>
{
map.Column("VoucherID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
ManyToOne(x => x.User, map =>
{
map.Column("UserID");
map.NotNullable(true);
map.Cascade(Cascade.None);
});
Bag(x => x.Inventories, colmap => { colmap.Key(x => x.Column("KotID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
}
}

View File

@ -1,49 +1,35 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities
{
public class Modifier
{
public virtual int ModifierID { get; set; }
public virtual Guid ModifierID { get; set; }
public virtual string Name { get; set; }
public virtual bool ShowInBill { get; set; }
public virtual decimal Price { get; set; }
public virtual IList<ProductGroupModifier> ProductGroupModifiers { get; set; }
public override int GetHashCode()
public virtual IList<InventoryModifier> InventoryModifiers { get; set; }
}
public class ModifierMap : ClassMapping<Modifier>
{
public ModifierMap()
{
return ModifierID.GetHashCode() ^ Name.GetHashCode();
Table("Modifiers");
Schema("dbo");
Lazy(true);
Id(x => x.ModifierID, m => m.Generator(Generators.GuidComb));
Property(x => x.Name, map => { map.NotNullable(true); map.Unique(true); });
Property(x => x.ShowInBill, map => { map.NotNullable(true); });
Property(x => x.Price, map => { map.NotNullable(true); });
Bag(x => x.InventoryModifiers, colmap => { colmap.Key(x => x.Column("ModifierID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
Bag(x => x.ProductGroupModifiers, colmap => { colmap.Key(x => x.Column("ModifierID")); colmap.Inverse(true); }, map => { map.OneToMany(); });
}
public override bool Equals(object obj)
{
if (obj is Modifier)
return (this == (Modifier)obj);
else
return false;
}
public override string ToString()
{
return string.Format("{0} - {1}", ModifierID, Name);
}
public static bool operator ==(Modifier a, Modifier b)
{
if (object.ReferenceEquals(null, a))
return object.ReferenceEquals(null, b);
if (!(a is Modifier))
return false;
if (!(b is Modifier))
return false;
return a.ModifierID == b.ModifierID && a.Name == b.Name;
}
public static bool operator !=(Modifier a, Modifier b)
{
return !(a == b);
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using Tanshu.Accounts.Entities.Auth;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.Entities
{
public class Payment
{
public virtual int PaymentID { get; set; }
public virtual DateTime Date { get; set; }
public virtual string Type { get; set; }
[NotNull]
public virtual User Cashier { get; set; }
public virtual decimal Amount { get; set; }
public virtual string Narration { get; set; }
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
namespace Tanshu.Accounts.Entities
{
public class PaymentGroup
{
public virtual int PaymentGroupID { get; set; }
public virtual string Name { get; set; }
}
}

View File

@ -1,49 +1,37 @@
using System;
using System.Runtime.Serialization;
using FluentNHibernate.Mapping;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
namespace Tanshu.Accounts.Entities
{
public class PrintLocation
{
public virtual int PrintLocationID { get; set; }
public virtual Guid PrintLocationID { get; set; }
public virtual ProductGroup ProductGroup { get; set; }
public virtual string Location { get; set; }
public virtual string Printer { get; set; }
public virtual int Copies { get; set; }
public virtual string CutCode { get; set; }
public override bool Equals(System.Object obj)
}
public class PrintLocationMap : ClassMapping<PrintLocation>
{
public PrintLocationMap()
{
if (obj is PrintLocation)
return (this == (PrintLocation)obj);
else
return false;
}
Table("PrintLocations");
Schema("dbo");
Lazy(true);
Id(x => x.PrintLocationID, map => map.Generator(Generators.GuidComb));
Property(x => x.Location);
Property(x => x.Printer);
Property(x => x.Copies);
Property(x => x.CutCode);
ManyToOne(x => x.ProductGroup, map =>
{
map.Column("ProductGroupID");
map.Cascade(Cascade.None);
});
public override int GetHashCode()
{
//return PrintLocationID.GetHashCode() ^ ProductTypeID.GetHashCode() ^ Location.GetHashCode() ^ Printer.GetHashCode() ^ Copies.GetHashCode() ^ CutCode.GetHashCode();
return Location.GetHashCode() ^ Printer.GetHashCode() ^ Copies.GetHashCode() ^ CutCode.GetHashCode();
}
public static bool operator ==(PrintLocation a, PrintLocation b)
{
if (object.ReferenceEquals(null, a))
return object.ReferenceEquals(null, b);
if (!(a is PrintLocation))
return false;
if (!(b is PrintLocation))
return false;
return (a.Location == b.Location)
&& (a.Printer == b.Printer)
&& (a.Copies == b.Copies)
&& (a.CutCode == b.CutCode);
}
public static bool operator !=(PrintLocation a, PrintLocation b)
{
return !(a == b);
}
}
}

View File

@ -1,17 +1,18 @@
using Tanshu.Accounts.Contracts;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;
using System.Collections.Generic;
using System;
namespace Tanshu.Accounts.Entities
{
public class Product
{
public virtual int ProductID { get; set; }
public virtual Guid ProductID { get; set; }
public virtual int Code { get; set; }
[NotNull]
public virtual string Name { get; set; }
public virtual string Units { get; set; }
[NotNull]
public virtual ProductGroup ProductGroup { get; set; }
[NotNull]
public virtual Tax Vat { get; set; }
public virtual Tax ServiceTax { get; set; }
public virtual decimal ServiceCharge { get; set; }
@ -24,5 +25,35 @@ namespace Tanshu.Accounts.Entities
public virtual int BaseCode { get; set; }
[NotNull]
public virtual decimal Quantity { get; set; }
public virtual IList<Inventory> Inventories { get; set; }
}
public class ProductMap : ClassMapping<Product>
{
public ProductMap()
{
Table("Products");
Schema("dbo"