2881 lines
139 KiB
C#
2881 lines
139 KiB
C#
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using HRM.BO;
|
|
using HRM.BO.Fund;
|
|
using HRM.DA;
|
|
using HRM.DA.Fund;
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
//using Microsoft.ReportingServices.ReportProcessing.ReportObjectModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Xml;
|
|
using static iTextSharp.awt.geom.Point2D;
|
|
|
|
|
|
|
|
namespace HRM.Report
|
|
{
|
|
public class FundReports
|
|
{
|
|
|
|
public FundReports() { }
|
|
|
|
public byte[] GetMemberInfo(EnumEmpSearchType empStatus, DateTime fromDate, DateTime toDate, string reportType, int fundTypeID)
|
|
{
|
|
byte[] bytes = null;
|
|
DataRow oRow = null;
|
|
List<Member> _members = new List<Member>();
|
|
if (empStatus != 0)
|
|
{
|
|
_members = new MemberService().GetByStatus(empStatus, fundTypeID);
|
|
}
|
|
else
|
|
{
|
|
_members = new MemberService().Get(fromDate, toDate, fundTypeID);
|
|
}
|
|
FundDataSet.FundDataSet.dtMemberInfoDataTable dtMembersInfo = new FundDataSet.FundDataSet.dtMemberInfoDataTable();
|
|
int memcount = _members.Count;
|
|
int livecount = _members.Where(x => x.MemberStatus == EnumEmpStatus.Live).Count();
|
|
|
|
foreach (Member omem in _members)
|
|
{
|
|
oRow = dtMembersInfo.NewRow();
|
|
oRow["EmpNo"] = omem.EmpCode;
|
|
oRow["Name"] = omem.Name;
|
|
oRow["DOJ"] = omem.DOJ.ToString("dd MMM yyyy");
|
|
oRow["PFMemberDate"] = (Convert.ToDateTime(omem.MembershipDate)).ToString("dd MMM yyyy");
|
|
oRow["Status"] = omem.MemberStatus.ToString() == "" ? "NoStatus" : omem.MemberStatus.ToString();
|
|
oRow["Designation"] = omem.Designation.ToString();
|
|
oRow["SalaryInfo"] = omem.CurrentBasic.ToString("#,##0");
|
|
|
|
if (Convert.ToDateTime(omem.FinalSettlementDate) != DateTime.MinValue)
|
|
{
|
|
oRow["SeparationDate"] = (Convert.ToDateTime(omem.FinalSettlementDate)).ToString("dd MMM yyyy");
|
|
}
|
|
else
|
|
{
|
|
oRow["SeparationDate"] = "";
|
|
}
|
|
dtMembersInfo.Rows.Add(oRow);
|
|
}
|
|
|
|
if (dtMembersInfo.Rows.Count > 0)
|
|
{
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
string rdlcName = "Fund_rptMemberInfo.rdlc";
|
|
return reportProcessor.GetMemberInfoReport(null, dtMembersInfo, livecount, reportType, fundTypeID, rdlcName);
|
|
}
|
|
return bytes;
|
|
}
|
|
public byte[] GetMemberYearlyReport(EnumEmpStatus status, DateTime fromDate, DateTime toDate,
|
|
string reportType, int fundTypeID)
|
|
{
|
|
byte[] bytes = null;
|
|
|
|
string empCode = string.Empty;
|
|
List<Member> oMembers = new List<Member>();
|
|
oMembers = new MemberService().GetByFundType(fundTypeID);
|
|
double amountTotal = 0;
|
|
DataSet dtYearlyReport = null;
|
|
dtYearlyReport = new MembersTransactionDetailsService().GetMembersYearlyBalance(fromDate, toDate, fundTypeID);
|
|
|
|
FundDataSet.FundDataSet.dtMembersScheduleDataTable odt = new FundDataSet.FundDataSet.dtMembersScheduleDataTable();
|
|
DataRow odR = null;
|
|
|
|
foreach (Member omember in oMembers)
|
|
{
|
|
|
|
// discard who become member after todate
|
|
if (omember.MembershipDate > toDate)
|
|
continue;
|
|
|
|
// discard who settled before to fromdate
|
|
if (omember.FinalSettlementDate < fromDate)
|
|
continue;
|
|
|
|
if (status == EnumEmpStatus.Live && omember.MemberStatus != EnumEmpStatus.Live)
|
|
continue;
|
|
|
|
if ((status == EnumEmpStatus.Setteled || status == EnumEmpStatus.Discontinued)
|
|
&& omember.MemberStatus == EnumEmpStatus.Live)
|
|
continue;
|
|
|
|
|
|
odR = odt.NewRow();
|
|
amountTotal = 0;
|
|
odR["EmpIDNo"] = omember.EmpCode;
|
|
|
|
odR["Name"] = omember.Name;
|
|
EnumEmpStatus enems = (EnumEmpStatus)Enum.Parse(typeof(EnumEmpStatus), omember.MemberStatus.ToString());
|
|
odR["DOJ"] = omember.DOJ.ToString("dd MMM yyyy");
|
|
|
|
odR["DOL"] = omember.DOL?.ToString("dd MMM yyyy") ?? "";
|
|
odR["Status"] = enems.ToString();
|
|
|
|
|
|
|
|
#region removed code
|
|
//if (omember.DOL != null)
|
|
//{
|
|
// if ((!(omember.DOL >= fromDate) && !(omember.DOL <= toDate)))
|
|
// {
|
|
// odR["DOL"] = "";
|
|
// odR["Status"] = "Live";
|
|
// }
|
|
// else if (omember.DOL > toDate)
|
|
// {
|
|
// if (status.ToString() != "Setteled")
|
|
// {
|
|
// odR["DOL"] = "";
|
|
// odR["Status"] = "Live";
|
|
// }
|
|
// }
|
|
// else if (omember.DOL >= fromDate && omember.DOL <= toDate)
|
|
// {
|
|
// if (status.ToString() == omember.MemberStatus.ToString())
|
|
// {
|
|
// if (status.ToString() == "Setteled" && (status == EnumEmpStatus.Setteled || status == EnumEmpStatus.All))
|
|
// {
|
|
// DateTime dol = Convert.ToDateTime(omember.DOL.ToString());
|
|
// odR["DOL"] = dol.ToString("dd MMM yyyy");
|
|
// odR["Status"] = enems.ToString();
|
|
// }
|
|
// else
|
|
// {
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// continue;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// continue;
|
|
// }
|
|
//}
|
|
|
|
//if (status.ToString() == "Setteled")
|
|
//{
|
|
// if (omember.DOL != null)
|
|
// {
|
|
// if (((omember.DOL <= fromDate) || (omember.DOL >= toDate)) && (!(omember.DOL.Value.Year == fromDate.Year) && !(omember.DOL.Value.Year == toDate.Year)))
|
|
// {
|
|
// continue;
|
|
// }
|
|
|
|
// }
|
|
// else if (omember.DOL == null)
|
|
// {
|
|
// continue;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
DateTime membershipdate = Convert.ToDateTime(omember.MembershipDate.ToString());
|
|
odR["MembershipDate"] = membershipdate.ToString("dd MMM yyyy");
|
|
|
|
|
|
|
|
foreach (DataRow orow in dtYearlyReport.Tables[2].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
odR["OwnContribution"] = Convert.ToDouble(orow["CurEPF"].ToString());
|
|
double dEPF = Convert.ToDouble(orow["CurEPF"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["CurEPF"].ToString());
|
|
odR["CompanyContribution"] = Convert.ToDouble(orow["CurCPF"].ToString());
|
|
double dcpf = Convert.ToDouble(orow["CurCPF"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["CurCPF"].ToString());
|
|
}
|
|
}
|
|
|
|
foreach (DataRow orow in dtYearlyReport.Tables[1].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
odR["OwnOpeningInterest"] = Convert.ToDouble(orow["EPFINTEREST"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["EPFINTEREST"].ToString());
|
|
odR["CompanyOpeningInterest"] = Convert.ToDouble(orow["CPFINTEREST"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["CPFINTEREST"].ToString());
|
|
}
|
|
}
|
|
|
|
foreach (DataRow orow in dtYearlyReport.Tables[0].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
odR["OwnOpeningBalance"] = Convert.ToDouble(orow["EPF"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["EPF"].ToString());
|
|
odR["CompanyOpeningBalance"] = Convert.ToDouble(orow["CPF"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["CPF"].ToString());
|
|
}
|
|
}
|
|
|
|
foreach (DataRow orow in dtYearlyReport.Tables[3].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
odR["OwnContributionInterest"] = Convert.ToDouble(orow["CurEPFINTEREST"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["CurEPFINTEREST"].ToString());
|
|
odR["CompanyContributionInterest"] = Convert.ToDouble(orow["CurCPFINTEREST"].ToString());
|
|
amountTotal = amountTotal + Convert.ToDouble(orow["CurCPFINTEREST"].ToString());
|
|
}
|
|
}
|
|
|
|
foreach (DataRow orow in dtYearlyReport.Tables[4].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
odR["DuringEPFWithdrawal"] = Convert.ToDouble(orow["CurEPFWithdrawal"].ToString());
|
|
odR["DuringCPFWithdrawal"] = Convert.ToDouble(orow["CurCPFWithdrawal"].ToString());
|
|
}
|
|
}
|
|
foreach (DataRow orow in dtYearlyReport.Tables[5].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
double x = Convert.ToDouble(orow["CurEPFInterestWithdrawal"].ToString());
|
|
double x1 = Convert.ToDouble(orow["CurCPFInterestWithdrawal"].ToString());
|
|
odR["OwnInterestWithdrawal"] = Convert.ToDouble(orow["CurEPFInterestWithdrawal"].ToString());
|
|
odR["CompanyInterestWithdrawal"] = Convert.ToDouble(orow["CurCPFInterestWithdrawal"].ToString());
|
|
}
|
|
}
|
|
|
|
foreach (DataRow orow in dtYearlyReport.Tables[6].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"].ToString()))
|
|
{
|
|
odR["EPFIntAdj"] = 0.00; //Convert.ToDouble(orow["CurEPFInterestAdjustment"].ToString());
|
|
odR["CPFIntAdj"] = 0.00; //Convert.ToDouble(orow["CurCPFInterestAdjustment"].ToString());
|
|
}
|
|
}
|
|
if (amountTotal != 0)
|
|
{
|
|
odt.Rows.Add(odR);
|
|
}
|
|
|
|
}
|
|
|
|
DataTable dt = odt.Copy();
|
|
DataView dv = dt.DefaultView;
|
|
dv.Sort = "EmpIDNo";
|
|
dt = dv.ToTable();
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ReportForMembersSchedule(null, dt, reportType, fundTypeID, fromDate, toDate);
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
|
|
public byte[] GetMemberVolYearlyReport(EnumEmpStatus status, DateTime fromDate, DateTime toDate,
|
|
string reportType, int fundTypeID)
|
|
{
|
|
byte[] bytes = null;
|
|
|
|
string empCode = string.Empty;
|
|
List<Member> oMembers = new List<Member>();
|
|
oMembers = new MemberService().GetByFundType(fundTypeID);
|
|
double amountTotal = 0;
|
|
DataSet dtYearlyReport = null;
|
|
dtYearlyReport = new MembersTransactionDetailsService().GetMembersVolYearlyBalance(fromDate, toDate, fundTypeID);
|
|
|
|
FundDataSet.FundDataSet.dtMembersVolScheduleDataTable odt = new FundDataSet.FundDataSet.dtMembersVolScheduleDataTable();
|
|
DataRow odR = null;
|
|
|
|
foreach (Member omember in oMembers)
|
|
{
|
|
// discard who become member after todate
|
|
if (omember.MembershipDate > toDate)
|
|
continue;
|
|
|
|
// discard who settled before to fromdate
|
|
if (omember.FinalSettlementDate < fromDate)
|
|
continue;
|
|
|
|
if (status == EnumEmpStatus.Live && omember.MemberStatus != EnumEmpStatus.Live)
|
|
continue;
|
|
|
|
if ((status == EnumEmpStatus.Setteled || status == EnumEmpStatus.Discontinued)
|
|
&& omember.MemberStatus == EnumEmpStatus.Live)
|
|
continue;
|
|
|
|
odR = odt.NewRow();
|
|
amountTotal = 0;
|
|
|
|
odR["EmpIDNo"] = omember.EmpCode;
|
|
odR["Name"] = omember.Name;
|
|
|
|
EnumEmpStatus enems = (EnumEmpStatus)Enum.Parse(typeof(EnumEmpStatus), omember.MemberStatus.ToString());
|
|
|
|
if (omember.DOL == null)
|
|
{
|
|
odR["DOL"] = "";
|
|
odR["Status"] = enems.ToString();
|
|
}
|
|
|
|
DateTime membershipdate = Convert.ToDateTime(omember.MembershipDate.ToString());
|
|
odR["MembershipDate"] = membershipdate.ToString("dd MMM yyyy");
|
|
|
|
// ---- Current Contribution (Table[2]) -------------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[2].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["OwnContribution"] = Convert.ToDouble(orow["CurEPF"]);
|
|
amountTotal += Convert.ToDouble(orow["CurEPF"]);
|
|
|
|
odR["CompanyContribution"] = Convert.ToDouble(orow["CurCPF"]);
|
|
amountTotal += Convert.ToDouble(orow["CurCPF"]);
|
|
|
|
// NEW: Voluntary Contribution
|
|
odR["VolContribution"] = Convert.ToDouble(orow["CurVolEPF"]);
|
|
amountTotal += Convert.ToDouble(orow["CurVolEPF"]);
|
|
}
|
|
}
|
|
|
|
// ---- Opening Balance Interest (Table[1]) ---------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[1].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["OwnOpeningInterest"] = Convert.ToDouble(orow["EPFINTEREST"]);
|
|
amountTotal += Convert.ToDouble(orow["EPFINTEREST"]);
|
|
|
|
odR["CompanyOpeningInterest"] = Convert.ToDouble(orow["CPFINTEREST"]);
|
|
amountTotal += Convert.ToDouble(orow["CPFINTEREST"]);
|
|
|
|
// NEW: Voluntary Interest
|
|
odR["VolOpeningInterest"] = Convert.ToDouble(orow["VolEPFINTEREST"]);
|
|
amountTotal += Convert.ToDouble(orow["VolEPFINTEREST"]);
|
|
}
|
|
}
|
|
|
|
// ---- Opening Balance (Table[0]) ------------------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[0].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["OwnOpeningBalance"] = Convert.ToDouble(orow["EPF"]);
|
|
amountTotal += Convert.ToDouble(orow["EPF"]);
|
|
|
|
odR["CompanyOpeningBalance"] = Convert.ToDouble(orow["CPF"]);
|
|
amountTotal += Convert.ToDouble(orow["CPF"]);
|
|
|
|
// NEW: Voluntary Opening Balance
|
|
odR["VolOpeningBalance"] = Convert.ToDouble(orow["VolEPF"]);
|
|
amountTotal += Convert.ToDouble(orow["VolEPF"]);
|
|
}
|
|
}
|
|
|
|
// ---- Current Interest (Table[3]) ------------------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[3].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["OwnContributionInterest"] = Convert.ToDouble(orow["CurEPFINTEREST"]);
|
|
amountTotal += Convert.ToDouble(orow["CurEPFINTEREST"]);
|
|
|
|
odR["CompanyContributionInterest"] = Convert.ToDouble(orow["CurCPFINTEREST"]);
|
|
amountTotal += Convert.ToDouble(orow["CurCPFINTEREST"]);
|
|
|
|
// NEW: Voluntary Contribution Interest
|
|
odR["VolContributionInterest"] = Convert.ToDouble(orow["CurVolEPFINTEREST"]);
|
|
amountTotal += Convert.ToDouble(orow["CurVolEPFINTEREST"]);
|
|
}
|
|
}
|
|
|
|
// ---- Withdrawals (Table[4]) ------------------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[4].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["DuringEPFWithdrawal"] = Convert.ToDouble(orow["CurEPFWithdrawal"]);
|
|
odR["DuringCPFWithdrawal"] = Convert.ToDouble(orow["CurCPFWithdrawal"]);
|
|
|
|
// NEW: Voluntary Withdrawal
|
|
odR["VolWithdrawal"] = Convert.ToDouble(orow["CurVolEPFWithdrawal"]);
|
|
}
|
|
}
|
|
|
|
// ---- Interest Withdrawals (Table[5]) ------------------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[5].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["OwnInterestWithdrawal"] = Convert.ToDouble(orow["CurEPFInterestWithdrawal"]);
|
|
odR["CompanyInterestWithdrawal"] = Convert.ToDouble(orow["CurCPFInterestWithdrawal"]);
|
|
|
|
// NEW: Voluntary Interest Withdrawal
|
|
odR["VolInterestWithdrawal"] = Convert.ToDouble(orow["CurVolEPFInterestWithdrawal"]);
|
|
}
|
|
}
|
|
|
|
// ---- Interest Adjustment (Table[6]) ------------------------------
|
|
foreach (DataRow orow in dtYearlyReport.Tables[6].Rows)
|
|
{
|
|
if (omember.ID == Convert.ToInt32(orow["MemberID"]))
|
|
{
|
|
odR["EPFIntAdj"] = 0.00; //Convert.ToDouble(orow["CurEPFInterestAdjustment"]);
|
|
odR["CPFIntAdj"] = 0.00; //Convert.ToDouble(orow["CurCPFInterestAdjustment"]);
|
|
|
|
// NEW: Voluntary Adjustment
|
|
odR["VolIntAdj"] = 0.00; //Convert.ToDouble(orow["CurVolEPFInterestAdjustment"]);
|
|
}
|
|
}
|
|
|
|
if (amountTotal != 0)
|
|
{
|
|
odt.Rows.Add(odR);
|
|
}
|
|
}
|
|
|
|
DataTable dt = odt.Copy();
|
|
DataView dv = dt.DefaultView;
|
|
dv.Sort = "EmpIDNo";
|
|
dt = dv.ToTable();
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ReportForVolMembersSchedule(null, dt, reportType, fundTypeID, fromDate, toDate);
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
private string VoucherTypeName(EnumGLTranType tranType)
|
|
{
|
|
switch (tranType)
|
|
{
|
|
case EnumGLTranType.BankPayment:
|
|
return "Bank Payment";
|
|
|
|
case EnumGLTranType.BankReceipt:
|
|
return "Bank Receipt";
|
|
|
|
case EnumGLTranType.BankToBank:
|
|
return "Bank To Bank";
|
|
|
|
case EnumGLTranType.BankToCash:
|
|
return "Bank To Cash";
|
|
|
|
case EnumGLTranType.CashPayment:
|
|
return "Cash Payment";
|
|
|
|
case EnumGLTranType.CashReceipt:
|
|
return "Cash Receipt";
|
|
|
|
case EnumGLTranType.CashToBank:
|
|
return "Cash To Bank";
|
|
|
|
case EnumGLTranType.CashToCash:
|
|
return "Cash To Cash";
|
|
|
|
case EnumGLTranType.JournalVoucher:
|
|
return "Journal Voucher";
|
|
case EnumGLTranType.OpeningVoucher:
|
|
return "Opening Voucher";
|
|
|
|
default: return "";
|
|
}
|
|
}
|
|
|
|
private string FindDecscription(GLTranUserRecord gtur, GLTranDetail gtd, GLTran gt)
|
|
{
|
|
string des = string.Empty;
|
|
if (gtur != null)
|
|
{
|
|
des = gtur.Description;
|
|
}
|
|
if (string.IsNullOrEmpty(des))
|
|
{
|
|
if (gtd != null)
|
|
{
|
|
des = gtd.Description;
|
|
}
|
|
if (string.IsNullOrEmpty(des))
|
|
{
|
|
des = gt.Description;
|
|
}
|
|
}
|
|
return des;
|
|
}
|
|
|
|
public byte[] LedgerReport(DateTime fromDate, DateTime toDate, List<GL> gls, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
|
|
DataTable ledger = new FundDataSet.FundDataSet.dtLedgerDataTable();
|
|
DataRow rpt_new_row;
|
|
foreach (GL gl in gls)
|
|
{
|
|
#region opening balance
|
|
double amount;
|
|
|
|
//open balance
|
|
amount = new GLTranService().GetOpeningBalance(gl.ID, fromDate);
|
|
|
|
ledger.Rows.Add(ledger.NewRow());
|
|
rpt_new_row = ledger.Rows[ledger.Rows.Count - 1];
|
|
|
|
rpt_new_row["glid"] = gl.ID;
|
|
rpt_new_row["VoucherType"] = gl.GLCode + "-" + gl.GLDescription;
|
|
rpt_new_row["Description"] = "Balance B/F";
|
|
|
|
amount = Math.Round(amount, 2);
|
|
if (gl.GLType == EnumGLType.Asset || gl.GLType == EnumGLType.Expenditure)
|
|
amount = -amount;
|
|
|
|
|
|
rpt_new_row["Balance"] = Math.Round(amount, 2);// (amount < 0) ? (Math.Round(amount, 2)).ToString() : Math.Round(amount, 2).ToString();
|
|
|
|
rpt_new_row["StartDate"] = fromDate.ToString("dd MMM yyyy");
|
|
rpt_new_row["EndDate"] = toDate.ToString("dd MMM yyyy");
|
|
#endregion opening balance
|
|
|
|
List<GLTran> gts = new List<GLTran>();
|
|
List<GLTran> gtsWithoutOpen = new GLTranService().GetGLTransOrderByDate(fromDate, toDate, gl);
|
|
|
|
gts = gtsWithoutOpen;
|
|
|
|
DataRow prev_row;
|
|
|
|
|
|
foreach (GLTran gt in gts)
|
|
{
|
|
foreach (GLTranDetail gtd in gt.GlTranDetails)
|
|
{
|
|
if (gtd.GLID != gl.ID) continue;
|
|
ledger.Rows.Add(ledger.NewRow());
|
|
rpt_new_row = ledger.Rows[ledger.Rows.Count - 1];
|
|
prev_row = ledger.Rows[ledger.Rows.Count - 2];
|
|
|
|
rpt_new_row["glid"] = gtd.GLID.ToString();
|
|
rpt_new_row["TranDate"] = gt.VoucherDate.ToString("dd MMM yyyy");
|
|
rpt_new_row["VoucherNo"] = gt.VoucherNo;
|
|
rpt_new_row["VoucherType"] = VoucherTypeName(gt.GLTranType);
|
|
rpt_new_row["Description"] = FindDecscription(null, gtd, gt);
|
|
if (gl.GLType == EnumGLType.Asset || gl.GLType == EnumGLType.Expenditure)
|
|
{
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_new_row["DebitAmount"] = Math.Round((decimal)gtd.Amount, 2);
|
|
amount = amount + gtd.Amount;
|
|
rpt_new_row["Balance"] = amount;
|
|
}
|
|
else
|
|
{
|
|
rpt_new_row["CreditAmount"] = Math.Round((decimal)gtd.Amount, 2);
|
|
amount = amount - gtd.Amount;
|
|
rpt_new_row["Balance"] = amount;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_new_row["DebitAmount"] = Math.Round((decimal)gtd.Amount, 2);
|
|
amount = amount - gtd.Amount;
|
|
rpt_new_row["Balance"] = amount;
|
|
}
|
|
else
|
|
{
|
|
rpt_new_row["CreditAmount"] = Math.Round((decimal)gtd.Amount, 2);
|
|
amount = amount + gtd.Amount;
|
|
rpt_new_row["Balance"] = amount;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#region closing
|
|
|
|
ledger.Rows.Add(ledger.NewRow());
|
|
rpt_new_row = ledger.Rows[ledger.Rows.Count - 1];
|
|
prev_row = ledger.Rows[ledger.Rows.Count - 2];
|
|
rpt_new_row["glid"] = gl.ID.ToString();
|
|
|
|
rpt_new_row["description"] = "Closing Balance";
|
|
|
|
rpt_new_row["Balance"] = amount;
|
|
|
|
#endregion closing
|
|
}
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.LedgerReport(ledger, reportType, fundTypeID);
|
|
|
|
return bytes;
|
|
}
|
|
|
|
public byte[] MakeIndividualMemberConReport(Member oMember, DateTime fromDate, DateTime toDate, string reportType, int fundTypeID)
|
|
{
|
|
try
|
|
{
|
|
DateTime tempTranDate = DateTime.MinValue;
|
|
DataRow odr = null;
|
|
double dOpeningBalance = 0.0;
|
|
|
|
FundDataSet.FundDataSet.dtIndividualMemberConDataTable oIndividualMemConDataTable = new FundDataSet.FundDataSet.dtIndividualMemberConDataTable();
|
|
Member member = oMember;
|
|
|
|
if (member != null)
|
|
{
|
|
double amountOfEPF = 0, amountOfCPF = 0, interestOfEPF = 0, interestOfCPF = 0;
|
|
double amountofEPFWithdrawal = 0, amountofCPFWithdrawal = 0, amountofCPFWithdrawalInterest = 0, amountofEPFWithdrawalInterest = 0;
|
|
int tempMonth = 0;
|
|
string searchCondition = string.Empty;
|
|
|
|
|
|
MembersTransactionDetailsService membersTransactionDetailsService = new MembersTransactionDetailsService();
|
|
|
|
searchCondition = SQLParser.MakeSQL(" and TranDate between %d and %d", GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(toDate));
|
|
dOpeningBalance = membersTransactionDetailsService.GetOpeningBalance(member.ID, fromDate);
|
|
|
|
List<MembersTransactionDetail> memTranDetailColl = membersTransactionDetailsService.GetMemberContribution(member.ID, searchCondition);
|
|
|
|
var dateGroupData = memTranDetailColl.GroupBy(x => x.TranDate);
|
|
List<MembersTransactionDetail> TempMemTranDetailColl = new List<MembersTransactionDetail>();
|
|
DateTime TempDate = DateTime.MinValue;
|
|
foreach (var item in dateGroupData)
|
|
{
|
|
if (TempDate != item.Key)
|
|
{
|
|
odr = oIndividualMemConDataTable.NewRow();
|
|
TempDate = item.Key;
|
|
TempMemTranDetailColl = memTranDetailColl.FindAll(x => x.TranDate == item.Key);
|
|
interestOfEPF = 0;
|
|
interestOfCPF = 0;
|
|
amountOfCPF = 0;
|
|
amountOfEPF = 0;
|
|
amountofCPFWithdrawal = 0;
|
|
amountofEPFWithdrawal = 0;
|
|
amountofCPFWithdrawalInterest = 0;
|
|
amountofEPFWithdrawalInterest = 0;
|
|
}
|
|
foreach (MembersTransactionDetail memTranDetail in TempMemTranDetailColl)
|
|
{
|
|
DateTime tranDate = memTranDetail.TranDate;
|
|
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest || memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest || memTranDetail.TranTypeID == EnumMemberTranType.CPF_Opening || memTranDetail.TranTypeID == EnumMemberTranType.EFP_Opening || memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest_Opening || memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest_Opening
|
|
)
|
|
{
|
|
if (tempTranDate != memTranDetail.TranDate || tempTranDate == DateTime.MinValue)
|
|
{
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
|
|
odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM yyyy");
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest)
|
|
{
|
|
interestOfEPF = interestOfEPF + memTranDetail.Amount;
|
|
odr["EPFInterest"] = interestOfEPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest)
|
|
{
|
|
interestOfCPF = interestOfCPF + memTranDetail.Amount;
|
|
odr["CPFInterest"] = interestOfCPF;
|
|
}
|
|
oIndividualMemConDataTable.Rows.Add(odr);
|
|
tempTranDate = memTranDetail.TranDate;
|
|
}
|
|
else if (tempTranDate == memTranDetail.TranDate)
|
|
{
|
|
if (tempMonth != memTranDetail.TranDate.Month)
|
|
{
|
|
interestOfCPF = 0; interestOfEPF = 0;
|
|
}
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest)
|
|
{
|
|
interestOfEPF = interestOfEPF + memTranDetail.Amount;
|
|
odr["EPFInterest"] = interestOfEPF;
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest)
|
|
{
|
|
interestOfCPF = interestOfCPF + memTranDetail.Amount;
|
|
odr["CPFInterest"] = interestOfCPF;
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if (tempTranDate != memTranDetail.TranDate || tempTranDate == DateTime.MinValue)
|
|
{
|
|
|
|
odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM yyyy");
|
|
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF)
|
|
{
|
|
amountOfEPF = amountOfEPF + memTranDetail.Amount;
|
|
odr["EPFContribution"] = amountOfEPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF)
|
|
{
|
|
amountOfCPF = amountOfCPF + memTranDetail.Amount;
|
|
odr["CPFContribution"] = amountOfCPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EFP_WithDrawl)
|
|
{
|
|
amountofEPFWithdrawal = amountofEPFWithdrawal + memTranDetail.Amount;
|
|
odr["EPFWithdrawal"] = amountofEPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl)
|
|
{
|
|
amountofCPFWithdrawal = amountofCPFWithdrawal + memTranDetail.Amount;
|
|
odr["CPFWithdrawal"] = amountofCPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_WithDrawl_Interest)
|
|
{
|
|
amountofEPFWithdrawalInterest = amountofEPFWithdrawalInterest + memTranDetail.Amount;
|
|
odr["WithdrawalEPFInterest"] = amountofEPFWithdrawalInterest;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl_Interest)
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest + memTranDetail.Amount;
|
|
odr["WithdrawalCPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
oIndividualMemConDataTable.Rows.Add(odr);
|
|
tempTranDate = memTranDetail.TranDate;
|
|
|
|
}
|
|
else if (tempTranDate == memTranDetail.TranDate)
|
|
{
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF)
|
|
{
|
|
amountOfEPF = amountOfEPF + memTranDetail.Amount;
|
|
odr["EPFContribution"] = amountOfEPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF)
|
|
{
|
|
amountOfCPF = amountOfCPF + memTranDetail.Amount;
|
|
odr["CPFContribution"] = amountOfCPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EFP_WithDrawl)
|
|
{
|
|
amountofEPFWithdrawal = amountofEPFWithdrawal + memTranDetail.Amount;
|
|
odr["EPFWithdrawal"] = amountofEPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl)
|
|
{
|
|
amountofCPFWithdrawal = amountofCPFWithdrawal + memTranDetail.Amount;
|
|
odr["CPFWithdrawal"] = amountofCPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_WithDrawl_Interest)
|
|
{
|
|
amountofEPFWithdrawalInterest = amountofEPFWithdrawalInterest + memTranDetail.Amount;
|
|
odr["WithdrawalEPFInterest"] = amountofEPFWithdrawalInterest;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl_Interest)
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest + memTranDetail.Amount;
|
|
odr["WithdrawalCPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
string rdlcName = "Fund_rptIndividualMemberCon.rdlc";
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ReportForIndividualMemberConForKCCL(null, member, oIndividualMemConDataTable, reportType, fundTypeID, rdlcName, dOpeningBalance);
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return null;
|
|
|
|
}
|
|
public byte[] MakeIndividualMemberVoluntaryConReport(Member oMember, DateTime fromDate, DateTime toDate, string reportType, int fundTypeID)
|
|
{
|
|
try
|
|
{
|
|
DateTime tempTranDate = DateTime.MinValue;
|
|
DataRow odr = null;
|
|
double dOpeningBalance = 0.0;
|
|
|
|
FundDataSet.FundDataSet.dtIndividualMemberVolantaryConDataTable oIndividualMemConDataTable = new FundDataSet.FundDataSet.dtIndividualMemberVolantaryConDataTable();
|
|
Member member = oMember;
|
|
|
|
if (member != null)
|
|
{
|
|
double amountOfEPF = 0, amountOfCPF = 0, interestOfEPF = 0, interestOfCPF = 0, voluntaryInterest = 0, amountOfVoluntary = 0;
|
|
double amountofEPFWithdrawal = 0, amountofCPFWithdrawal = 0, amountofCPFWithdrawalInterest = 0, amountofEPFWithdrawalInterest = 0, amountOfVoluntaryWithdrawal = 0, amountofVoluntaryWithdrawalInterest = 0;
|
|
int tempMonth = 0;
|
|
string searchCondition = string.Empty;
|
|
|
|
|
|
MembersTransactionDetailsService membersTransactionDetailsService = new MembersTransactionDetailsService();
|
|
|
|
searchCondition = SQLParser.MakeSQL(" and TranDate between %d and %d", GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(toDate));
|
|
dOpeningBalance = membersTransactionDetailsService.GetOpeningBalance(member.ID, fromDate);
|
|
List<MembersTransactionDetail> memTranDetailColl = membersTransactionDetailsService.GetMemberContribution(member.ID, searchCondition);
|
|
|
|
var dateGroupData = memTranDetailColl.GroupBy(x => x.TranDate);
|
|
List<MembersTransactionDetail> TempMemTranDetailColl = new List<MembersTransactionDetail>();
|
|
DateTime TempDate = DateTime.MinValue;
|
|
foreach (var item in dateGroupData)
|
|
{
|
|
if (TempDate != item.Key)
|
|
{
|
|
odr = oIndividualMemConDataTable.NewRow();
|
|
TempDate = item.Key;
|
|
TempMemTranDetailColl = memTranDetailColl.FindAll(x => x.TranDate == item.Key);
|
|
}
|
|
foreach (MembersTransactionDetail memTranDetail in TempMemTranDetailColl)
|
|
{
|
|
DateTime tranDate = memTranDetail.TranDate;
|
|
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_Opening || memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest_Opening ||
|
|
memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest || memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest ||
|
|
memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Interest || memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Interest_Opening
|
|
)
|
|
{
|
|
if (tempTranDate != memTranDetail.TranDate || tempTranDate == DateTime.MinValue)
|
|
{
|
|
interestOfCPF = 0; interestOfEPF = 0;
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
|
|
odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM yyyy");
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest)
|
|
{
|
|
interestOfEPF = interestOfEPF + memTranDetail.Amount;
|
|
odr["EPFInterest"] = interestOfEPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest)
|
|
{
|
|
interestOfCPF = interestOfCPF + memTranDetail.Amount;
|
|
odr["CPFInterest"] = interestOfCPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Interest)
|
|
{
|
|
voluntaryInterest = voluntaryInterest + memTranDetail.Amount;
|
|
odr["VoluntaryEPFInterest"] = voluntaryInterest;
|
|
}
|
|
oIndividualMemConDataTable.Rows.Add(odr);
|
|
tempTranDate = memTranDetail.TranDate;
|
|
}
|
|
else if (tempTranDate == memTranDetail.TranDate)
|
|
{
|
|
if (tempMonth != memTranDetail.TranDate.Month)
|
|
{
|
|
interestOfCPF = 0; interestOfEPF = 0; voluntaryInterest = 0;
|
|
}
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest)
|
|
{
|
|
interestOfEPF = interestOfEPF + memTranDetail.Amount;
|
|
odr["EPFInterest"] = interestOfEPF;
|
|
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest)
|
|
{
|
|
interestOfCPF = interestOfCPF + memTranDetail.Amount;
|
|
odr["CPFInterest"] = interestOfCPF;
|
|
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Interest)
|
|
{
|
|
voluntaryInterest = voluntaryInterest + memTranDetail.Amount;
|
|
odr["VoluntaryEPFInterest"] = voluntaryInterest;
|
|
tempMonth = memTranDetail.TranDate.Month;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if (tempTranDate != memTranDetail.TranDate || tempTranDate == DateTime.MinValue)
|
|
{
|
|
amountOfCPF = 0; amountOfEPF = 0;
|
|
amountOfVoluntary = 0;
|
|
amountofCPFWithdrawal = 0;
|
|
amountofCPFWithdrawal = 0;
|
|
amountofCPFWithdrawalInterest = 0;
|
|
amountOfVoluntaryWithdrawal = 0;
|
|
amountofVoluntaryWithdrawalInterest = 0;
|
|
amountofEPFWithdrawalInterest = 0;
|
|
odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM yyyy");
|
|
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF)
|
|
{
|
|
amountOfEPF = amountOfEPF + memTranDetail.Amount;
|
|
odr["EPFContribution"] = amountOfEPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF)
|
|
{
|
|
amountOfCPF = amountOfCPF + memTranDetail.Amount;
|
|
odr["CPFContribution"] = amountOfCPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_EFP)
|
|
{
|
|
amountOfVoluntary = amountOfVoluntary + memTranDetail.Amount;
|
|
odr["VoluntaryEPF"] = amountOfVoluntary;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EFP_WithDrawl)
|
|
{
|
|
amountofEPFWithdrawal = amountofEPFWithdrawal + memTranDetail.Amount;
|
|
odr["EPFWithdrawal"] = amountofEPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl)
|
|
{
|
|
amountofCPFWithdrawal = amountofCPFWithdrawal + memTranDetail.Amount;
|
|
odr["CPFWithdrawal"] = amountofCPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Withdrawal)
|
|
{
|
|
amountOfVoluntaryWithdrawal = amountOfVoluntaryWithdrawal + memTranDetail.Amount;
|
|
odr["VoluntaryWithdrawal"] = amountOfVoluntaryWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_WithDrawl_Interest)
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest + memTranDetail.Amount;
|
|
odr["WithdrawalEPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl_Interest)
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest - memTranDetail.Amount;
|
|
odr["WithdrawalCPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Withdrawal_Interest) //not sure
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest - memTranDetail.Amount;
|
|
odr["WithdrawalCPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
oIndividualMemConDataTable.Rows.Add(odr);
|
|
tempTranDate = memTranDetail.TranDate;
|
|
|
|
}
|
|
else if (tempTranDate == memTranDetail.TranDate)
|
|
{
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF)
|
|
{
|
|
amountOfEPF = amountOfEPF + memTranDetail.Amount;
|
|
odr["EPFContribution"] = amountOfEPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF)
|
|
{
|
|
amountOfCPF = amountOfCPF + memTranDetail.Amount;
|
|
odr["CPFContribution"] = amountOfCPF;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_EFP)
|
|
{
|
|
amountOfVoluntary = amountOfVoluntary + memTranDetail.Amount;
|
|
odr["VoluntaryEPF"] = amountOfVoluntary;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EFP_WithDrawl)
|
|
{
|
|
amountofEPFWithdrawal = amountofEPFWithdrawal + memTranDetail.Amount;
|
|
odr["EPFWithdrawal"] = amountofEPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl)
|
|
{
|
|
amountofCPFWithdrawal = amountofCPFWithdrawal + memTranDetail.Amount;
|
|
odr["CPFWithdrawal"] = amountofCPFWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Withdrawal)
|
|
{
|
|
amountOfVoluntaryWithdrawal = amountOfVoluntaryWithdrawal + memTranDetail.Amount;
|
|
odr["VoluntaryWithdrawal"] = amountOfVoluntaryWithdrawal;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_WithDrawl_Interest)
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest + memTranDetail.Amount;
|
|
odr["WithdrawalEPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_WithDrawl_Interest)
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest - memTranDetail.Amount;
|
|
odr["WithdrawalCPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.Voluntary_Withdrawal_Interest) //not sure
|
|
{
|
|
amountofCPFWithdrawalInterest = amountofCPFWithdrawalInterest - memTranDetail.Amount;
|
|
odr["WithdrawalCPFInterest"] = amountofCPFWithdrawalInterest;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
string rdlcName = "Fund_rptIndividualMemberVoluntaryCon.rdlc";
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ReportForIndividualMemberVoluntaryConForKCCL(null, member, oIndividualMemConDataTable, reportType, fundTypeID, rdlcName, dOpeningBalance);
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return null;
|
|
|
|
}
|
|
public byte[] MakeIndividualMemberLedgerReport(Member oMember, DateTime Fromdate, DateTime Todate, string reportType, int fundTypeID)
|
|
{
|
|
try
|
|
{
|
|
DateTime tempTranDate = DateTime.MinValue;
|
|
DataRow odr = null;
|
|
double dOpeningBalance = 0.0;
|
|
FundDataSet.FundDataSet.dtIndividualMemberConDataTable oIndividualMemConDataTable = new FundDataSet.FundDataSet.dtIndividualMemberConDataTable();
|
|
Member member = oMember;
|
|
|
|
if (member != null)
|
|
{
|
|
string searchCondition = string.Empty;
|
|
MembersTransactionDetail membersTransactionDetail = new MembersTransactionDetail();
|
|
searchCondition = SQLParser.MakeSQL(" and TranDate between %d and %d", Fromdate, Todate);
|
|
dOpeningBalance = new MembersTransactionDetailsService().GetOpeningBalance(member.ID, Fromdate);
|
|
List<MembersTransactionDetail> memTranDetailColl = new MembersTransactionDetailsService().GetMemberContribution(member.ID, searchCondition);
|
|
|
|
foreach (MembersTransactionDetail memTranDetail in memTranDetailColl)
|
|
{
|
|
if (memTranDetail.Amount != 0)
|
|
{
|
|
odr = oIndividualMemConDataTable.NewRow();
|
|
|
|
odr["EmployeeNo"] = member.EmpCode;
|
|
odr["Name"] = member.Name;
|
|
odr["Status"] = member.MemberStatus;
|
|
odr["MonthOfContribution"] = memTranDetail.TranDate.ToString("dd MMM yyyy");
|
|
EnumMemberTranType otrn = (EnumMemberTranType)memTranDetail.TranTypeID;
|
|
odr["TranTypeName"] = (string)otrn.ToString();
|
|
if (memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest || memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest_Opening ||
|
|
memTranDetail.TranTypeID == EnumMemberTranType.EPF_Interest
|
|
)
|
|
{
|
|
odr["EPFInterest"] = memTranDetail.Amount;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest || memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest_Opening ||
|
|
memTranDetail.TranTypeID == EnumMemberTranType.CPF_Interest)
|
|
{
|
|
odr["CPFInterest"] = memTranDetail.Amount;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.EPF) //memTranDetail.TranTypeID == (int)EnumMemberTranType.InterestAdjustment &&
|
|
{
|
|
odr["EPFIntAdj"] = memTranDetail.Amount;
|
|
}
|
|
else if (memTranDetail.TranTypeID == EnumMemberTranType.CPF) //(memTranDetail.TranTypeID == (int)EnumMemberTranType.InterestAdjustment &&
|
|
{
|
|
odr["CPFIntAdj"] = memTranDetail.Amount;
|
|
}
|
|
else if (EnumMemberTranType.EPF == (EnumMemberTranType)memTranDetail.TranTypeID || EnumMemberTranType.EFP_Opening == (EnumMemberTranType)memTranDetail.TranTypeID)
|
|
{
|
|
odr["EPFContribution"] = memTranDetail.Amount;
|
|
}
|
|
else if (EnumMemberTranType.CPF == (EnumMemberTranType)memTranDetail.TranTypeID || EnumMemberTranType.CPF == (EnumMemberTranType)memTranDetail.TranTypeID)
|
|
{
|
|
odr["CPFContribution"] = memTranDetail.Amount;
|
|
}
|
|
//else if (EnumMemberTranType.EPF_LTA == (EnumMemberTranType)memTranDetail.TranTypeID.Integer)
|
|
//{
|
|
// odr["EPFContribution"] = memTranDetail.Amount;
|
|
//}
|
|
//else if (EnumMemberTranType.CPF_LTA == (EnumMemberTranType)memTranDetail.TranTypeID.Integer)
|
|
//{
|
|
// odr["CPFContribution"] = memTranDetail.Amount;
|
|
//}
|
|
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
oIndividualMemConDataTable.Rows.Add(odr);
|
|
}
|
|
}
|
|
|
|
|
|
string rdlcName = "Fund_rptIndividualMemberCon.rdlc";
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ReportForIndividualMemberLedgerForKCCL(null, oIndividualMemConDataTable, reportType, fundTypeID, rdlcName);
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return null;
|
|
|
|
}
|
|
|
|
public byte[] GetMemberPFContribution(Member oMember, DateTime Todate, string reportType, CurrentUser currentUser, int fundTypeID)
|
|
{
|
|
try
|
|
{
|
|
|
|
DateTime dtEndMonth = new MembersTransactionDetailsService().GetMonth(oMember.ID);
|
|
|
|
FundDataSet.FundDataSet.dtIndividualMemberConDataTable oIndividualMemConDataTable = new FundDataSet.FundDataSet.dtIndividualMemberConDataTable();
|
|
DataRow owithRow = null;
|
|
string searchCondition = string.Empty;
|
|
if (oMember != null)
|
|
{
|
|
int firstYear = 2005;
|
|
int secondYear = Todate.Year;
|
|
int Years = secondYear - firstYear;
|
|
|
|
for (int i = 0; i < Years; i++)
|
|
{
|
|
string Date = " and TranDate between '01 July " + firstYear.ToString() + "' and '30 June " + Convert.ToString(firstYear + 1) + "'";
|
|
System.Data.DataSet odata = new MembersTransactionDetailsService().GetMemberContributionDataTable(oMember.ID, Date, fundTypeID);
|
|
|
|
if (odata != null)
|
|
{
|
|
foreach (DataRow orr in odata.Tables[0].Rows)
|
|
{
|
|
double x = Convert.ToDouble(orr["EPF"].ToString());
|
|
double y = Convert.ToDouble(orr["CPF"].ToString());
|
|
|
|
if (Convert.ToDouble(orr["EPF"].ToString()) != 0 && Convert.ToDouble(orr["CPF"].ToString()) != 0)
|
|
{
|
|
owithRow = oIndividualMemConDataTable.NewRow();
|
|
|
|
owithRow["Name"] = oMember.Name;
|
|
owithRow["FromDate"] = "July " + firstYear.ToString();
|
|
if (i + 1 < Years)
|
|
{
|
|
owithRow["ToDate"] = "June " + Convert.ToString(firstYear + 1);
|
|
}
|
|
else if (i + 1 == Years)
|
|
{
|
|
owithRow["ToDate"] = dtEndMonth.ToString("MMM") + " " + dtEndMonth.ToString("yyyy");
|
|
}
|
|
owithRow["EPFContribution"] = Convert.ToDouble(orr["EPF"].ToString());
|
|
owithRow["CPFContribution"] = Convert.ToDouble(orr["CPF"].ToString());
|
|
owithRow["EPFInterest"] = Convert.ToDouble(orr["EPFINTEREST"].ToString());
|
|
owithRow["CPFInterest"] = Convert.ToDouble(orr["CPFINTEREST"].ToString());
|
|
owithRow["EPFIntAdj"] = Convert.ToDouble(orr["EPFINTERESTAdjustment"].ToString());
|
|
owithRow["CPFIntAdj"] = Convert.ToDouble(orr["CPFINTERESTAdjustment"].ToString());
|
|
|
|
oIndividualMemConDataTable.Rows.Add(owithRow);
|
|
}
|
|
}
|
|
}
|
|
firstYear = firstYear + 1;
|
|
}
|
|
|
|
if (oIndividualMemConDataTable.Rows.Count > 0)
|
|
{
|
|
string rdlcName = "Fund_rptNewMemberBalanceSummary.rdlc";
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ReportForMemberPFContribution(null, oIndividualMemConDataTable, reportType, rdlcName, currentUser, oMember, fundTypeID);
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e.InnerException == null)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
private void insertUperLevelAmount(FundDataSet.FundDataSet.dtTrialBalanceDataTable trialBalance, int level)
|
|
{
|
|
DataRow rpt_row_i, rpt_row_j; int j;
|
|
int loopCounter = trialBalance.Rows.Count;
|
|
for (int i = 0; i < loopCounter; i++)
|
|
{
|
|
rpt_row_i = trialBalance.Rows[i];
|
|
int tierNO = Convert.ToInt32(rpt_row_i["tierNo"]);
|
|
EnumGLType glType = (EnumGLType)Convert.ToInt32(rpt_row_i["glType"]);
|
|
if (tierNO == level - 1) //upper level
|
|
{
|
|
decimal openDrAmount = 0, openCrAmount = 0, duringDrAmount = 0, duringCrAmount = 0, closeDrAmount = 0, closeCrAmount = 0;
|
|
int upLevelindex = i; bool foundChild = false;
|
|
for (j = i + 1; j < loopCounter; j++)
|
|
{
|
|
rpt_row_j = trialBalance.Rows[j];
|
|
int child_tier = Convert.ToInt32(rpt_row_j["tierNo"]);
|
|
if (child_tier <= level - 1) break;
|
|
if (child_tier != level) continue;
|
|
foundChild = true;
|
|
openDrAmount += Convert.ToDecimal(rpt_row_j["openDrAmount"]);
|
|
openCrAmount += Convert.ToDecimal(rpt_row_j["openCrAmount"]);
|
|
duringDrAmount += Convert.ToDecimal(rpt_row_j["duringDrAmount"]);
|
|
duringCrAmount += Convert.ToDecimal(rpt_row_j["duringCrAmount"]);
|
|
closeDrAmount += Convert.ToDecimal(rpt_row_j["closeDrAmount"]);
|
|
closeCrAmount += Convert.ToDecimal(rpt_row_j["closeCrAmount"]);
|
|
}
|
|
i = j - 1;
|
|
|
|
rpt_row_i["openDrAmount"] = openDrAmount;
|
|
rpt_row_i["openCrAmount"] = openCrAmount;
|
|
rpt_row_i["duringDrAmount"] = duringDrAmount;
|
|
rpt_row_i["duringCrAmount"] = duringCrAmount;
|
|
rpt_row_i["closeDrAmount"] = closeDrAmount;
|
|
rpt_row_i["closeCrAmount"] = closeCrAmount;
|
|
|
|
|
|
if (!foundChild)
|
|
{ trialBalance.Rows.RemoveAt(upLevelindex); loopCounter--; i--; }
|
|
}
|
|
}
|
|
}
|
|
|
|
private string getSpace(int a)
|
|
{
|
|
string s = string.Empty;
|
|
for (int i = 0; i < a - 2; i++)
|
|
s = s + " ";
|
|
return s;
|
|
}
|
|
|
|
public byte[] TrialBalanceReport(int uptoglLevel, bool isIncludingSub, DateTime fromDate, DateTime toDate, bool isCascading, int fundTypeID, string reportType, int payrollTypeId)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
FundDataSet.FundDataSet.dtTrialBalanceDataTable dtTrialBalances = new FundDataSet.FundDataSet.dtTrialBalanceDataTable();
|
|
int glLevel = 4;
|
|
DataTable gls = new DataTable();
|
|
|
|
gls = new GLService().GetGLs(glLevel, fundTypeID);
|
|
|
|
DataRow rpt_row;
|
|
foreach (DataRow row in gls.Rows)
|
|
{
|
|
//increasePSGB();
|
|
dtTrialBalances.Rows.Add(dtTrialBalances.NewRow());
|
|
rpt_row = dtTrialBalances.Rows[dtTrialBalances.Rows.Count - 1];
|
|
|
|
int tierNo = Convert.ToInt32(row["TierNo"]);
|
|
int glID = (Convert.ToInt32(row["GLID"]));
|
|
EnumGLType glType = (EnumGLType)Convert.ToInt32(row["GLType"]);
|
|
|
|
string sp = getSpace(tierNo);
|
|
rpt_row["uptoGLLevel"] = uptoglLevel;
|
|
rpt_row["acntCode"] = sp + Convert.ToString(row["GLCode"]);
|
|
rpt_row["acntName"] = sp + Convert.ToString(row["GLDescription"]);
|
|
rpt_row["tierNo"] = tierNo;
|
|
rpt_row["glType"] = glType;
|
|
if (tierNo != glLevel) continue;
|
|
// get only the bottommost level's amounts, upperlevels' amount will be found from sum
|
|
|
|
double openDrAmount, openCrAmount, duringDrAmount, duringCrAmount, closeDrAmount, closeCrAmount;
|
|
//opening balance -1 days addded because we calculate opening balance as last day closing balance
|
|
openDrAmount = new GLTranService().GetOpeningBalanceOnSide(glID, fromDate, EnumTranSide.Debit);
|
|
openCrAmount = new GLTranService().GetOpeningBalanceOnSide(glID, fromDate, EnumTranSide.Credit);
|
|
|
|
if (openCrAmount > openDrAmount)
|
|
{
|
|
openCrAmount = openCrAmount - openDrAmount;
|
|
openDrAmount = 0;
|
|
}
|
|
else
|
|
{
|
|
openDrAmount = openDrAmount - openCrAmount;
|
|
openCrAmount = 0;
|
|
}
|
|
|
|
duringDrAmount = new GLTranService().GetTranSideBalance(glID, EnumTranSide.Debit, fromDate, toDate);
|
|
duringCrAmount = new GLTranService().GetTranSideBalance(glID, EnumTranSide.Credit, fromDate, toDate);
|
|
|
|
//closing balance
|
|
closeDrAmount = openDrAmount + duringDrAmount;
|
|
closeCrAmount = openCrAmount + duringCrAmount;
|
|
if (closeCrAmount > closeDrAmount)
|
|
{
|
|
closeCrAmount = closeCrAmount - closeDrAmount;
|
|
closeDrAmount = 0;
|
|
}
|
|
else
|
|
{
|
|
closeDrAmount = closeDrAmount - closeCrAmount;
|
|
closeCrAmount = 0;
|
|
}
|
|
|
|
rpt_row["openDrAmount"] = openDrAmount;
|
|
rpt_row["openCrAmount"] = openCrAmount;
|
|
rpt_row["duringDrAmount"] = duringDrAmount;
|
|
rpt_row["duringCrAmount"] = duringCrAmount;
|
|
rpt_row["closeDrAmount"] = closeDrAmount;
|
|
rpt_row["closeCrAmount"] = closeCrAmount;
|
|
|
|
if (openDrAmount == 0 && openCrAmount == 0 && closeDrAmount == 0 &&
|
|
closeCrAmount == 0 && duringDrAmount == 0 && duringCrAmount == 0)
|
|
{
|
|
dtTrialBalances.Rows.RemoveAt(dtTrialBalances.Rows.Count - 1);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
for (int thisLevel = glLevel; thisLevel > 2; thisLevel--) // 2 --> SystemConfig.GroupLevel
|
|
{
|
|
insertUperLevelAmount(dtTrialBalances, thisLevel);
|
|
}
|
|
|
|
|
|
DataRow drow; //drow_next;
|
|
|
|
int count = dtTrialBalances.Rows.Count;//2
|
|
for (int m = 0; m < count; m++)
|
|
{
|
|
drow = dtTrialBalances.Rows[m];
|
|
if (!isCascading)
|
|
{
|
|
if (Convert.ToInt32(drow["tierno"]) < uptoglLevel)
|
|
{ dtTrialBalances.Rows.RemoveAt(m); m--; count--; }
|
|
}
|
|
}
|
|
|
|
|
|
//date range and other parameter
|
|
if (dtTrialBalances.Rows.Count == 0) dtTrialBalances.Rows.Add(dtTrialBalances.NewRow());
|
|
|
|
string reportname = string.Empty;
|
|
|
|
// reportname += "Level: " + SystemConfig.GetGLLevelName(uptoglLevel);
|
|
dtTrialBalances.Rows[0]["trialBalanceName"] = reportname;
|
|
dtTrialBalances.Rows[0]["dateRange"] = "From: " + fromDate.ToString("dd MMM yyyy") + " To: " + toDate.ToString("dd MMM yyyy");
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForTrialBalance(null, dtTrialBalances, fundTypeID, reportType);
|
|
return bytes;
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
|
|
}
|
|
|
|
public byte[] GetBSReport(DateTime processingDate, int fundTypeID, int payrollTypeId, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
decimal inventory = 0;
|
|
decimal profit = 0;
|
|
FundDataSet.FundDataSet.dtSpecialReportDataTable dtSpecialReport = new FundDataSet.FundDataSet.dtSpecialReportDataTable();
|
|
DataRow drRow = null;
|
|
RDReport oRDReport = new RDReport();
|
|
oRDReport = new RDReportService().GetByReportTypeAndFundTypeID(EnumReportTypes.BS, fundTypeID);
|
|
|
|
List<RDReportRow> oRDReportRows = new List<RDReportRow>();
|
|
oRDReportRows = new RDReportRowService().GetByReoprtIDAndFundTypeID(oRDReport.ID, fundTypeID);
|
|
if (oRDReportRows.Count > 0)
|
|
{
|
|
foreach (RDReportRow oItem in oRDReportRows)
|
|
{
|
|
drRow = dtSpecialReport.NewRow();
|
|
|
|
drRow["RowID"] = oItem.ID;
|
|
drRow["ReportID"] = oItem.ReportID;
|
|
drRow["RowCode"] = oItem.RowCode;
|
|
drRow["AccountName"] = oItem.RowDescription;
|
|
drRow["SLNo"] = oItem.SerialNo;
|
|
|
|
drRow["RowType"] = (int)oItem.RowType;
|
|
|
|
drRow["AmountFrom"] = (int)oItem.AmountFrom;
|
|
|
|
if (oItem.AmountFrom == EnumAmountFrom.FromGL)
|
|
{
|
|
drRow["Amount"] = ReportGlobal.GetBalanceForBS(oItem.RDRowAmountCalItems, processingDate.AddDays(1));
|
|
|
|
if (oItem.FromOtherSourceType == EnumFromOtherSourceType.PL)
|
|
{
|
|
drRow["Amount"] = Convert.ToDecimal(drRow["Amount"]) + profit;
|
|
}
|
|
|
|
if (oItem.FromOtherSourceType == EnumFromOtherSourceType.Inventory)
|
|
{
|
|
if (oItem.FromOtherSourceOperator == EnumOperator.Addition)
|
|
{
|
|
drRow["Amount"] = inventory;
|
|
}
|
|
else
|
|
{
|
|
drRow["Amount"] = -inventory;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double total = 0;
|
|
double subTotal = 0;
|
|
foreach (RowSumCalcItem rowSumCalc in oItem.RowSumCalcItems)
|
|
{
|
|
if (rowSumCalc.RDReportRow.RDRowAmountCalItems != null && rowSumCalc.RDReportRow.RDRowAmountCalItems.Count > 0)
|
|
{
|
|
subTotal = ReportGlobal.GetBalanceForBS(rowSumCalc.RDReportRow.RDRowAmountCalItems, processingDate.AddDays(1));
|
|
if (rowSumCalc.Operator == EnumOperator.Addition)
|
|
{
|
|
total = total + subTotal;
|
|
}
|
|
else
|
|
{
|
|
total = total - subTotal;
|
|
}
|
|
}
|
|
|
|
}
|
|
drRow["Amount"] = total;
|
|
|
|
}
|
|
|
|
if (oItem.RowType == EnumRowType.NormalRow)
|
|
{
|
|
drRow["Notes"] = oItem.Note;
|
|
}
|
|
|
|
dtSpecialReport.Rows.Add(drRow);
|
|
}
|
|
|
|
DataTable GLAmountTable = new DataTable();
|
|
decimal _nAssetAmount = 0m, _nLiabilitiesAmount = 0m;
|
|
GLAmountTable = dtSpecialReport;
|
|
foreach (DataRow oRow in GLAmountTable.Rows)
|
|
{
|
|
try
|
|
{
|
|
if (Convert.ToInt32(oRow["AmountFrom"]) == (int)EnumAmountFrom.FromRow)
|
|
{
|
|
DataRow drow = dtSpecialReport.Rows.Find(oRow["RowID"]);
|
|
drow["Amount"] = ReportGlobal.GetRowSUM(dtSpecialReport, Convert.ToInt32(oRow["RowID"]));
|
|
drow.AcceptChanges();
|
|
if (Convert.ToString(oRow["RowCode"]) == "0011")
|
|
{
|
|
_nAssetAmount = Convert.ToDecimal(drow["Amount"]);
|
|
}
|
|
if (Convert.ToString(oRow["RowCode"]) == "0024")
|
|
{
|
|
_nLiabilitiesAmount = Convert.ToDecimal(drow["Amount"]);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
|
|
}
|
|
string balanceSheet = "Balance Sheet at " + processingDate.ToString("dd MMM yyyy");
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForBS(null, dtSpecialReport, balanceSheet, fundTypeID, reportType, fundTypeID);
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
|
|
}
|
|
private string CalculateServiceDuration(DateTime startDate, DateTime endDate)
|
|
{
|
|
int years = endDate.Year - startDate.Year;
|
|
int months = endDate.Month - startDate.Month;
|
|
int days = endDate.Day - startDate.Day;
|
|
|
|
if (days < 0)
|
|
{
|
|
months--;
|
|
days += DateTime.DaysInMonth(endDate.Year, endDate.Month);
|
|
}
|
|
|
|
if (months < 0)
|
|
{
|
|
years--;
|
|
months += 12;
|
|
}
|
|
|
|
return $"{years} Years, {months} Months, {days} Days";
|
|
}
|
|
|
|
private int CalculateGFLength(DateTime startDate, DateTime endDate)
|
|
{
|
|
int years = endDate.Year - startDate.Year;
|
|
int months = endDate.Month - startDate.Month;
|
|
int days = endDate.Day - startDate.Day;
|
|
|
|
if (days < 0)
|
|
{
|
|
months--;
|
|
days += DateTime.DaysInMonth(endDate.Year, endDate.Month);
|
|
}
|
|
|
|
if (months < 0)
|
|
{
|
|
years--;
|
|
months += 12;
|
|
}
|
|
|
|
if (months > 5 || (months == 5 && days > 29))
|
|
{
|
|
years++;
|
|
}
|
|
else if (months == 5 && days == 29)
|
|
{
|
|
}
|
|
else if (months == 5 && days == 29)
|
|
{
|
|
years--;
|
|
}
|
|
|
|
return years;
|
|
}
|
|
public byte[] GetGratuityProvisioneport(DateTime operationDate, int payrollTypeId, int fundTypeID, string reportType)
|
|
{
|
|
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
DataSet ds = new DataSet();
|
|
DataRow oRow = null;
|
|
List<Member> _members = new List<Member>();
|
|
_members = new MemberService().GetByFundType(fundTypeID);
|
|
FundDataSet.FundDataSet.dtGratuityProvisionDataTable dtGratuityProvision = new FundDataSet.FundDataSet.dtGratuityProvisionDataTable();
|
|
int memcount = _members.Count;
|
|
int livecount = _members.Where(x => x.MemberStatus == EnumEmpStatus.Live).Count();
|
|
int SLNo = 0;
|
|
double lastBasic, gfEligibleAmount, benefitFactor;
|
|
int gfLength;
|
|
List<BO.Fund.ESBSlab> _esbslabList = new List<BO.Fund.ESBSlab>();
|
|
_esbslabList = new ESBSlabService().GetByFundTypeID(fundTypeID);
|
|
foreach (Member omem in _members)
|
|
{
|
|
if (omem.MemberStatus == EnumEmpStatus.Live)
|
|
{
|
|
SLNo++;
|
|
oRow = dtGratuityProvision.NewRow();
|
|
oRow["SLNo"] = SLNo.ToString();
|
|
oRow["EmpID"] = omem.EmpCode;
|
|
oRow["EmployeeName"] = omem.Name;
|
|
oRow["DateOfJoining"] = (Convert.ToDateTime(omem.DOJ)).ToString("dd MMM yyyy");
|
|
oRow["CutOff"] = operationDate.ToString("dd MMM yyyy");
|
|
oRow["ServiceDuration"] = CalculateServiceDuration(omem.DOJ, operationDate);
|
|
oRow["GFLength"] = CalculateGFLength(omem.DOJ, operationDate);
|
|
oRow["LastBasic"] = Math.Round(omem.CurrentBasic, 2).ToString("N2");
|
|
lastBasic = Math.Round(omem.CurrentBasic, 2);
|
|
gfEligibleAmount = 0.00;
|
|
gfLength = CalculateGFLength(omem.DOJ, operationDate);
|
|
benefitFactor = GetBenefitFactor(gfLength, _esbslabList);
|
|
gfEligibleAmount = lastBasic * benefitFactor * gfLength;
|
|
oRow["GFEligibleAmount"] = Math.Round(gfEligibleAmount, 2).ToString("N2");
|
|
oRow["Outgoing"] = "";
|
|
oRow["Closing"] = Math.Round(gfEligibleAmount, 2).ToString("N2");
|
|
dtGratuityProvision.Rows.Add(oRow);
|
|
}
|
|
|
|
}
|
|
|
|
if (dtGratuityProvision.Rows.Count > 0)
|
|
{
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForGratuityProvision(dtGratuityProvision, memcount, livecount, payrollTypeId, reportType, fundTypeID);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
return bytes;
|
|
}
|
|
public double GetBenefitFactor(int gfLength, List<BO.Fund.ESBSlab> _esbslabList)
|
|
{
|
|
|
|
double benefitFactor = 0;
|
|
try
|
|
{
|
|
if (_esbslabList.Count > 0)
|
|
{
|
|
benefitFactor = _esbslabList.Where(esbslab => esbslab.ServiceYear <= gfLength)
|
|
.OrderByDescending(esbslab => esbslab.ServiceYear)
|
|
.Select(esbsLab => esbsLab.CalculNo)
|
|
.FirstOrDefault();
|
|
}
|
|
return benefitFactor;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// will make data table and add to Profit and loss dataset , this is done for saving the rpt to SavedReport table
|
|
/// </summary>
|
|
/// <param name="dtSpecialRpt"> the table prepared by 'public DataTable PreparePL(decimal COGS, decimal Tax)' method</param>
|
|
///
|
|
//private void makeProfitAndLoss_Level_zero(DataTable dtSpecialRpt)
|
|
//{
|
|
// FundDataSet.FundDataSet.dtProfitANDLossDataTable masterTable = new FundDataSet.FundDataSet.dtProfitANDLossDataTable();
|
|
// masterTable.TableName = EnumReportTypes.P_L.ToString();
|
|
// DataRow rptRow;
|
|
// DataSet _profitANDLoss = null;
|
|
// //dtSpecialRpt: AccountName RowType Amount Notes
|
|
// //SavedReportRowID ParentSavedReportRowID RowName RowAmount1 RowType RowAmount2 RowAmount3 Notes
|
|
// int id = 1;
|
|
// foreach (DataRow row in dtSpecialRpt.Rows)
|
|
// {
|
|
// masterTable.Rows.Add(masterTable.NewRow());
|
|
// rptRow = masterTable.Rows[masterTable.Rows.Count - 1];
|
|
// rptRow["SavedReportRowID"] = id; // dummy id, wont be saved in DB
|
|
// rptRow["ParentSavedReportRowID"] = DBNull.Value;
|
|
// rptRow["RowName"] = row["AccountName"];
|
|
// rptRow["RowAmount1"] = row["Amount"];
|
|
// rptRow["RowType"] = row["RowType"];
|
|
// rptRow["Notes"] = row["Notes"];
|
|
// id++;
|
|
// }
|
|
// masterTable.PrimaryKey = new DataColumn[] { masterTable.Columns["SavedReportRowID"] };
|
|
// _profitANDLoss = new DataSet();
|
|
// ProfitAndLoss.Tables.Add(masterTable);
|
|
//}
|
|
|
|
public byte[] GetIncomeStatmentReport(DateTime fromDate, DateTime toDate, int fundTypeID, int payrollTypeId, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
decimal COGS = 0, Tax = 0;
|
|
decimal _provisionForTaxAmount = Tax;
|
|
|
|
FundDataSet.FundDataSet.dtSpecialReportDataTable dtSpecialReport = new FundDataSet.FundDataSet.dtSpecialReportDataTable();
|
|
DataRow drRow = null;
|
|
|
|
RDReport oRDReport = new RDReport();
|
|
oRDReport = new RDReportService().GetByReportTypeAndFundTypeID(EnumReportTypes.P_L, fundTypeID);
|
|
|
|
List<RDReportRow> oRDReportRows = new List<RDReportRow>();
|
|
oRDReportRows = new RDReportRowService().GetByReoprtIDAndFundTypeID(oRDReport.ID, fundTypeID);
|
|
|
|
foreach (RDReportRow oItem in oRDReportRows)
|
|
{
|
|
drRow = dtSpecialReport.NewRow();
|
|
|
|
drRow["RowID"] = oItem.ID;
|
|
drRow["RowCode"] = oItem.RowCode;
|
|
drRow["ReportID"] = oItem.ReportID;
|
|
drRow["AccountName"] = oItem.RowDescription; //save
|
|
drRow["SLNo"] = oItem.SerialNo;
|
|
|
|
drRow["RowType"] = (int)oItem.RowType; //save
|
|
drRow["FromOtherSourceType"] = (int)oItem.FromOtherSourceType;
|
|
|
|
drRow["AmountFrom"] = (int)oItem.AmountFrom;
|
|
drRow["Amount"] = 0;
|
|
|
|
if (oItem.AmountFrom == EnumAmountFrom.FromGL)
|
|
{
|
|
double amount = ReportGlobal.GetBalancePL(oItem.RDRowAmountCalItems, fromDate, toDate);
|
|
drRow["Amount"] = amount;
|
|
//if (amount >= 0)
|
|
//{
|
|
// drRow["Amount"] = amount;
|
|
//}
|
|
//else
|
|
//{
|
|
// var aa = "(" + Convert.ToString(amount * -1) + ")";
|
|
// drRow["Amount"] = aa;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
if (oItem.RowType == EnumRowType.NormalRow)
|
|
{
|
|
drRow["Notes"] = oItem.Note; //save
|
|
}
|
|
|
|
dtSpecialReport.Rows.Add(drRow);
|
|
}
|
|
|
|
DataTable GLAmountTable = new DataTable();
|
|
GLAmountTable = dtSpecialReport;
|
|
//int counter = 0;
|
|
foreach (DataRow oRow in GLAmountTable.Rows)
|
|
{
|
|
if (Convert.ToInt32(oRow["AmountFrom"]) == (int)EnumAmountFrom.FromOther)
|
|
{
|
|
|
|
if (Convert.ToInt32(oRow["FromOtherSourceType"]) == (int)EnumFromOtherSourceType.COGS)
|
|
{
|
|
DataRow drow = dtSpecialReport.Rows.Find(oRow["RowID"]);
|
|
drow["Amount"] = 0;
|
|
drow.AcceptChanges();
|
|
//counter++;
|
|
}
|
|
else if (Convert.ToInt32(oRow["FromOtherSourceType"]) == (int)EnumFromOtherSourceType.Tax)
|
|
{
|
|
DataRow drow = dtSpecialReport.Rows.Find(oRow["RowID"]);
|
|
drow["Amount"] = Tax;
|
|
drow.AcceptChanges();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
GLAmountTable = new DataTable();
|
|
GLAmountTable = dtSpecialReport;
|
|
foreach (DataRow oRow in GLAmountTable.Rows)
|
|
{
|
|
if (Convert.ToInt32(oRow["AmountFrom"]) == (int)EnumAmountFrom.FromRow)
|
|
{
|
|
DataRow drow = dtSpecialReport.Rows.Find(oRow["RowID"]);
|
|
drow["Amount"] = ReportGlobal.GetRowSUM(dtSpecialReport, Convert.ToInt32(oRow["RowID"]));
|
|
drow.AcceptChanges();
|
|
}
|
|
}
|
|
if (dtSpecialReport.Rows.Count > 0)
|
|
{
|
|
decimal _pnlamount = Convert.ToDecimal(dtSpecialReport.Rows[dtSpecialReport.Rows.Count - 1]["Amount"]);
|
|
}
|
|
|
|
//makeProfitAndLoss_Level_zero(dtSpecialReport);
|
|
|
|
string balanceSheet = "Income Statement at " + fromDate.ToString("dd MMM yyyy");
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForBS(null, dtSpecialReport, balanceSheet, payrollTypeId, reportType, fundTypeID);
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
|
public byte[] LoanScheduleReport(DateTime toDate, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
|
|
try
|
|
{
|
|
DataTable dLoanSchedule = new DataTable();
|
|
dLoanSchedule = new FMLoanService().GetLoanInfoByMonth(GlobalFunctions.LastDateOfMonth(toDate), fundTypeID);
|
|
|
|
DataRow oDR = null;
|
|
DateTime scheduleDate = DateTime.MinValue;
|
|
|
|
FundDataSet.FundDataSet.dtIndividualLoanDataTable oLoanScheduleDTable = new FundDataSet.FundDataSet.dtIndividualLoanDataTable();
|
|
if (dLoanSchedule != null && dLoanSchedule.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in dLoanSchedule.Rows)
|
|
{
|
|
oDR = oLoanScheduleDTable.NewRow();
|
|
oDR["EmpCode"] = dr["EmpCode"];
|
|
oDR["Name"] = dr["Name"];
|
|
oDR["LoanCategoryCode"] = dr["LoanCategory"];
|
|
oDR["LoanName"] = dr["LoanNo"];
|
|
oDR["InstallmentNo"] = dr["ScheduleNO"];
|
|
scheduleDate = Convert.ToDateTime(dr["ScheduleDate"]);
|
|
oDR["ScheduledPayDate"] = scheduleDate.ToString("dd MMM yyyy");
|
|
oDR["PrincipalAmount"] = Math.Round(Convert.ToDouble(dr["InstallmentPrincipal"]), 2);
|
|
oDR["InstallmentInterest"] = Math.Round(Convert.ToDouble(dr["InstallmentInterest"]), 2);
|
|
oDR["InstallmentAmount"] = Convert.ToDouble(dr["InstallmentPrincipal"]) + Convert.ToDouble(dr["InstallmentInterest"]);
|
|
if (dr["PayDate"] is DBNull)
|
|
oDR["Status"] = "Not Paid";
|
|
else
|
|
oDR["Status"] = "Paid";
|
|
oLoanScheduleDTable.Rows.Add(oDR);
|
|
}
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportLoanSchedule(null, oLoanScheduleDTable, toDate.ToString("MMMM yyyy"), fundTypeID, reportType);
|
|
return bytes;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message, e.InnerException);
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
public byte[] MakeLoanToMembersReport(DateTime fromDate, DateTime toDate, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
DataTable dt = new DataTable();
|
|
DataTable tempDt = new DataTable();
|
|
tempDt.Columns.Add("EmpCode");
|
|
tempDt.Columns.Add("Name");
|
|
tempDt.Columns.Add("LoanNo");
|
|
tempDt.Columns.Add("LastInstallmentPaidMonth", typeof(DateTime));
|
|
tempDt.Columns.Add("LoanAmount");
|
|
tempDt.Columns.Add("OpenPRINCIPALAMOUNT");
|
|
tempDt.Columns.Add("OpenPrincipalInterest");
|
|
tempDt.Columns.Add("PrincipalAmount");
|
|
tempDt.Columns.Add("SanctionInstaInte");
|
|
tempDt.Columns.Add("LoanRecovered");
|
|
tempDt.Columns.Add("InterestAmount");
|
|
tempDt.Columns.Add("IssueDate");
|
|
tempDt.Columns.Add("Remarks");
|
|
|
|
dt = new LoanService().GetTable(fromDate, toDate, fundTypeID);
|
|
DataRow orow = null;
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow orr in dt.Rows)
|
|
{
|
|
if (orr["LastInstallmentPaidMonth"] != DBNull.Value)
|
|
{
|
|
orow = tempDt.NewRow();
|
|
orow.ItemArray = orr.ItemArray;
|
|
tempDt.Rows.Add(orow);
|
|
}
|
|
}
|
|
}
|
|
|
|
string rdlcName = "Fund_rptLoanPayRecoverSummary.rdlc";
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForMakeLoanToMembersReport(null, tempDt, fromDate, toDate, reportType, fundTypeID, rdlcName);
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
|
public byte[] GetPFStatmentReport(int memberID, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
FundDataSet.FundDataSet.PFStatementDataTable dtPFStatement = new FundDataSet.FundDataSet.PFStatementDataTable();
|
|
Member member = new MemberService().Get(memberID);
|
|
PFCalculation pFCalculation = new PFCalculation(fundTypeID);
|
|
dtPFStatement = new PFCalculation().PFReportCalCulation(member);
|
|
|
|
|
|
string rdlcName = "Fund_PFStatement.rdlc";
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForPFStatment(null, dtPFStatement, reportType, fundTypeID, rdlcName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
public byte[] GetPFRefundStatmentReport(int memberID, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
|
|
try
|
|
{
|
|
Member oMember = new MemberService().Get(memberID);
|
|
PFCalculation pFCalculation = new PFCalculation(fundTypeID);
|
|
FundDataSet.FundDataSet.PFRefundStatementDataTable dtpFRefunds = pFCalculation.PFRefundCalculation(oMember);
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForPFRefund(dtpFRefunds, fundTypeID, reportType);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
public byte[] DayBookReport(int voucherTypes, DateTime fromDate, DateTime toDate, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
DataTable DayBook = new GLService().GetCheckList(fromDate, toDate, voucherTypes, fundTypeID);
|
|
|
|
FundDataSet.FundDataSet.dtCheckListDataTable rptTable = new FundDataSet.FundDataSet.dtCheckListDataTable();
|
|
EnumGLTranType voucherType = EnumGLTranType.None;
|
|
EnumTranSide tranSide;
|
|
string subHead1 = string.Empty;
|
|
//setMaxValPSGB(DayBook.Rows.Count);
|
|
foreach (DataRow row in DayBook.Rows)
|
|
{
|
|
//increasePSGB();
|
|
rptTable.Rows.Add(rptTable.NewRow());
|
|
DataRow rpt_row = rptTable.Rows[rptTable.Rows.Count - 1];
|
|
|
|
if (row["VoucherDate"] != DBNull.Value && row["VoucherDate"] != null)
|
|
rpt_row["voucherdate"] = Convert.ToDateTime(row["VoucherDate"]).ToString("dd MMM yyyy");
|
|
else rpt_row["voucherdate"] = DateTime.MinValue;
|
|
|
|
if (row["VoucherType"] != DBNull.Value && row["VoucherType"] != null)
|
|
voucherType = (EnumGLTranType)Convert.ToInt32(row["VoucherType"]);
|
|
else voucherType = EnumGLTranType.None;
|
|
|
|
rpt_row["vouchertype"] = VoucherTypeName(voucherType);
|
|
|
|
if (row["VoucherNo"] != DBNull.Value && row["VoucherNo"] != null)
|
|
rpt_row["voucherno"] = Convert.ToString(row["VoucherNo"]);
|
|
else rpt_row["voucherno"] = string.Empty;
|
|
|
|
|
|
if (row["PostingCode"] != DBNull.Value && row["PostingCode"] != null)
|
|
rpt_row["postingcode"] = Convert.ToString(row["PostingCode"]);
|
|
else rpt_row["postingcode"] = DBNull.Value;
|
|
|
|
if (row["PostingHead"] != DBNull.Value && row["PostingHead"] != null)
|
|
rpt_row["postinghead"] = Convert.ToString(row["PostingHead"]);
|
|
else rpt_row["postinghead"] = DBNull.Value;
|
|
|
|
if (row["Description"] != DBNull.Value && row["Description"] != null)
|
|
rpt_row["description"] = Convert.ToString(row["Description"]);
|
|
else rpt_row["description"] = DBNull.Value;
|
|
|
|
if (row["SubSidaryHead1"] != DBNull.Value && row["SubSidaryHead1"] != null)
|
|
subHead1 = Convert.ToString(row["SubSidaryHead1"]);
|
|
else subHead1 = string.Empty;
|
|
|
|
if (row["TranSide"] != DBNull.Value && row["TranSide"] != null)
|
|
{
|
|
tranSide = (EnumTranSide)Convert.ToInt32(row["TranSide"]);
|
|
if (tranSide == EnumTranSide.Debit)
|
|
{
|
|
if (string.IsNullOrEmpty(subHead1))
|
|
{
|
|
if (row["Amount"] != DBNull.Value && row["Amount"] != null)
|
|
rpt_row["DebitAmount"] = Convert.ToDouble(row["Amount"]);
|
|
else rpt_row["DebitAmount"] = DBNull.Value;
|
|
}
|
|
else
|
|
{
|
|
if (row["SubAmount"] != DBNull.Value && row["SubAmount"] != null)
|
|
rpt_row["DebitAmount"] = Convert.ToDouble(row["SubAmount"]);
|
|
else rpt_row["DebitAmount"] = DBNull.Value;
|
|
}
|
|
|
|
rpt_row["CreditAmount"] = DBNull.Value;
|
|
}
|
|
else if (tranSide == EnumTranSide.Credit)
|
|
{
|
|
if (string.IsNullOrEmpty(subHead1))
|
|
{
|
|
if (row["Amount"] != DBNull.Value && row["Amount"] != null)
|
|
rpt_row["CreditAmount"] = Convert.ToDouble(row["Amount"]);
|
|
else rpt_row["CreditAmount"] = DBNull.Value;
|
|
}
|
|
else
|
|
{
|
|
if (row["SubAmount"] != DBNull.Value && row["SubAmount"] != null)
|
|
rpt_row["CreditAmount"] = Convert.ToDouble(row["SubAmount"]);
|
|
else rpt_row["CreditAmount"] = DBNull.Value;
|
|
}
|
|
rpt_row["DebitAmount"] = DBNull.Value;
|
|
}
|
|
}
|
|
|
|
if (row["SubSidaryHead1"] != DBNull.Value && row["SubSidaryHead1"] != null)
|
|
rpt_row["subsidaryhead1"] = Convert.ToString(row["SubSidaryHead1"]);
|
|
else rpt_row["subsidaryhead1"] = DBNull.Value;
|
|
|
|
if (row["SubSidaryHead2"] != DBNull.Value && row["SubSidaryHead2"] != null)
|
|
rpt_row["subsidaryhead2"] = Convert.ToString(row["SubSidaryHead2"]);
|
|
else rpt_row["subsidaryhead2"] = DBNull.Value;
|
|
if (!string.IsNullOrEmpty(subHead1))//overwrite
|
|
{
|
|
if (row["SubDescription"] != DBNull.Value && row["SubDescription"] != null)
|
|
rpt_row["description"] = Convert.ToString(row["SubDescription"]);
|
|
else rpt_row["description"] = DBNull.Value;
|
|
}
|
|
}
|
|
if (rptTable.Rows.Count > 0)
|
|
{
|
|
rptTable.Rows[0]["startdate"] = fromDate.ToString("dd MMM yyyy");
|
|
rptTable.Rows[0]["enddate"] = toDate.ToString("dd MMM yyyy");
|
|
|
|
}
|
|
else
|
|
{
|
|
rptTable.Rows.Add(rptTable.NewRow());
|
|
DataRow blank_row = rptTable.Rows[rptTable.Rows.Count - 1];
|
|
rptTable.Rows[0]["startdate"] = fromDate.ToString("dd MMM yyyy");
|
|
rptTable.Rows[0]["enddate"] = toDate.ToString("dd MMM yyyy");
|
|
|
|
}
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForDayBook(null, rptTable, fundTypeID, reportType);
|
|
return bytes;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public byte[] MakeIndividualLoanReport(int memberID, string memName, string memCode, int loanID, int fundTypeID, string reportType)
|
|
{
|
|
try
|
|
{
|
|
byte[] bytes = null;
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
FMLoan loan = new FMLoan();
|
|
DataTable dt = new FMLoanService().GetLoanMember(0, string.Empty, DateTime.MinValue, DateTime.MinValue, string.Empty, DateTime.MinValue, DateTime.MinValue, EnumLoanStatus.All, memberID, 0, loanID, fundTypeID);
|
|
FMLoan fMLoan = new FMLoan();
|
|
fMLoan = new FMLoanService().Get(loanID, true);
|
|
double ddRLoan = 0; double ddRIntLoan = 0; double ddURLoan = 0; double ddURIntLoan = 0; double ddcUnLoan = 0;
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
if (fMLoan.ESPrincipalReceive == 0)
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (Convert.ToString(dr["PayDate"]) != "")
|
|
{
|
|
ddRLoan += Math.Round(Convert.ToDouble(dr["InstallmentPrincipal"]), 2);
|
|
ddRIntLoan += Math.Round(Convert.ToDouble(dr["InstallmentInterest"]), 2);
|
|
}
|
|
else
|
|
{
|
|
ddURLoan += Math.Round(Convert.ToDouble(dr["InstallmentPrincipal"]), 2);
|
|
ddURIntLoan += Math.Round(Convert.ToDouble(dr["InstallmentInterest"]), 2);
|
|
ddcUnLoan += 1;
|
|
}
|
|
}
|
|
|
|
bytes = reportProcessor.IndividualLoanReport(dt, ddRLoan, ddRIntLoan, ddURLoan, ddURIntLoan, ddcUnLoan, memName, memCode, fundTypeID, reportType, fMLoan);
|
|
}
|
|
else
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
var x = dr["isSettle"];
|
|
if (Convert.ToString(dr["PayDate"]) != "" && Convert.ToString(dr["isSettle"]) == "")
|
|
{
|
|
ddRLoan += Math.Round(Convert.ToDouble(dr["InstallmentPrincipal"]), 2);
|
|
ddRIntLoan += Math.Round(Convert.ToDouble(dr["InstallmentInterest"]), 2);
|
|
}
|
|
else
|
|
{
|
|
ddcUnLoan += 1;
|
|
}
|
|
}
|
|
ddURLoan += Math.Round(Convert.ToDouble(fMLoan.ESPrincipalReceive), 2);
|
|
ddURIntLoan += Math.Round(Convert.ToDouble(fMLoan.ESIntrReceive), 2);
|
|
|
|
|
|
bytes = reportProcessor.SettledIndividualLoanReport(dt, ddRLoan, ddRIntLoan, ddURLoan, ddURIntLoan, ddcUnLoan, memName, memCode, fundTypeID, reportType, fMLoan);
|
|
}
|
|
}
|
|
return bytes;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
public byte[] MakeInvestmentSummaryReport(DateTime fromDate, DateTime toDate, int investmentID, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
DataTable dtInvest = new DataTable();
|
|
DataSet dsInv = new DataSet();
|
|
DataSet dsInvTotal = new DataSet();
|
|
DataRow drr = null;
|
|
|
|
dsInv = new InvestmentService().GetIndvInvestment(investmentID, fromDate, toDate);
|
|
|
|
FundDataSet.FundDataSet.dtIndividualInvestmentDataTable dtIndividualInvestment = new FundDataSet.FundDataSet.dtIndividualInvestmentDataTable();
|
|
FundDataSet.FundDataSet.dtTranInvestmentDataTable dtTranInvest = new FundDataSet.FundDataSet.dtTranInvestmentDataTable();
|
|
|
|
if (dsInv.Tables.Count > 0)
|
|
{
|
|
foreach (DataRow item in dsInv.Tables[0].Rows)
|
|
{
|
|
drr = dtIndividualInvestment.NewRow();
|
|
|
|
drr["CategoryName"] = item["CategoryName"];
|
|
drr["CertificateNo"] = item["CertificateNo"];
|
|
drr["AccountNo"] = item["AccountNo"];
|
|
drr["Description"] = item["Description"];
|
|
drr["IssueDate"] = item["IssueDate"] != null ? DateTime.Parse(item["IssueDate"].ToString()).ToString("dd MMM yyyy") : string.Empty;
|
|
drr["MaturityDate"] = item["MaturityDate"] != null ? DateTime.Parse(item["MaturityDate"].ToString()).ToString("dd MMM yyyy") : string.Empty;
|
|
drr["Facevalue"] = item["Facevalue"];
|
|
drr["AccuruedDate"] = item["AccuruedDate"] != null ? DateTime.Parse(item["AccuruedDate"].ToString()).ToString("dd MMM yyyy") : string.Empty;
|
|
drr["AccruedAmount"] = item["AccuruedDate"] != null ? double.Parse(item["AccruedAmount"].ToString()).ToString() + "%" : string.Empty;
|
|
drr["FromDate"] = item["FromDate"] != null ? !string.IsNullOrEmpty(item["FromDate"].ToString()) ? DateTime.Parse(item["FromDate"].ToString()).ToString("dd MMM yyyy") : string.Empty : string.Empty;
|
|
drr["ToDate"] = item["ToDate"] != null ? !string.IsNullOrEmpty(item["ToDate"].ToString()) ? DateTime.Parse(item["ToDate"].ToString()).ToString("dd MMM yyyy") : string.Empty : string.Empty;
|
|
drr["Status"] = item["Status"].ToString();
|
|
|
|
dtIndividualInvestment.Rows.Add(drr);
|
|
}
|
|
|
|
foreach (DataRow item in dsInv.Tables[1].Rows)
|
|
{
|
|
drr = dtTranInvest.NewRow();
|
|
|
|
drr["TranDate"] = DateTime.Parse(item["VoucherDate1"].ToString()).ToString("dd MMM yyyy");
|
|
drr["Description"] = item["VoucherDescription"];
|
|
if (Convert.ToInt32(item["TRANTYPEID"]) == (int)EnumInvestmentActivities.InvestmentRenewal || Convert.ToInt32(item["TRANTYPEID"]) == (int)EnumInvestmentActivities.InvestmentEncashment)
|
|
{
|
|
drr["crAmount"] = Convert.ToDouble(item["Amount"]);
|
|
}
|
|
else
|
|
{
|
|
drr["drAmount"] = Convert.ToDouble(item["Amount"]);
|
|
}
|
|
|
|
dtTranInvest.Rows.Add(drr);
|
|
}
|
|
|
|
dsInvTotal.Tables.Add(dtIndividualInvestment);
|
|
dsInvTotal.Tables.Add(dtTranInvest);
|
|
}
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.InvestmentSummary(dsInvTotal, fundTypeID, reportType);
|
|
return bytes;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public byte[] InvestmentDetailReport(DateTime fromDate, DateTime toDate, int investmentType, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
|
|
List<InvestmentInfo> objTemInvestmentInfos = new List<InvestmentInfo>();
|
|
DataSet objInvTrans = new DataSet();
|
|
|
|
string sSearch = string.Empty;
|
|
sSearch = GlobalFunctions.TagSQL(sSearch, "MatureDate >= " + "'" + fromDate.Date.ToString("dd MMM yyyy") + "' And CategoryID = " + investmentType);
|
|
|
|
objTemInvestmentInfos = new InvestmentService().GetBySearch(sSearch, fromDate, toDate, fundTypeID);
|
|
objInvTrans = new InvestmentTranService().Get(fromDate, toDate);
|
|
|
|
DataTable investmentReportTable = new FundDataSet.FundDataSet.StatementOfInvestmentDataTable();
|
|
DataRow investmentReportTableRow;
|
|
|
|
|
|
foreach (InvestmentInfo item in objTemInvestmentInfos)
|
|
{
|
|
investmentReportTable.Rows.Add(investmentReportTable.NewRow());
|
|
investmentReportTableRow = investmentReportTable.Rows[investmentReportTable.Rows.Count - 1];
|
|
|
|
investmentReportTableRow["CategoryName"] = item.InvestmentCategoryName;
|
|
investmentReportTableRow["Particulars"] = item.CertificateNo;
|
|
investmentReportTableRow["AccountNo"] = item.AccountNo;
|
|
|
|
investmentReportTableRow["IssueDate"] = item.IssueDate.Date;
|
|
investmentReportTableRow["MaturityDate"] = item.MatureDate.Date;
|
|
|
|
if (item.IssueDate < fromDate)
|
|
{
|
|
investmentReportTableRow["OpeningInvestment"] = item.Amount;
|
|
}
|
|
else if (item.IssueDate >= fromDate && item.IssueDate <= toDate && item.RenewalDate == DateTime.MinValue)
|
|
{
|
|
investmentReportTableRow["AdditionDuringThePeriod"] = item.Amount;
|
|
}
|
|
else if (item.RenewalDate != DateTime.MinValue)
|
|
{
|
|
investmentReportTableRow["Renewal"] = item.Amount;
|
|
}
|
|
|
|
if (objInvTrans.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (DataRow orr in objInvTrans.Tables[0].Rows)
|
|
{
|
|
if (Convert.ToInt32(orr["INVESTMENTID"].ToString()) == item.ID)
|
|
{
|
|
investmentReportTableRow["TotalAccreudAmount"] = Convert.ToDouble(orr["TranAccruedAmount"].ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
int issueYear = item.IssueDate.Date.Year;
|
|
int serverYear = DateTime.Now.Year;
|
|
//investmentReportTableRow["EncashMadeDuringYear"] = item.Amount;
|
|
investmentReportTableRow["FaceValueOfCertificate"] = item.Amount;
|
|
|
|
if (item.CurrentStatus == EnumInvestmentStatus.Encash)
|
|
{
|
|
investmentReportTableRow["EncashMadeDuringYear"] = item.Amount;
|
|
}
|
|
else if (item.CurrentStatus == EnumInvestmentStatus.Renewal)
|
|
{
|
|
if (item.MatureDate.Date <= toDate)
|
|
{
|
|
investmentReportTableRow["Liquidition"] = item.Amount;
|
|
}
|
|
}
|
|
|
|
|
|
if (item.IssueDate.Year == DateTime.Now.Year)
|
|
{
|
|
investmentReportTableRow["IsInvestmentDuringYear"] = true;
|
|
}
|
|
else
|
|
{
|
|
investmentReportTableRow["IsInvestmentDuringYear"] = false;
|
|
}
|
|
}
|
|
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.ReportForStatementOfInvestment(null, investmentReportTable, fromDate, toDate, investmentType, fundTypeID, reportType);
|
|
return bytes;
|
|
}
|
|
|
|
public byte[] makePLVoucherReport(GLTran gt, int payRollTypeID, string reportType)
|
|
{
|
|
DataTable vourcher = new FundDataSet.FundDataSet.dtJournalVoucherDataTable();
|
|
|
|
// for debit
|
|
foreach (GLTranDetail gtd in gt.GlTranDetails)
|
|
{
|
|
if (gtd.Transide != EnumTranSide.Debit) continue;
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
DataRow rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
rpt_row["voucherDate"] = gt.VoucherDate.ToString("dd MMM yyyy");
|
|
rpt_row["voucherNo"] = gt.VoucherNo;
|
|
if (gt.ChequeNo.ToString() != "")
|
|
{
|
|
rpt_row["CheckNo"] = gt.ChequeNo;
|
|
rpt_row["CheckDate"] = gt.ChequeDate.HasValue ? gt.ChequeDate.Value.ToString("dd MMM yyyy") : "No date available";
|
|
}
|
|
|
|
rpt_row["tranDetailID"] = gtd.ID.ToString();
|
|
rpt_row["postingCode"] = gtd.GLCode;
|
|
rpt_row["postingHead"] = gtd.GL.GLDescription;
|
|
rpt_row["description"] = gtd.Description;
|
|
|
|
List<GLTranUserRecord> a = new List<GLTranUserRecord>(); //GLUserObjects
|
|
a = new GLTranUserRecordService().GetByGLID(gtd.GL.ID);
|
|
int i = 0;
|
|
DataRow new_rpt_row = vourcher.NewRow();
|
|
foreach (GLTranUserRecord gtur in gtd.GLTranUserRecords)
|
|
{
|
|
if (i != 0)
|
|
{
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
new_rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
}
|
|
else new_rpt_row = rpt_row;
|
|
i++;
|
|
if (a.Count == 1)
|
|
{
|
|
new_rpt_row["subsidaryHead"] = gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2;
|
|
}
|
|
else if (a.Count == 2)
|
|
{
|
|
new_rpt_row["subsidaryHead"] = gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2 + ", " + "-" + gtur.UserRecord1.Field2;
|
|
}
|
|
|
|
if (gtd.Transide == EnumTranSide.Debit) { new_rpt_row["drAmount"] = gtur.Amount; }
|
|
else { new_rpt_row["crAmount"] = gtur.Amount; }
|
|
|
|
new_rpt_row["tranDetailID"] = rpt_row["tranDetailID"];
|
|
new_rpt_row["costCenter"] = rpt_row["costCenter"];
|
|
new_rpt_row["detailParamName"] = rpt_row["detailParamName"];
|
|
new_rpt_row["detailParam"] = rpt_row["detailParam"];
|
|
new_rpt_row["postingCode"] = rpt_row["postingCode"];
|
|
new_rpt_row["postingHead"] = rpt_row["postingHead"];
|
|
new_rpt_row["description"] = gtur.Description;
|
|
}
|
|
//if (a.Count == 0)
|
|
//{
|
|
if (gtd.GLTranUserRecords.Count == 0)
|
|
{
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_row["drAmount"] = gtd.Amount;
|
|
}
|
|
else rpt_row["crAmount"] = gtd.Amount;
|
|
}
|
|
}
|
|
|
|
// for credit
|
|
foreach (GLTranDetail gtd in gt.GlTranDetails)
|
|
{
|
|
if (gtd.Transide != EnumTranSide.Credit) continue;
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
DataRow rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
rpt_row["voucherDate"] = gt.VoucherDate.ToString("dd MMM yyyy");
|
|
rpt_row["voucherNo"] = gt.VoucherNo;
|
|
if (gt.ChequeNo.ToString() != "")
|
|
{
|
|
rpt_row["CheckNo"] = gt.ChequeNo;
|
|
|
|
rpt_row["CheckDate"] = gt.ChequeDate.HasValue ? gt.ChequeDate.Value.ToString("dd MMM yyyy") : "No date available";
|
|
|
|
}
|
|
//if (SystemConfig.HasMasterParam)
|
|
//{
|
|
// rpt_row["masterParamName"] = SystemConfig.MasterParamName;
|
|
// rpt_row["masterParam"] = "[" + gt.MasterParam.MasterParamCode + "] " + gt.MasterParam.MasterParamDescription;
|
|
//}
|
|
//else
|
|
{
|
|
rpt_row["masterParamName"] = string.Empty;
|
|
//rpt_row["masterParam"] = string.Empty;
|
|
rpt_row["masterParam"] = gt.Description;
|
|
}
|
|
//if (gtd.CostCenter != null)
|
|
// rpt_row["costCenter"] = "[" + gtd.CostCenter.CostCenterCode + "] " + gtd.CostCenter.CostCenterDescription;
|
|
//if (SystemConfig.HasDetailParam)
|
|
//{
|
|
// rpt_row["detailParamName"] = SystemConfig.DetailParamName;
|
|
// rpt_row["detailParam"] = "[" + gtd.DetailParam.DetailParamCode + "] " + gtd.DetailParam.DetailParamDescription;
|
|
//}
|
|
//else
|
|
{
|
|
rpt_row["detailParamName"] = string.Empty;
|
|
rpt_row["detailParam"] = string.Empty;
|
|
}
|
|
rpt_row["tranDetailID"] = gtd.ID.ToString();
|
|
rpt_row["postingCode"] = gtd.GLCode;
|
|
rpt_row["postingHead"] = gtd.GL.GLDescription;
|
|
rpt_row["description"] = gtd.Description;
|
|
|
|
|
|
List<GLTranUserRecord> a = new List<GLTranUserRecord>();
|
|
a = new GLTranUserRecordService().GetByGLID(gtd.GL.ID);
|
|
int i = 0;
|
|
DataRow new_rpt_row = vourcher.NewRow();
|
|
foreach (GLTranUserRecord gtur in gtd.GLTranUserRecords)
|
|
{
|
|
if (i != 0)
|
|
{
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
new_rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
}
|
|
else new_rpt_row = rpt_row;
|
|
i++;
|
|
if (a.Count == 1)
|
|
{
|
|
//new_rpt_row["subsidaryHead"] = gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2;
|
|
}
|
|
else if (a.Count == 2)
|
|
{
|
|
// new_rpt_row["subsidaryHead"] = gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2 + ", " + gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2;
|
|
}
|
|
|
|
if (gtd.Transide == EnumTranSide.Debit) { new_rpt_row["drAmount"] = gtur.Amount; }
|
|
else { new_rpt_row["crAmount"] = gtur.Amount; }
|
|
|
|
new_rpt_row["tranDetailID"] = rpt_row["tranDetailID"];
|
|
new_rpt_row["costCenter"] = rpt_row["costCenter"];
|
|
new_rpt_row["detailParamName"] = rpt_row["detailParamName"];
|
|
new_rpt_row["detailParam"] = rpt_row["detailParam"];
|
|
new_rpt_row["postingCode"] = rpt_row["postingCode"];
|
|
new_rpt_row["postingHead"] = rpt_row["postingHead"];
|
|
new_rpt_row["description"] = rpt_row["description"];
|
|
new_rpt_row["description"] = gtur.Description;
|
|
}
|
|
//if (a.Count == 0)
|
|
//{
|
|
if (gtd.GLTranUserRecords.Count == 0)
|
|
{
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_row["drAmount"] = gtd.Amount;
|
|
}
|
|
else rpt_row["crAmount"] = gtd.Amount;
|
|
}
|
|
}
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
byte[] bytes = reportProcessor.VoucherReport(null, vourcher, gt, payRollTypeID, reportType);
|
|
return bytes;
|
|
}
|
|
|
|
public byte[] makeJournalVoucherReport(GLTran gt, int fundTypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
try
|
|
{
|
|
DataTable vourcher = new FundDataSet.FundDataSet.dtJournalVoucherDataTable();
|
|
gt.GlTranDetails = new GLTranDetailService().GetByGLTranID(gt.ID);
|
|
// for debit
|
|
foreach (GLTranDetail gtd in gt.GlTranDetails)
|
|
{
|
|
if (gtd.Transide != EnumTranSide.Debit) continue;
|
|
gtd.GL = new GLService().Get(gtd.GLID);
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
DataRow rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
rpt_row["voucherDate"] = gt.VoucherDate.ToString("dd MMM yyyy");
|
|
rpt_row["voucherNo"] = gt.VoucherNo;
|
|
if (gt.ChequeNo.ToString() != "" && gt.ChequeNo != null)
|
|
{
|
|
rpt_row["CheckNo"] = gt.ChequeNo;
|
|
rpt_row["CheckDate"] = gt.ChequeDate.HasValue ? gt.ChequeDate.Value.ToString("dd MMM yyyy") : "No date available";
|
|
}
|
|
rpt_row["tranDetailID"] = gtd.ID.ToString();
|
|
rpt_row["postingCode"] = gtd.GL.GLCode;
|
|
rpt_row["postingHead"] = gtd.GL.GLDescription;
|
|
rpt_row["description"] = gtd.Description;
|
|
|
|
List<GLTranUserRecord> a = new List<GLTranUserRecord>();
|
|
a = new GLTranUserRecordService().GetByGLID(gtd.GLID);
|
|
int i = 0;
|
|
DataRow new_rpt_row = vourcher.NewRow();
|
|
gtd.GLTranUserRecords = new GLTranUserRecordService().GetByGLTranDetailID(gtd.ID);
|
|
foreach (GLTranUserRecord gtur in gtd.GLTranUserRecords)
|
|
{
|
|
gtur.UserRecord1 = new UserRecordService().Get(gtur.UserRecord1ID);
|
|
if (i != 0)
|
|
{
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
new_rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
}
|
|
else new_rpt_row = rpt_row;
|
|
i++;
|
|
if (gtur.UserRecord1 != null)
|
|
{
|
|
if (gtur.UserRecord1.Field1 != null && gtur.UserRecord1.Field2 != null)
|
|
{
|
|
new_rpt_row["subsidaryHead"] = gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2;
|
|
|
|
}
|
|
}
|
|
if (gtd.Transide == EnumTranSide.Debit) { new_rpt_row["drAmount"] = gtur.Amount; }
|
|
else { new_rpt_row["crAmount"] = gtur.Amount; }
|
|
|
|
new_rpt_row["tranDetailID"] = rpt_row["tranDetailID"];
|
|
new_rpt_row["costCenter"] = rpt_row["costCenter"];
|
|
new_rpt_row["detailParamName"] = rpt_row["detailParamName"];
|
|
new_rpt_row["detailParam"] = rpt_row["detailParam"];
|
|
new_rpt_row["postingCode"] = rpt_row["postingCode"];
|
|
new_rpt_row["postingHead"] = rpt_row["postingHead"];
|
|
new_rpt_row["description"] = gtur.Description;
|
|
}
|
|
|
|
if (gtd.GLTranUserRecords.Count == 0)
|
|
{
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_row["drAmount"] = gtd.Amount;
|
|
}
|
|
else rpt_row["crAmount"] = gtd.Amount;
|
|
}
|
|
}
|
|
|
|
// for credit
|
|
foreach (GLTranDetail gtd in gt.GlTranDetails)
|
|
{
|
|
if (gtd.Transide != EnumTranSide.Credit) continue;
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
gtd.GL = new GLService().Get(gtd.GLID);
|
|
DataRow rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
rpt_row["voucherDate"] = gt.VoucherDate.ToString("dd MMM yyyy");
|
|
rpt_row["voucherNo"] = gt.VoucherNo;
|
|
if (gt.ChequeNo.ToString() != "" && gt.ChequeNo != null)
|
|
{
|
|
rpt_row["CheckNo"] = gt.ChequeNo;
|
|
rpt_row["CheckDate"] = gt.ChequeDate.HasValue ? gt.ChequeDate.Value.ToString("dd MMM yyyy") : "No date available";
|
|
}
|
|
|
|
rpt_row["tranDetailID"] = gtd.ID.ToString();
|
|
rpt_row["postingCode"] = gtd.GL.GLCode == null ? "101" : gtd.GL.GLCode;
|
|
rpt_row["postingHead"] = gtd.GL.GLDescription;
|
|
rpt_row["description"] = gtd.Description;
|
|
|
|
List<GLTranUserRecord> a = new List<GLTranUserRecord>();
|
|
a = new GLTranUserRecordService().GetByGLID(gtd.GL.ID);
|
|
int i = 0;
|
|
DataRow new_rpt_row = vourcher.NewRow();
|
|
gtd.GLTranUserRecords = new GLTranUserRecordService().GetByGLTranDetailID(gtd.ID);
|
|
foreach (GLTranUserRecord gtur in gtd.GLTranUserRecords)
|
|
{
|
|
gtur.UserRecord1 = new UserRecordService().Get(gtur.UserRecord1ID);
|
|
if (i != 0)
|
|
{
|
|
vourcher.Rows.Add(vourcher.NewRow());
|
|
new_rpt_row = vourcher.Rows[vourcher.Rows.Count - 1];
|
|
}
|
|
else new_rpt_row = rpt_row;
|
|
i++;
|
|
if (gtur.UserRecord1 != null)
|
|
{
|
|
if (gtur.UserRecord1.Field1 != null && gtur.UserRecord1.Field2 != null)
|
|
{
|
|
new_rpt_row["subsidaryHead"] = gtur.UserRecord1.Field1 + "-" + gtur.UserRecord1.Field2;
|
|
}
|
|
}
|
|
if (gtd.Transide == EnumTranSide.Debit) { new_rpt_row["drAmount"] = gtur.Amount; }
|
|
else { new_rpt_row["crAmount"] = gtur.Amount; }
|
|
|
|
new_rpt_row["tranDetailID"] = rpt_row["tranDetailID"];
|
|
new_rpt_row["costCenter"] = rpt_row["costCenter"];
|
|
new_rpt_row["detailParamName"] = rpt_row["detailParamName"];
|
|
new_rpt_row["detailParam"] = rpt_row["detailParam"];
|
|
new_rpt_row["postingCode"] = rpt_row["postingCode"];
|
|
new_rpt_row["postingHead"] = rpt_row["postingHead"];
|
|
new_rpt_row["description"] = rpt_row["description"];
|
|
new_rpt_row["description"] = gtur.Description;
|
|
}
|
|
if (gtd.GLTranUserRecords.Count == 0)
|
|
{
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_row["drAmount"] = gtd.Amount;
|
|
}
|
|
else rpt_row["crAmount"] = gtd.Amount;
|
|
}
|
|
}
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.VoucherReport(null, vourcher, gt, fundTypeID, reportType);
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message);
|
|
}
|
|
return bytes;
|
|
}
|
|
|
|
public byte[] GetSubsidiaryLedgerBookReport(GL gl, int userRecordID, int userRecordType, int fundtypeID, DateTime fromDate, DateTime toDate, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
DataRow oRow = null;
|
|
DataTable ledger = new FundDataSet.FundDataSet.dtLedgerDataTable();
|
|
DataRow rpt_new_row;
|
|
List<GLTran> gts = new List<GLTran>();
|
|
int uo = 0;
|
|
|
|
List<GLTran> gtsWithoutOpen = new GLTranService().GetGLTransOrderByDate(fromDate, toDate, gl);
|
|
UserRecord oUR = new UserRecordService().Get(userRecordID);
|
|
try
|
|
{
|
|
uo++;
|
|
|
|
#region opening balance
|
|
decimal amount, openDrAmount, openCrAmount;
|
|
|
|
amount = new GLTranService().GetOpen(gl.ID, userRecordType, userRecordID, fromDate);
|
|
if (gl.GLType == EnumGLType.Asset || gl.GLType == EnumGLType.Expenditure)
|
|
amount = -amount;
|
|
|
|
ledger.Rows.Add(ledger.NewRow());
|
|
rpt_new_row = ledger.Rows[ledger.Rows.Count - 1];
|
|
|
|
rpt_new_row["glid"] = gl.ID.ToString() + userRecordID.ToString();
|
|
rpt_new_row["VoucherType"] = gl.GLCode + "-" + gl.GLDescription + "; " + oUR.Field1 + ", " + oUR.Field2;
|
|
rpt_new_row["Description"] = "Balance B/F";
|
|
rpt_new_row["Balance"] = Math.Round(amount, 2);
|
|
|
|
rpt_new_row["StartDate"] = fromDate.ToString("dd MMM yyyy");
|
|
rpt_new_row["EndDate"] = toDate.ToString("dd MMM yyyy");
|
|
#endregion opening balance
|
|
|
|
gts = gtsWithoutOpen;
|
|
|
|
DataRow prev_row;
|
|
foreach (GLTran gt in gts)
|
|
{
|
|
foreach (GLTranDetail gtd in gt.GlTranDetails)
|
|
{
|
|
if (gtd.GLID != gl.ID) continue;
|
|
gtd.GLTranUserRecords = new GLTranUserRecordService().GetByGLTranDetailID(gtd.ID);
|
|
foreach (GLTranUserRecord gtur in gtd.GLTranUserRecords)
|
|
{
|
|
if (gtur.UserRecord1ID != oUR.ID) continue;
|
|
|
|
ledger.Rows.Add(ledger.NewRow());
|
|
rpt_new_row = ledger.Rows[ledger.Rows.Count - 1];
|
|
prev_row = ledger.Rows[ledger.Rows.Count - 2];
|
|
|
|
rpt_new_row["glid"] = gl.ID.ToString() + oUR.ID.ToString();
|
|
rpt_new_row["TranDate"] = gt.VoucherDate.ToString("dd MMM yyyy");
|
|
rpt_new_row["VoucherNo"] = gt.VoucherNo;
|
|
rpt_new_row["VoucherType"] = VoucherTypeName(gt.GLTranType);
|
|
string desc = string.Empty;
|
|
rpt_new_row["Description"] = FindDecscription(gtur, gtd, gt);
|
|
|
|
|
|
decimal prevBalance = Convert.ToDecimal(prev_row["Balance"]);
|
|
decimal amt = (decimal)gtur.Amount;
|
|
decimal newBalance = prevBalance;
|
|
|
|
bool isAssetOrExpense = (gtd.GL.GLType == EnumGLType.Asset || gtd.GL.GLType == EnumGLType.Expenditure);
|
|
|
|
if (gtd.Transide == EnumTranSide.Debit)
|
|
{
|
|
rpt_new_row["DebitAmount"] = Math.Round(amt, 2);
|
|
|
|
if (isAssetOrExpense)
|
|
newBalance = prevBalance + amt;
|
|
else
|
|
newBalance = prevBalance - amt;
|
|
}
|
|
else // CREDIT SIDE
|
|
{
|
|
rpt_new_row["CreditAmount"] = Math.Round(amt, 2);
|
|
|
|
if (isAssetOrExpense)
|
|
newBalance = prevBalance - amt;
|
|
else
|
|
newBalance = prevBalance + amt;
|
|
}
|
|
|
|
rpt_new_row["Balance"] = Math.Round(newBalance, 2);
|
|
|
|
//if (gtd.Transide == EnumTranSide.Debit)
|
|
//{
|
|
// rpt_new_row["DebitAmount"] = Math.Round(Convert.ToDouble(gtur.Amount), 2);
|
|
|
|
// if (gtd.GL.GLType == EnumGLType.Asset || gtd.GL.GLType == EnumGLType.Expenditure)
|
|
// {
|
|
// rpt_new_row["Balance"] = gtur.Amount + Convert.ToDouble(prev_row["Balance"]);
|
|
// }
|
|
// else if (gtd.GL.GLType == EnumGLType.Liability || gtd.GL.GLType == EnumGLType.Income)
|
|
// {
|
|
// string strBalance = prev_row["Balance"].ToString();
|
|
// if (strBalance != "")
|
|
// {
|
|
// int index = prev_row["Balance"].ToString().IndexOf(strBalance);
|
|
// string strBalance1 = prev_row["Balance"].ToString().Substring(index + 1);
|
|
// if (gtur.Amount < Convert.ToDouble(strBalance1))
|
|
// {
|
|
// rpt_new_row["Balance"] = Convert.ToDouble(strBalance1) - gtur.Amount;
|
|
// strBalance = strBalance.Substring(0, 1);
|
|
// if (strBalance == "-")
|
|
// {
|
|
// rpt_new_row["Balance"] = strBalance + rpt_new_row["Balance"];
|
|
// }
|
|
// }
|
|
// else if (gtur.Amount > Convert.ToDouble(strBalance1))
|
|
// {
|
|
// rpt_new_row["Balance"] = gtur.Amount - Convert.ToDouble(strBalance1);
|
|
// }
|
|
|
|
// else
|
|
// {
|
|
// rpt_new_row["Balance"] = Convert.ToDouble(prev_row["Balance"]) + gtur.Amount;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#region closing
|
|
DataRow lastRow = ledger.Rows[ledger.Rows.Count - 1];
|
|
|
|
ledger.Rows.Add(ledger.NewRow());
|
|
DataRow closingRow = ledger.Rows[ledger.Rows.Count - 1];
|
|
|
|
closingRow["glid"] = gl.ID.ToString() + oUR.ID.ToString();
|
|
closingRow["Description"] = "Closing Balance";
|
|
closingRow["StartDate"] = fromDate.ToString("dd MMM yyyy");
|
|
closingRow["EndDate"] = toDate.ToString("dd MMM yyyy");
|
|
|
|
if (lastRow["Balance"] != DBNull.Value)
|
|
closingRow["Balance"] = lastRow["Balance"];
|
|
else
|
|
closingRow["Balance"] = 0;
|
|
|
|
#endregion closing
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.GetSubsidiaryLedgerBookReport(null, ledger, fundtypeID, reportType);
|
|
}
|
|
catch (Exception es)
|
|
{
|
|
throw new ServiceException("Your uo count is " + uo.ToString());
|
|
}
|
|
return bytes;
|
|
}
|
|
|
|
|
|
public byte[] GetGFSettlementReport(int id, int fundtypeID, string reportType)
|
|
{
|
|
byte[] bytes = null;
|
|
DataTable dtGFSettlement = new FundDataSet.FundDataSet.GFSettlementDataTable();
|
|
try
|
|
{
|
|
GFSettlement gfSettlement = new GFSettlementService().Get(id);
|
|
gfSettlement.Member = new MemberService().Get(gfSettlement.MemberID);
|
|
//gfSettlement.Member.Designation
|
|
DataRow oRow = dtGFSettlement.NewRow();
|
|
DateTime lastDate = gfSettlement.Member.DOL ?? DateTime.MinValue;
|
|
|
|
oRow["Name"] = gfSettlement.Member.Name;
|
|
oRow["WorkDayID"] = "";
|
|
oRow["EmpId"] = gfSettlement.Member.EmpCode;
|
|
oRow["Designation"] = gfSettlement.Member.Designation;
|
|
oRow["JoiningDate"] = gfSettlement.Member.DOJ.ToString("dd MMM yyyy");
|
|
oRow["PrimaryCostCenter"] = "";
|
|
oRow["LastMonthSalary"] = Math.Round(gfSettlement.Member.CurrentBasic).ToString("N2");
|
|
oRow["ModeOfSeperation"] = ((EnumSeparationMode)gfSettlement.SeparationMode).ToString();
|
|
oRow["NoticePeriodRequired"] = gfSettlement.NoticePeriodRequired + " Day's";
|
|
oRow["NoticePeriodGiven"] = gfSettlement.NoticePeriodGiven + " Day's";
|
|
oRow["LastWorkingDay"] = gfSettlement.LastWorkingDay.HasValue ? gfSettlement.LastWorkingDay.Value.ToString("dd MMM yyyy") : "";
|
|
oRow["ExitNoticeDate"] = gfSettlement.ExitNoticeDate.HasValue ? gfSettlement.ExitNoticeDate.Value.ToString("dd MMM yyyy") : "";
|
|
oRow["NoticePeriodEndDate"] = gfSettlement.NoticePeriodEndDate.HasValue ? gfSettlement.NoticePeriodEndDate.Value.ToString("dd MMM yyyy") : "";
|
|
oRow["TerminationEffectiveFrom"] = gfSettlement.TerminationEffectiveDate.HasValue ? gfSettlement.TerminationEffectiveDate.Value.ToString("dd MMM yyyy") : "";
|
|
oRow["PFMembership"] = gfSettlement.Member.MembershipDate != null ? "Yes" : "No";
|
|
|
|
oRow["LengthOfService"] = gfSettlement.LengthOfService.ToString();
|
|
oRow["GratuityAmount"] = Math.Round(gfSettlement.GFAmount).ToString("N2");
|
|
oRow["SubTotal"] = Math.Round(gfSettlement.GFAmount).ToString("N2"); ;
|
|
oRow["tax"] = "0.00";
|
|
oRow["SubTotalDeduction"] = "0.00";
|
|
oRow["NetPay"] = Math.Round(gfSettlement.GFAmount).ToString("N2"); ;
|
|
oRow["inword"] = ConvertAmountToWords((decimal)gfSettlement.GFAmount);
|
|
dtGFSettlement.Rows.Add(oRow);
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
bytes = reportProcessor.GetGFSettlementReport(dtGFSettlement, fundtypeID, reportType);
|
|
}
|
|
catch (Exception es)
|
|
{
|
|
throw new ServiceException(es.Message);
|
|
}
|
|
return bytes;
|
|
}
|
|
public byte[] ESSWPPFStatmentReport(int wppfSetttlementID, string reportType)
|
|
{
|
|
DataRow oDR = null;
|
|
WPPFSettlementService wPPFSettlementService = new WPPFSettlementService();
|
|
WPPFSettlement employeeWPPF = wPPFSettlementService.Get(wppfSetttlementID);
|
|
Member oMember = new MemberService().Get(employeeWPPF.MemberID);
|
|
Employee oEmployee = new EmployeeService().GetByEmpCode(oMember.EmpCode);
|
|
Designation designation = new Designation();
|
|
if (oEmployee.DesignationID != null)
|
|
{
|
|
designation = new DesignationService().Get(oEmployee.DesignationID.Value);
|
|
}
|
|
FundEssDataSet.FundEssDataSet.WPPFTaxCertificateDataTable wPPFStatement = new FundEssDataSet.FundEssDataSet.WPPFTaxCertificateDataTable(); ;
|
|
|
|
oDR = wPPFStatement.NewRow();
|
|
|
|
oDR["EmpNo"] = oMember.EmpCode;
|
|
oDR["EmpName"] = oMember.Name;
|
|
oDR["EmpGender"] = oEmployee.Gender;
|
|
oDR["EmpTIN"] = oEmployee.TinNo;
|
|
oDR["EmpDepartment"] = designation.Name;
|
|
oDR["EmpLocation"] = oEmployee.Location;
|
|
oDR["TotalAmount"] = employeeWPPF.WPPFAmount.ToString("N2");
|
|
oDR["TaxDeduction"] = 0.00;
|
|
oDR["NetAmount"] = employeeWPPF.WPPFAmount.ToString("N2"); ;
|
|
wPPFStatement.Rows.Add(oDR);
|
|
|
|
ReportProcessor reportProcessor = new ReportProcessor();
|
|
return reportProcessor.ShowWPPFStatmentReport(null, wPPFStatement, reportType);
|
|
}
|
|
public static string ConvertAmountToWords(decimal amount)
|
|
{
|
|
string[] unitsMap = { "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten",
|
|
"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
|
|
|
|
string[] tensMap = { "Zero", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
|
|
|
|
long rupees = (long)Math.Floor(amount);
|
|
int paise = (int)((amount - rupees) * 100);
|
|
|
|
string result = NumberToWords(rupees, unitsMap, tensMap) + "Taka";
|
|
|
|
if (paise > 0)
|
|
{
|
|
result += " and " + NumberToWords(paise, unitsMap, tensMap) + " Paise";
|
|
}
|
|
|
|
result += " Only";
|
|
|
|
return result;
|
|
}
|
|
|
|
private static string NumberToWords(long number, string[] unitsMap, string[] tensMap)
|
|
{
|
|
if (number == 0)
|
|
return "Zero";
|
|
|
|
if (number < 0)
|
|
return "Minus " + NumberToWords(Math.Abs(number), unitsMap, tensMap);
|
|
|
|
string words = "";
|
|
|
|
if ((number / 10000000) > 0)
|
|
{
|
|
words += NumberToWords(number / 10000000, unitsMap, tensMap) + " Crore ";
|
|
number %= 10000000;
|
|
}
|
|
|
|
if ((number / 100000) > 0)
|
|
{
|
|
words += NumberToWords(number / 100000, unitsMap, tensMap) + " Lakh ";
|
|
number %= 100000;
|
|
}
|
|
|
|
if ((number / 1000) > 0)
|
|
{
|
|
words += NumberToWords(number / 1000, unitsMap, tensMap) + " Thousand ";
|
|
number %= 1000;
|
|
}
|
|
|
|
if ((number / 100) > 0)
|
|
{
|
|
words += NumberToWords(number / 100, unitsMap, tensMap) + " Hundred ";
|
|
number %= 100;
|
|
}
|
|
|
|
if (number > 0)
|
|
{
|
|
if (words != "")
|
|
words += "and ";
|
|
|
|
if (number < 20)
|
|
words += unitsMap[number];
|
|
else
|
|
{
|
|
words += tensMap[number / 10];
|
|
if ((number % 10) > 0)
|
|
words += "-" + unitsMap[number % 10];
|
|
}
|
|
}
|
|
|
|
return words.Trim();
|
|
}
|
|
}
|
|
}
|