narsil/Tanshu.Accounts.BI/CheckoutBI.cs
2010-03-02 23:26:21 +05:30

128 lines
5.0 KiB
C#

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Threading;
using System.Data.SqlClient;
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; }
public decimal CCReceipts { get; private set; }
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; } //
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; }
}
private string cCString;
public string CCString
{
get { return cCString; }
}
private string voidsString;
public string VoidsString
{
get { return voidsString; }
}
private string discountString;
public string DiscountString
{
get { return discountString; }
}
//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)
{
GetFactory factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (IConnectionDAO connection = factory.Connection)
{
using (ICheckoutDAO dao = factory.GetCheckoutDAO(startDate, finishDate, cashier, connection))
{
//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;
PendingBills = dao.GetPending(ref pendingString);
CCReceipts = dao.GetCreditCard(ref cCString);
VoidsInSystem = dao.GetVoids(ref voidsString);
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();
dao.GetDiscountsBills(ref discountString);
ClosingBalance = Opening
+ Receipts
+ AdvanceReceipts
- CCReceipts
- AdvanceAdjusted
- CashPayments
- AdditionalVoids
+ NetSales;
}
}
}
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);
}
}
}