2011-03-11 18:49:48 +00:00
|
|
|
|
using System.Collections.Generic;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
using Tanshu.Accounts.Contracts;
|
2014-10-12 09:41:45 +00:00
|
|
|
|
using NHibernate.Mapping.ByCode.Conformist;
|
|
|
|
|
using NHibernate.Mapping.ByCode;
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
namespace Tanshu.Accounts.Entities
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public class Inventory
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
public Inventory()
|
|
|
|
|
{
|
|
|
|
|
InventoryModifier = new List<InventoryModifier>();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public virtual Guid InventoryID { get; set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public virtual Kot Kot { get; set; }
|
2014-11-10 11:06:49 +00:00
|
|
|
|
public virtual int SortOrder { get; set; }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual Product Product { get; set; }
|
2011-02-09 12:03:22 +00:00
|
|
|
|
public virtual decimal Quantity { get; set; }
|
2011-08-28 12:17:15 +00:00
|
|
|
|
public virtual decimal Price { get; set; }
|
|
|
|
|
public virtual decimal FullPrice { get; set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public virtual decimal ServiceCharge { get; set; }
|
2012-04-08 12:28:15 +00:00
|
|
|
|
public virtual bool IsScTaxable { get; set; }
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public virtual decimal ServiceTaxRate { get; set; }
|
|
|
|
|
public virtual decimal VatRate { get; set; }
|
|
|
|
|
public virtual Tax ServiceTax { get; set; }
|
|
|
|
|
public virtual Tax Vat { get; set; }
|
2012-04-08 12:28:15 +00:00
|
|
|
|
public virtual decimal Discount { get; set; }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
public virtual IList<InventoryModifier> InventoryModifier { get; set; }
|
2011-03-11 18:49:48 +00:00
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual decimal Amount
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2012-04-08 12:28:15 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (IsScTaxable)
|
2014-10-12 09:41:45 +00:00
|
|
|
|
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTaxRate + VatRate);
|
|
|
|
|
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTaxRate + VatRate);
|
2012-04-08 12:28:15 +00:00
|
|
|
|
}
|
2014-10-12 09:41:45 +00:00
|
|
|
|
set { }
|
|
|
|
|
}
|
2016-03-29 09:36:46 +00:00
|
|
|
|
|
|
|
|
|
public virtual decimal ServiceTaxAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (IsScTaxable)
|
|
|
|
|
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * ServiceTaxRate;
|
|
|
|
|
return Quantity * Price * (1 - Discount) * ServiceTaxRate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual decimal VatAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (IsScTaxable)
|
|
|
|
|
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * VatRate;
|
|
|
|
|
return Quantity * Price * (1 - Discount) * VatRate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual decimal ServiceChargeAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Quantity * Price * (1 - Discount) * ServiceCharge;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual decimal DiscountAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Quantity * Price * Discount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual decimal Net
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Quantity * Price * (1 - Discount);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
|
|
|
|
public class InventoryMap : ClassMapping<Inventory>
|
|
|
|
|
{
|
|
|
|
|
public InventoryMap()
|
|
|
|
|
{
|
|
|
|
|
Table("Inventories");
|
|
|
|
|
Schema("dbo");
|
|
|
|
|
Lazy(true);
|
|
|
|
|
Id(x => x.InventoryID, m => m.Generator(Generators.GuidComb));
|
2014-11-10 11:06:49 +00:00
|
|
|
|
Property(x => x.SortOrder, map => map.NotNullable(true));
|
2014-10-12 09:41:45 +00:00
|
|
|
|
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(); });
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|