narsil/Tanshu.Accounts.BI/CheckoutBI.cs

151 lines
6.0 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Threading;
using System.Data.SqlClient;
2011-12-05 09:23:02 +00:00
using Tanshu.Accounts.Contracts;
2010-03-02 17:56:21 +00:00
using Tanshu.Accounts.DAOFactory;
using Tanshu.Data.DAO;
namespace Tanshu.Accounts.BI
{
public class CheckoutBI
{
#region Properties
public decimal Opening { get; private set; }
public decimal Receipts { get; private set; }
public decimal AdvanceReceipts { get; private set; }
2011-12-05 09:23:02 +00:00
public decimal CreditCardReceipts { get; private set; }
2010-03-02 17:56:21 +00:00
public decimal AdvanceAdjusted { get; private set; }
public decimal CashPayments { get; private set; }
public decimal AdditionalVoids { get; private set; }
public decimal VoidsInSystem { get; private set; }
public decimal PendingBills { get; private set; }
public decimal NetSales { get; private set; }
public decimal ClosingBalance { get; private set; }
public decimal RetainedOvernight { get; private set; }
public decimal CashDeposited { get; private set; } //
public decimal Excess { get; private set; } //
public string Status { get; private set; } //
public string Cashiers { get; private set; } //
public Guid CashierID { get; private set; } //
public string Cashier { get; private set; } //
2011-12-05 09:23:02 +00:00
public decimal StaffReceipts { get; set; }
public decimal CreditReceipts { get; set; }
2010-03-02 17:56:21 +00:00
public decimal OldPending { get; private set; }
public decimal OldReceipts { get; private set; }
public decimal OldVoided { get; private set; }
public DateTime StartDate { get; private set; } //
public DateTime FinishDate { get; private set; } //
private string pendingString;
public string PendingString
{
get { return pendingString; }
}
2011-12-05 09:23:02 +00:00
private string creditCardString;
2010-03-02 17:56:21 +00:00
public string CCString
{
2011-12-05 09:23:02 +00:00
get { return creditCardString; }
2010-03-02 17:56:21 +00:00
}
2011-12-05 09:23:02 +00:00
private readonly string _voidsString;
2010-03-02 17:56:21 +00:00
public string VoidsString
{
2011-12-05 09:23:02 +00:00
get { return _voidsString; }
2010-03-02 17:56:21 +00:00
}
2011-12-05 09:23:02 +00:00
private readonly string _discountString;
2010-03-02 17:56:21 +00:00
public string DiscountString
{
2011-12-05 09:23:02 +00:00
get { return _discountString; }
}
private readonly string _staffString;
public string StaffString
{
get { return _staffString; }
}
private readonly string _creditString;
public string CreditString
{
get { return _creditString; }
2010-03-02 17:56:21 +00:00
}
//public string PendingString { get; private set; } //
//public string CCString { get; private set; } //
//public string VoidsString { get; private set; }
//public string DiscountString { get; private set; }
public string PaymentString { get; private set; } //
public string Manager
{
get { return Thread.CurrentPrincipal.Identity.Name; }
}
#endregion
public CheckoutBI(Guid cashier, DateTime startDate, DateTime finishDate)
{
2011-12-05 09:23:02 +00:00
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
2010-03-02 17:56:21 +00:00
{
2011-12-05 09:23:02 +00:00
using (var dao = factory.GetCheckoutDAO(startDate, finishDate, cashier, connection))
2010-03-02 17:56:21 +00:00
{
//Actual Closing
this.CashierID = cashier;
this.StartDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", startDate));
this.FinishDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", finishDate));
Cashier = new UserBI().GetUser(CashierID).Name;
2011-12-05 09:23:02 +00:00
PendingBills = dao.GetDetail(ref pendingString, PaidStatus.Pending, "\n\r--- Pending Bills ------------------------");
CreditCardReceipts = dao.GetDetail(ref creditCardString, PaidStatus.CreditCard, "\n\r--- Credit Card Bills --------------------");
VoidsInSystem = dao.GetDetail(ref _voidsString, PaidStatus.Void, "\n\r--- Void Bills ---------------------------");
StaffReceipts = dao.GetDetail(ref _staffString, PaidStatus.Staff, "\n\r--- Staff Bills --------------------------");
CreditReceipts = dao.GetDetail(ref _creditString, PaidStatus.Credit, "\n\r--- Credit Bills -------------------------");
2010-03-02 17:56:21 +00:00
Opening = dao.GetOpenings();
Receipts = dao.GetReceipts();
CashPayments = dao.GetPayments();
AdditionalVoids = dao.GetAdditionalVoids();
RetainedOvernight = dao.GetRetainedOvernight();
AdvanceReceipts = dao.GetAdvancesReceived();
AdvanceAdjusted = dao.GetAdvancesAdjusted();
PaymentString = dao.GetPaymentString();
OldPending = dao.GetOldPending();
OldReceipts = dao.GetOldReceipts();
OldVoided = dao.GetOldVoided();
Cashiers = dao.GetActiveCashiers();
NetSales = dao.GetNetSales();
2011-12-05 09:23:02 +00:00
dao.GetDiscountsBills(ref _discountString);
2010-03-02 17:56:21 +00:00
ClosingBalance = Opening
+ Receipts
+ AdvanceReceipts
2011-12-05 09:23:02 +00:00
+ NetSales
- CreditCardReceipts
- StaffReceipts
- CreditReceipts
2010-03-02 17:56:21 +00:00
- AdvanceAdjusted
- CashPayments
2011-12-05 09:23:02 +00:00
- AdditionalVoids;
2010-03-02 17:56:21 +00:00
}
}
}
2011-12-05 09:23:02 +00:00
2010-03-02 17:56:21 +00:00
public void Calculate(decimal cashDeposited, decimal retainedOvernight)
{
this.CashDeposited = cashDeposited;
this.RetainedOvernight = retainedOvernight;
Excess = CashDeposited - ClosingBalance;
Status = string.Format("{0:Extra Cash Rs #,##0.00; Cash Short Rs #,##0.00;Cash Perfect}", Excess);
}
}
}