using System; using System.Data; using System.Linq; using System.Text; using Ease.Core.Model; using Ease.Core.Utility; using System.Collections.Generic; using HRM.BO; using HRM.DA; using Microsoft.Reporting.NETCore; namespace HRM.Report { public class LoanReport { private LoanIssue _LoanIssue = null; private LoanParameter _LoanParameter = null; ReportItem _item = null; DataSet dSet = null; string RDLC = string.Empty; public LoanReport() { } //public DataTable GetLoanPaymentDue(DateTime dFromDate, DateTime dToDate) //{ // DataRow oDR = null; // DataSet oLaonPayments = null; // oLaonPayments = LoanSchedule.GetLoanPaymentDue(dFromDate, dToDate); // PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable(); // foreach (DataRow oDRow in oLaonPayments.Tables[0].Rows) // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = oDRow["EmployeeNo"]; // oDR["EmpName"] = oDRow["Name"]; // oDR["Loan"] = oDRow["Description"]; // oDR["LoanAmount"] = oDRow["LoanAmount"]; // oDR["InstalmentAmount"] = oDRow["InstallmentPrincipal"]; // oDR["InstallInterest"] = oDRow["InstallmentInterest"]; // oDR["TotalAmount"] = Convert.ToDouble(oDRow["InstallmentPrincipal"]) + Convert.ToDouble(oDRow["InstallmentInterest"]); // oDR["Balance"] = oDRow["ClosingBalance"]; // dTable.Rows.Add(oDR); // } // return dTable; //} //public void GetAllActiveLoan() //{ // DataRow oDR = null; // DataSet oLaonPayments = null; // fReportViewer form = new fReportViewer(); // string sEmpID = _selectedParameter.ReportItem.INSQL; // oLaonPayments = LoanSchedule.GetAllActiveLoan(sEmpID); // PayrollDataSet.PayrollDataSet.dtAllActiveLaonsDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.dtAllActiveLaonsDataTable(); // foreach (DataRow oDRow in oLaonPayments.Tables[0].Rows) // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = oDRow["EmployeeNo"]; // oDR["EmpName"] = oDRow["Name"]; // oDR["Grade"] = oDRow["Grade"]; // oDR["Designation"] = oDRow["Designation"]; // oDR["Loan"] = oDRow["Description"]; // oDR["IssueDate"] = (Convert.ToDateTime(oDRow["IssueDate"])).ToString("dd MMM yyyy"); // oDR["LoanAmount"] = oDRow["LoanAmount"]; // oDR["DisburseFrom"] = (Convert.ToDateTime(oDRow["STARTPAYBACKMONTHDATE"])).ToString("MMM yyyy"); // oDR["NoofInstallment"] = oDRow["NOOFINSTALLMENTS"]; // if (Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer == 1) // oDR["NoofInstallmentPaid"] = oDRow["NoofPaid"]; // else // { // if (Convert.ToInt16(oDRow["INTERESTRATE"]) > 0) // { // if (Convert.ToInt16(oDRow["NOOFINSTALLMENTS"]) < 24) // oDR["NoofInstallmentPaid"] = (Convert.ToInt16(oDRow["NoofPaid"]) + 1).ToString(); // else // oDR["NoofInstallmentPaid"] = (Convert.ToInt16(oDRow["NoofPaid"]) + 2).ToString(); // } // else // oDR["NoofInstallmentPaid"] = oDRow["NoofPaid"]; // } // //oDR["TotalAmount"] = Convert.ToDouble(oDRow["InstallmentPrincipal"]) + Convert.ToDouble(oDRow["InstallmentInterest"]); // oDR["ClosingBalance"] = oDRow["OutStanding"]; // dTable.Rows.Add(oDR); // } // form.ShowDlgForAllActiveLoan(_selectedParameter.ReportItem, dTable); //} public byte[] LoanPaymentDue(DateTime salaryMonth, string empIds, int payrollTypeId, string reportType) { DataRow oDR = null; DateTime dSalaryMonth = salaryMonth; DataSet dsLoan = new LoanIssueService().GetDueLoans(empIds, GlobalFunctions.LastDateOfMonth(dSalaryMonth)); int crgID = 0; DataTable dtCRG = new DataTable(); PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable(); PayrollDataSet.PayrollDataSet.LoanDueWithCCDataTable dTableCC = new PayrollDataSet.PayrollDataSet.LoanDueWithCCDataTable(); try { foreach (DataRow dr in dsLoan.Tables[0].Rows) { oDR = dTable.NewRow(); oDR["EmpNo"] = dr["EMPLOYEENO"]; oDR["EmpName"] = dr["NAME"]; oDR["Loan"] = dr["Loan"]; oDR["LoanNo"] = dr["LOANNO"]; oDR["LoanAmount"] = dr["LOANAMOUNT"]; oDR["OpeningBalance"] = Convert.ToDouble(dr["OpeningBalance"]); ; oDR["InstalmentAmount"] = Convert.ToDouble(dr["INSTALLMENTPRINCIPAL"]); oDR["InstallInterest"] = Convert.ToDouble(dr["INSTALLMENTINTEREST"]); oDR["CostCenter"] = dr["CostCenter"]; oDR["CRGID"] = Convert.ToInt32(dr["CRGID"]); dTable.Rows.Add(oDR); } DataView dv = dTable.DefaultView; dv.Sort = "CRGID"; dtCRG = dv.ToTable(); foreach (DataRow drr in dtCRG.Rows) { if (crgID != Convert.ToInt32(drr["CRGID"])) { oDR = dTableCC.NewRow(); crgID = Convert.ToInt32(drr["CRGID"]); double dTotalLoanAmount = Convert.ToDouble(dtCRG.AsEnumerable().Where(x => Convert.ToInt32(x["CRGID"]) == crgID).Sum(x => Convert.ToDouble(x["LoanAmount"]))); double dTotalInstalmentAmount = Convert.ToDouble(dtCRG.AsEnumerable().Where(x => Convert.ToInt32(x["CRGID"]) == crgID).Sum(x => Convert.ToDouble(x["InstalmentAmount"]))); double dTotalInterest = Convert.ToDouble(dtCRG.AsEnumerable().Where(x => Convert.ToInt32(x["CRGID"]) == crgID).Sum(x => Convert.ToDouble(x["InstallInterest"]))); double dTotalBalance = Convert.ToDouble(dtCRG.AsEnumerable().Where(x => Convert.ToInt32(x["CRGID"]) == crgID).Sum(x => Convert.ToDouble(x["OpeningBalance"]))); oDR["CostCenter"] = drr["CostCenter"].ToString(); oDR["LoanAmount"] = dTotalLoanAmount; oDR["InstallmentPrincipal"] = dTotalInstalmentAmount; oDR["Interest"] = dTotalInterest; oDR["OpeningBalance"] = dTotalBalance; dTableCC.Rows.Add(oDR); } } string LoanMonths = dSalaryMonth.ToString("MMM yyyy"); dTable.TableName = "PayrollDataSet_LaonPaymentDue"; dTableCC.TableName = "PayrollDataSet_LoanDueWithCC"; ReportParameter LoanMonth = new ReportParameter("LoanMonth",LoanMonths); List rParams = new List(); rParams.Add(LoanMonth); DataSet resultSet = new DataSet(); resultSet.Tables.Add(dTable); resultSet.Tables.Add(dTableCC); RDLC = "HRM.Report.RDLC.LoanPaymentDue.rdlc"; return new ReportProcessor().CommonReportView(null, RDLC, resultSet, null, rParams, true, payrollTypeId, reportType); } catch (Exception ex) { throw new Exception(ex.Message); } } public PayrollDataSet.PayrollDataSet.LoanIssueDataTable GetLaonIssue(LoanIssue oLoanIssue) { DataRow oDR = null; PayrollDataSet.PayrollDataSet.LoanIssueDataTable dTable = new PayrollDataSet.PayrollDataSet.LoanIssueDataTable(); foreach (LoanSchedule oLSchedule in oLoanIssue.Schedules) { oDR = dTable.NewRow(); oDR["Month"] = oLSchedule.DueInstallmentDate.ToString("MMM yyyy"); if (oLSchedule.OpeningBalance < 0) oDR["Balance"] = Math.Round(Convert.ToDouble(0.0)); else oDR["Balance"] = Math.Round(Convert.ToDouble(oLSchedule.OpeningBalance)); oDR["Interest1"] = Math.Round(Convert.ToDouble(oLSchedule.ActualInterest)); oDR["Interest2"] = Math.Round(Convert.ToDouble(oLSchedule.InstallmentInterest)); oDR["Days"] = oLSchedule.Days; oDR["Installment"] = Math.Round(Convert.ToDouble(oLSchedule.Installment)); if (oLSchedule.ClosingBalance < 0) oDR["ClosingBalance"] = Math.Round(Convert.ToDouble(0.0)); else oDR["ClosingBalance"] = Math.Round(Convert.ToDouble(oLSchedule.ClosingBalance)); oDR["Principal"] = Math.Round(Convert.ToDouble(oLSchedule.InstallmentPrincipal)); oDR["Deduct"] = Convert.ToDouble(oLSchedule.InstallmentPrincipal + oLSchedule.InstallmentInterest); if (oLSchedule.PaymentDate != null) //oLSchedule.PaymentDate != DateTime.MinValue { oDR["Status"] = " Paid"; } else { oDR["Status"] = " Not Paid"; } dTable.Rows.Add(oDR); } return dTable; } public byte[] LatestIndividualLoanReport(int loanIssueId, string oEmpId, int payrollTypeId, string reportType) { byte[] rsbyte = null; dSet = new DataSet(); double LoanAmount = 0; double InterestRate = 0; int noOfInstallment = 0; string LoanName = string.Empty; string sDesignation = string.Empty; string sRC = string.Empty; string sDepartment = string.Empty; string sLocation = string.Empty; string empName = string.Empty; string empNo = string.Empty; DateTime IssueDate = DateTime.MinValue; DateTime dFromDate = DateTime.MinValue; DateTime dToDate = DateTime.MinValue; PayrollDataSet.PayrollDataSet.LoanIssueDataTable oDTable = new PayrollDataSet.PayrollDataSet.LoanIssueDataTable(); _LoanIssue = new LoanIssueService().Get(loanIssueId); _LoanIssue.Schedules = new LoanScheduleService().GetByIssueID(loanIssueId); Loan oLoan = new LoanService().Get(_LoanIssue.LoanID); Employee oEmp = new EmployeeService().GetByEmpIDs(oEmpId, payrollTypeId).FirstOrDefault(); List costCenters = new CostcenterService().Get(EnumStatus.Active, payrollTypeId); List CostCenterNames = new List(); if (_LoanIssue != null && _LoanIssue.Schedules.Count > 0 && oEmp != null) { List oEmpCCs = new EmployeeCostCenterService().GetByEmpID(oEmp.ID); empName = oEmp.Name; empNo = oEmp.EmployeeNo; oDTable = GetLaonIssue(_LoanIssue); _item = new ReportItemService().GetByReportType(Convert.ToInt32(EnumReportType.LoanIssue)); InterestRate = _LoanIssue.InterestRate; IssueDate = _LoanIssue.IssueDate != DateTime.MinValue ? _LoanIssue.IssueDate : DateTime.Now; LoanAmount = _LoanIssue.LoanAmount; noOfInstallment = _LoanIssue.NoOfInstallments; LoanName = oLoan.Name; dFromDate = _LoanIssue.Schedules[0].DueInstallmentDate; dToDate = _LoanIssue.Schedules[_LoanIssue.Schedules.Count - 1].DueInstallmentDate; if (oEmp.Designation != null) sDesignation = oEmp.DescriptionText; else sDesignation = ""; if (oEmp.Department != null) sDepartment = oEmp.Department.Name; else sDepartment = ""; if (oEmp.Location != null) sLocation = oEmp.Location.Name; else sLocation = ""; foreach (EmployeeCostCenter oEmpCC in oEmpCCs) { Costcenter tempCostCenter = costCenters.Find(item => item.ID == oEmpCC.CostCenterID); if (tempCostCenter != null) { CostCenterNames.Add(tempCostCenter.Name); } } if (CostCenterNames != null && CostCenterNames.Count > 0) { sRC = string.Join(",", CostCenterNames); } } oDTable.TableName = "PayrollDataSet_LoanIssue"; RDLC = "HRM.Report.RDLC.LoanIssue.rdlc"; dSet.Tables.Add(oDTable); rsbyte = new ReportProcessor().LatestIndividualLoanReport(_item, dSet, RDLC, empName, empNo, LoanAmount, InterestRate, noOfInstallment, dFromDate, dToDate, LoanName, IssueDate, payrollTypeId, reportType); return rsbyte; } public byte[] MonthlyLoanReport(DateTime loanMonth, int payrollTypeId, string reportType, string locationIds) { DataRow oDR = null; byte[] rsByte = null; DataSet dsLoan = new LoanIssueService().GetMonthWiseLoans(GlobalFunctions.LastDateOfMonth(loanMonth), locationIds); int crgID = 0; DataTable dtCRG = new DataTable(); string locantionName = "All Locations"; if (!string.IsNullOrEmpty(locationIds)) { locantionName = string.Empty; string[] ids = locationIds.Split(','); List Locations = new LocationService().GetLocations(); List LocationTemp = new List(); for (int i = 0; i < ids.Length; i++) { Location location = Locations.FirstOrDefault(x => x.ID == Convert.ToInt32(ids[i])); if (location != null) { LocationTemp.Add(location); } } foreach (Location item in LocationTemp) { locantionName += item.Name + ","; } locantionName = locantionName.Trim(','); } PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable(); PayrollDataSet.PayrollDataSet.LoanDueWithCCDataTable dTableCC = new PayrollDataSet.PayrollDataSet.LoanDueWithCCDataTable(); try { foreach (DataRow dr in dsLoan.Tables[0].Rows) { oDR = dTable.NewRow(); oDR["EmpNo"] = dr["EMPLOYEENO"]; oDR["EmpName"] = dr["NAME"]; oDR["InstalmentAmount"] = Convert.ToDouble(dr["INSTALLMENTPRINCIPAL"]); oDR["InstallInterest"] = Convert.ToDouble(dr["INSTALLMENTINTEREST"]); oDR["CostCenter"] = dr["CostCenter"]; oDR["CRGID"] = Convert.ToInt32(dr["CRGID"]); oDR["AccountNo"] = dr["ACCOUNTNO"]; dTable.Rows.Add(oDR); } DataView dv = dTable.DefaultView; dv.Sort = "CRGID"; dtCRG = dv.ToTable(); foreach (DataRow drr in dtCRG.Rows) { if (crgID != Convert.ToInt32(drr["CRGID"])) { oDR = dTableCC.NewRow(); crgID = Convert.ToInt32(drr["CRGID"]); double dTotalInstalmentAmount = Convert.ToDouble(dtCRG.AsEnumerable().Where(x => Convert.ToInt32(x["CRGID"]) == crgID).Sum(x => Convert.ToDouble(x["InstalmentAmount"]))); double dTotalInterest = Convert.ToDouble(dtCRG.AsEnumerable().Where(x => Convert.ToInt32(x["CRGID"]) == crgID).Sum(x => Convert.ToDouble(x["InstallInterest"]))); oDR["CostCenter"] = drr["CostCenter"].ToString(); oDR["InstallmentPrincipal"] = dTotalInstalmentAmount; oDR["Interest"] = dTotalInterest; dTableCC.Rows.Add(oDR); } } string LoanMonth = loanMonth.ToString("MMM yyyy"); DataSet dSet = new DataSet(); dTable.TableName = "PayrollDataSet_LaonPaymentDue"; dTableCC.TableName = "PayrollDataSet_LoanDueWithCC"; RDLC = "HRM.Report.RDLC.LocationWiseLoanReport.rdlc"; dSet.Tables.Add(dTable); dSet.Tables.Add(dTableCC); rsByte = new ReportProcessor().MonthlyLoanReport(null, dSet, RDLC, LoanMonth, payrollTypeId, locantionName, reportType); } catch (Exception ex) { throw new Exception(ex.Message); } return rsByte; } //public DataTable GetLaonIssue(LoanIssue oLoanIssue) //{ // DataRow oDR = null; // PayrollDataSet.PayrollDataSet.LoanIssueDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanIssueDataTable(); // #region Old Code // #endregion // foreach (LoanSchedule oLSchedule in oLoanIssue.Schedules) // { // oDR = dTable.NewRow(); // oDR["Month"] = oLSchedule.DueInstallmentDate.ToString("MMMM-yyyy"); // oDR["OpeningBalance"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.OpeningBalance)); // oDR["Interest"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.InstallmentInterest)); // oDR["Installment"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.Installment)); // oDR["ClosingBalance"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.ClosingBalance)); // oDR["Principal"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.InstallmentPrincipal)); // if (oLSchedule.PaymentDate != null) //oLSchedule.PaymentDate != DateTime.MinValue // { // oDR["Status"] = "Paid"; // } // else // { // oDR["Status"] = "Not Paid"; // } // dTable.Rows.Add(oDR); // } // foreach (LoanSchedule oLSchedule in oLoanIssue.Schedules) // { // oDR = dTable.NewRow(); // oDR["Month"] = oLSchedule.DueInstallmentDate.ToString("25-MMM-yyyy"); // if (oLSchedule.OpeningBalance < 0) // oDR["Balance"] = Convert.ToDouble(0.0); // else // oDR["Balance"] = Convert.ToDouble(oLSchedule.OpeningBalance); // oDR["Interest1"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.ActualInterest)); // oDR["Interest2"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.InstallmentInterest)); // oDR["Days"] = oLSchedule.Days; // oDR["Installment"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.Installment)); // if (oLSchedule.ClosingBalance < 0) // oDR["ClosingBalance"] = GlobalFunctions.Round(Convert.ToDouble(0.0)); // else // oDR["ClosingBalance"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.ClosingBalance)); // oDR["Principal"] = GlobalFunctions.Round(Convert.ToDouble(oLSchedule.InstallmentPrincipal)); // oDR["Deduct"] = Convert.ToDouble(oLSchedule.InstallmentPrincipal + oLSchedule.InstallmentInterest); // if (oLSchedule.PaymentDate != null && oLSchedule.PaymentDate != DateTime.MinValue) //oLSchedule.PaymentDate != DateTime.MinValue // { // oDR["Status"] = " Paid"; // } // else // { // oDR["Status"] = " Not Paid"; // } // dTable.Rows.Add(oDR); // } // return dTable; //} //public void CurrentLoanIssue() //{ // Loan oLoan = null; // DataRow oDR = null; // fReportViewer form = new fReportViewer(); // DateTime dSalaryMonth = _selectedParameter.FromDate.Value; // DateTime dSalaryMonth = Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate; // string sEmpID = _selectedParameter.ReportItem.INSQL; // string[] sEMPIDs = sEmpID.Split(','); // ID loanID = null; // ObjectsTemplate loanIssues = LoanIssue.Get(GlobalFunctions.FirstDateOfMonth(dSalaryMonth), GlobalFunctions.LastDateOfMonth(dSalaryMonth)); // loanIssues = loanIssues.Where(x => sEmpID.Contains(x.EmployeeID.Integer.ToString())).ToObjectsTemplate(); // if (_selectedParameter.Loans != null && _selectedParameter.Loans.Count > 0) // { // loanID = _selectedParameter.Loans[0].ID; // loanIssues = loanIssues.Where(x => x.LoanID.Integer == loanID.Integer).ToObjectsTemplate(); // } // ObjectsTemplate Loans = Loan.Get(EnumStatus.Regardless); // ObjectsTemplate oEmployees = Employee.Get(); // PayrollDataSet.PayrollDataSet.NewlyIssuedLoanDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.NewlyIssuedLoanDataTable(); // try // { // foreach (LoanIssue oLoanIssue in loanIssues) // { // if (_selectedParameter.IsEmployeeExist(oLoanIssue.EmployeeID) == false) continue; // ObjectsTemplate oschedules = oLoanIssue.MonthlySchedules(GlobalFunctions.LastDateOfMonth(dSalaryMonth)); // oLoan = Loans.GetItem(oLoanIssue.LoanID); // if (oLoan != null) // { // oDR = dTable.NewRow(); // oDR["EmpCode"] = oLoanIssue.Employee.EmployeeNo; // oDR["Name"] = oLoanIssue.Employee.Name; // oDR["LoanType"] = oLoan.Name; // oDR["LoanCode"] = oLoanIssue.LoanNo; // oDR["LoanAmount"] = oLoanIssue.LoanAmount; // oDR["NoOfInstallment"] = oLoanIssue.NoOfInstallments; // oDR["IssueDate"] = oLoanIssue.IssueDate.ToString("dd MMM yyyy"); // oDR["InterestRate"] = oLoanIssue.InterestRate; // oDR["InstallmentAmount"] = oLoanIssue.InstallmentPrincipal;// oLSchedule.InstallmentPrincipal; // if (oLoanIssue.NoOfInstallments > 12) // { // oDR["InterestAmount"] = Math.Round(2 * oLoanIssue.LoanAmount * oLoanIssue.InterestRate / 100); // } // else // { // oDR["InterestAmount"] = Math.Round(oLoanIssue.LoanAmount * oLoanIssue.InterestRate / 100); // } // dTable.Rows.Add(oDR); // } // } // } // catch (Exception ex) // { // throw new Exception(ex.Message); // } // string LoanMonth = dSalaryMonth.ToString("MMM yyyy"); // form.ShowDlgForCurrentLoan(_selectedParameter.ReportItem, dTable, LoanMonth); //} //public void LoanPaymentDueNew() //{ // Loan oLoan = null; // DataRow oDR = null; // fReportViewer form = new fReportViewer(); // DateTime dSalaryMonth = _selectedParameter.FromDate.Value; // string sEmpID = _selectedParameter.ReportItem.INSQL; // ObjectsTemplate loanIssues = LoanIssue.GetByDueInstallmentDate(GlobalFunctions.LastDateOfMonth(dSalaryMonth), sEmpID); // ObjectsTemplate Loans = Loan.Get(EnumStatus.Regardless); // PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable(); // try // { // foreach (LoanIssue oLoanIssue in loanIssues) // { // if (_selectedParameter.IsEmployeeExist(oLoanIssue.EmployeeID) == false) continue; // ObjectsTemplate oschedules = oLoanIssue.MonthlySchedules(GlobalFunctions.LastDateOfMonth(dSalaryMonth)); // foreach (LoanSchedule oLSchedule in oschedules) // { // oLoan = Loans.GetItem(oLoanIssue.LoanID); // if (oLoan != null) // { // if (oLSchedule.ScheduleNo == 1) // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = oLoanIssue.Employee.EmployeeNo; // oDR["EmpName"] = oLoanIssue.Employee.Name; // oDR["Loan"] = oLoan.Name; // oDR["LoanNo"] = oLoanIssue.LoanNo; // oDR["LoanAmount"] = oLoanIssue.LoanAmount; // oDR["OpeningBalance"] = oLSchedule.OpeningBalance; // oDR["InstalmentAmount"] = oLSchedule.InstallmentPrincipal; // oDR["InstallInterest"] = oLSchedule.InstallmentInterest; // dTable.Rows.Add(oDR); // } // else if (oLoanIssue.NoOfInstallments == oLSchedule.ScheduleNo) // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = oLoanIssue.Employee.EmployeeNo; // oDR["EmpName"] = oLoanIssue.Employee.Name; // oDR["Loan"] = oLoan.Name; // oDR["LoanNo"] = oLoanIssue.LoanNo; // oDR["LoanAmount"] = oLoanIssue.LoanAmount; // oDR["OpeningBalance"] = oLSchedule.OpeningBalance; // oDR["InstalmentAmount"] = oLSchedule.InstallmentPrincipal; // oDR["InstallInterest"] = oLSchedule.InstallmentInterest; // dTable.Rows.Add(oDR); // } // else // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = oLoanIssue.Employee.EmployeeNo; // oDR["EmpName"] = oLoanIssue.Employee.Name; // oDR["Loan"] = oLoan.Name; // oDR["LoanNo"] = oLoanIssue.LoanNo; // oDR["LoanAmount"] = oLoanIssue.LoanAmount; // oDR["OpeningBalance"] = oLSchedule.OpeningBalance; // oDR["InstalmentAmount"] = oLSchedule.InstallmentPrincipal; // oDR["InstallInterest"] = oLSchedule.InstallmentInterest; // dTable.Rows.Add(oDR); // } // } // } // } // } // catch (Exception ex) // { // throw new Exception(ex.Message); // } // string LoanMonth = dSalaryMonth.ToString("MMM yyyy"); // form.ShowDlgForLoanPaymentDue(_selectedParameter.ReportItem, dTable, LoanMonth); //} //public void IndivisualLoanReport() //{ // int count = 1; // Loan oLoan = null; // DataRow oDR = null; // fReportViewer form = new fReportViewer(); // DateTime dSalaryMonth = _selectedParameter.FromDate.Value; // string empID = _selectedParameter.ReportItem.INSQL; // ObjectsTemplate loanIssues = LoanIssue.Get(GlobalFunctions.LastDateOfMonth(dSalaryMonth)); // ObjectsTemplate loanIssues = LoanIssue.Get(empID); // ObjectsTemplate Loans = Loan.Get(EnumStatus.Regardless); // PayrollDataSet.PayrollDataSet.IndividualLoanReportDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.IndividualLoanReportDataTable(); // foreach (LoanIssue oLoanIssue in loanIssues) // { // if (_selectedParameter.IsEmployeeExist(oLoanIssue.EmployeeID) == false) continue; // ObjectsTemplate oschedules = LoanSchedule.GetByIssueID(oLoanIssue.ID); // foreach (LoanSchedule oLSchedule in oschedules) // { // oLoan = Loans.GetItem(oLoanIssue.LoanID); // if (oLoan != null) // { // oDR = dTable.NewRow(); // oDR["SLNo"] = count; // oDR["EmployeeID"] = oLoanIssue.Employee.EmployeeNo; // oDR["EmpName"] = oLoanIssue.Employee.Name; // oDR["LoanType"] = oLoan.Name; // oDR["LoanNo"] = oLoanIssue.LoanNo; // oDR["LoanAmount"] = oLoanIssue.LoanAmount; // oDR["InterestRate"] = oLoanIssue.InterestRate; // oDR["ScheduleInstallments"] = oLoanIssue.NoOfInstallments; // oDR["DisburseFrom"] = oLoanIssue.IssueDate; // oDR["OpeningBalance"] = oLSchedule.OpeningBalance; // oDR["PrincipleBalance"] = oLSchedule.InstallmentPrincipal; // oDR["InstallmentAmount"] = oLSchedule.Installment; // oDR["Interest"] = oLSchedule.InstallmentInterest; // oDR["TotalAmount"] = oLSchedule.Installment + oLSchedule.InstallmentInterest; // oDR["ClosingBalance"] = oLSchedule.ClosingBalance; // oDR["InstallmentsDue"] = oLoanIssue.NoOfInstallments - oLSchedule.ScheduleNo; // oDR["Month"] = dSalaryMonth; // dTable.Rows.Add(oDR); // count++; // } // } // } // form.ShowDlgForIndivisualLoanReport(_selectedParameter.ReportItem, dTable); //} //public void individualLoanReportByLoan(ID empId, string loanNo) //{ // Loan oLoan = null; // DataRow oDR = null; // int count = 1; // fReportViewer form = new fReportViewer(); // ObjectsTemplate loanIssues = new ObjectsTemplate(); // ObjectsTemplate tloanIssues; // tloanIssues = LoanIssue.Get(); // foreach (LoanIssue oLoanIssue in tloanIssues) // { // if ((oLoanIssue.EmployeeID == empId) && (oLoanIssue.LoanNo == loanNo)) // { // loanIssues.Add(oLoanIssue); // } // } // ObjectsTemplate Loans = Loan.Get(EnumStatus.Regardless); // PayrollDataSet.PayrollDataSet.IndividualLoanReportDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.IndividualLoanReportDataTable(); // foreach (LoanIssue oLoanIssue in loanIssues) // { // ObjectsTemplate oschedules = LoanSchedule.GetByIssueID(oLoanIssue.ID); // foreach (LoanSchedule oLSchedule in oschedules) // { // oLoan = Loans.GetItem(oLoanIssue.LoanID); // if (oLoan != null) // { // oDR = dTable.NewRow(); // oDR["SLNo"] = count; // oDR["EmployeeID"] = oLoanIssue.Employee.EmployeeNo; // oDR["EmpName"] = oLoanIssue.Employee.Name; // oDR["LoanType"] = oLoan.Name; // oDR["LoanNo"] = oLoanIssue.LoanNo; // oDR["LoanAmount"] = oLoanIssue.LoanAmount; // oDR["InterestRate"] = oLoanIssue.InterestRate; // oDR["ScheduleInstallments"] = oLoanIssue.NoOfInstallments; // oDR["DisburseFrom"] = oLoanIssue.IssueDate; // oDR["OpeningBalance"] = oLSchedule.OpeningBalance; // oDR["PrincipleBalance"] = oLSchedule.InstallmentPrincipal; // oDR["InstallmentAmount"] = oLSchedule.Installment; // oDR["Interest"] = oLSchedule.InstallmentInterest; // oDR["TotalAmount"] = oLSchedule.Installment + oLSchedule.InstallmentInterest; // oDR["ClosingBalance"] = oLSchedule.ClosingBalance; // oDR["InstallmentsDue"] = oLoanIssue.NoOfInstallments - oLSchedule.ScheduleNo; // oDR["Month"] = oLoanIssue.IssueDate; // dTable.Rows.Add(oDR); // count++; // } // } // } // form.ShowDlgForindividualLoanReportByLoan; // form.ShowDlgForindividualLoanReportByLoan(dTable); //} //public void LatestIndividualLoanReport(LoanIssue oLoanIssues, Employee oEmp, string sLoanName) //{ // _LoanIssue = oLoanIssues; // ObjectsTemplate oEmpCCs = EmployeeCostCenter.GetByEmpID(oEmp.ID); // if (_LoanIssue != null && _LoanIssue.Schedules.Count > 0) // { // DataTable oDTable = null; // dSet = new DataSet(); // LoanReport oLoanReport = new LoanReport(); // oDTable = oLoanReport.GetLaonIssue(_LoanIssue); // fReportViewer form = new fReportViewer(); // _item = ReportItem.GetByReportType(Convert.ToInt32(EnumReportType.LoanIssue)); // oDTable.TableName = "PayrollDataSet_LoanIssue"; // RDLC = "Payroll.Report.RDLC.LoanIssue.rdlc"; // dSet.Tables.Add(oDTable); // double LoanAmount; // double InterestRate; // int noOfInstallment; // string LoanName; // string sDesignation; // string sRC = ""; // string sDepartment; // string sLocation; // DateTime IssueDate; // DateTime dFromDate; // DateTime dToDate; // InterestRate = _LoanIssue.InterestRate; // IssueDate = _LoanIssue.IssueDate != DateTime.MinValue ? _LoanIssue.IssueDate : DateTime.Now; // LoanAmount = _LoanIssue.LoanAmount; // noOfInstallment = _LoanIssue.NoOfInstallments; // LoanName = sLoanName; // dFromDate = _LoanIssue.Schedules[0].DueInstallmentDate; // dToDate = _LoanIssue.Schedules[_LoanIssue.Schedules.Count - 1].DueInstallmentDate; // if (oEmp.Designation != null) // sDesignation = oEmp.DescriptionText; // else // sDesignation = ""; // if (oEmp.Department != null) // sDepartment = oEmp.Department.Name; // else // sDepartment = ""; // if (oEmp.Location != null) // sLocation = oEmp.Location.Name; // else // sLocation = ""; // foreach (EmployeeCostCenter oEmpCC in oEmpCCs) // { // if (sRC == string.Empty) // { // sRC = oEmpCC.Costcenter.Name; // } // else // { // sRC = "," + oEmpCC.Costcenter.Name; // } // } // form.ShowDlgForLoanIssue(_item, dSet, RDLC, oEmp.Name, oEmp.EmployeeNo, LoanAmount, InterestRate, noOfInstallment, dFromDate, dToDate, LoanName, _LoanIssue.IssueDate); // form.ShowDlgForNovartisLoanIssue(_item, dSet, RDLC, oEmp.Name, oEmp.EmployeeNo, LoanAmount, InterestRate, noOfInstallment, dFromDate, dToDate, LoanName, sDesignation, sRC, sDepartment, sLocation); // } //} //public void CurrentMonthDueLoan() //{ // DataRow oDR = null; // DataSet oLaonPayments = null; // fReportViewer form = new fReportViewer(); // ID loanID = null; // string sEmpID = _selectedParameter.ReportItem.INSQL; // if (_selectedParameter.Loans != null && _selectedParameter.Loans.Count > 0) // loanID = _selectedParameter.Loans[0].ID; // oLaonPayments = LoanSchedule.GetCurrentMonthDueLoan(sEmpID, loanID); // PayrollDataSet.PayrollDataSet.CurrentMonthDueLoanDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.CurrentMonthDueLoanDataTable(); // foreach (DataRow oDRow in oLaonPayments.Tables[0].Rows) // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = oDRow["EmployeeNo"]; // oDR["EmpName"] = oDRow["Name"]; // oDR["Loan"] = oDRow["Description"]; // oDR["LoanNo"] = oDRow["LoanNo"]; // oDR["LoanAmount"] = oDRow["LoanAmount"]; // oDR["InstallmentPrincipal"] = oDRow["InstallmentPrincipal"]; // oDR["NoofInstallment"] = oDRow["NoofInstallments"]; // if (Convert.ToInt32(oDRow["NOOFINSTALLMENTS"]) > 12) // { // oDR["Interest"] = Math.Round(2 * Convert.ToDouble(oDRow["LoanAmount"]) * Convert.ToDouble(oDRow["INTERESTRATE"]) / 100); // } // else // { // oDR["Interest"] = Math.Round(Convert.ToDouble(oDRow["LoanAmount"]) * Convert.ToDouble(oDRow["INTERESTRATE"]) / 100); // } // if (Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer == 1) // oDR["NoofInstallmentPaid"] = oDRow["NoofPaid"]; // else // { // if (Convert.ToInt16(oDRow["INTERESTRATE"]) > 0) // { // if (Convert.ToInt16(oDRow["NOOFINSTALLMENTS"]) < 24) // oDR["NoofInstallmentPaid"] = (Convert.ToInt16(oDRow["NoofPaid"]) + 1).ToString(); // else // oDR["NoofInstallmentPaid"] = (Convert.ToInt16(oDRow["NoofPaid"]) + 2).ToString(); // } // else // oDR["NoofInstallmentPaid"] = oDRow["NoofPaid"]; // } // oDR["InstallmentPaid"] = (Convert.ToDouble(oDRow["InstallmentPrincipal"]) * Convert.ToDouble(oDR["NoofInstallmentPaid"])).ToString(); // if (Convert.ToDouble(oDRow["OutStanding"]) > Convert.ToDouble(oDR["Interest"])) // { // oDR["RemainingInstallment"] = (Convert.ToDouble(oDRow["OutStanding"]) - Convert.ToDouble(oDR["Interest"])); // } // else // { // oDR["RemainingInstallment"] = (Convert.ToDouble(oDR["Interest"]) - Convert.ToDouble(oDRow["OutStanding"])); // } // oDR["TotalDue"] = oDRow["OutStanding"]; // dTable.Rows.Add(oDR); // } // form.ShowDlgForCurrentMonthDueLoan(_selectedParameter.ReportItem, dTable); //} //public void CashRefund() //{ // DataRow oDR = null; // fReportViewer form = new fReportViewer(); // ID loanID = null; // string sEmpID = _selectedParameter.ReportItem.INSQL; // DateTime dLoanMonth = _selectedParameter.FromDate.Value; // ObjectsTemplate loanIssues = LoanIssue.GetByEmpIDs(sEmpID); // loanIssues = loanIssues.Where(l => (l.SettledPrincipal + l.SettledInterest) > 0 && (l.ModifiedDate >= GlobalFunctions.FirstDateOfMonth(dLoanMonth) && l.ModifiedDate <= GlobalFunctions.LastDateOfMonth(dLoanMonth))).ToObjectsTemplate(); // if (_selectedParameter.Loans != null && _selectedParameter.Loans.Count > 0) // { // loanID = _selectedParameter.Loans[0].ID; // loanIssues = loanIssues.Where(l => l.LoanID.Integer == loanID.Integer).ToObjectsTemplate(); // } // PayrollDataSet.PayrollDataSet.CashRefundDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.CashRefundDataTable(); // foreach (LoanIssue item in loanIssues) // { // oDR = dTable.NewRow(); // oDR["EmpNo"] = item.Employee.EmployeeNo; // oDR["EmpName"] = item.Employee.Name; // oDR["Loan"] = item.LoanObj.Name; // oDR["LoanNo"] = item.LoanNo; // oDR["InstallmentPrinciple"] = item.SettledPrincipal > 0 ? item.SettledPrincipal.ToString("#,###") : "0"; // oDR["Interest"] = item.SettledInterest > 0 ? item.SettledInterest.ToString("#,###") : "0"; // oDR["SettlementType"] = item.IsTopup ? "Top-up" : "Cash"; // oDR["RefundDate"] = item.ModifiedDate.Value.ToString("dd-MMM-yyyy"); // dTable.Rows.Add(oDR); // } // form.ShowDlgForCashRefund(_selectedParameter.ReportItem, dTable); //} //public void IndividualSharedLoanReport(LoanIssue oLoanIssues, Employee oEmp, string sLoanName, LoanParameter oloanParameter) //{ // _LoanIssue = oLoanIssues; // _LoanParameter = oloanParameter; // ObjectsTemplate oEmpCCs = EmployeeCostCenter.GetByEmpID(oEmp.ID); // if (_LoanIssue != null && _LoanIssue.Schedules.Count > 0) // { // DataTable oDTable = null; // dSet = new DataSet(); // oDTable = GetSharedLaonIssue(oLoanIssues); // fReportViewer form = new fReportViewer(); // _item = ReportItem.GetByReportType(Convert.ToInt32(EnumReportType.LoanIssue)); // oDTable.TableName = "PayrollDataSet_SharedLoanIssue"; // RDLC = "Payroll.Report.RDLC.LoanSharedIssue.rdlc"; // dSet.Tables.Add(oDTable); // double LoanAmount; // double InterestRate; // double MaxCmpPayPercent;//new // double ResiduePercent;//new // double PMTValue;//new // int noOfInstallment; // string LoanName; // string sDesignation; // string sRC = ""; // string sDepartment; // string sLocation; // DateTime IssueDate; // DateTime dFromDate; // DateTime dToDate; // InterestRate = _LoanIssue.InterestRate; // IssueDate = _LoanIssue.IssueDate != DateTime.MinValue ? _LoanIssue.IssueDate : DateTime.Now; // LoanAmount = _LoanIssue.LoanAmount; // MaxCmpPayPercent = _LoanParameter.CmpSharePercent; // ResiduePercent = _LoanParameter.CmpShareIntPercent; // PMTValue = _LoanIssue.Schedules[0].InstallmentPrincipal; // noOfInstallment = _LoanIssue.NoOfInstallments; // LoanName = sLoanName; // dFromDate = _LoanIssue.Schedules[0].DueInstallmentDate; // dToDate = _LoanIssue.Schedules[_LoanIssue.Schedules.Count - 1].DueInstallmentDate; // if (oEmp.Designation != null) // sDesignation = oEmp.Designation.Name; // else // sDesignation = ""; // if (oEmp.Department != null) // sDepartment = oEmp.Department.Name; // else // sDepartment = ""; // if (oEmp.Location != null) // sLocation = oEmp.Location.Name; // else // sLocation = ""; // foreach (EmployeeCostCenter oEmpCC in oEmpCCs) // { // if (sRC == string.Empty) // { // sRC = oEmpCC.Costcenter.Name; // } // else // { // sRC = "," + oEmpCC.Costcenter.Name; // } // } // form.ShowDlgForSharedLoanIssue(_item, dSet, RDLC, oEmp.Name, oEmp.EmployeeNo, LoanAmount, InterestRate, noOfInstallment, dFromDate, dToDate, LoanName, _LoanIssue.Schedules[0].LoanIssue.IssueDate,MaxCmpPayPercent,ResiduePercent,PMTValue); // // form.ShowDlgForNovartisLoanIssue(_item, dSet, RDLC, oEmp.Name, oEmp.EmployeeNo, LoanAmount, InterestRate, noOfInstallment, dFromDate, dToDate, LoanName, sDesignation, sRC, sDepartment, sLocation); // } //} } }