diff --git a/.gitignore b/.gitignore index aedc00d..1b8b135 100644 --- a/.gitignore +++ b/.gitignore @@ -749,3 +749,4 @@ FodyWeavers.xsd # Additional files built by Visual Studio # End of https://www.toptal.com/developers/gitignore/api/csharp,angular,aspnetcore,visualstudio,visualstudiocode +/Scripts diff --git a/Payroll.BO/Basic/Enums.cs b/Payroll.BO/Basic/Enums.cs index faea663..ab55a41 100644 --- a/Payroll.BO/Basic/Enums.cs +++ b/Payroll.BO/Basic/Enums.cs @@ -1295,6 +1295,7 @@ namespace Payroll.BO StuffAccountWithoutSalary = 507, SalaryComparisonNew = 508, AuditReport = 509, + SalaryCertificateLastAgreement = 510, BankForwording = 400, //PF PFLedger = 61, diff --git a/Payroll.Report/Class/rptIncomeTax.cs b/Payroll.Report/Class/rptIncomeTax.cs index c7f0f86..d57e51c 100644 --- a/Payroll.Report/Class/rptIncomeTax.cs +++ b/Payroll.Report/Class/rptIncomeTax.cs @@ -256,7 +256,7 @@ namespace Payroll.Report m_nYpos = m_nYpos + nLineHeight; nLineHeight = 0; - oCaption = m_oDoc.CreateText("Employee ID:", m_nColWidth[1]); + oCaption = m_oDoc.CreateText("Employee ID:", m_nColWidth[1] + 1); oCaption.HAlignment = EPHAlignConstants.EPHAlignLeft; if (oCaption.Height > nLineHeight) nLineHeight = oCaption.Height; m_oDoc.CurrentPage.AddText(oCaption, m_nXpos[0], m_nYpos); @@ -535,7 +535,7 @@ namespace Payroll.Report m_nYpos = m_nYpos + nLineHeight; nLineHeight = 0; - oCaption = m_oDoc.CreateText("Employee ID:", m_nColWidth[1]); + oCaption = m_oDoc.CreateText("Employee ID:", m_nColWidth[1] + 1); oCaption.Style.Font.Size = 8; oCaption.HAlignment = EPHAlignConstants.EPHAlignLeft; if (oCaption.Height > nLineHeight) nLineHeight = oCaption.Height; diff --git a/Payroll.Report/Class/rptSalarySheet.cs b/Payroll.Report/Class/rptSalarySheet.cs index 4197b79..47af1a8 100644 --- a/Payroll.Report/Class/rptSalarySheet.cs +++ b/Payroll.Report/Class/rptSalarySheet.cs @@ -5154,6 +5154,148 @@ namespace Payroll.Report form.ShowDlgForSalaryCertificate(_selectedParameter.ReportItem, dtTempSalarySheet, _SalaryMonth, toDate); } + /// + /// Salary Certificate as per the last salary agreement (employee life cycle) effective in the selected month. + /// Basic comes from the grade salary assignment in force at the month end; every grade-defined allowance + /// applicable to that grade is calculated from the allowance parameter, the same way the salary process does it. + /// + public void SalaryCertificateLastAgreement() + { + if (_selectedParameter.FromDate == null) + throw new ServiceException("Please select the month."); + + string sEmpID = _selectedParameter.ReportItem.INSQL; + if (string.IsNullOrEmpty(sEmpID)) + throw new ServiceException("Please select at least one employee."); + + DateTime salaryMonth = GlobalFunctions.LastDateOfMonth(_selectedParameter.FromDate.Value); + + DataTable dtCertificate = new DataTable("SalaryCertificateLastAgreement"); + dtCertificate.Columns.Add("EmployeeID", typeof(int)); + dtCertificate.Columns.Add("EmpNo", typeof(string)); + dtCertificate.Columns.Add("EmpName", typeof(string)); + dtCertificate.Columns.Add("Salutation", typeof(string)); + dtCertificate.Columns.Add("HisHer", typeof(string)); + dtCertificate.Columns.Add("Designation", typeof(string)); + dtCertificate.Columns.Add("Department", typeof(string)); + dtCertificate.Columns.Add("Grade", typeof(string)); + dtCertificate.Columns.Add("JoiningDate", typeof(string)); + dtCertificate.Columns.Add("EffectDate", typeof(string)); + dtCertificate.Columns.Add("SLNo", typeof(int)); + dtCertificate.Columns.Add("ItemName", typeof(string)); + dtCertificate.Columns.Add("Amount", typeof(double)); + dtCertificate.Columns.Add("TakaInWords", typeof(string)); + dtCertificate.Columns.Add("HeShe", typeof(string)); + dtCertificate.Columns.Add("HisHerCap", typeof(string)); + dtCertificate.Columns.Add("NID", typeof(string)); + dtCertificate.Columns.Add("Article", typeof(string)); + + ObjectsTemplate employees = Employee.GetByEmpIDs(sEmpID); + ObjectsTemplate hrEmployees = HREmployee.GetByIds(sEmpID); + ObjectsTemplate allParameters = ADParameter.Get(EnumStatus.Active); + StringBuilder skipped = new StringBuilder(); + + foreach (Employee emp in employees.OrderBy(x => x.EmployeeNo)) + { + EmployeeGradeSalary gradeSalary = EmployeeGradeSalary.Get(emp.ID, salaryMonth, EnumArrearType.NotPresent); + if (gradeSalary == null) + { + skipped.AppendLine(emp.EmployeeNo + " - " + emp.Name); + continue; + } + // full month value as per agreement, not prorated + gradeSalary.FractionofFromTo = 1; + + // item name, amount, position + List> items = new List>(); + items.Add(new Tuple("Basic Salary", GlobalFunctions.Round(gradeSalary.BasicSalary), -1)); + + if (allParameters != null) + { + List applicable = ADParameter.GetApplicableParameters(emp, gradeSalary.GradeID, allParameters); + foreach (ADParameter parameter in applicable) + { + if (parameter.EntitleType != EnumEntitleType.Grade) continue; + if (parameter.AllowOrDeductType != EnumAllowOrDeduct.Allowance) continue; + if (parameter.AllowanceDeduction == null) continue; + + double amount = GlobalFunctions.Round(parameter.GetGradeDefinedAmount(emp, + gradeSalary.BasicSalary, gradeSalary.GrossSalary, gradeSalary)); + if (amount == 0) continue; + + int index = items.FindIndex(x => x.Item1 == parameter.AllowanceDeduction.Name); + if (index >= 0) + items[index] = new Tuple(items[index].Item1, items[index].Item2 + amount, items[index].Item3); + else + items.Add(new Tuple(parameter.AllowanceDeduction.Name, amount, parameter.AllowanceDeduction.Sequence)); + } + } + + double total = items.Sum(x => x.Item2); + string takaInWords = Ease.CoreV35.Utility.Global.NumericFunctions.TakaWords(total); + + Grade grade = Grade.Get(gradeSalary.GradeID); + bool isFemale = emp.Gender == EnumGender.Female; + string designation = emp.Designation != null ? emp.Designation.Name : string.Empty; + string department = emp.Department != null ? emp.Department.Name : string.Empty; + HREmployee hrEmp = hrEmployees == null ? null : hrEmployees.Find(x => x.ID.Integer == emp.ID.Integer); + string nid = hrEmp != null && hrEmp.NationalID != null ? hrEmp.NationalID.Trim() : string.Empty; + string article = designation.Length > 0 && "AEIOUaeiou".IndexOf(designation[0]) >= 0 ? "an" : "a"; + // e.g. "1st December, 2023" + Func ordinalDate = d => + { + int day = d.Day; + string suffix = (day % 100 >= 11 && day % 100 <= 13) ? "th" + : day % 10 == 1 ? "st" : day % 10 == 2 ? "nd" : day % 10 == 3 ? "rd" : "th"; + return day + suffix + " " + d.ToString("MMMM, yyyy"); + }; + string joiningDate = ordinalDate(emp.JoiningDate); + + int sl = 1; + foreach (Tuple item in items.OrderBy(x => x.Item3)) + { + DataRow row = dtCertificate.NewRow(); + row["EmployeeID"] = emp.ID.Integer; + row["EmpNo"] = emp.EmployeeNo; + row["EmpName"] = emp.Name; + row["Salutation"] = isFemale ? "Ms." : "Mr."; + row["HisHer"] = isFemale ? "her" : "his"; + row["Designation"] = designation; + row["Department"] = department; + row["Grade"] = grade != null ? grade.Name : string.Empty; + row["JoiningDate"] = joiningDate; + row["HeShe"] = isFemale ? "She" : "He"; + row["HisHerCap"] = isFemale ? "Her" : "His"; + row["NID"] = nid; + row["Article"] = article; + row["EffectDate"] = ordinalDate(gradeSalary.EffectDate); + row["SLNo"] = sl++; + row["ItemName"] = item.Item1; + row["Amount"] = item.Item2; + row["TakaInWords"] = takaInWords; + dtCertificate.Rows.Add(row); + } + } + + if (dtCertificate.Rows.Count == 0) + throw new ServiceException("No salary agreement (grade salary) found on or before " + + salaryMonth.ToString("MMMM yyyy") + " for the selected employee(s)."); + + if (skipped.Length > 0) + System.Windows.Forms.MessageBox.Show("No salary agreement found on or before " + salaryMonth.ToString("MMMM yyyy") + + " for the following employee(s); they are left out:" + Environment.NewLine + skipped.ToString(), + "Salary Certificate", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); + + DataSet ds = new DataSet(); + ds.Tables.Add(dtCertificate); + + List parameters = new List(); + parameters.Add(new Microsoft.Reporting.WinForms.ReportParameter("SalaryMonth", salaryMonth.ToString("MMMM yyyy"))); + + fReportViewer form = new fReportViewer(); + form.CommonReportView(_selectedParameter.ReportItem, ds, "Payroll.Report.RDLC.SalaryCertificateLastAgreement.rdlc", parameters); + } + internal void PrepareSalarySummaryReport(DateTime dateTime, int deptId) { fReportViewer oviewer = new fReportViewer(); diff --git a/Payroll.Report/Payroll.Report.csproj b/Payroll.Report/Payroll.Report.csproj index 9bb6fa9..d3ea99b 100644 --- a/Payroll.Report/Payroll.Report.csproj +++ b/Payroll.Report/Payroll.Report.csproj @@ -532,6 +532,7 @@ + diff --git a/Payroll.Report/RDLC/SalaryCertificateLastAgreement.rdlc b/Payroll.Report/RDLC/SalaryCertificateLastAgreement.rdlc new file mode 100644 index 0000000..6e5b3b2 --- /dev/null +++ b/Payroll.Report/RDLC/SalaryCertificateLastAgreement.rdlc @@ -0,0 +1,751 @@ + + + + + + + + + 6.5in + + + + + 4.9in + + + + + + + true + true + + + + + ="Date: " & Format(Today(), "dd MMMM yyyy") + + + + true + true + + + + + SALARY CERTIFICATE + + + + + + + 0.45in + 0.35in + 6.5in + 1 + + + + true + true + + + + + TO WHOM IT MAY CONCERN + + + + + + + 0.85in + 0.25in + 6.5in + 2 + + + + true + true + + + + + ="This is to certify that " & Fields!Salutation.Value & " " & Fields!EmpName.Value & " (CEL ID- " & Fields!EmpNo.Value & ") has been working in " & Parameters!CompanyInfo.Value & " since " & Fields!JoiningDate.Value & " as " & Fields!Article.Value & " " & Fields!Designation.Value & "." & IIf(Len(Fields!NID.Value) > 0, " " & Fields!HisHerCap.Value & " NID No. " & Fields!NID.Value & ".", "") & " " & Fields!HeShe.Value & " is a permanent employee of " & Parameters!CompanyInfo.Value & ". Currently, as per " & Fields!HisHer.Value & " last salary agreement effective from " & Fields!EffectDate.Value & ", " & LCase(Fields!HeShe.Value) & " has been drawing salary with the following breakdown:" + + + + 1.3in + 0.6in + 6.5in + 3 + + + + + + + 0.6in + + + 3.4in + + + 1.8in + + + + + 0.25in + + + + + true + true + + + + + SL + + + + + + + + + Gainsboro + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Particulars + + + + + + Gainsboro + Middle + 4pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Amount (Tk.) + + + + + + + + + Gainsboro + Middle + 2pt + 4pt + 2pt + 2pt + + + + + + + + 0.25in + + + + + true + true + + + + + =Fields!SLNo.Value + + + + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!ItemName.Value + + + Middle + 4pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Amount.Value + + + + + + + + + Middle + 2pt + 4pt + 2pt + 2pt + + + + + + + + 0.25in + + + + + true + true + + + + + Total Monthly Gross Salary + + + + + + + + + Middle + 2pt + 4pt + 2pt + 2pt + + + 2 + + + + + + + true + true + + + + + =Sum(Fields!Amount.Value) + + + + + + + + + Middle + 2pt + 4pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + =Fields!SLNo.Value + + + + + Before + + + + SalaryCertificateLastAgreement + 2.05in + 0.35in + 0.75in + 5.8in + 4 + + + + + + true + true + + + + + ="In Words: " & Fields!TakaInWords.Value + + + + + + + true + true + + + + + ="His other deductions are paid by the company." + + + + 3.4in + 0.4in + 6.5in + 6 + + + + true + true + + + + + Authorized Signature + + + + + + + 4.55in + 0.25in + 2in + 7 + + + 2pt + 2pt + 2pt + 2pt + + + + true + + + + + + + + + + + + + + + + + + + + + =Fields!EmployeeID.Value + + + Between + + + + + =Fields!EmpNo.Value + + + + + + SalaryCertificateLastAgreement + 0.275in + 4.9in + 6.5in + + + + + + 6.4in + + + + + 11.69in + 8.27in + 0.885in + 0.885in + 0.7in + 0.7in +