From 4e0b8278591b074e3bc9338a1c9629b684717de1 Mon Sep 17 00:00:00 2001 From: Mohaimen Hasan Date: Wed, 25 Nov 2026 14:24:56 +0600 Subject: [PATCH] Employee Wise PF Handling including Uploader --- HRM.BO/Employee/Employee.cs | 1 + HRM.BO/HREmployee/EmpLifeCycle.cs | 9 ++ HRM.DA/DA/HREmployee/EmpLifeCycleDA.cs | 10 +- HRM.DA/DA/HREmployee/HREmployeeDA.cs | 6 + .../Common/BasicDataUploadProcessService.cs | 30 ++++ .../Common/RegularDataUploadService.cs | 20 +++ HRM.DA/Service/Employee/EmployeeService.cs | 7 + .../Service/HREmployee/EmpLifeCycleService.cs | 17 ++ HRM.DA/Service/Salary/SalaryCalculator.cs | 152 +++++++++++++++++- .../src/app/_models/Employee/empLifeCycle.ts | 1 + .../src/app/_models/Employee/employee.ts | 2 + .../employee/empLifeCycle.service.ts | 3 + .../src/app/app.topbar.component.html | 2 +- .../src/app/app.topbar.component.scss | 5 +- .../ClientApp/src/app/app.topbar.component.ts | 5 + .../data-upload/data-upload.component.ts | 9 ++ .../life-cycle-entry.component.html | 26 ++- .../life-cycle-entry.component.ts | 37 +++++ .../Employee/empLifeCycleController.cs | 16 ++ 19 files changed, 348 insertions(+), 10 deletions(-) diff --git a/HRM.BO/Employee/Employee.cs b/HRM.BO/Employee/Employee.cs index e93399d..448aa54 100644 --- a/HRM.BO/Employee/Employee.cs +++ b/HRM.BO/Employee/Employee.cs @@ -123,6 +123,7 @@ namespace HRM.BO public bool IsShownInTaxSheet { get; set; } // R public EnumPFMembershipType PFMemberType { get; set; } public DateTime? PFMemberShiptDate { get; set; } + public double PFPercentage { get; set; } public int? BranchID { get; set; } public string AccountNo { get; set; } public int? OutPayBranchID { get; set; } diff --git a/HRM.BO/HREmployee/EmpLifeCycle.cs b/HRM.BO/HREmployee/EmpLifeCycle.cs index 5b01b3a..8fa3e3e 100644 --- a/HRM.BO/HREmployee/EmpLifeCycle.cs +++ b/HRM.BO/HREmployee/EmpLifeCycle.cs @@ -168,6 +168,14 @@ namespace HRM.BO } } #endregion + #region PFPercentage : double + private double? _pFPercentage; + public double? PFPercentage + { + get { return _pFPercentage; } + set { _pFPercentage = value; } + } + #endregion #region EmployeeID : ID private int _employeeID; public int EmployeeID @@ -577,6 +585,7 @@ namespace HRM.BO List GetEmpID(int nEmpID, DateTime effectDate); EmpLifeCycle GetLastPosition(int nEmpID); void UpdateApprovalStatus(List oEmpLifeCycles, int currentPayrollTypeID); + bool IsAutoPFMembership(); int Save(EmpLifeCycle item, DateTime nextPayProcessDate, int payrollTypeID); int Save(List items, DateTime nextPayProcessDate); void Delete(EmpLifeCycle item, DateTime nextPayProcessDate); diff --git a/HRM.DA/DA/HREmployee/EmpLifeCycleDA.cs b/HRM.DA/DA/HREmployee/EmpLifeCycleDA.cs index c3ea03c..090a1aa 100644 --- a/HRM.DA/DA/HREmployee/EmpLifeCycleDA.cs +++ b/HRM.DA/DA/HREmployee/EmpLifeCycleDA.cs @@ -26,8 +26,8 @@ namespace HRM.DA public static void Insert(TransactionContext tc, EmpLifeCycle item) { tc.ExecuteNonQuery( - "INSERT INTO EmpLifeCycle(EmpLifeCycleID,EffectDate,NodeID,GrossSalary,BasicSalary,GradeID,CategoryID,CompanyID,FunctionID,DesignationID,LocationID,DepartmentID,IsConfirm,pFMemberType,IsDiscontinue,IsContinue,EmployeeID,StatusDetailID,Remarks,Description,Status,CreatedBy, CreationDate, SequenceNo,SalaryMonth,IsCurrentMonthIncluded,CostCenterID,GradeSalaryAssesmentID,EmployeeCCID,IncrementNo,PayrollTypeID,ComplainID,PunishmentID,ApprovalStatus)" + - " VALUES( %n , %D , %n , %n , %n , %n , %n , %n , %n , %n , %n , %n , %b , %n , %b , %b , %n , %n , %s , %s , %n , %n , %D , %n , %D , %b , %n , %n , %n ,%n, %n,%n,%n,%n )", + "INSERT INTO EmpLifeCycle(EmpLifeCycleID,EffectDate,NodeID,GrossSalary,BasicSalary,GradeID,CategoryID,CompanyID,FunctionID,DesignationID,LocationID,DepartmentID,IsConfirm,pFMemberType,IsDiscontinue,IsContinue,EmployeeID,StatusDetailID,Remarks,Description,Status,CreatedBy, CreationDate, SequenceNo,SalaryMonth,IsCurrentMonthIncluded,CostCenterID,GradeSalaryAssesmentID,EmployeeCCID,IncrementNo,PayrollTypeID,ComplainID,PunishmentID,ApprovalStatus,PFPercentage)" + + " VALUES( %n , %D , %n , %n , %n , %n , %n , %n , %n , %n , %n , %n , %b , %n , %b , %b , %n , %n , %s , %s , %n , %n , %D , %n , %D , %b , %n , %n , %n ,%n, %n,%n,%n,%n,%n )", item.ID, item.EffectDate, item.NodeID, item.GrossSalary, item.BasicSalary, item.GradeID, item.CategoryID, item.CompanyID, item.FunctionID, @@ -37,7 +37,7 @@ namespace HRM.DA item.Description, item.EmployeeStatus, DataReader.GetNullValue(item.CreatedBy, 0), item.CreatedDate, item.Sequence, item.SalaryMonth, item.IsCurrentMonthIncluded, item.CostCenterID, item.GradeSalaryAssesmentID, - item.EmployeeCCID, item.IncrementNo, DataReader.GetNullValue(item.PayrollTypeID, 0), DataReader.GetNullValue(item.ComplainID, 0), DataReader.GetNullValue(item.PunishmentID, 0), item.ApprovalStatus); + item.EmployeeCCID, item.IncrementNo, DataReader.GetNullValue(item.PayrollTypeID, 0), DataReader.GetNullValue(item.ComplainID, 0), DataReader.GetNullValue(item.PunishmentID, 0), item.ApprovalStatus, item.PFPercentage); //1 //2 //3 //4 //5 //6 //7 //8 //9 //10 //11 //12 //13 //14 //15 //16 //17 //18 //19 //20 //21 //21 //22 //23 //24 //25 } @@ -49,7 +49,7 @@ namespace HRM.DA { tc.ExecuteNonQuery(@"UPDATE EmpLifeCycle set EffectDate=%D,NodeID=%n,GrossSalary=%n,BasicSalary=%n,GradeID=%n,CategoryID=%n,CompanyID=%n,FunctionID=%n,DesignationID=%n, LocationID=%n,DepartmentID=%n,IsConfirm=%b,pFMemberType=%n,IsDiscontinue=%b,IsContinue=%b,EmployeeID=%n,StatusDetailID=%n,Remarks=%s,Description=%s,Status=%n,CreatedBy=%n, CreationDate=%D, -SequenceNo=%n,SalaryMonth=%D,IsCurrentMonthIncluded=%b,CostCenterID=%n,GradeSalaryAssesmentID=%n,EmployeeCCID=%n,IncrementNo=%n,PayrollTypeID=%n,ComplainID=%n,PunishmentID=%n,ApprovalStatus=%n +SequenceNo=%n,SalaryMonth=%D,IsCurrentMonthIncluded=%b,CostCenterID=%n,GradeSalaryAssesmentID=%n,EmployeeCCID=%n,IncrementNo=%n,PayrollTypeID=%n,ComplainID=%n,PunishmentID=%n,ApprovalStatus=%n,PFPercentage=%n WHERE EmpLifeCycleID=%n", item.EffectDate, item.NodeID, item.GrossSalary, item.BasicSalary, item.GradeID, item.CategoryID, item.CompanyID, item.FunctionID, @@ -59,7 +59,7 @@ WHERE EmpLifeCycleID=%n", item.EffectDate, item.NodeID, item.GrossSalary, item.B item.Description, item.EmployeeStatus, DataReader.GetNullValue(item.CreatedBy, 0), item.CreatedDate, item.Sequence, item.SalaryMonth, item.IsCurrentMonthIncluded, item.CostCenterID, item.GradeSalaryAssesmentID, - item.EmployeeCCID, item.IncrementNo, DataReader.GetNullValue(item.PayrollTypeID, 0), DataReader.GetNullValue(item.ComplainID, 0), DataReader.GetNullValue(item.PunishmentID, 0), item.ApprovalStatus, item.ID); + item.EmployeeCCID, item.IncrementNo, DataReader.GetNullValue(item.PayrollTypeID, 0), DataReader.GetNullValue(item.ComplainID, 0), DataReader.GetNullValue(item.PunishmentID, 0), item.ApprovalStatus, item.PFPercentage, item.ID); } public static void UpdateApprovalStatus(TransactionContext tc, EmpLifeCycle item) diff --git a/HRM.DA/DA/HREmployee/HREmployeeDA.cs b/HRM.DA/DA/HREmployee/HREmployeeDA.cs index f5f1bf3..526b751 100644 --- a/HRM.DA/DA/HREmployee/HREmployeeDA.cs +++ b/HRM.DA/DA/HREmployee/HREmployeeDA.cs @@ -318,6 +318,12 @@ namespace HRM.DA } + public static void UpdatePFPercentage(TransactionContext tc, int EmployeeID, double pfPercentage) + { + tc.ExecuteNonQuery("UPDATE Employee SET PFPercentage=%n WHERE EmployeeID=%n", + pfPercentage, EmployeeID); + } + public static void UpdateEndofContact(TransactionContext tc, int EmployeeID, DateTime dt) { tc.ExecuteNonQuery("UPDATE Employee SET ENDOFCONTRACTDATE= %d WHERE EmployeeID=%n", diff --git a/HRM.DA/Service/Common/BasicDataUploadProcessService.cs b/HRM.DA/Service/Common/BasicDataUploadProcessService.cs index 2b88c94..b4d7651 100644 --- a/HRM.DA/Service/Common/BasicDataUploadProcessService.cs +++ b/HRM.DA/Service/Common/BasicDataUploadProcessService.cs @@ -189,6 +189,25 @@ namespace HRM.DA } } + // PF Percentage column exists only when autopfmembership is on; it is needed when this row makes the employee a Live PF member + if (autopf && odataTable.Columns.Contains("PF Percentage")) + { + string sPFPercentage = dr["PF Percentage"].ToString().Trim(); + double pfPercentage = 0; + if (sPFPercentage != string.Empty + && (!double.TryParse(sPFPercentage, out pfPercentage) || pfPercentage <= 0 || pfPercentage > 100)) + { + _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("PF Percentage", nRow, "PF Percentage must be greater than 0 and up to 100", oemployee.EmployeeNo, oemployee.Name)); + } + else if (oemployee.PFMemberType == EnumPFMembershipType.Live) + { + if (sPFPercentage == string.Empty) + _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("PF Percentage", nRow, "PF Percentage can't be empty when Confirmation Date is given", oemployee.EmployeeNo, oemployee.Name)); + else + oemployee.PFPercentage = pfPercentage; + } + } + //Refresh Employee Grade Salary if (oemployee.GradeID != null) { @@ -841,6 +860,7 @@ namespace HRM.DA bool isbankCodeAutoGen = Convert.ToBoolean(ocManager.GetconfigBooleanValue(EnumConfigurationType.Logic, "bank", "codeautogenerate")); bool isbranchCodeAutoGen = Convert.ToBoolean(ocManager.GetconfigBooleanValue(EnumConfigurationType.Logic, "branch", "codeautogenerate")); bool isGrossApplicable = ocManager.GetconfigBooleanValue(EnumConfigurationType.Logic, "grade", "grossapplicable"); + bool autopf = ocManager.GetconfigBooleanValue(EnumConfigurationType.Logic, "confirmation", "autopfmembership"); item.SheetName = "EmpBasicInformation"; @@ -883,6 +903,9 @@ namespace HRM.DA // item.Add("PayScaleID", "String", "Yes"); //15 item.Add("Confirmation Date", "Date", "Yes"); //17 + // auto PF membership on confirmation: the employee's own PF % (Employee.PFPercentage) + if (autopf == true) + item.Add("PF Percentage", "Double", "Yes"); item.Add("Basic Salary", "Double", "No"); //16 if (isGrossApplicable == true) item.Add("Gross Salary", "Double", "No"); //15 @@ -1077,6 +1100,13 @@ namespace HRM.DA } } + // PF membership needs the employee's own PF % (Employee.PFPercentage): the event makes the employee a + // Live PF member either through its PF_Member component, or through Confirm when autopfmembership is on + bool autopf = ocManager.GetconfigBooleanValue(EnumConfigurationType.Logic, "confirmation", "autopfmembership"); + bool hasPFMember = ostatus.EmployeeStatusComponents.Exists(x => x.ComponentType == EnumLifeCycleComponent.PF_Member); + bool hasConfirm = ostatus.EmployeeStatusComponents.Exists(x => x.ComponentType == EnumLifeCycleComponent.Confirm); + if (hasPFMember || (hasConfirm && autopf)) + item.Add("PF Percentage", "Double", "No"); return item; } diff --git a/HRM.DA/Service/Common/RegularDataUploadService.cs b/HRM.DA/Service/Common/RegularDataUploadService.cs index ba85660..02dbfdb 100644 --- a/HRM.DA/Service/Common/RegularDataUploadService.cs +++ b/HRM.DA/Service/Common/RegularDataUploadService.cs @@ -5221,6 +5221,9 @@ namespace HRM.DA int locationid = new MiscellaneousService().GetNextID("location", "locationid", ""); int designationid = new MiscellaneousService().GetNextID("Designation", "DesignationID", ""); int costcenterid = new MiscellaneousService().GetNextID("crg", "crgid", ""); + bool needPFPercentage = ostatus.EmployeeStatusComponents.Exists(x => x.ComponentType == EnumLifeCycleComponent.PF_Member) + || (ostatus.EmployeeStatusComponents.Exists(x => x.ComponentType == EnumLifeCycleComponent.Confirm) + && new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "confirmation", "autopfmembership")); string description = ""; try { @@ -5657,6 +5660,23 @@ namespace HRM.DA } } + // PF membership needs the employee's own PF % (Employee.PFPercentage): the event makes the employee a + // Live PF member either through its PF_Member component, or through Confirm when autopfmembership is on + if (needPFPercentage) + { + double pfPercentage = 0; + string sPFPercentage = dr.Table.Columns.Contains("PF Percentage") ? dr["PF Percentage"].ToString().Trim() : ""; + if (sPFPercentage == "") + _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("PF Percentage", nRow, "(" + dr["Employee No"].ToString() + ")" + "PF Percentage can't be Empty")); + else if (!double.TryParse(sPFPercentage, out pfPercentage) || pfPercentage <= 0 || pfPercentage > 100) + _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("PF Percentage", nRow, "(" + dr["Employee No"].ToString() + ")" + "PF Percentage must be greater than 0 and up to 100")); + else + { + lifeCycle.PFPercentage = pfPercentage; + description = description + " PF Percentage " + pfPercentage.ToString() + "%"; + } + } + if (lifeCycle.EffectDate.Date < DateTime.Today) { lifeCycle.IsProcessed = null; diff --git a/HRM.DA/Service/Employee/EmployeeService.cs b/HRM.DA/Service/Employee/EmployeeService.cs index 23513a2..2bd4f12 100644 --- a/HRM.DA/Service/Employee/EmployeeService.cs +++ b/HRM.DA/Service/Employee/EmployeeService.cs @@ -50,6 +50,7 @@ namespace HRM.DA oEmployee.PFMemberShiptDate = oReader.GetDateTime("pfMemberShipDt").HasValue ? oReader.GetDateTime("pfMemberShipDt").Value : DateTime.Now; + oEmployee.PFPercentage = oReader.GetDouble("PFPercentage", true, 0); oEmployee.BranchID = oReader.GetInt32("branchID"); oEmployee.AccountNo = oReader.GetString("accountNo"); oEmployee.OutPayBranchID = oReader.GetInt32("OUTPAYBRANCHID"); @@ -3459,6 +3460,10 @@ namespace HRM.DA oEmployee.Name = oEmployee.Name == "" ? "Employee-" + oEmployee.EmployeeNo : oEmployee.Name; EmployeeDA.Insert(tc, oEmployee); + // employee's own PF % (from the upload's PF Percentage column), used by SalaryCalculator.PFNEW + if (oEmployee.PFMemberType == EnumPFMembershipType.Live && oEmployee.PFPercentage > 0) + HREmployeeDA.UpdatePFPercentage(tc, oEmployee.ID, oEmployee.PFPercentage); + int id = 0; if (uploadtype == EnumRegularDataUpload.EmployeeWithBasic || !IsFinantialAprovalRequired) @@ -3534,6 +3539,8 @@ namespace HRM.DA oEmployee.EmpLifeCycle.LocationID = oEmployee.LocationID; oEmployee.EmpLifeCycle.CategoryID = oEmployee.CategoryID; oEmployee.EmpLifeCycle.IsConfirm = (oEmployee.IsConfirmed == true) ? true : false; + if (oEmployee.PFMemberType == EnumPFMembershipType.Live && oEmployee.PFPercentage > 0) + oEmployee.EmpLifeCycle.PFPercentage = oEmployee.PFPercentage; oEmployee.EmpLifeCycle.CreatedBy = oEmployee.CreatedBy; oEmployee.EmpLifeCycle.CreatedDate = oEmployee.CreatedDate; oEmployee.EmpLifeCycle.GradeSalaryAssesmentID = oEmployee.EmployeeGradeSalary.ID; diff --git a/HRM.DA/Service/HREmployee/EmpLifeCycleService.cs b/HRM.DA/Service/HREmployee/EmpLifeCycleService.cs index af40cb5..674c1b3 100644 --- a/HRM.DA/Service/HREmployee/EmpLifeCycleService.cs +++ b/HRM.DA/Service/HREmployee/EmpLifeCycleService.cs @@ -51,6 +51,8 @@ namespace HRM.DA if (oReader.GetInt32("pFMemberType").HasValue) oEmpLifeCycle.PFMemberType = (EnumPFMembershipType)oReader.GetInt32("pFMemberType").Value; else oEmpLifeCycle.PFMemberType = null; + double pfPercentage = oReader.GetDouble("PFPercentage", true, 0); + oEmpLifeCycle.PFPercentage = pfPercentage > 0 ? pfPercentage : (double?)null; oEmpLifeCycle.IsDiscontinue = oReader.GetBoolean("IsDiscontinue"); oEmpLifeCycle.IsContinue = oReader.GetBoolean("IsContinue"); oEmpLifeCycle.EmployeeID = oReader.GetInt32("EmployeeID").Value; @@ -749,6 +751,12 @@ namespace HRM.DA } } + // Logic XML confirmation/autopfmembership: confirming an employee also makes them a Live PF member + public bool IsAutoPFMembership() + { + return new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "confirmation", "autopfmembership"); + } + public void UpdateApprovalStatus(List oEmpLifeCycles, int currentPayrollTypeID) { TransactionContext tc = null; @@ -943,6 +951,9 @@ namespace HRM.DA HREmployeeDA.UpdatePFInfo(tc, oEmpLifeCycle.EmployeeID, EnumPFMembershipType.Live, oEmpLifeCycle.EffectDate); + // PF membership: the employee's own PF % (used by SalaryCalculator.PFNEW) + if (oEmpLifeCycle.PFPercentage != null) + HREmployeeDA.UpdatePFPercentage(tc, oEmpLifeCycle.EmployeeID, (double)oEmpLifeCycle.PFPercentage); } } //else @@ -971,8 +982,14 @@ namespace HRM.DA // if conponent contain pf member, update employee pfMembership property property and pfMembership date. if (oEmpLifeCycle.PFMemberType != null) + { HREmployeeDA.UpdatePFInfo(tc, oEmpLifeCycle.EmployeeID, (EnumPFMembershipType)oEmpLifeCycle.PFMemberType, oEmpLifeCycle.EffectDate); + + // PF membership: the employee's own PF % (used by SalaryCalculator.PFNEW) + if (oEmpLifeCycle.PFMemberType == EnumPFMembershipType.Live && oEmpLifeCycle.PFPercentage != null) + HREmployeeDA.UpdatePFPercentage(tc, oEmpLifeCycle.EmployeeID, (double)oEmpLifeCycle.PFPercentage); + } break; case EnumEmployeeStatus.Discontinued: EmployeeDA.UpdateStatus(tc, oEmpLifeCycle.EmployeeID, oEmpLifeCycle.ID, diff --git a/HRM.DA/Service/Salary/SalaryCalculator.cs b/HRM.DA/Service/Salary/SalaryCalculator.cs index f6e1934..91e5fcd 100644 --- a/HRM.DA/Service/Salary/SalaryCalculator.cs +++ b/HRM.DA/Service/Salary/SalaryCalculator.cs @@ -125,8 +125,9 @@ namespace HRM.DA UpdateprocessStatus("Calculating Salary deduct item(unauthorized leave)...."); this.UnAuthorizeLeave(); UpdateprocessStatus("Calculating PF & CPF...."); - - this.PF(); + + //this.PF(); + this.PFNEW(); // this.OverTimeArrearProcess(); needed later //UpdateprocessStatus("Calculating Employees Income tax...."); UpdateprocessStatus("Calculating Income Tax"); @@ -692,6 +693,153 @@ namespace HRM.DA } + private void PFNEW() + { + UpdateProgressStatus(EnumProcessStatus.Start); + bool bEchoTexException = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "salary", "echotexexception"); + + bool earnedBasic = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "pf", "earnedbasic"); + // PF % comes from each employee (Employee.PFPercentage), not from SystemInformation. + //List oPfExceptions = PFException.Get(); + foreach (SalaryMonthly salary in _salaryMonthlys) + { + + UpdateProgressStatus(EnumProcessStatus.PerformStep); + SalaryMonthlyDetail pfDetail = null; + + if (salary.Employee.PFMemberType != EnumPFMembershipType.Live) continue; + double pfPercent = (salary.Employee.PFPercentage / 100); + // SalaryMonthly prvSalary = _PrvMonthsalary.FirstOrDefault(x => x.EmployeeID == salary.EmployeeID); + + var basicitem = _PrvMonthsalaryItems.FirstOrDefault(x => x.itemCode == EnumSalaryItemCode.Basic_Salary + && x.empid == salary.EmployeeID); + bool RcvLastMonthSalary = false; + if (basicitem != null) RcvLastMonthSalary = true; + double arrearPF = 0; + + if (earnedBasic == true) + { + if (RcvLastMonthSalary == true) + { + //SalaryMonthlyDetail prvPF = prvSalary.Details.Find(delegate (SalaryMonthlyDetail detail) + //{ + // return (detail.ItemCode == EnumSalaryItemCode.PF_Contribution + // && detail.itemGroupCode == EnumSalaryGroup.Deductions); + //}); + + var prvPF = _PrvMonthsalaryItems.FirstOrDefault(x => x.itemCode == EnumSalaryItemCode.PF_Contribution + && x.empid == salary.EmployeeID); + + if (salary.Employee.ConfirDate != null && salary.Employee.ConfirDate < + GlobalFunctions.FirstDateOfMonth(_processMonth) && RcvLastMonthSalary == true && prvPF == null) // if pf continue with previous month salary + { + DateTime? tepConfirm = salary.Employee.ConfirDate; + while (GlobalFunctions.LastDateOfMonth((DateTime)tepConfirm) <= this.payrollType.LastPayProcessDate) + { + EmployeeGradeSalary gradeSal = new EmployeeGradeSalaryService().GetBasicOnDateBAT(salary.EmployeeID, (DateTime)tepConfirm); + if (gradeSal == null) + { + AddProcessStatus(salary.Employee, " Employee previous salary not found during PF arrear calculation"); + break; + } + + double fractionate = 0; + if (tepConfirm == GlobalFunctions.FirstDateOfMonth((DateTime)tepConfirm)) + fractionate = 1; + if (tepConfirm == GlobalFunctions.LastDateOfMonth((DateTime)tepConfirm)) + fractionate = 30 / 29; + else fractionate = GlobalFunctions.GetFractinalOfMonth((DateTime)tepConfirm); + + arrearPF = arrearPF + ((gradeSal.BasicSalary * fractionate) * pfPercent); + + tepConfirm = GlobalFunctions.FirstDateOfMonth(((DateTime)tepConfirm).AddMonths(1)); + } + } + } + SalaryMonthlyDetail basic = salary.Details.Find(delegate (SalaryMonthlyDetail detail) { return (detail.ItemCode == EnumSalaryItemCode.Basic_Salary + && detail.itemGroupCode == EnumSalaryGroup.Gross); }); + if (basic != null) + { + pfDetail = this.AddDetail(salary, EnumSalaryGroup.Deductions, + EnumSalaryItemCode.PF_Contribution, (int)EnumSalaryItemCode.PF_Contribution, 0, + "PF", GlobalFunctions.Round(basic.CalculatedAmount * pfPercent)); + } + + basic = salary.Details.Find(delegate (SalaryMonthlyDetail detail) { return (detail.ItemCode == EnumSalaryItemCode.Basic_Salary + && detail.itemGroupCode == EnumSalaryGroup.Arrear); }); + if (basic != null) + { + pfDetail.CalculatedAmount = pfDetail.CalculatedAmount + GlobalFunctions.Round(basic.CalculatedAmount * pfPercent); + } + + basic = salary.Details.Find(delegate (SalaryMonthlyDetail detail) { return (detail.ItemCode == EnumSalaryItemCode.Basic_Salary + && detail.itemGroupCode == EnumSalaryGroup.UnauthLeave); }); + if (basic != null) + { + pfDetail.CalculatedAmount = pfDetail.CalculatedAmount - GlobalFunctions.Round(basic.CalculatedAmount * pfPercent); + } + + if (pfDetail != null) + { + + if (salary.Employee.ConfirDate != null && + GlobalFunctions.LastDateOfMonth((DateTime)salary.Employee.ConfirDate) == _processMonth) + { + if ((DateTime)salary.Employee.ConfirDate != salary.Employee.JoiningDate) + { + pfDetail.CalculatedAmount = GlobalFunctions.Round(pfDetail.CalculatedAmount * + ((double)(31 - ((DateTime)salary.Employee.ConfirDate).Day) / (double)30)); + } + } + pfDetail.CalculatedAmount = pfDetail.CalculatedAmount + GlobalFunctions.Round(arrearPF); + pfDetail.ChangedAmount = pfDetail.CalculatedAmount; + + } + } + else + { + double months = 1; + if (bEchoTexException == false) + { + salaryHistory prvPF = null; + if (RcvLastMonthSalary == true) + { + prvPF = _PrvMonthsalaryItems.FirstOrDefault(x => x.itemCode == EnumSalaryItemCode.PF_Contribution + && x.empid == salary.EmployeeID); + } + + if (RcvLastMonthSalary == true) + { + if (prvPF == null) + months = Global.DateFunctions.DateDiff("m", (DateTime)salary.Employee.ConfirDate, _processMonth) + 1; + else + { + if (salary.ArrearGradeSalaries.Count > 0) + { + pfDetail = this.AddDetail(salary, EnumSalaryGroup.Deductions, + EnumSalaryItemCode.PF_Contribution, (int)EnumSalaryItemCode.PF_Contribution, + 0, "PF", GlobalFunctions.Round(salary.GetGrossAmount(EnumSalaryItemCode.Basic_Salary, (int)EnumSalaryItemCode.Basic_Salary) + * pfPercent)); + continue; + } + } + } + else if ((Global.DateFunctions.DateDiff("m", (DateTime)salary.Employee.JoiningDate, _processMonth) + 1) <= 2) // joining in last month + { + months = Global.DateFunctions.DateDiff("m", (DateTime)salary.Employee.JoiningDate, _processMonth) + 1; + } + } + pfDetail = this.AddDetail(salary, EnumSalaryGroup.Deductions, + EnumSalaryItemCode.PF_Contribution, (int)EnumSalaryItemCode.PF_Contribution, + 0, "PF", GlobalFunctions.Round(salary.ThisMonthBasic * pfPercent * months)); + + } + + } + UpdateProgressStatus(EnumProcessStatus.End); + + } + private void AllowanceDeduction() { diff --git a/HRM.UI/ClientApp/src/app/_models/Employee/empLifeCycle.ts b/HRM.UI/ClientApp/src/app/_models/Employee/empLifeCycle.ts index 31ebf14..468ac47 100644 --- a/HRM.UI/ClientApp/src/app/_models/Employee/empLifeCycle.ts +++ b/HRM.UI/ClientApp/src/app/_models/Employee/empLifeCycle.ts @@ -20,6 +20,7 @@ export class EmpLifeCycle extends BaseObject { departmentID: number; isConfirm?: boolean; pfMemberType?: EnumPFMembershipType; + pfPercentage?: number; employeeID: number; statusDetailID: number; grossSalary: number; diff --git a/HRM.UI/ClientApp/src/app/_models/Employee/employee.ts b/HRM.UI/ClientApp/src/app/_models/Employee/employee.ts index 18eb0f3..8b4e0eb 100644 --- a/HRM.UI/ClientApp/src/app/_models/Employee/employee.ts +++ b/HRM.UI/ClientApp/src/app/_models/Employee/employee.ts @@ -47,6 +47,7 @@ export class Employee { isShownInTaxSheet: boolean; pfMemberType: EnumPFMembershipType; pfMemberShiptDate: Date; + pfPercentage: number; branchID: number; accountNo: string; outPayBranchID: number; @@ -142,6 +143,7 @@ export class Employee { this.statusName = ''; this.isShownInTaxSheet = false; this.pfMemberType = EnumPFMembershipType.NotYetLive; + this.pfPercentage = 0; this.branchID = null; this.accountNo = ''; this.outPayBranchID = null; diff --git a/HRM.UI/ClientApp/src/app/_services/employee/empLifeCycle.service.ts b/HRM.UI/ClientApp/src/app/_services/employee/empLifeCycle.service.ts index b8f2e78..6159090 100644 --- a/HRM.UI/ClientApp/src/app/_services/employee/empLifeCycle.service.ts +++ b/HRM.UI/ClientApp/src/app/_services/employee/empLifeCycle.service.ts @@ -33,6 +33,9 @@ export class EmpLifeCycleServices { GetByUserID() { return this.apiService.httpGet('/EmpLifeCycle/GetByUserID'); } + IsAutoPFMembership() { + return this.apiService.httpGet('/EmpLifeCycle/IsAutoPFMembership'); + } getEmpLifeCyclesByDate(param: any) { return this.apiService.httpPost('/EmpLifeCycle/getEmpLifeCyclesByDate', param); } diff --git a/HRM.UI/ClientApp/src/app/app.topbar.component.html b/HRM.UI/ClientApp/src/app/app.topbar.component.html index e25b04d..22c845c 100644 --- a/HRM.UI/ClientApp/src/app/app.topbar.component.html +++ b/HRM.UI/ClientApp/src/app/app.topbar.component.html @@ -101,7 +101,7 @@ @if (payrollTypeName) {
  • - {{payrollTypeName}} + {{payrollTypeName}}@if (salaryMonth) { | {{salaryMonth | date:'MMMM-yyyy'}}}
  • } diff --git a/HRM.UI/ClientApp/src/app/app.topbar.component.scss b/HRM.UI/ClientApp/src/app/app.topbar.component.scss index 910c584..75e0522 100644 --- a/HRM.UI/ClientApp/src/app/app.topbar.component.scss +++ b/HRM.UI/ClientApp/src/app/app.topbar.component.scss @@ -442,7 +442,7 @@ } .topbar-payroll-type { display: inline-block; - max-width: 260px; + max-width: 380px; padding: 4px 12px; border: 1px solid color-mix(in srgb, $color-white 35%, transparent); border-radius: 999px; @@ -456,6 +456,9 @@ text-overflow: ellipsis; cursor: default; } +.topbar-salary-month { + font-weight: 500; +} // Admin / super-user profile menu (Babylon li.user-profile > ul) drawn exactly like the ESS user // menu (.ss-dd.ss-user-dd above): white card, 14px corners, soft shadow, header row with a divider, diff --git a/HRM.UI/ClientApp/src/app/app.topbar.component.ts b/HRM.UI/ClientApp/src/app/app.topbar.component.ts index 3b5fe32..7fd0a71 100644 --- a/HRM.UI/ClientApp/src/app/app.topbar.component.ts +++ b/HRM.UI/ClientApp/src/app/app.topbar.component.ts @@ -59,6 +59,8 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy { // (EnumUserType.User) logins only. Re-read whenever the stored token changes // (login, user switch, payroll-type switch, logout). payrollTypeName: string = ''; + // current salary month = the payroll type's nextPayProcessDate + salaryMonth: Date = null; private payrollTypeToken: string | null | undefined = undefined; private payrollTypeSub: Subscription | null = null; @@ -196,15 +198,18 @@ export class AppTopBarComponent implements OnInit, DoCheck, OnDestroy { } if (!user || user.UserType != EnumUserType.User || !user.PayrollTypeID) { this.payrollTypeName = ''; + this.salaryMonth = null; return; } this.payrollTypeSub = this.authService.GetPayrollTypeByLoginID().subscribe({ next: (payrollType) => { this.payrollTypeName = payrollType?.description ?? ''; + this.salaryMonth = payrollType?.nextPayProcessDate ? new Date(payrollType.nextPayProcessDate) : null; }, error: () => { this.payrollTypeName = ''; + this.salaryMonth = null; }, }); } diff --git a/HRM.UI/ClientApp/src/app/common-interface/data-upload/data-upload.component.ts b/HRM.UI/ClientApp/src/app/common-interface/data-upload/data-upload.component.ts index 6b53f60..d6bd092 100644 --- a/HRM.UI/ClientApp/src/app/common-interface/data-upload/data-upload.component.ts +++ b/HRM.UI/ClientApp/src/app/common-interface/data-upload/data-upload.component.ts @@ -117,6 +117,8 @@ export class DataUploadComponent implements OnInit, OnDestroy { this.dataUploadColumnDefinition = undefined; this.sheetName = undefined; this.scolName = undefined; + this.htmlContent = undefined; + this.test = undefined; this.uploadErrorOrSuccess = []; this.uploadFileList = []; this.dataUploadForm = new FormGroup({}); @@ -174,6 +176,11 @@ export class DataUploadComponent implements OnInit, OnDestroy { this.dataUploadColumnDefinition = undefined; this.sheetName = undefined; this.scolName = undefined; + // the component is reused across upload types: clear the previous page's columns and selection + this.htmlContent = undefined; + this.test = undefined; + this.itemid = undefined; + this.itemidTwo = undefined; this.uploadErrorOrSuccess = []; this.uploadFileList = []; this.dataUploadForm = new FormGroup({}); @@ -236,6 +243,8 @@ export class DataUploadComponent implements OnInit, OnDestroy { name: x.description, }); }); + // events in alphabetical order + this.ItemData.sort((a, b) => (a.name || '').localeCompare(b.name || '')); }, (x) => { this.loadingPanel.ShowLoadingPanel = false; diff --git a/HRM.UI/ClientApp/src/app/payroll/career-and-profile/life-cycle-entry/life-cycle-entry.component.html b/HRM.UI/ClientApp/src/app/payroll/career-and-profile/life-cycle-entry/life-cycle-entry.component.html index 230108c..f7d82d2 100644 --- a/HRM.UI/ClientApp/src/app/payroll/career-and-profile/life-cycle-entry/life-cycle-entry.component.html +++ b/HRM.UI/ClientApp/src/app/payroll/career-and-profile/life-cycle-entry/life-cycle-entry.component.html @@ -193,11 +193,35 @@ kendoCheckBox /> -
    + +
    } + @if (this.isPFPercentage == true) { +
    + +
    +
    :
    +
    + + +
    + @if (this.isShowConfirmed != true) { +
    + } + } +