Refactor: Refactored the bill inventory in the hope of making it less
error prone and more understandable.
Refactor: Also upgrade path to moving from Price/FullPrice to HasHappyHour/
IsHappyHour
Must have a few errors.
This commit is contained in:
@ -6,163 +6,61 @@ namespace Tanshu.Accounts.Contracts
|
|||||||
{
|
{
|
||||||
public class BillItemValue
|
public class BillItemValue
|
||||||
{
|
{
|
||||||
public Guid ProductID { get; set; }
|
public Inventory inventory { get; set; }
|
||||||
public string Name { get; set; }
|
public Kot kot { get; private 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; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value < 0)
|
|
||||||
throw new ArgumentException("Discount has to be non-negative greater than or equal to zero.");
|
|
||||||
if (value > 1)
|
|
||||||
throw new ArgumentException("Discount has to be less than one.");
|
|
||||||
_discount = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsScTaxable { 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) * ServiceTaxRate;
|
|
||||||
return Quantity * Price * (1 - Discount) * ServiceTaxRate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tax Vat { get; set; }
|
|
||||||
public decimal VatRate { get; set; }
|
|
||||||
public decimal VatAmount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (IsScTaxable)
|
|
||||||
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * VatRate;
|
|
||||||
return Quantity * Price * (1 - Discount) * VatRate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public decimal ServiceCharge { get; set; }
|
|
||||||
public decimal ServiceChargeAmount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Quantity * Price * (1 - Discount) * ServiceCharge;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public decimal DiscountAmount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Quantity * Price * Discount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public decimal GrossAmount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Quantity * Price * (1 - Discount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Printed { get; set; }
|
|
||||||
|
|
||||||
public decimal Value
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (IsScTaxable)
|
|
||||||
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTaxRate + VatRate);
|
|
||||||
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTaxRate + VatRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Display
|
public string Display
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
|
if (inventory != null)
|
||||||
if (_discount != 0)
|
{
|
||||||
output += string.Format(" - {0:#.##%}", _discount);
|
var output = string.Format("{0} @ Rs. {1:#.##}", inventory.Product.FullName, inventory.Price);
|
||||||
if (Modifiers != null)
|
if (inventory.Discount != 0)
|
||||||
foreach (var item in Modifiers)
|
output += string.Format(" - {0:#.##%}", inventory.Discount);
|
||||||
output += string.Format("\n\r -- {0}", item.Name);
|
foreach (var item in inventory.InventoryModifier)
|
||||||
return output;
|
output += string.Format("\n\r -- {0}", item.Modifier.Name);
|
||||||
|
return output;
|
||||||
//if (Price == 0)
|
}
|
||||||
// return string.Format(" -- {0}", Name);
|
else if (kot.KotID != Guid.Empty)
|
||||||
//string output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
|
{
|
||||||
//if (discount != 0)
|
return string.Format("Kot: S-{0} / {1:dd-MMM HH:mm} ({2})", kot.Code, kot.Date, kot.User.Name);
|
||||||
// output += string.Format(" - {0:#.##%}", discount);
|
}
|
||||||
//return output;
|
else
|
||||||
|
{
|
||||||
|
return "== New Kot ==";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string ToString()
|
public BillItemValue(Inventory inv)
|
||||||
{
|
{
|
||||||
return string.Format("{0} - {1}", ProductID, Name);
|
inventory = inv;
|
||||||
}
|
}
|
||||||
public IList<Modifier> Modifiers { get; set; }
|
|
||||||
public BillItemValue(Product product)
|
public BillItemValue(Product product)
|
||||||
{
|
{
|
||||||
Modifiers = new List<Modifier>();
|
inventory = new Inventory()
|
||||||
if (product != null)
|
|
||||||
{
|
{
|
||||||
Product = product;
|
Product = product,
|
||||||
ProductID = product.ProductID;
|
FullPrice = product.FullPrice,
|
||||||
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")";
|
Price = product.Price,
|
||||||
Quantity = 1;
|
IsScTaxable = product.IsScTaxable,
|
||||||
Price = product.Price;
|
Quantity = 1,
|
||||||
FullPrice = product.FullPrice;
|
ServiceCharge = product.ServiceCharge,
|
||||||
IsScTaxable = product.IsScTaxable;
|
ServiceTax = product.ServiceTax,
|
||||||
ServiceTax = product.ServiceTax;
|
Vat = product.Vat,
|
||||||
Vat = product.Vat;
|
Discount = 0,
|
||||||
ServiceTaxRate = product.ServiceTax.Rate;
|
ServiceTaxRate = product.ServiceTax.Rate,
|
||||||
VatRate = product.Vat.Rate;
|
VatRate = product.Vat.Rate
|
||||||
ServiceCharge = product.ServiceCharge;
|
};
|
||||||
Discount = 0;
|
|
||||||
Printed = false;
|
|
||||||
IsKot = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public BillItemValue()
|
public BillItemValue()
|
||||||
{
|
{
|
||||||
Product = null;
|
this.kot = new Kot();
|
||||||
ProductID = Guid.Empty;
|
|
||||||
Discount = 0;
|
|
||||||
Name = "== New Kot ==";
|
|
||||||
Price = 0;
|
|
||||||
FullPrice = 0;
|
|
||||||
Printed = true;
|
|
||||||
Quantity = 0;
|
|
||||||
ServiceCharge = 0;
|
|
||||||
IsKot = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BillItemValue(Kot kot)
|
public BillItemValue(Kot kot)
|
||||||
{
|
{
|
||||||
Product = null;
|
this.kot = kot;
|
||||||
ProductID = kot.KotID;
|
|
||||||
Discount = 0;
|
|
||||||
Name = string.Format("Kot: S-{0} / {1:dd-MMM HH:mm} ({2})", kot.Code, kot.Date, kot.User.Name);
|
|
||||||
Price = 0;
|
|
||||||
FullPrice = 0;
|
|
||||||
Printed = true;
|
|
||||||
Quantity = 0;
|
|
||||||
ServiceCharge = 0;
|
|
||||||
IsKot = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,50 @@ namespace Tanshu.Accounts.Entities
|
|||||||
}
|
}
|
||||||
set { }
|
set { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class InventoryMap : ClassMapping<Inventory>
|
public class InventoryMap : ClassMapping<Inventory>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -33,7 +33,17 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
if (_saleForm.BindingSource.Position == -1)
|
if (_saleForm.BindingSource.Position == -1)
|
||||||
return null;
|
return null;
|
||||||
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
|
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
|
||||||
return item.Key.BillItemType == BillItemType.Product ? item.Value : null;
|
return item.Key.BillItemType != BillItemType.Kot ? item.Value : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BillItemKey CurrentKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_saleForm.BindingSource.Position == -1)
|
||||||
|
return null;
|
||||||
|
var item = _bill.ElementAt(_saleForm.BindingSource.Position);
|
||||||
|
return item.Key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public BillItemKey CurrentKot
|
public BillItemKey CurrentKot
|
||||||
@ -60,7 +70,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
if (_bill.ContainsKey(newKey))
|
if (_bill.ContainsKey(newKey))
|
||||||
{
|
{
|
||||||
_saleForm.BindingSource.CurrencyManager.Position = _bill.IndexOfKey(newKey);
|
_saleForm.BindingSource.CurrencyManager.Position = _bill.IndexOfKey(newKey);
|
||||||
_bill[newKey].Quantity += 1;
|
_bill[newKey].inventory.Quantity += 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -68,30 +78,29 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
var old = _bill.FirstOrDefault(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID);
|
var old = _bill.FirstOrDefault(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == newKey.ProductID);
|
||||||
if (old.Key != null)
|
if (old.Key != null)
|
||||||
{
|
{
|
||||||
billItemValue.Discount = old.Value.Discount;
|
billItemValue.inventory.Discount = old.Value.inventory.Discount;
|
||||||
billItemValue.Price = old.Value.Price;
|
billItemValue.inventory.Price = old.Value.inventory.Price;
|
||||||
}
|
}
|
||||||
_bill.Add(newKey, billItemValue);
|
_bill.Add(newKey, billItemValue);
|
||||||
_saleForm.BindingSource.DataSource = _bill.Values.ToList();
|
_saleForm.BindingSource.DataSource = _bill.ToList();
|
||||||
_saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1;
|
_saleForm.BindingSource.CurrencyManager.Position = _saleForm.BindingSource.CurrencyManager.Count - 1;
|
||||||
|
|
||||||
using (var bi = new ProductGroupModifierBI())
|
using (var bi = new ProductGroupModifierBI())
|
||||||
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
|
if (bi.HasCompulsoryModifier(product.ProductGroup.ProductGroupID))
|
||||||
{
|
{
|
||||||
var item = CurrentProduct;
|
ShowModifiers();
|
||||||
ShowModifiers(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShowAmount();
|
ShowAmount();
|
||||||
}
|
}
|
||||||
public void ShowModifiers(BillItemValue item)
|
public void ShowModifiers()
|
||||||
{
|
{
|
||||||
if (item.Printed)
|
var item = CurrentProduct;
|
||||||
return;
|
if (item == null || CurrentKey.KotID != Guid.Empty)
|
||||||
using (var frm = new ModifierForm(Cache.ProductGroupModifiers(item.Product.ProductGroup.ProductGroupID), item.Modifiers))
|
return; // No Product or Old Product
|
||||||
|
using (var frm = new ModifierForm(Cache.ProductGroupModifiers(item.inventory.Product.ProductGroup.ProductGroupID), item.inventory.InventoryModifier))
|
||||||
{
|
{
|
||||||
frm.ShowDialog();
|
frm.ShowDialog();
|
||||||
item.Modifiers = frm.Selection;
|
|
||||||
}
|
}
|
||||||
ShowAmount();
|
ShowAmount();
|
||||||
}
|
}
|
||||||
@ -112,14 +121,14 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
if (discount > 1 || discount < 0)
|
if (discount > 1 || discount < 0)
|
||||||
return; // throw new ValidationException("Invalid Discount Amount");
|
return; // throw new ValidationException("Invalid Discount Amount");
|
||||||
|
|
||||||
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && outList.Contains(x.Value.Product.ProductGroup.GroupType)))
|
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && outList.Contains(x.Value.inventory.Product.ProductGroup.GroupType)))
|
||||||
{
|
{
|
||||||
var product = item.Value.Product;
|
var product = item.Value.inventory.Product;
|
||||||
var maxDiscount = product.ProductGroup.DiscountLimit;
|
var maxDiscount = product.ProductGroup.DiscountLimit;
|
||||||
if (discount > item.Value.Product.ProductGroup.DiscountLimit)
|
if (discount > item.Value.inventory.Product.ProductGroup.DiscountLimit)
|
||||||
MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", product.Name, maxDiscount),
|
MessageBox.Show(string.Format("Maximum discount for {0} is {1:P}", product.Name, maxDiscount),
|
||||||
"Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
"Excessive Discount", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
item.Value.Discount = discount;
|
item.Value.inventory.Discount = discount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,36 +138,37 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
public void SetQuantity(decimal quantity, bool prompt)
|
public void SetQuantity(decimal quantity, bool prompt)
|
||||||
{
|
{
|
||||||
var item = CurrentProduct;
|
var item = CurrentProduct;
|
||||||
if (!Allowed(item))
|
var key = CurrentKey;
|
||||||
return;
|
if (item == null || key.KotID != Guid.Empty)
|
||||||
if (item.Printed)
|
return; // No Product or Old Product
|
||||||
return;
|
|
||||||
if (prompt && !GetInput("Quantity", ref quantity))
|
if (prompt && !GetInput("Quantity", ref quantity))
|
||||||
return;
|
return;
|
||||||
if (!prompt)
|
if (!prompt)
|
||||||
quantity += item.Quantity;
|
quantity += item.inventory.Quantity;
|
||||||
if (quantity < 0 && !Session.IsAllowed("Edit Printed Product"))
|
if (quantity < 0 && !Session.IsAllowed("Edit Printed Product"))
|
||||||
return;
|
return;
|
||||||
var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product && x.Value.Printed).Sum(x => x.Value.Quantity);
|
//TODO: check if he kotid of the item is not null
|
||||||
|
//var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product && x.Value.Printed).Sum(x => x.Value.Quantity);
|
||||||
|
var total = quantity + _bill.Where(x => x.Key.ProductID == key.ProductID && x.Key.BillItemType == key.BillItemType).Sum(x => x.Value.inventory.Quantity);
|
||||||
if (total < 0)
|
if (total < 0)
|
||||||
quantity -= total;
|
quantity -= total;
|
||||||
item.Quantity = quantity;
|
item.inventory.Quantity = quantity;
|
||||||
ShowAmount();
|
ShowAmount();
|
||||||
}
|
}
|
||||||
public void SetRate()
|
public void SetPrice()
|
||||||
{
|
{
|
||||||
var item = CurrentProduct;
|
var item = CurrentProduct;
|
||||||
if (item == null)
|
if (item == null)
|
||||||
throw new ValidationException("No Product Selected");
|
throw new ValidationException("No Product Selected");
|
||||||
if (!Session.IsAllowed("Change Rate"))
|
if (!Session.IsAllowed("Change Rate"))
|
||||||
throw new PermissionException("Rate Change not Allowed");
|
throw new PermissionException("Price Change not Allowed");
|
||||||
var rate = item.Price;
|
var price = item.inventory.Price;
|
||||||
if (!GetInput("Price", ref rate))
|
if (!GetInput("Price", ref price))
|
||||||
return;
|
return;
|
||||||
if (rate == 0 && !Session.IsAllowed("NC Product"))
|
if (price == 0 && !Session.IsAllowed("NC Product"))
|
||||||
throw new PermissionException("NC of Product is not Allowed");
|
throw new PermissionException("NC of Product is not Allowed");
|
||||||
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID))
|
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.inventory.Product.ProductID))
|
||||||
sub.Value.Price = rate;
|
sub.Value.inventory.Price = price;
|
||||||
|
|
||||||
ShowAmount();
|
ShowAmount();
|
||||||
}
|
}
|
||||||
@ -198,26 +208,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
private void ShowAmount()
|
private void ShowAmount()
|
||||||
{
|
{
|
||||||
var taxAmount = _bill.Values.Sum(b => b.ServiceTaxAmount + b.VatAmount);
|
_saleForm.ShowAmount(_bill.Discount, _bill.NetAmount, _bill.ServiceCharge, _bill.Tax, _bill.Amount, _bill);
|
||||||
var discountAmount = _bill.Values.Sum(b => b.DiscountAmount);
|
|
||||||
var grossAmount = _bill.Values.Sum(b => b.GrossAmount);
|
|
||||||
var valueAmount = _bill.Values.Sum(b => b.Value);
|
|
||||||
var serviceChargeAmount = _bill.Values.Sum(b => b.ServiceChargeAmount);
|
|
||||||
_saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount,
|
|
||||||
_bill.Values.ToList());
|
|
||||||
}
|
|
||||||
private static bool Allowed(BillItemValue item)
|
|
||||||
{
|
|
||||||
return item != null;
|
|
||||||
}
|
|
||||||
private static void IsPrintedOrVoid(Voucher voucher, out bool isPrinted, out bool isVoid)
|
|
||||||
{
|
|
||||||
using (var bi = new VoucherBI())
|
|
||||||
{
|
|
||||||
var dbVoucher = bi.Get(x => x.VoucherID == voucher.VoucherID);
|
|
||||||
isPrinted = dbVoucher.Printed;
|
|
||||||
isVoid = dbVoucher.Void;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private static bool IsPrintedOrVoid(Voucher voucher)
|
private static bool IsPrintedOrVoid(Voucher voucher)
|
||||||
{
|
{
|
||||||
@ -277,7 +268,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
|
|
||||||
public void CancelBillChanges()
|
public void CancelBillChanges()
|
||||||
{
|
{
|
||||||
if (_bill.Values.Any(i => i.Printed == false) &&
|
if (_bill.Any(x => x.Key.BillItemType != BillItemType.Kot) &&
|
||||||
MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo,
|
MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo,
|
||||||
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
|
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
|
||||||
return;
|
return;
|
||||||
@ -291,7 +282,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
var newKotKey = new BillItemKey(Guid.Empty);
|
var newKotKey = new BillItemKey(Guid.Empty);
|
||||||
var newKotItem = new BillItemValue();
|
var newKotItem = new BillItemValue();
|
||||||
_bill.Add(newKotKey, newKotItem);
|
_bill.Add(newKotKey, newKotItem);
|
||||||
_saleForm.ClearBill(_bill.Values.ToList());
|
_saleForm.ClearBill(_bill);
|
||||||
}
|
}
|
||||||
public SaleFormState FormLoad()
|
public SaleFormState FormLoad()
|
||||||
{
|
{
|
||||||
@ -312,11 +303,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
internal void SettleBill()
|
internal void SettleBill()
|
||||||
{
|
{
|
||||||
if (_voucher.VoucherID == Guid.Empty)
|
if (_voucher.VoucherID == Guid.Empty || !_voucher.Printed || !Session.IsAllowed("Settle Bill"))
|
||||||
return;
|
|
||||||
if (!_voucher.Printed)
|
|
||||||
return;
|
|
||||||
if (!Session.IsAllowed("Settle Bill"))
|
|
||||||
return;
|
return;
|
||||||
IDictionary<SettleOption, decimal> options;
|
IDictionary<SettleOption, decimal> options;
|
||||||
var amount = -1 * _voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
var amount = -1 * _voucher.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
|
||||||
@ -353,9 +340,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
internal void MoveKot()
|
internal void MoveKot()
|
||||||
{
|
{
|
||||||
if (_voucher.VoucherID == Guid.Empty)
|
if (_voucher.VoucherID == Guid.Empty || IsPrintedOrVoid(_voucher))
|
||||||
return;
|
|
||||||
if (IsPrintedOrVoid(_voucher))
|
|
||||||
return;
|
return;
|
||||||
var kot = CurrentKot;
|
var kot = CurrentKot;
|
||||||
if (kot == null)
|
if (kot == null)
|
||||||
@ -487,7 +472,12 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
return;
|
return;
|
||||||
bool isPrinted = false, isVoid = false;
|
bool isPrinted = false, isVoid = false;
|
||||||
if (_voucher.VoucherID != Guid.Empty)
|
if (_voucher.VoucherID != Guid.Empty)
|
||||||
IsPrintedOrVoid(_voucher, out isPrinted, out isVoid);
|
using (var bi = new VoucherBI())
|
||||||
|
{
|
||||||
|
var dbVoucher = bi.Get(x => x.VoucherID == _voucher.VoucherID);
|
||||||
|
isPrinted = dbVoucher.Printed;
|
||||||
|
isVoid = dbVoucher.Void;
|
||||||
|
}
|
||||||
if (isVoid)
|
if (isVoid)
|
||||||
{
|
{
|
||||||
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
@ -497,7 +487,8 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
return;
|
return;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
var amount = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty).Sum(x => x.Value.GrossAmount);
|
var amount = _bill.NetAmount;
|
||||||
|
|
||||||
SetDiscount();
|
SetDiscount();
|
||||||
if (isPrinted)
|
if (isPrinted)
|
||||||
{
|
{
|
||||||
@ -556,8 +547,8 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
if (splitList == null || splitList.Count == 0)
|
if (splitList == null || splitList.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var listFirst = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty && splitList.Contains(x.Value.Product.ProductGroup.GroupType));
|
var listFirst = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty && splitList.Contains(x.Value.inventory.Product.ProductGroup.GroupType));
|
||||||
var listSecond = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty && !splitList.Contains(x.Value.Product.ProductGroup.GroupType));
|
var listSecond = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty && !splitList.Contains(x.Value.inventory.Product.ProductGroup.GroupType));
|
||||||
|
|
||||||
if (listFirst.Count() == 0 || listSecond.Count() == 0)
|
if (listFirst.Count() == 0 || listSecond.Count() == 0)
|
||||||
return; // all or none items selected to be moved
|
return; // all or none items selected to be moved
|
||||||
@ -661,8 +652,9 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
}
|
}
|
||||||
private void SaveReprintOrDiscountBill(decimal oldAmount)
|
private void SaveReprintOrDiscountBill(decimal oldAmount)
|
||||||
{
|
{
|
||||||
var amountChanged = oldAmount != _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty).Sum(x => x.Value.GrossAmount);
|
var amountChanged = oldAmount != _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty).Sum(x => x.Value.inventory.Net);
|
||||||
var itemsChanged = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == Guid.Empty).Count() != 0;
|
var itemsChanged = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == Guid.Empty).Count() != 0;
|
||||||
|
|
||||||
if (amountChanged || itemsChanged) // Discount or Products changed
|
if (amountChanged || itemsChanged) // Discount or Products changed
|
||||||
{
|
{
|
||||||
#region new voucherFirst
|
#region new voucherFirst
|
||||||
@ -704,7 +696,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
_voucher.Printed = finalBill;
|
_voucher.Printed = finalBill;
|
||||||
_voucher.Void = false;
|
_voucher.Void = false;
|
||||||
_voucher.Narration = "";
|
_voucher.Narration = "";
|
||||||
var kot = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == Guid.Empty && x.Value.Quantity != 0));
|
var kot = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == Guid.Empty && x.Value.inventory.Quantity != 0));
|
||||||
if (kot == null)
|
if (kot == null)
|
||||||
return null;
|
return null;
|
||||||
_voucher.Kots.Add(kot);
|
_voucher.Kots.Add(kot);
|
||||||
@ -732,12 +724,12 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty))
|
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty))
|
||||||
{
|
{
|
||||||
var i = voucher.Kots.Single(x => x.KotID == item.Key.KotID).Inventories.Single(x => x.Product.ProductID == item.Key.ProductID);
|
var i = voucher.Kots.Single(x => x.KotID == item.Key.KotID).Inventories.Single(x => x.Product.ProductID == item.Key.ProductID);
|
||||||
i.Discount = item.Value.Discount;
|
i.Discount = item.Value.inventory.Discount;
|
||||||
i.Price = item.Value.Price;
|
i.Price = item.Value.inventory.Price;
|
||||||
}
|
}
|
||||||
if (!_voucher.Printed)
|
if (!_voucher.Printed)
|
||||||
{
|
{
|
||||||
var kot = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == Guid.Empty && x.Value.Quantity != 0));
|
var kot = GetKot(_bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID == Guid.Empty && x.Value.inventory.Quantity != 0));
|
||||||
if (kot != null)
|
if (kot != null)
|
||||||
voucher.Kots.Add(kot);
|
voucher.Kots.Add(kot);
|
||||||
}
|
}
|
||||||
@ -760,7 +752,7 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
var oldInv = kot.Inventories.SingleOrDefault(x => x.Product.ProductID == item.Key.ProductID);
|
var oldInv = kot.Inventories.SingleOrDefault(x => x.Product.ProductID == item.Key.ProductID);
|
||||||
if (oldInv != null)
|
if (oldInv != null)
|
||||||
{
|
{
|
||||||
oldInv.Quantity += item.Value.Quantity;
|
oldInv.Quantity += item.Value.inventory.Quantity;
|
||||||
if (oldInv.Quantity == 0)
|
if (oldInv.Quantity == 0)
|
||||||
kot.Inventories.Remove(oldInv);
|
kot.Inventories.Remove(oldInv);
|
||||||
}
|
}
|
||||||
@ -768,20 +760,20 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
var inv = new Inventory
|
var inv = new Inventory
|
||||||
{
|
{
|
||||||
Product = item.Value.Product,
|
Product = item.Value.inventory.Product,
|
||||||
Quantity = item.Value.Quantity,
|
Quantity = item.Value.inventory.Quantity,
|
||||||
Price = item.Value.Price,
|
Price = item.Value.inventory.Price,
|
||||||
FullPrice = item.Value.FullPrice,
|
FullPrice = item.Value.inventory.FullPrice,
|
||||||
Discount = item.Value.Discount,
|
Discount = item.Value.inventory.Discount,
|
||||||
ServiceCharge = item.Value.ServiceCharge,
|
ServiceCharge = item.Value.inventory.ServiceCharge,
|
||||||
IsScTaxable = item.Value.IsScTaxable,
|
IsScTaxable = item.Value.inventory.IsScTaxable,
|
||||||
ServiceTaxRate = item.Value.ServiceTaxRate,
|
ServiceTaxRate = item.Value.inventory.ServiceTaxRate,
|
||||||
VatRate = item.Value.VatRate,
|
VatRate = item.Value.inventory.VatRate,
|
||||||
ServiceTax = item.Value.ServiceTax,
|
ServiceTax = item.Value.inventory.ServiceTax,
|
||||||
Vat = item.Value.Vat
|
Vat = item.Value.inventory.Vat
|
||||||
};
|
};
|
||||||
foreach (var mod in item.Value.Modifiers)
|
foreach (var mod in item.Value.inventory.InventoryModifier)
|
||||||
inv.InventoryModifier.Add(new InventoryModifier { Modifier = mod });
|
inv.InventoryModifier.Add(new InventoryModifier { Modifier = mod.Modifier });
|
||||||
kot.Inventories.Add(inv);
|
kot.Inventories.Add(inv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Tanshu.Accounts.Contracts;
|
using System.Linq;
|
||||||
|
using Tanshu.Accounts.Contracts;
|
||||||
using Tanshu.Common;
|
using Tanshu.Common;
|
||||||
using Tanshu.Accounts.Entities;
|
using Tanshu.Accounts.Entities;
|
||||||
|
|
||||||
@ -7,7 +8,8 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
|
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
|
||||||
{
|
{
|
||||||
public delegate void ItemChangedHandler();
|
public delegate void ItemChangedHandler();
|
||||||
public void Load(Voucher voucher) {
|
public void Load(Voucher voucher)
|
||||||
|
{
|
||||||
foreach (var kot in voucher.Kots)
|
foreach (var kot in voucher.Kots)
|
||||||
{
|
{
|
||||||
var kotKey = new BillItemKey(kot.KotID);
|
var kotKey = new BillItemKey(kot.KotID);
|
||||||
@ -16,30 +18,45 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
foreach (var inv in kot.Inventories)
|
foreach (var inv in kot.Inventories)
|
||||||
{
|
{
|
||||||
var key = new BillItemKey(inv.Product.ProductID, kot.KotID);
|
var key = new BillItemKey(inv.Product.ProductID, kot.KotID);
|
||||||
var item = new BillItemValue(inv.Product)
|
var item = new BillItemValue(inv);
|
||||||
{
|
|
||||||
ProductID = inv.Product.ProductID,
|
|
||||||
Discount = inv.Discount,
|
|
||||||
Name =
|
|
||||||
inv.Product.Units == string.Empty
|
|
||||||
? inv.Product.Name
|
|
||||||
: inv.Product.Name + " (" + inv.Product.Units + ")",
|
|
||||||
Price = inv.Price,
|
|
||||||
Printed = true,
|
|
||||||
Quantity = inv.Quantity,
|
|
||||||
IsScTaxable = inv.IsScTaxable,
|
|
||||||
ServiceTaxRate = inv.ServiceTaxRate,
|
|
||||||
VatRate = inv.VatRate,
|
|
||||||
ServiceTax = inv.ServiceTax,
|
|
||||||
Vat = inv.Vat,
|
|
||||||
ServiceCharge = inv.ServiceCharge,
|
|
||||||
};
|
|
||||||
foreach (var mod in inv.InventoryModifier)
|
|
||||||
item.Modifiers.Add(mod.Modifier);
|
|
||||||
this.Add(key, item);
|
this.Add(key, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public decimal Tax
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.ServiceTaxAmount + i.Value.inventory.VatAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public decimal Discount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.DiscountAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public decimal ServiceCharge
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.ServiceChargeAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public decimal NetAmount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Net);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public decimal Amount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11,10 +11,10 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
public interface ISaleForm
|
public interface ISaleForm
|
||||||
{
|
{
|
||||||
void ClearBill(List<BillItemValue> bill);
|
void ClearBill(BillDict bill);
|
||||||
void SetCustomerDisplay(string name);
|
void SetCustomerDisplay(string name);
|
||||||
void CloseWindow();
|
void CloseWindow();
|
||||||
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List<BillItemValue> bill);
|
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, BillDict bill);
|
||||||
void ShowInfo(Voucher voucher);
|
void ShowInfo(Voucher voucher);
|
||||||
void SetUserName(string name);
|
void SetUserName(string name);
|
||||||
BindingSource BindingSource { get; }
|
BindingSource BindingSource { get; }
|
||||||
|
|||||||
@ -30,25 +30,24 @@
|
|||||||
{
|
{
|
||||||
this.flpModifier = new System.Windows.Forms.FlowLayoutPanel();
|
this.flpModifier = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.btnClose = new System.Windows.Forms.Button();
|
this.btnClose = new System.Windows.Forms.Button();
|
||||||
this.flpModifier.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// flpModifier
|
// flpModifier
|
||||||
//
|
//
|
||||||
this.flpModifier.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
this.flpModifier.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
this.flpModifier.Controls.Add(this.btnClose);
|
this.flpModifier.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.flpModifier.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.flpModifier.Location = new System.Drawing.Point(0, 84);
|
||||||
this.flpModifier.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.flpModifier.Name = "flpModifier";
|
this.flpModifier.Name = "flpModifier";
|
||||||
this.flpModifier.Size = new System.Drawing.Size(486, 408);
|
this.flpModifier.Size = new System.Drawing.Size(486, 324);
|
||||||
this.flpModifier.TabIndex = 6;
|
this.flpModifier.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// btnClose
|
// btnClose
|
||||||
//
|
//
|
||||||
this.btnClose.Location = new System.Drawing.Point(3, 3);
|
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); this.btnClose.Location = new System.Drawing.Point(3, 3);
|
||||||
this.btnClose.Name = "btnClose";
|
this.btnClose.Name = "btnClose";
|
||||||
this.btnClose.Size = new System.Drawing.Size(480, 75);
|
this.btnClose.Size = new System.Drawing.Size(480, 75);
|
||||||
this.btnClose.TabIndex = 6;
|
this.btnClose.TabIndex = 7;
|
||||||
this.btnClose.Text = "Close";
|
this.btnClose.Text = "Close";
|
||||||
this.btnClose.UseVisualStyleBackColor = true;
|
this.btnClose.UseVisualStyleBackColor = true;
|
||||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||||
@ -59,16 +58,14 @@
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(486, 408);
|
this.ClientSize = new System.Drawing.Size(486, 408);
|
||||||
this.ControlBox = false;
|
this.ControlBox = false;
|
||||||
|
this.Controls.Add(this.btnClose);
|
||||||
this.Controls.Add(this.flpModifier);
|
this.Controls.Add(this.flpModifier);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "ModifierForm";
|
this.Name = "ModifierForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Modifier";
|
this.Text = "Modifier";
|
||||||
this.Load += new System.EventHandler(this.ModifierForm_Load);
|
this.Load += new System.EventHandler(this.ModifierForm_Load);
|
||||||
this.flpModifier.ResumeLayout(false);
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -14,10 +14,10 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
{
|
{
|
||||||
public partial class ModifierForm : Form
|
public partial class ModifierForm : Form
|
||||||
{
|
{
|
||||||
private IList<Modifier> selection;
|
private IList<InventoryModifier> selection;
|
||||||
private IList<Modifier> source;
|
private IList<Modifier> source;
|
||||||
private IList<CheckBox> list;
|
private IList<CheckBox> list;
|
||||||
public ModifierForm(IList<Modifier> source, IList<Modifier> selection)
|
public ModifierForm(IList<Modifier> source, IList<InventoryModifier> selection)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.selection = selection;
|
this.selection = selection;
|
||||||
@ -28,18 +28,41 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
private void button_Click(object sender, EventArgs e)
|
private void button_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CheckBox button = sender as CheckBox;
|
CheckBox button = sender as CheckBox;
|
||||||
if (button == null)
|
|
||||||
return;
|
|
||||||
if (button.CheckState == CheckState.Checked)
|
if (button.CheckState == CheckState.Checked)
|
||||||
selection.Add((Modifier)button.Tag);
|
selection.Add(new InventoryModifier() { Modifier = (Modifier)button.Tag });
|
||||||
else
|
else
|
||||||
selection.Remove((Modifier)button.Tag);
|
selection.Remove(selection.First(x => x.Modifier.ModifierID == ((Modifier)button.Tag).ModifierID));
|
||||||
}
|
}
|
||||||
public IList<Modifier> Selection
|
private void ModifierForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
get
|
var size = new Point(75, 75);
|
||||||
|
int count = 30;
|
||||||
|
ButtonClickDelegate bcDelegate = new ButtonClickDelegate(button_Click);
|
||||||
|
if (list.Count != 0)
|
||||||
{
|
{
|
||||||
return selection;
|
for (int i = list.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
list[i].Dispose();
|
||||||
|
}
|
||||||
|
list = new List<CheckBox>();
|
||||||
|
}
|
||||||
|
if (count > source.Count)
|
||||||
|
count = source.Count;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var control = new CheckBox()
|
||||||
|
{
|
||||||
|
Name = i.ToString(),
|
||||||
|
Text = source[i].Name,
|
||||||
|
Width = size.X,
|
||||||
|
Height = size.Y,
|
||||||
|
Tag = source[i],
|
||||||
|
Appearance = Appearance.Button,
|
||||||
|
Checked = selection.Count(x => x.Modifier.ModifierID == source[i].ModifierID) > 0
|
||||||
|
};
|
||||||
|
control.Click += new EventHandler(bcDelegate);
|
||||||
|
flpModifier.Controls.Add(control);
|
||||||
|
list.Add(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,10 +71,5 @@ namespace Tanshu.Accounts.PointOfSale
|
|||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ModifierForm_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ControlFactory.GenerateModifiers(ref flpModifier, ref list, selection, new Point(75, 75), 30, source, new ButtonClickDelegate(button_Click));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
System.Windows.Forms.DataGridViewCellStyle dgvCellStyleDisplay = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
System.Windows.Forms.DataGridViewCellStyle dgvCellStyleQuantity = new System.Windows.Forms.DataGridViewCellStyle();
|
||||||
this.label7 = new System.Windows.Forms.Label();
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
this.txtDiscount = new System.Windows.Forms.TextBox();
|
this.txtDiscount = new System.Windows.Forms.TextBox();
|
||||||
this.Label12 = new System.Windows.Forms.Label();
|
this.Label12 = new System.Windows.Forms.Label();
|
||||||
@ -43,8 +43,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.label5 = new System.Windows.Forms.Label();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.txtGrossTax = new System.Windows.Forms.TextBox();
|
this.txtGrossTax = new System.Windows.Forms.TextBox();
|
||||||
this.dgvProducts = new System.Windows.Forms.DataGridView();
|
this.dgvProducts = new System.Windows.Forms.DataGridView();
|
||||||
this.Display = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.displayColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.printedDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
|
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||||
this.pnlBilling = new System.Windows.Forms.Panel();
|
this.pnlBilling = new System.Windows.Forms.Panel();
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
@ -53,7 +52,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.flpGroup = new System.Windows.Forms.FlowLayoutPanel();
|
this.flpGroup = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.flpActions = new System.Windows.Forms.FlowLayoutPanel();
|
this.flpActions = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.btnQuantity = new System.Windows.Forms.Button();
|
this.btnQuantity = new System.Windows.Forms.Button();
|
||||||
this.btnRate = new System.Windows.Forms.Button();
|
this.btnPrice = new System.Windows.Forms.Button();
|
||||||
this.btnDelete = new System.Windows.Forms.Button();
|
this.btnDelete = new System.Windows.Forms.Button();
|
||||||
this.btnDiscount = new System.Windows.Forms.Button();
|
this.btnDiscount = new System.Windows.Forms.Button();
|
||||||
this.btnModifier = new System.Windows.Forms.Button();
|
this.btnModifier = new System.Windows.Forms.Button();
|
||||||
@ -81,6 +80,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.txtBillID = new System.Windows.Forms.TextBox();
|
this.txtBillID = new System.Windows.Forms.TextBox();
|
||||||
this.txtKotID = new System.Windows.Forms.TextBox();
|
this.txtKotID = new System.Windows.Forms.TextBox();
|
||||||
this.btnCustomer = new System.Windows.Forms.Button();
|
this.btnCustomer = new System.Windows.Forms.Button();
|
||||||
|
this.quantityColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
|
||||||
this.pnlBilling.SuspendLayout();
|
this.pnlBilling.SuspendLayout();
|
||||||
@ -190,8 +190,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.dgvProducts.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
|
this.dgvProducts.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
|
||||||
this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dgvProducts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
this.dgvProducts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
this.Display,
|
this.displayColumn,
|
||||||
this.printedDataGridViewTextBoxColumn});
|
this.quantityColumn});
|
||||||
this.dgvProducts.DataSource = this.bindingSource;
|
this.dgvProducts.DataSource = this.bindingSource;
|
||||||
this.dgvProducts.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
|
this.dgvProducts.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
|
||||||
this.dgvProducts.Location = new System.Drawing.Point(12, 90);
|
this.dgvProducts.Location = new System.Drawing.Point(12, 90);
|
||||||
@ -206,31 +206,31 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
//
|
//
|
||||||
// Display
|
// Display
|
||||||
//
|
//
|
||||||
this.Display.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
this.displayColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||||
this.Display.DataPropertyName = "Display";
|
this.displayColumn.DataPropertyName = "Display";
|
||||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
dgvCellStyleDisplay.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
this.Display.DefaultCellStyle = dataGridViewCellStyle1;
|
this.displayColumn.DefaultCellStyle = dgvCellStyleDisplay;
|
||||||
this.Display.HeaderText = "Display";
|
this.displayColumn.HeaderText = "Display";
|
||||||
this.Display.MinimumWidth = 250;
|
this.displayColumn.MinimumWidth = 250;
|
||||||
this.Display.Name = "Display";
|
this.displayColumn.Name = "DisplayColumn";
|
||||||
this.Display.ReadOnly = true;
|
this.displayColumn.ReadOnly = true;
|
||||||
this.Display.Width = 250;
|
this.displayColumn.Width = 250;
|
||||||
//
|
//
|
||||||
// printedDataGridViewTextBoxColumn
|
// quantityColumn
|
||||||
//
|
//
|
||||||
this.printedDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
this.quantityColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||||
this.printedDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
|
this.quantityColumn.DataPropertyName = "Quantity";
|
||||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
|
dgvCellStyleQuantity.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
|
||||||
dataGridViewCellStyle2.Format = "N2";
|
dgvCellStyleQuantity.Format = "N2";
|
||||||
this.printedDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
|
this.quantityColumn.DefaultCellStyle = dgvCellStyleQuantity;
|
||||||
this.printedDataGridViewTextBoxColumn.HeaderText = "Printed";
|
this.quantityColumn.HeaderText = "Quantity";
|
||||||
this.printedDataGridViewTextBoxColumn.Name = "printedDataGridViewTextBoxColumn";
|
this.quantityColumn.Name = "QuantityColumn";
|
||||||
this.printedDataGridViewTextBoxColumn.ReadOnly = true;
|
this.quantityColumn.ReadOnly = true;
|
||||||
this.printedDataGridViewTextBoxColumn.Width = 65;
|
this.quantityColumn.Width = 65;
|
||||||
//
|
//
|
||||||
// bindingSource
|
// bindingSource
|
||||||
//
|
//
|
||||||
this.bindingSource.DataSource = typeof(Tanshu.Accounts.Contracts.BillItemValue);
|
this.bindingSource.DataSource = typeof(System.Collections.Generic.KeyValuePair<Tanshu.Accounts.Contracts.BillItemKey, Tanshu.Accounts.Contracts.BillItemValue>);
|
||||||
//
|
//
|
||||||
// pnlBilling
|
// pnlBilling
|
||||||
//
|
//
|
||||||
@ -309,7 +309,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
// flpActions
|
// flpActions
|
||||||
//
|
//
|
||||||
this.flpActions.Controls.Add(this.btnQuantity);
|
this.flpActions.Controls.Add(this.btnQuantity);
|
||||||
this.flpActions.Controls.Add(this.btnRate);
|
this.flpActions.Controls.Add(this.btnPrice);
|
||||||
this.flpActions.Controls.Add(this.btnDelete);
|
this.flpActions.Controls.Add(this.btnDelete);
|
||||||
this.flpActions.Controls.Add(this.btnDiscount);
|
this.flpActions.Controls.Add(this.btnDiscount);
|
||||||
this.flpActions.Controls.Add(this.btnModifier);
|
this.flpActions.Controls.Add(this.btnModifier);
|
||||||
@ -338,15 +338,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
this.btnQuantity.UseVisualStyleBackColor = true;
|
this.btnQuantity.UseVisualStyleBackColor = true;
|
||||||
this.btnQuantity.Click += new System.EventHandler(this.btnQuantity_Click);
|
this.btnQuantity.Click += new System.EventHandler(this.btnQuantity_Click);
|
||||||
//
|
//
|
||||||
// btnRate
|
// btnPrice
|
||||||
//
|
//
|
||||||
this.btnRate.Location = new System.Drawing.Point(84, 3);
|
this.btnPrice.Location = new System.Drawing.Point(84, 3);
|
||||||
this.btnRate.Name = "btnRate";
|
this.btnPrice.Name = "btnPrice";
|
||||||
this.btnRate.Size = new System.Drawing.Size(75, 75);
|
this.btnPrice.Size = new System.Drawing.Size(75, 75);
|
||||||
this.btnRate.TabIndex = 146;
|
this.btnPrice.TabIndex = 146;
|
||||||
this.btnRate.Text = "&Rate";
|
this.btnPrice.Text = "btnPrice";
|
||||||
this.btnRate.UseVisualStyleBackColor = true;
|
this.btnPrice.UseVisualStyleBackColor = true;
|
||||||
this.btnRate.Click += new System.EventHandler(this.btnRate_Click);
|
this.btnPrice.Click += new System.EventHandler(this.btnPrice_Click);
|
||||||
//
|
//
|
||||||
// btnDelete
|
// btnDelete
|
||||||
//
|
//
|
||||||
@ -657,7 +657,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private System.Windows.Forms.Button btnPrintKot;
|
private System.Windows.Forms.Button btnPrintKot;
|
||||||
private System.Windows.Forms.Button btnPrintBill;
|
private System.Windows.Forms.Button btnPrintBill;
|
||||||
private System.Windows.Forms.Button btnVoid;
|
private System.Windows.Forms.Button btnVoid;
|
||||||
private System.Windows.Forms.Button btnRate;
|
private System.Windows.Forms.Button btnPrice;
|
||||||
private System.Windows.Forms.Button btnClear;
|
private System.Windows.Forms.Button btnClear;
|
||||||
internal System.Windows.Forms.Label lblServiceCharge;
|
internal System.Windows.Forms.Label lblServiceCharge;
|
||||||
internal System.Windows.Forms.TextBox txtServiceCharge;
|
internal System.Windows.Forms.TextBox txtServiceCharge;
|
||||||
@ -668,8 +668,8 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private System.Windows.Forms.FlowLayoutPanel flpMain;
|
private System.Windows.Forms.FlowLayoutPanel flpMain;
|
||||||
private System.Windows.Forms.Button btnDelete;
|
private System.Windows.Forms.Button btnDelete;
|
||||||
private System.Windows.Forms.Button btnMoveTable;
|
private System.Windows.Forms.Button btnMoveTable;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn Display;
|
private System.Windows.Forms.DataGridViewTextBoxColumn displayColumn;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn printedDataGridViewTextBoxColumn;
|
private System.Windows.Forms.DataGridViewTextBoxColumn quantityColumn;
|
||||||
private System.Windows.Forms.Button btnMore;
|
private System.Windows.Forms.Button btnMore;
|
||||||
private System.Windows.Forms.Button btnMoveKot;
|
private System.Windows.Forms.Button btnMoveKot;
|
||||||
private readonly BillController _billController;
|
private readonly BillController _billController;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Tanshu.Accounts.Contracts;
|
using Tanshu.Accounts.Contracts;
|
||||||
@ -173,11 +174,11 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnRate_Click(object sender, EventArgs e)
|
private void btnPrice_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_billController.SetRate();
|
_billController.SetPrice();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -194,14 +195,14 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
private void dgvProducts_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
||||||
{
|
{
|
||||||
var dgv = sender as DataGridView;
|
var dgv = sender as DataGridView;
|
||||||
var data = dgv.Rows[e.RowIndex].DataBoundItem as BillItemValue;
|
var data = (KeyValuePair<BillItemKey, BillItemValue>)dgv.Rows[e.RowIndex].DataBoundItem;
|
||||||
|
|
||||||
if (data.IsKot)
|
if (data.Key.BillItemType == BillItemType.Kot)
|
||||||
{
|
{
|
||||||
e.CellStyle.SelectionBackColor = Color.Blue;
|
e.CellStyle.SelectionBackColor = Color.Blue;
|
||||||
e.CellStyle.BackColor = Color.LightBlue;
|
e.CellStyle.BackColor = Color.LightBlue;
|
||||||
}
|
}
|
||||||
else if (data.Printed)
|
else if (data.Value.inventory.Kot != null)
|
||||||
{
|
{
|
||||||
e.CellStyle.SelectionBackColor = Color.HotPink;
|
e.CellStyle.SelectionBackColor = Color.HotPink;
|
||||||
e.CellStyle.BackColor = Color.LightPink;
|
e.CellStyle.BackColor = Color.LightPink;
|
||||||
@ -211,6 +212,15 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
e.CellStyle.SelectionBackColor = Color.Green;
|
e.CellStyle.SelectionBackColor = Color.Green;
|
||||||
e.CellStyle.BackColor = Color.LightGreen;
|
e.CellStyle.BackColor = Color.LightGreen;
|
||||||
}
|
}
|
||||||
|
if (dgv.Columns[e.ColumnIndex].Name.Equals("DisplayColumn"))
|
||||||
|
e.Value = data.Value.Display;
|
||||||
|
else if (dgv.Columns[e.ColumnIndex].Name.Equals("QuantityColumn"))
|
||||||
|
{
|
||||||
|
if (data.Key.BillItemType != BillItemType.Kot)
|
||||||
|
e.Value = data.Value.inventory.Quantity;
|
||||||
|
else
|
||||||
|
e.Value = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSettle_Click(object sender, EventArgs e)
|
private void btnSettle_Click(object sender, EventArgs e)
|
||||||
@ -220,11 +230,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
|
|
||||||
private void btnModifier_Click(object sender, EventArgs e)
|
private void btnModifier_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var item = _billController.CurrentProduct;
|
_billController.ShowModifiers();
|
||||||
if (item == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_billController.ShowModifiers(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDelete_Click(object sender, EventArgs e)
|
private void btnDelete_Click(object sender, EventArgs e)
|
||||||
@ -254,7 +260,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
{
|
{
|
||||||
btnMore.Text = more ? "Less" : "More";
|
btnMore.Text = more ? "Less" : "More";
|
||||||
btnQuantity.Visible = !more;
|
btnQuantity.Visible = !more;
|
||||||
btnRate.Visible = more;
|
btnPrice.Visible = more;
|
||||||
btnDelete.Visible = !more;
|
btnDelete.Visible = !more;
|
||||||
btnDiscount.Visible = !more;
|
btnDiscount.Visible = !more;
|
||||||
btnModifier.Visible = !more;
|
btnModifier.Visible = !more;
|
||||||
@ -271,7 +277,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
|
|
||||||
#region Helper Functions
|
#region Helper Functions
|
||||||
|
|
||||||
public void ClearBill(List<BillItemValue> bill)
|
public void ClearBill(BillDict bill)
|
||||||
{
|
{
|
||||||
txtBillID.Text = "";
|
txtBillID.Text = "";
|
||||||
txtKotID.Text = "";
|
txtKotID.Text = "";
|
||||||
@ -292,14 +298,14 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount,
|
public void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount,
|
||||||
decimal taxAmount, decimal valueAmount, List<BillItemValue> bill)
|
decimal taxAmount, decimal valueAmount, BillDict bill)
|
||||||
{
|
{
|
||||||
txtGrossTax.Text = string.Format("{0:#0.00}", taxAmount);
|
txtGrossTax.Text = string.Format("{0:#0.00}", taxAmount);
|
||||||
txtDiscount.Text = string.Format("{0:#0.00}", discountAmount);
|
txtDiscount.Text = string.Format("{0:#0.00}", discountAmount);
|
||||||
txtServiceCharge.Text = string.Format("{0:#0.00}", serviceChargeAmount);
|
txtServiceCharge.Text = string.Format("{0:#0.00}", serviceChargeAmount);
|
||||||
txtGrossAmount.Text = string.Format("{0:#0.00}", grossAmount);
|
txtGrossAmount.Text = string.Format("{0:#0.00}", grossAmount);
|
||||||
txtAmount.Text = string.Format("{0:#0.00}", Math.Round(valueAmount));
|
txtAmount.Text = string.Format("{0:#0.00}", Math.Round(valueAmount));
|
||||||
bindingSource.DataSource = bill;
|
bindingSource.DataSource = bill.ToList();
|
||||||
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
|
dgvProducts.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user