From fa8c19b2095237ee492d3be6ffa6b1105542ce55 Mon Sep 17 00:00:00 2001 From: Mohaimen Hasan Date: Sun, 29 Nov 2026 09:50:10 +0600 Subject: [PATCH] LFA BANK Advice --- HRM.BO/HRBasic/Enums.cs | 3 +- HRM.BO/LFA/LFAPayment.cs | 4 + HRM.DA/DA/LFA/LFAPaymentDA.cs | 32 +++++ HRM.DA/Service/LFA/LFAPaymentService.cs | 59 +++++++++ HRM.Report/Class/rptLFABankAdvice.cs | 85 +++++++++++++ HRM.Report/HRM.Report.csproj | 2 + HRM.Report/RDLC/LFABankAdvice.rdlc | 19 +++ HRM.UI/ClientApp/src/app/_models/enums.ts | 1 + .../lfa-bank-advice.component.html | 8 -- .../lfa-bank-advice.component.scss | 0 .../lfa-bank-advice.component.ts | 19 --- .../payroll-lfa/payroll-lfa-routing.module.ts | 6 +- .../src/app/payroll-lfa/payroll-lfa.module.ts | 4 +- .../report-viewer/report-viewer.component.ts | 115 ++++++++++++++++++ HRM.UI/Controllers/Payroll/LFAController.cs | 19 +++ HRM.UI/Controllers/Report/ReportController.cs | 4 + 16 files changed, 347 insertions(+), 33 deletions(-) create mode 100644 HRM.Report/Class/rptLFABankAdvice.cs create mode 100644 HRM.Report/RDLC/LFABankAdvice.rdlc delete mode 100644 HRM.UI/ClientApp/src/app/payroll-lfa/lfa-bank-advice/lfa-bank-advice.component.html delete mode 100644 HRM.UI/ClientApp/src/app/payroll-lfa/lfa-bank-advice/lfa-bank-advice.component.scss delete mode 100644 HRM.UI/ClientApp/src/app/payroll-lfa/lfa-bank-advice/lfa-bank-advice.component.ts diff --git a/HRM.BO/HRBasic/Enums.cs b/HRM.BO/HRBasic/Enums.cs index fad6fef..1b4f3ec 100644 --- a/HRM.BO/HRBasic/Enums.cs +++ b/HRM.BO/HRBasic/Enums.cs @@ -2439,7 +2439,8 @@ namespace HRM.BO ITReport177Yearly = 1005, TAXReconciliation = 1006, BasePay = 1008, - ITReport177Quaterly = 1010 + ITReport177Quaterly = 1010, + LFABankAdvice = 1201 } diff --git a/HRM.BO/LFA/LFAPayment.cs b/HRM.BO/LFA/LFAPayment.cs index 36cc42c..2514326 100644 --- a/HRM.BO/LFA/LFAPayment.cs +++ b/HRM.BO/LFA/LFAPayment.cs @@ -181,6 +181,10 @@ namespace HRM.BO LFAApproverBatch GetApproverBatch(int wfMovementTranID, int? employeeID); LFAApprovalResult ApproveFromApprover(LFAApproverActionRequest request, int? employeeID, int userID); LFAApprovalResult RevertFromApprover(LFAApproverActionRequest request, int? employeeID); + + // LFA Bank Advice (report viewer, EnumReportType.LFABankAdvice) + List GetBankAdviceBatches(int payrollTypeID); + System.Data.DataSet GetBankAdvice(int lfaPaymentID, string sEmpIDs, int bankID, int payrollTypeID); } #endregion diff --git a/HRM.DA/DA/LFA/LFAPaymentDA.cs b/HRM.DA/DA/LFA/LFAPaymentDA.cs index 5ab61c6..f3fb467 100644 --- a/HRM.DA/DA/LFA/LFAPaymentDA.cs +++ b/HRM.DA/DA/LFA/LFAPaymentDA.cs @@ -281,6 +281,38 @@ namespace HRM.DA payrollTypeID, fromDate, toDate); } + /// + /// LFA Bank Advice: the employees of one batch with an amount to pay, with the bank account kept on the + /// detail row when the batch was processed. empIDs = joined ints made by the service (empty = whole batch); + /// bankID 0 = every bank. + /// + internal static DataSet GetBankAdvice(TransactionContext tc, int lfaPaymentID, string empIDs, int bankID, int payrollTypeID) + { + string sql = SQLParser.MakeSQL( + @"SELECT e.EMPLOYEENO, e.NAME, e.EMAILADDRESS, ds.NAME AS DesignationName, d.DESCRIPTION AS DepartmentName, + ISNULL(cc.DESCRIPTION, '') AS CostCenter, dt.AccountNo, ISNULL(bk.NAME, '') AS BankName, + ISNULL(br.NAME, '') AS BranchName, ISNULL(br.ROUTINGNO, '') AS RoutingNo, dt.Amount, + p.BatchNumber, p.PaymentDate, p.LFAYear + FROM LFAPayment p + INNER JOIN LFAPaymentDetail dt ON dt.LFAPaymentID = p.LFAPaymentID + INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = dt.EmployeeID + LEFT JOIN DESIGNATION ds ON ds.DESIGNATIONID = dt.DesignationID + LEFT JOIN DEPARTMENT d ON d.DEPARTMENTID = dt.DepartmentID + LEFT JOIN CRG cc ON cc.CRGID = dt.CostCenterID + LEFT JOIN BRANCHES br ON br.BRANCHID = dt.BranchID + LEFT JOIN BANKS bk ON bk.BANKID = br.BANKID + WHERE p.LFAPaymentID=%n AND p.PayrollTypeID=%n AND dt.Amount > 0", + lfaPaymentID, payrollTypeID); + + if (!string.IsNullOrEmpty(empIDs)) + sql += SQLParser.MakeSQL(" AND dt.EmployeeID IN (%q)", empIDs); + if (bankID > 0) + sql += SQLParser.MakeSQL(" AND br.BANKID=%n", bankID); + sql += " ORDER BY bk.NAME, e.EMPLOYEENO"; + + return tc.ExecuteDataSet(sql); + } + #endregion } diff --git a/HRM.DA/Service/LFA/LFAPaymentService.cs b/HRM.DA/Service/LFA/LFAPaymentService.cs index ba6d767..66fd04d 100644 --- a/HRM.DA/Service/LFA/LFAPaymentService.cs +++ b/HRM.DA/Service/LFA/LFAPaymentService.cs @@ -1160,6 +1160,65 @@ namespace HRM.DA return result; } + #region LFA Bank Advice + + /// LFA Bank Advice: only the approved batches of the payroll type can go to the bank. + public List GetBankAdviceBatches(int payrollTypeID) + { + return GetBatches(payrollTypeID).Where(x => x.WFStatus == enumwfStatus.Approve).ToList(); + } + + /// + /// The bank advice rows of one approved batch of the payroll type: the selected employees (sEmpIDs, + /// comma separated; empty = the whole batch), of one bank (bankID; 0 = every bank). Not approved, + /// or not of this payroll type, is refused. + /// + public System.Data.DataSet GetBankAdvice(int lfaPaymentID, string sEmpIDs, int bankID, int payrollTypeID) + { + // the IDs go into the SQL as %q, so only digits pass + string empIDs = string.Join(",", (sEmpIDs ?? string.Empty) + .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) + .Select(x => int.TryParse(x.Trim(), out int id) ? id : 0) + .Where(id => id > 0) + .Distinct()); + + System.Data.DataSet ds = null; + TransactionContext tc = null; + try + { + tc = TransactionContext.Begin(); + LFAPayment oPayment = null; + DataReader dr = new DataReader(LFAPaymentDA.Get(tc, lfaPaymentID)); + if (dr.Read()) + { + oPayment = this.CreateObject(dr); + } + dr.Close(); + + if (oPayment == null || oPayment.PayrollTypeID != payrollTypeID) + throw new Exception("LFA payment batch not found."); + if (oPayment.WFStatus != enumwfStatus.Approve) + throw new Exception("LFA payment batch " + oPayment.BatchNumber + " is not approved yet."); + + ds = LFAPaymentDA.GetBankAdvice(tc, lfaPaymentID, empIDs, bankID, payrollTypeID); + tc.End(); + } + catch (Exception e) + { + #region Handle Exception + + if (tc != null) + tc.HandleError(); + ExceptionLog.Write(e); + throw new ServiceException(e.Message, e); + + #endregion + } + return ds; + } + + #endregion + /// lfaapproval/workflow = Yes. private static bool IsWorkflowRequired() { diff --git a/HRM.Report/Class/rptLFABankAdvice.cs b/HRM.Report/Class/rptLFABankAdvice.cs new file mode 100644 index 0000000..12db918 --- /dev/null +++ b/HRM.Report/Class/rptLFABankAdvice.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Data; +using HRM.BO; +using HRM.DA; +using Microsoft.Reporting.NETCore; + +namespace HRM.Report +{ + /// + /// LFA Bank Advice (EnumReportType.LFABankAdvice, /payroll-lfa/lfa-bank-advice): the employees of one + /// approved LFA payment batch with their bank account and LFA amount, rendered with LFABankAdvice.rdlc. + /// + public class rptLFABankAdvice + { + private const string RdlcName = "HRM.Report.RDLC.LFABankAdvice.rdlc"; + private const string DataSetName = "dsLFABankAdvice"; + + public byte[] ShowLFABankAdvice(int lfaPaymentID, string sEmpIDs, int bankID, int payrollTypeId, string reportType) + { + if (lfaPaymentID <= 0) + throw new Exception("Select an LFA payment batch."); + + DataSet oSource = new LFAPaymentService().GetBankAdvice(lfaPaymentID, sEmpIDs, bankID, payrollTypeId); + if (oSource == null || oSource.Tables.Count == 0 || oSource.Tables[0].Rows.Count == 0) + throw new Exception("No employee of the selected batch has an LFA amount to pay for this selection."); + + DataTable bankAdvice = new DataTable(DataSetName); + bankAdvice.Columns.Add("SLNo", typeof(int)); + bankAdvice.Columns.Add("EmpNo", typeof(string)); + bankAdvice.Columns.Add("EmpName", typeof(string)); + bankAdvice.Columns.Add("Designation", typeof(string)); + bankAdvice.Columns.Add("Department", typeof(string)); + bankAdvice.Columns.Add("CostCenter", typeof(string)); + bankAdvice.Columns.Add("AccountNo", typeof(string)); + bankAdvice.Columns.Add("Bank", typeof(string)); + bankAdvice.Columns.Add("Branch", typeof(string)); + bankAdvice.Columns.Add("RoutingNo", typeof(string)); + bankAdvice.Columns.Add("Email", typeof(string)); + bankAdvice.Columns.Add("Amount", typeof(double)); + + string batchNumber = string.Empty; + DateTime paymentDate = DateTime.Today; + DateTime lfaYear = DateTime.Today; + int count = 1; + foreach (DataRow oDRow in oSource.Tables[0].Rows) + { + DataRow oDR = bankAdvice.NewRow(); + oDR["SLNo"] = count; + oDR["EmpNo"] = Convert.ToString(oDRow["EMPLOYEENO"]); + oDR["EmpName"] = Convert.ToString(oDRow["NAME"]); + oDR["Designation"] = Convert.ToString(oDRow["DesignationName"]); + oDR["Department"] = Convert.ToString(oDRow["DepartmentName"]); + oDR["CostCenter"] = Convert.ToString(oDRow["CostCenter"]); + oDR["AccountNo"] = Convert.ToString(oDRow["AccountNo"]); + oDR["Bank"] = Convert.ToString(oDRow["BankName"]); + oDR["Branch"] = Convert.ToString(oDRow["BranchName"]); + oDR["RoutingNo"] = Convert.ToString(oDRow["RoutingNo"]); + oDR["Email"] = Convert.ToString(oDRow["EMAILADDRESS"]); + oDR["Amount"] = Math.Round(Convert.ToDouble(oDRow["Amount"])); + bankAdvice.Rows.Add(oDR); + + if (count == 1) + { + batchNumber = Convert.ToString(oDRow["BatchNumber"]); + paymentDate = Convert.ToDateTime(oDRow["PaymentDate"]); + lfaYear = Convert.ToDateTime(oDRow["LFAYear"]); + } + count++; + } + + DataSet dSet = new DataSet(); + dSet.Tables.Add(bankAdvice); + + List parameters = new List + { + new ReportParameter("BatchNumber", batchNumber), + new ReportParameter("PaymentDate", paymentDate.ToString("dd MMM yyyy")), + new ReportParameter("LFAYear", lfaYear.Year.ToString()) + }; + + return new ReportProcessor().CommonReportView(null, RdlcName, dSet, null, parameters, true, payrollTypeId, reportType); + } + } +} diff --git a/HRM.Report/HRM.Report.csproj b/HRM.Report/HRM.Report.csproj index 0b3d320..3c8f9d2 100644 --- a/HRM.Report/HRM.Report.csproj +++ b/HRM.Report/HRM.Report.csproj @@ -61,6 +61,7 @@ + @@ -376,6 +377,7 @@ + diff --git a/HRM.Report/RDLC/LFABankAdvice.rdlc b/HRM.Report/RDLC/LFABankAdvice.rdlc new file mode 100644 index 0000000..801c4cb --- /dev/null +++ b/HRM.Report/RDLC/LFABankAdvice.rdlc @@ -0,0 +1,19 @@ + + +0 +SQL0484ed6e-5b42-4ef1-9904-d52d763ef1b2 +DummyDataSourcetrueSLNoSystem.Int32EmpNoSystem.StringEmpNameSystem.StringDesignationSystem.StringDepartmentSystem.StringCostCenterSystem.StringAccountNoSystem.StringBankSystem.StringBranchSystem.StringRoutingNoSystem.StringEmailSystem.StringAmountSystem.Double + +truetrue="LFA Bank Advice - LFA Year " & Parameters!LFAYear.Value0.05in0.1in0.25in7.5intruetrue="Batch No : " & Parameters!BatchNumber.Value & " Payment Date : " & Parameters!PaymentDate.Value0.32in0.1in0.22in7.5in0.35in0.85in1.9in1.3in1.35in0.85in0.9in0.25intruetrueSLSilverMiddle2pt2pt2pt2pttruetrueEmp IDSilverMiddle2pt2pt2pt2pttruetrueEmployee NameSilverMiddle2pt2pt2pt2pttruetrueAccount NoSilverMiddle2pt2pt2pt2pttruetrueBranchSilverMiddle2pt2pt2pt2pttruetrueRouting NoSilverMiddle2pt2pt2pt2pttruetrueAmount BDT.SilverMiddle2pt2pt2pt2pt0.22intruetrue="Bank : " & IIf(Fields!Bank.Value = "", "(No bank)", Fields!Bank.Value)WhiteSmokeMiddle2pt2pt2pt2pt70.22intruetrue=Fields!SLNo.ValueMiddle2pt2pt2pt2pttruetrue=Fields!EmpNo.ValueMiddle2pt2pt2pt2pttruetrue=Fields!EmpName.ValueMiddle2pt2pt2pt2pttruetrue=Fields!AccountNo.ValueMiddle2pt2pt2pt2pttruetrue=Fields!Branch.ValueMiddle2pt2pt2pt2pttruetrue=Fields!RoutingNo.ValueMiddle2pt2pt2pt2pttruetrue=Fields!Amount.ValueMiddle2pt2pt2pt2pt0.22intruetrue="Sub Total (" & CountRows() & " employees)"Middle2pt2pt2pt2pt6truetrue=Sum(Fields!Amount.Value)Middle2pt2pt2pt2pt0.25intruetrue="Total Amount (" & CountRows() & " employees)"SilverMiddle2pt2pt2pt2pt6truetrue=Sum(Fields!Amount.Value)SilverMiddle2pt2pt2pt2ptAftertruetrue=Fields!Bank.Value=Fields!Bank.ValueAftertrueBeforetrueBeforetruedsLFABankAdvice0.62in0.1in1.16in7.5in0.3in1.8in0.25in4intruetrue=Parameters!Address.Value0.55in1.8in0.2in4inExternal="file:///" & Parameters!Logo.Valueimage/pngFitProportional0.05in0.1in0.7in1.6in0.05in0.1in0.2in2.2intruetrue="Page " & Globals!PageNumber & " of " & Globals!TotalPages0.05in6.4in0.2in1.2in