From d4ea454addb1bf008a29dba812c13f219395806c Mon Sep 17 00:00:00 2001 From: Tanshu Date: Sat, 5 Oct 2013 15:20:32 +0530 Subject: [PATCH] Feature: Added a net field in printed bill. --- Tanshu.Accounts.Print/Thermal.cs | 20 ------------------- Tanshu.Accounts.Print/ThermalBill.cs | 18 ++++++++++++----- .../BusinessLayer/VoucherBI.cs | 1 - 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/Tanshu.Accounts.Print/Thermal.cs b/Tanshu.Accounts.Print/Thermal.cs index 87786b9..4fa25a4 100644 --- a/Tanshu.Accounts.Print/Thermal.cs +++ b/Tanshu.Accounts.Print/Thermal.cs @@ -71,26 +71,6 @@ namespace Tanshu.Accounts.Print return list.Where(x => x.Vat == rate).Sum(item => item.Quantity * item.Price * (1 - item.Discount) * (1 + (item.IsScTaxable ? item.ServiceCharge : 0)) * item.Vat); } - private static decimal ServiceCharge(IEnumerable list) - { - return list.Sum(item => item.Quantity * item.Price * (1 - item.Discount) * item.ServiceCharge); - } - - private static decimal Discount(IEnumerable list) - { - return list.Sum(item => item.Quantity * item.Price * item.Discount); - } - - private static decimal Net(IEnumerable list) - { - return list.Sum(item => item.Quantity * item.FullPrice); - } - - private static decimal HappyHourDiscount(IEnumerable list) - { - return list.Sum(item => item.Quantity * (item.FullPrice - item.Price)); - } - private static string Name(Product product) { return string.IsNullOrEmpty(product.Units) diff --git a/Tanshu.Accounts.Print/ThermalBill.cs b/Tanshu.Accounts.Print/ThermalBill.cs index 014e325..505d9cf 100644 --- a/Tanshu.Accounts.Print/ThermalBill.cs +++ b/Tanshu.Accounts.Print/ThermalBill.cs @@ -16,19 +16,27 @@ namespace Tanshu.Accounts.Print billText += Products(voucher, list); decimal amount; - amount = Net(list.Values); + amount = list.Values.Sum(item => item.Quantity * item.FullPrice); if (amount != 0) - billText += "\n\r" + FormatText("Net : ", 33, Align.Right) + FormatBillNum(amount, 9); + billText += "\n\r" + FormatText("Total : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = HappyHourDiscount(list.Values); + amount = list.Values.Sum(item => item.Quantity * (item.FullPrice - item.Price)); if (amount != 0) billText += "\n\r" + FormatText("Happy Hour Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = Discount(list.Values); + amount = list.Values.Sum(item => item.Quantity * item.Price * item.Discount); if (amount != 0) billText += "\n\r" + FormatText("Discount : ", 33, Align.Right) + FormatBillNum(amount, 9); - amount = ServiceCharge(list.Values); + amount = list.Values.Sum(item => item.Quantity * item.Price * (1 - item.Discount)); + if (amount != 0) + { + billText += "\n\r" + FormatText(" : ", 33, Align.Right) + "---------"; + billText += "\n\r" + FormatText("Net : ", 33, Align.Right) + FormatBillNum(amount, 9); + + } + + amount = list.Values.Sum(item => item.Quantity * item.Price * (1 - item.Discount) * item.ServiceCharge); if (amount != 0) billText += "\n\r" + FormatText("Service Charge : ", 33, Align.Right) + FormatBillNum(amount, 9); diff --git a/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs b/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs index 464931c..de46b0d 100644 --- a/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs +++ b/Tanshu.Accounts.Repository/BusinessLayer/VoucherBI.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; -using NHibernate.Criterion; using Tanshu.Accounts.Entities; using Tanshu.Common.Helpers; using NHibernate;