168 lines
6.9 KiB
C#
168 lines
6.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
//using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Data.SqlClient;
|
|
using Tanshu.Data.DAO;
|
|
using Tanshu.Accounts.SqlDAO;
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
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 int 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(int cashier, DateTime startDate, DateTime finishDate)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
//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 = 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);
|
|
}
|
|
// public decimal GetPending(ref string info)
|
|
// {
|
|
// using (var session = SessionManager.Session)
|
|
// {
|
|
// var a = from i in session.QueryOver<SaleVoucher>()
|
|
// where i.LastEditDate >= StartDate && i.LastEditDate <= FinishDate && i.User.UserID == userid
|
|
// }
|
|
// decimal amount = 0;
|
|
// info = "";
|
|
|
|
// string query = @"
|
|
//SELECT t.Date, s.BillID, c.Name, SUM(i.Amount) AS Amount, SUM(Quantity * Rate * Discount) AS Discount FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
|
//INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
|
//INNER JOIN Customers c ON s.CustomerID = c.CustomerID
|
|
//WHERE t.Type = 'S'
|
|
//AND t.LastEditDate BETWEEN @StartDate AND @FinishDate AND t.UserID = @UserID
|
|
//AND s.Void = 0 AND s.Paid = 0
|
|
//GROUP BY t.Date, c.Name, s.BillID
|
|
//";
|
|
// using (SqlCommand cmd = new SqlCommand(query))
|
|
// {
|
|
// cmd.Parameters.AddWithValue("@StartDate", startDate);
|
|
// cmd.Parameters.AddWithValue("@FinishDate", finishDate);
|
|
// cmd.Parameters.AddWithValue("@UserID", userID);
|
|
|
|
// using (IDataReader dr = connection.ExecuteReader(cmd))
|
|
// {
|
|
// if (dr.Read())
|
|
// {
|
|
// info = "\n\r--- Pending Bills ------------------------";
|
|
|
|
// do
|
|
// {
|
|
// amount += dr.GetDecimal(3);
|
|
// info += string.Format("\n\r{0:dd-MMM-yyyy HH:mm:ss} {1} {2}", dr.GetDateTime(0), dr.GetString(1), dr.GetString(2));
|
|
// info += string.Format("\n\rAmount: {0:#0.00} :: Discount: {1:#0.00}", dr.GetDecimal(3), dr.GetDecimal(4));
|
|
// info += "\n\r------------------------------------------";
|
|
// } while (dr.Read());
|
|
// }
|
|
// }
|
|
// }
|
|
// return amount;
|
|
// }
|
|
}
|
|
|
|
}
|