From d4077203686ec47c05e7ff6bde5c9a22e560b49e Mon Sep 17 00:00:00 2001 From: SamSys Date: Sun, 9 Feb 2025 18:10:31 +0330 Subject: [PATCH] insurance EditModal --- .../IInsuranceListApplication.cs | 6 +++- .../InsuranceListApplication.cs | 10 +++--- .../Pages/Company/InsuranceList/Create.cshtml | 11 +++++++ .../Pages/Company/InsuranceList/Edit.cshtml | 12 ++++++- .../Company/InsuranceList/Index.cshtml.cs | 33 +++++++++++++++++-- 5 files changed, 62 insertions(+), 10 deletions(-) diff --git a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs index f8eade80..16b954d3 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs @@ -15,7 +15,11 @@ public interface IInsuranceListApplication EditInsuranceList GetDetails(long id); List Search(InsuranceListSearchModel searchModel); MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList(EmployeeForCreateInsuranceListSearchModel searchModel); - OperationResult CreateEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command); + + double MarriedAllowance(string maritalStatus, long jobId, bool includedStatus, + int countWorkingDays, double marriedAlowance, int endMonthCurrentDay); + + OperationResult CreateEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command); OperationResult EditEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command); OperationResult Remove(long id); EditInsuranceList GetDetailsForEdit(long id); diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index 7807dd69..46128af0 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -424,7 +424,7 @@ public class InsuranceListApplication: IInsuranceListApplication var baseYears = _insuranceListRepositpry.GetEmployeeInsuranceBaseYear(employee.EmployeeId, workshopId, workingDays.countWorkingDays, startDateGr, endDateGr,workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth); //آیا کارفرما یا مدیر عامل است؟ - bool isManager = employee.JobId is 10 or 16 or 17 or 18 ; + bool isManager = employee.JobId is 10 or 16 or 17 or 18 or 3498; baseYears.baseYear = isManager ? 0 : baseYears.baseYear; Console.WriteLine(employee.JobId + " - "+ baseYears.baseYear); //جمع مزد روزانه و پایه سنوات @@ -877,10 +877,10 @@ public class InsuranceListApplication: IInsuranceListApplication return result; } - private double MarriedAllowance(string maritalStatus,long jobId, bool includedStatus, + public double MarriedAllowance(string maritalStatus,long jobId, bool includedStatus, int countWorkingDays, double marriedAlowance,int endMonthCurrentDay) { - bool isManager = jobId is 10 or 16 or 17 or 18; + bool isManager = jobId is 10 or 16 or 17 or 18 or 3498; if (isManager)//اگر مدیر عامل بود return 0; if (maritalStatus != "متاهل")//اگر مجرد بود @@ -1420,7 +1420,7 @@ public class InsuranceListApplication: IInsuranceListApplication var startWorkFa = employeeData.StartWorkDateGr.ToFarsi(); //آیا کارفرما است - bool isManager = employeeData.JobId is 10 or 16 or 17 or 18; + bool isManager = employeeData.JobId is 10 or 16 or 17 or 18 or 3498; //محاسبه حق بیمه سهم کارفرما var employerShare = (employeeData.BenefitsIncludedContinuous * 20) / 100; @@ -1662,7 +1662,7 @@ public class InsuranceListApplication: IInsuranceListApplication //اگر پرسنل کارفرما بود و نوع لیست کارگاه کمک دولت بود مزایا محاسبه نشود //اگر تیک مشمول مزایا در ترک کار خاموش بود مزایا نگیرد - bool isManager = jobId is 10 or 16 or 17 or 18; + bool isManager = jobId is 10 or 16 or 17 or 18 or 3498; if (isManager && !includeStatus) return 0; //پرسنل استثناء diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml index 1502062c..9809a744 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml @@ -356,6 +356,7 @@ +
@@ -775,6 +776,14 @@ $(this).find('td:eq(19)').text($('#LName').val()); $(this).find('td:eq(20)').text($('#FName').val()); $(this).find('td:eq(21)').text($('#InsuranceCode').val()); + + var marriedAllowance = getNumberValue($('#hiddenMarriedAllowance').val()); + $(this).find('td:eq(9)').text($('#hiddenMarriedAllowance').val()); + $(this).find('td:eq(9)').attr("data-MarriedAllowance", marriedAllowance); + + var baseYears = getNumberValue($('#hiddenBaseYearToEditModal').val()); + $(this).find('td:eq(10)').text($('#hiddenBaseYearToEditModal').val()); + $(this).find('td:eq(10)').attr("data-BaseYears", baseYears); return false; } }); @@ -973,6 +982,8 @@ $("#BenefitsIncludedContinuous").val(response.benefitsIncludedContinuous); $("#hiddenMonthlySalaryPlusBaseYear").val(response.monthlySalaryPlusBaseYear); $("#hiddendaailyWagePlusBaseYear").val(response.dailyWagePlusBaseYear); + $("#hiddenMarriedAllowance").val(response.marriedAllowance); + $("#hiddenBaseYearToEditModal").val(response.baseYears); document.getElementById("edit").disabled = false; $(".insurance-disabled").removeClass("insurance-disabled"); $("#btnComputing").removeClass("compute"); diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Edit.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Edit.cshtml index a021332f..44d23c0a 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Edit.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Edit.cshtml @@ -301,6 +301,7 @@ +
@@ -717,6 +718,14 @@ $(this).find('td:eq(19)').text($('#LName').val()); $(this).find('td:eq(20)').text($('#FName').val()); $(this).find('td:eq(21)').text($('#InsuranceCode').val()); + + var marriedAllowance = getNumberValue($('#hiddenMarriedAllowance').val()); + $(this).find('td:eq(9)').text($('#hiddenMarriedAllowance').val()); + $(this).find('td:eq(9)').attr("data-MarriedAllowance", marriedAllowance); + + var baseYears = getNumberValue($('#hiddenBaseYearToEditModal').val()); + $(this).find('td:eq(10)').text($('#hiddenBaseYearToEditModal').val()); + $(this).find('td:eq(10)').attr("data-BaseYears", baseYears); return false; } }); @@ -982,7 +991,8 @@ $("#BenefitsIncludedContinuous").val(response.benefitsIncludedContinuous); $("#hiddenMonthlySalaryPlusBaseYear").val(response.monthlySalaryPlusBaseYear); $("#hiddendaailyWagePlusBaseYear").val(response.dailyWagePlusBaseYear); - + $("#hiddenMarriedAllowance").val(response.marriedAllowance); + $("#hiddenBaseYearToEditModal").val(response.baseYears); //-----------------------comput button--------------------------- $(".insurance-disabled").removeClass("insurance-disabled"); $("#btnComputing").removeClass("compute"); diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs index ebf3f42a..7484e4dd 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs @@ -1,5 +1,6 @@ using System.Text; using _0_Framework.Application; +using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects; using Company.Domain.EmployeeAgg; using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.Employer; @@ -922,9 +923,24 @@ public class IndexModel : PageModel string benefitsIncludedContinuous, string jobId, string housingAllowance, string includeStatus, string consumableItems, string endMonthCurrentDay, long employeeId, double maritalStatus, double baseYear) { + if(workingDays == "0") + return new JsonResult(new + { + monthlySalaryPlusBaseYear = "0", + monthlySalary = "0", + benefitsIncludedContinuous = "0", + insuranceShare = "0", + workingDay = 0, + dailyWag = "0", + dailyWagePlusBaseYear = "0", + marriedAllowance = "0", + baseYesr = "0", + }); + + var benefitsIncludedContinuousL = benefitsIncludedContinuous.MoneyToDouble(); - bool isManager = jobId is "10" or "16" or "17" or "18"; + bool isManager = jobId is "10" or "16" or "17" or "18" or "3498"; //if (isManager && includeStatus !="1") شنبه if (isManager) maritalStatus = 0; @@ -986,10 +1002,19 @@ public class IndexModel : PageModel workingDaysL = 0; if (benefitsIncludedContinuousL == 0 && monthlySalaryL == 0 && insuranceShareL == 0 && workingDaysL == 0) dailyWageL = 0; + + var includeStatusBool = includeStatus == "1"; + double marridAllowance = 0; + if (employeeMaritalStatus.MaritalStatus == "متاهل" && !isManager) + { + marridAllowance = _insuranceListApplication.MarriedAllowance(employeeMaritalStatus.MaritalStatus, 0, + includeStatusBool, Convert.ToInt32(workingDays), maritalStatus, Convert.ToInt32(endMonthCurrentDay)); + } + + var baseYears = baseYear; + Console.WriteLine(baseYears); return new JsonResult(new { - - monthlySalaryPlusBaseYear = monthlySalaryL.ToMoney(), monthlySalary = monthlySalaryWithOutBaseYear.ToMoney(), benefitsIncludedContinuous = benefitsIncludedContinuousL.ToMoney(), @@ -997,6 +1022,8 @@ public class IndexModel : PageModel workingDay = workingDaysL, dailyWag = dailyWageWithOutBaseYear.ToMoney(), dailyWagePlusBaseYear = dailyWageL, + marriedAllowance = marridAllowance.ToMoney(), + baseYears = baseYears.ToMoney(), }); }