diff --git a/Payroll.BO/Basic/Enums.cs b/Payroll.BO/Basic/Enums.cs index afe2780..faea663 100644 --- a/Payroll.BO/Basic/Enums.cs +++ b/Payroll.BO/Basic/Enums.cs @@ -1248,6 +1248,7 @@ namespace Payroll.BO Memorandum = 52, SalarySMS = 53, SalarySheetSummary = 54, + SalarySheetSummaryWithLWP = 541, SalarySheetArrear = 57, SalaryBankSummary = 55, SalaryByMonthAndYear = 111111, diff --git a/Payroll.Report/Class/rptSalarySheet.cs b/Payroll.Report/Class/rptSalarySheet.cs index a9e60ca..4197b79 100644 --- a/Payroll.Report/Class/rptSalarySheet.cs +++ b/Payroll.Report/Class/rptSalarySheet.cs @@ -931,14 +931,53 @@ namespace Payroll.Report return null; } public void ShowReport() + { + ShowSalarySheet(false); + } + + /// + /// Salary Sheet with LWP (ReportID 541): items are shown at full amount and the + /// unauthorized leave (LWP) deduction is shown as a separate deduction column. + /// + public void ShowReportWithLWP() + { + ShowSalarySheet(true); + } + + private void ShowSalarySheet(bool withLWP) { fReportViewer form = new fReportViewer(); _SalaryMonth = _selectedParameter.FromDate.Value; - ID nReportID = _selectedParameter.ReportItem.ReportID; + // Signatures/authorization are shared with the normal Salary Sheet (54) + ID nReportID = withLWP ? ID.FromInteger((int)EnumReportType.SalarySheetSummary) : _selectedParameter.ReportItem.ReportID; string sEmpID = _selectedParameter.ReportItem.INSQL; DataRow oDR = null; DataSet oSalarySheets = null; oSalarySheets = SalaryMonthly.GetEmpSalarySheet(GlobalFunctions.LastDateOfMonth(_SalaryMonth), sEmpID); + + // One "LWP" row per employee = sum of all unauthorized leave deductions + DataTable dtLWP = oSalarySheets.Tables["UnAuthorizedLeave"].Clone(); + dtLWP.Columns["Description"].ReadOnly = false; + if (withLWP) + { + foreach (DataRow src in oSalarySheets.Tables["UnAuthorizedLeave"].Rows) + { + DataRow lwp = GetItem3(dtLWP, src["EMPLOYEENO"].ToString()); + if (lwp == null) + { + lwp = dtLWP.NewRow(); + lwp.ItemArray = src.ItemArray; + lwp["ITEMCODE"] = 0; + lwp["ITEMID"] = 0; + lwp["Description"] = "LWP"; + dtLWP.Rows.Add(lwp); + } + else + { + lwp["Amount"] = Convert.ToDouble(lwp["Amount"]) + Convert.ToDouble(src["Amount"]); + } + } + } PayrollDataSet.PayrollDataSet.SalarySheetDataTable dTSalarySheet = new Payroll.Report.PayrollDataSet.PayrollDataSet.SalarySheetDataTable(); List components = new List() { "Basic", "Allowance", "OT", "Deduction", "Loan" }; @@ -1056,6 +1095,12 @@ namespace Payroll.Report } + seq++; + foreach (DataRow dr in dtLWP.Rows) + { + dr["SequenceNo"] = seq; + } + seq++; foreach (DataRow dr in oSalarySheets.Tables["TotalDeduction"].Rows) { @@ -1083,7 +1128,8 @@ namespace Payroll.Report oDR = dTSalarySheet.NewRow(); this.CopyNonMngtForGross(oDR, source); - if (source["ITEMGROUP"].ToString() == "1") + // With LWP the items stay at full amount; LWP is shown as a separate deduction + if (!withLWP && source["ITEMGROUP"].ToString() == "1") { DataRow dr = this.GetItem2(oSalarySheets.Tables["UnAuthorizedLeave"], source["EMPLOYEENO"].ToString(), EnumSalaryGroup.UnauthLeave, (EnumSalaryItemCode)Convert.ToInt16(source["ITEMCODE"]), Convert.ToInt16(source["ITEMID"])); if (dr != null) @@ -1106,6 +1152,15 @@ namespace Payroll.Report { oDR["Amount"] = Convert.ToDouble(dr2["Amount"]) + Convert.ToDouble(dr["Amount"]); } + if (withLWP && dr2 != null) + { + // Gross before LWP = Net Pay + Total Deduction + LWP + DataRow drLWP = this.GetItem3(dtLWP, source["EMPLOYEENO"].ToString()); + double nGross = Convert.ToDouble(dr2["Amount"]); + if (dr != null) nGross += Convert.ToDouble(dr["Amount"]); + if (drLWP != null) nGross += Convert.ToDouble(drLWP["Amount"]); + oDR["Amount"] = nGross; + } dTSalarySheet.Rows.Add(oDR); } @@ -1116,10 +1171,35 @@ namespace Payroll.Report dTSalarySheet.Rows.Add(oDR); } + foreach (DataRow source in dtLWP.Rows) + { + oDR = dTSalarySheet.NewRow(); + this.CopyNonMngtForDeduct(oDR, source); + dTSalarySheet.Rows.Add(oDR); + } + foreach (DataRow source in oSalarySheets.Tables["TotalDeduction"].Rows) { oDR = dTSalarySheet.NewRow(); this.CopyNonManagement(oDR, source); + if (withLWP) + { + DataRow drLWP = this.GetItem3(dtLWP, source["EMPLOYEENO"].ToString()); + if (drLWP != null) + oDR["Amount"] = Convert.ToDouble(oDR["Amount"]) + Convert.ToDouble(drLWP["Amount"]); + } + dTSalarySheet.Rows.Add(oDR); + } + + // Employee with LWP but no regular deduction has no Total Deduction row + foreach (DataRow source in dtLWP.Rows) + { + if (this.GetItem3(oSalarySheets.Tables["TotalDeduction"], source["EMPLOYEENO"].ToString()) != null) continue; + oDR = dTSalarySheet.NewRow(); + this.CopyNonManagement(oDR, source); + oDR["Description"] = "Total Deduction"; + oDR["SequenceNo"] = oSalarySheets.Tables["TotalDeduction"].Rows.Count > 0 + ? oSalarySheets.Tables["TotalDeduction"].Rows[0]["SequenceNo"] : Convert.ToInt32(source["SequenceNo"]) + 1; dTSalarySheet.Rows.Add(oDR); } @@ -1130,7 +1210,7 @@ namespace Payroll.Report dTSalarySheet.Rows.Add(oDR); } - + #endregion //return dTSalarySheet; diff --git a/Payroll.UI/Payroll.UI/Menu.xml b/Payroll.UI/Payroll.UI/Menu.xml index 17c5ea6..29a5627 100644 --- a/Payroll.UI/Payroll.UI/Menu.xml +++ b/Payroll.UI/Payroll.UI/Menu.xml @@ -1101,6 +1101,14 @@ + + Payroll.Report.fReportSearch + ShowDlg + + + + + frmPayRollRegisterForAll