Added inverse Attribute to ProductGroup.

BillInventory Renamed.
Refactored Bill to be more usable.
Added Bill Detail Report.
Added Open Bill and Bill Details Roles.
Zero Rate Products have Yellow background Color.
Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI,
Cached the Products List.
Product and Product Group Form Working.
This commit is contained in:
unknown
2011-06-23 18:17:48 +05:30
parent 0cb7d3cf09
commit d8ecec8bb6
85 changed files with 3520 additions and 2264 deletions

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tanshu.Accounts.Contracts
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class InverseAttribute : Attribute
{
private string message = string.Empty;
public string Message
{
get { return message; }
set { message = value; }
}
}
}

View File

@ -1,28 +1,28 @@
using System;
using System.Runtime.Serialization;
using Tanshu.Accounts.Entities;
using System.Collections.Generic;
namespace Tanshu.Accounts.Contracts
{
public class BillInventory
public class BillItemValue
{
public int ProductID { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public decimal Quantity { get; set; }
private decimal discount = 0;
private decimal _discount;
public Product Product { get; private set; }
public decimal Discount
{
get { return discount; }
get { return _discount; }
set
{
if (value < 0)
throw new ArgumentException("Discount has to be non-negative greater than or equal to zero.");
else if (value > 1)
if (value > 1)
throw new ArgumentException("Discount has to be less than one.");
else
discount = value;
_discount = value;
}
}
@ -31,7 +31,7 @@ namespace Tanshu.Accounts.Contracts
{
get
{
return Quantity * Price * (1 - discount) * (1 + ServiceCharge) * Tax;
return Quantity * Price * (1 - _discount) * (1 + ServiceCharge) * Tax;
}
}
@ -40,7 +40,7 @@ namespace Tanshu.Accounts.Contracts
{
get
{
return Quantity * Price * (1 - discount) * ServiceCharge;
return Quantity * Price * (1 - _discount) * ServiceCharge;
}
}
@ -48,7 +48,7 @@ namespace Tanshu.Accounts.Contracts
{
get
{
return Quantity * Price * discount;
return Quantity * Price * _discount;
}
}
@ -56,17 +56,17 @@ namespace Tanshu.Accounts.Contracts
{
get
{
return Quantity * Price * (1 - discount);
return Quantity * Price * (1 - _discount);
}
}
public bool Printed {get; set;}
public bool Printed { get; set; }
public decimal Value
{
get
{
return Price * Quantity * (1 - discount) * (1 + ServiceCharge) * (1 + Tax);
return Price * Quantity * (1 - _discount) * (1 + ServiceCharge) * (1 + Tax);
}
}
@ -74,9 +74,9 @@ namespace Tanshu.Accounts.Contracts
{
get
{
string output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
if (discount != 0)
output += string.Format(" - {0:#.##%}", discount);
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
if (_discount != 0)
output += string.Format(" - {0:#.##%}", _discount);
foreach (var item in Modifiers)
output += string.Format("\n\r -- {0}", item.Name);
return output;
@ -94,11 +94,12 @@ namespace Tanshu.Accounts.Contracts
return string.Format("{0} - {1}", ProductID, Name);
}
public IList<Modifier> Modifiers { get; set; }
public BillInventory()
public BillItemValue(Product product)
{
Quantity = 1;
Printed = false;
Modifiers = new List<Modifier>();
Product = product;
}
}
}

View File

@ -1,23 +1,46 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
public enum BillItemType
{
Product,
Kot
}
public class BillItemKey
{
//Old = 0, New = 1, Modifiers = 2+
public BillItemKey(int ProductID, int KotID)
private BillItemKey(int productID, int kotID, BillItemType billItemType)
{
this.ProductID = ProductID;
this.KotID = KotID;
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(int productID, int kotID)
: this(productID, kotID, BillItemType.Product)
{ }
private int _productID;
public int ProductID
{
get { return BillItemType == BillItemType.Product ? _productID : 0; }
private set { _productID = BillItemType == BillItemType.Product ? value : 0; }
}
public int ProductID { get; private set; }
public int KotID { get; private set; }
public BillItemType BillItemType { get; private set; }
public override int GetHashCode()
{
return ProductID.GetHashCode() ^ KotID.GetHashCode();
return BillItemType == BillItemType.Product ?
ProductID.GetHashCode() ^ KotID.GetHashCode() ^ BillItemType.GetHashCode()
: KotID.GetHashCode() ^ BillItemType.GetHashCode(); ;
}
public override bool Equals(object obj)
{
@ -41,7 +64,12 @@ namespace Tanshu.Accounts.Contracts
if (!(b is BillItemKey))
return false;
return a.ProductID == b.ProductID && a.KotID == b.KotID;
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)
{

View File

@ -16,4 +16,11 @@ namespace Tanshu.Accounts.Contracts
public virtual decimal Sale { get; set; }
public virtual decimal NC { get; set; }
}
public class BillDetail
{
public virtual DateTime Date { get; set; }
public virtual string BillID { get; set; }
public virtual string Settlement { get; set; }
public virtual decimal Amount { get; set; }
}
}

View File

@ -18,6 +18,7 @@ namespace Tanshu.Accounts.Entities
public virtual decimal DiscountLimit { get; set; }
public virtual bool IsModifierCompulsory { get; set; }
public virtual string GroupType { get; set; }
[Inverse]
public virtual IList<Product> Products { get; set; }
}
}

View File

@ -10,5 +10,15 @@ namespace Tanshu.Common.Helpers
var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
return attribute != null ? attribute.Name : "";
}
public static bool Visible(this SettleOption settleOption)
{
var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
return attribute != null ? attribute.ShowInChoices : false;
}
public static DisplayAttribute Attribute(this SettleOption settleOption)
{
var attribute = (DisplayAttribute)settleOption.GetType().GetField(settleOption.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false)[0];
return attribute;
}
}
}

View File

@ -32,9 +32,11 @@ namespace Tanshu.Accounts.Contracts
public static RoleConstants MOVE_TABLE = new RoleConstants("Sales/MoveTable");
public static RoleConstants MERGE_KOT = new RoleConstants("Sales/MergeKot");
public static RoleConstants MOVE_KOT = new RoleConstants("Sales/MoveKot");
public static RoleConstants OPEN_BILL = new RoleConstants("Sales/OpenBill");
public static RoleConstants PRINT_BILL = new RoleConstants("Sales/PrintBill");
public static RoleConstants PRINT_KOT = new RoleConstants("Sales/PrintKOT");
public static RoleConstants SALES = new RoleConstants("Sales/SalesBill");
public static RoleConstants BILL_DETAILS = new RoleConstants("Sales/BillDetails");
public static RoleConstants SALE_ANALYSIS = new RoleConstants("Sales/SaleAnalysis");
public static RoleConstants SALE_DETAIL = new RoleConstants("Sales/SaleDetail");
public static RoleConstants VOID_BILL = new RoleConstants("Sales/VoidPrintedBill");

View File

@ -79,6 +79,7 @@
<ItemGroup>
<Compile Include="Attributes\CascadeAttribute.cs" />
<Compile Include="Attributes\AllowNullAttribute.cs" />
<Compile Include="Attributes\InverseAttribute.cs" />
<Compile Include="Attributes\DisplayAttribute.cs" />
<Compile Include="Attributes\FormulaAttribute.cs" />
<Compile Include="Attributes\UniqueAttribute.cs" />