diff --git a/0_Framework/Application/Tools.cs b/0_Framework/Application/Tools.cs index 8de9bf00..47f250fb 100644 --- a/0_Framework/Application/Tools.cs +++ b/0_Framework/Application/Tools.cs @@ -57,8 +57,10 @@ public static class Tools startWorkInMonth = true; } + if(leftWork == null) + leftWork = DateTime.MinValue; //اگر ترک کار پرسنل در ماه مشخص شده لیست بیمه بود - if (leftWork != null && leftWork.Value <= endDate) + if (leftWork != DateTime.MinValue && leftWork.Value <= endDate) { end = leftWork.Value; endWorkInMonth = true; diff --git a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs index 355184f9..e99d7a11 100644 --- a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs +++ b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs @@ -39,7 +39,7 @@ public interface IInsuranceListRepository:IRepository /// محاسبه پایه سنوات بیمه برای پرسنل /// /// - (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay, DateTime listStartDate, DateTime endDate); + (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay, DateTime listStartDate, DateTime listEndDate, DateTime startWorkDate, DateTime leftDate, bool hasLeft); #endregion #region client diff --git a/CompanyManagment.App.Contracts/InsuranceList/EmployeeDetailsForInsuranceListViewModel.cs b/CompanyManagment.App.Contracts/InsuranceList/EmployeeDetailsForInsuranceListViewModel.cs index 5bf4da84..415d893e 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/EmployeeDetailsForInsuranceListViewModel.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/EmployeeDetailsForInsuranceListViewModel.cs @@ -134,9 +134,13 @@ public class EmployeeDetailsForInsuranceListViewModel /// DSW_MASH /// public double MonthlyBenefitsIncluded { get; set; } - // مزایای مشمول مستمر + /// + /// مزایای مشمول مستمر + /// public double BenefitsIncludedContinuous { get; set; } - //مزایای مشمول غیر مستمر + /// + /// مزایای مشمول غیر مستمر + /// public double BenefitsIncludedNonContinuous { get; set; } /// @@ -191,9 +195,14 @@ public class EmployeeDetailsForInsuranceListViewModel public bool IsMaritalStatusSet { get; set; } public int EndMonthCurrentDay { get; set; } public double SumOfDailyWage { get; set; } - //بیمه سهم کارفرما + + /// + /// حق بیمه سهم کارفرما + /// public double EmployerShare { get; set; } - //بیمه بیکاری + /// + /// بیمه بیکاری + /// public double UnEmploymentInsurance { get; set; } public string StartMonthCurrent { get; set; } public bool HasLeftWorkInMonth { get; set; } @@ -231,13 +240,13 @@ public class EmployeeDetailsForInsuranceListViewModel /// پایه سنواتی /// DSW_INC /// - public string BaseYears { get; set; } + public double BaseYears { get; set; } /// /// جمع پایه سنوات و دستمزد روزانه /// DSW_INC /// - public string DailyWagePlusBaseYears { get; set; } + public double DailyWagePlusBaseYears { get; set; } /// /// حق تاهل diff --git a/CompanyManagment.App.Contracts/InsuranceList/MainEmployeeDetailsViewModel.cs b/CompanyManagment.App.Contracts/InsuranceList/MainEmployeeDetailsViewModel.cs index 3f541a9c..740380f4 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/MainEmployeeDetailsViewModel.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/MainEmployeeDetailsViewModel.cs @@ -12,4 +12,5 @@ public class MainEmployeeDetailsViewModel public bool IsExist { get; set; } public bool IsBlock { get; set; } public double MaritalStatus { get; set; } + } \ No newline at end of file diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index 810edb35..cd9bf530 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using _0_Framework.Application; +using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects; using Company.Domain.DateSalaryAgg; using Company.Domain.DateSalaryItemAgg; using Company.Domain.EmployeeAgg; @@ -384,11 +385,13 @@ public class InsuranceListApplication: IInsuranceListApplication x.Year == searchModel.Year && x.Month == searchModel.Month && searchModel.WorkshopIds.Contains(x.WorkshopId))) { - DateTime startDateGr = (searchModel.Year + "/" + searchModel.Month + "/01").ToGeorgianDateTime(); - DateTime endDateGr = (searchModel.Year + "/" + searchModel.Month + "/01").FindeEndOfMonth() + var startMonthFa = $"{searchModel.Year}/{searchModel.Month}/01"; + DateTime startDateGr = startMonthFa.ToGeorgianDateTime(); + DateTime endDateGr = startMonthFa.FindeEndOfMonth() .ToGeorgianDateTime(); + int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2)); - List list = new List(); + //مقادیر سالانه این تاریخ var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, searchModel.Year); @@ -403,12 +406,46 @@ public class InsuranceListApplication: IInsuranceListApplication var dateOfBirth = employee.DateOfBirthGr.ToFarsi(); var dateOfIssue = employee.DateOfIssueGr.ToFarsi(); var leftDate = employee.LeftWorkDateGr != null ? employee.LeftWorkDateGr.Value.AddDays(-1) : new DateTime(); - var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr,endDateGr, employee.EmployeeId); - //به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر - var dailyWage = searchModel.FixedSalary ? + + var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr,endDateGr, employee.EmployeeId); + var leftWorkFa = workingDays.hasLeftWorkInMonth ? employee.LeftWorkDateGr.ToFarsi(): ""; + var startWorkFa = workingDays.startWork.ToFarsi(); + //به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر + var dailyWage = searchModel.FixedSalary ? Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, workshopId, employee.EmployeeId, startDateGr, endDateGr, employee.JobId, searchModel.Population, searchModel.InsuranceJobId)) : ComputeDailyWage(yearlysaleries.DayliWage, employee.EmployeeId, workshopId, searchModel.Year); - return new EmployeeDetailsForInsuranceListViewModel + //بدست آوردن پایه سنوات + var baseYears = _insuranceListRepositpry.GetEmployeeInsuranceBaseYear(employee.EmployeeId, workshopId, + workingDays.countWorkingDays, startDateGr, endDateGr,workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth); + + + + //جمع مزد روزانه و پایه سنوات + var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear; + + + + //دستمزد ماهانه با محاسبه پایه سنوات + var monthlySalary = GetRoundValue(dailyWagePlusBaseYears * workingDays.countWorkingDays); + + //حق تاهل + var marriedAllowance = employee.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0; + + //محاسبه مزایای ماهانه + var monthlyBenefits = GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, employee.JobId, employee.EmployeeId); + + //محاسبه مزایای مشمول مستمر + var benefitsIncludedContinuous = monthlyBenefits + monthlySalary; + + //محاسبه حق بیمه سهم بیمه شده + var insuranceShare = (benefitsIncludedContinuous * 7) / 100; + + //محاسبه حق بیمه سهم کارفرما + var employerShare = (benefitsIncludedContinuous * 20) / 100; + + // محاسبه بیمه بیکاری + var unEmploymentInsurance = (benefitsIncludedContinuous * 3) / 100; + return new EmployeeDetailsForInsuranceListViewModel { #region EmployeeInfo @@ -427,319 +464,391 @@ public class InsuranceListApplication: IInsuranceListApplication NationalCode = employee.NationalCode, Nationality = employee.Nationality, InsuranceCode = employee.InsuranceCode, + // آیا وضعیت تاهل پرسنل ست شده است + IsMaritalStatusSet = !string.IsNullOrWhiteSpace(employee.MaritalStatus), + MaritalStatus = employee.MaritalStatus, - #endregion + StartMonthCurrent = startMonthFa, + WorkingDays = workingDays.countWorkingDays, + StartWorkDate = startWorkFa, + StartWorkDateGr = workingDays.startWork, + LeftWorkDate = leftWorkFa, + LeftWorkDateGr = workingDays.hasLeftWorkInMonth ? employee.LeftWorkDateGr : null, + JobId = employee.JobId, + JobName = employee.JobName, + JobCode = employee.JobCode, - #region Compute + HasStartWorkInMonth = workingDays.hasStartWorkInMonth, + HasLeftWorkInMonth = workingDays.hasLeftWorkInMonth, + #endregion - IncludeStatus = employee.IncludeStatus, + #region Compute + //مشمول مزایا بودن + IncludeStatus = employee.IncludeStatus, + + //دستمزد روزانه DailyWage = GetRoundValue(dailyWage), + DailyWageStr = dailyWage.ToMoney(), - #endregion + HasConfilictJobs = dailyWage == 0, + + //پایه سنوات + BaseYears = baseYears.baseYear, + + //مجموع مزد روزانه و پایه سنوات + DailyWagePlusBaseYears = dailyWagePlusBaseYears, + + //حق تاهل + MarriedAllowance = employee.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0, + + //دستمزد ماهانه + MonthlySalary = monthlySalary, + + + //مزایای ماهانه + MonthlyBenefits = monthlyBenefits, + + //مزایای مشمول مستمر + BenefitsIncludedContinuous = benefitsIncludedContinuous, + + //مزیایی مشمول غیر مستمر + BenefitsIncludedNonContinuous = 0, + + // جمع کل دستمزد و مزایای ماهانه + IncludedAndNotIncluded = benefitsIncludedContinuous, + + //حق بیمه سهم بیمه شده + InsuranceShare = GetRoundValue(insuranceShare), + + //حق بیمه سهم کارفرما + EmployerShare = GetRoundValue(employerShare), + + //بیمه بیکاری + UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance), + + //کمک هزینه مسکن + HousingAllowance = yearlysaleries.HousingAllowance, + //کمک هزینه اقلام + ConsumableItems = yearlysaleries.ConsumableItems, + + EndMonthCurrentDay = endOfMonth, + YearlySalaryItem = yearlysaleries.DayliWage, + MonthlyBaseYearsStr = "0", + MonthlyBaseYears = 0, + #endregion - }; + }; }); Console.WriteLine("New Compute : " + watch.Elapsed); watch.Stop(); watch.Start(); - var leftWorkInsuranceViewModel = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModel); - //int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count(); - string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01"; - string endMonthCurrent = startMonthCurrent.FindeEndOfMonth(); + #region Old_heydari + //List list = new List(); + //var leftWorkInsuranceViewModel = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModel); + ////int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count(); - var model = new YearlySalarySearchModel(); - var startDate = startMonthCurrent.ToGeorgianDateTime(); - var endDate = endMonthCurrent.ToGeorgianDateTime(); - model.StartDateGr = startDate; - model.EndDateGr = endMonthCurrent.ToGeorgianDateTime(); - model.year = searchModel.Year; + //string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01"; + //string endMonthCurrent = startMonthCurrent.FindeEndOfMonth(); - - + //var model = new YearlySalarySearchModel(); + //var startDate = startMonthCurrent.ToGeorgianDateTime(); + //var endDate = endMonthCurrent.ToGeorgianDateTime(); + //model.StartDateGr = startDate; + //model.EndDateGr = endMonthCurrent.ToGeorgianDateTime(); + //model.year = searchModel.Year; - foreach (var item in leftWorkInsuranceViewModel) - { - var employeeObject = _employeeRepository.GetDetailsByADDate(item.EmployeeId); - - var employeeDetailsForInsuranceObj = new EmployeeDetailsForInsuranceListViewModel(); - employeeDetailsForInsuranceObj.HasConfilictJobs = false; - - // آیا وضعیت تاهل پرسنل ست شده است - employeeDetailsForInsuranceObj.IsMaritalStatusSet = - !string.IsNullOrWhiteSpace(employeeObject.MaritalStatus); - //دزیافت اطلاعات هویتی پرسنل - //در صورت نداشن دیتا از جدول پرسنل پر می شود - #region PersonnelInfo - - if (_insuranceEmployeeInfoRepository.Exists(x => x.EmployeeId == item.EmployeeId)) - { - var employeeInfoObject = _insuranceEmployeeInfoApplication.GetDetailsByEmployeeId(item.EmployeeId); - employeeDetailsForInsuranceObj.InsuranceEmployeeInformationId = employeeInfoObject.Id; - employeeDetailsForInsuranceObj.EmployeeId = employeeInfoObject.EmployeeId; - employeeDetailsForInsuranceObj.FName = employeeInfoObject.FName; - employeeDetailsForInsuranceObj.LName = employeeInfoObject.LName; - employeeDetailsForInsuranceObj.FatherName = employeeInfoObject.FatherName; - employeeDetailsForInsuranceObj.DateOfBirth = employeeInfoObject.DateOfBirth; - employeeDetailsForInsuranceObj.DateOfIssue = employeeInfoObject.DateOfIssue; - employeeDetailsForInsuranceObj.DateOfBirthGr = employeeInfoObject.DateOfBirthGr; - employeeDetailsForInsuranceObj.DateOfIssueGr = employeeInfoObject.DateOfIssueGr; - employeeDetailsForInsuranceObj.PlaceOfIssue = employeeInfoObject.PlaceOfIssue; - employeeDetailsForInsuranceObj.IdNumber = employeeInfoObject.IdNumber; - employeeDetailsForInsuranceObj.Gender = employeeInfoObject.Gender; - - //از جدول پرسنل پر می شود - employeeDetailsForInsuranceObj.NationalCode = employeeObject.NationalCode; //employeeInfoObject.NationalCode; - employeeDetailsForInsuranceObj.Nationality = employeeObject.Nationality; - employeeDetailsForInsuranceObj.InsuranceCode = employeeObject.InsuranceCode; //employeeInfoObject.InsuranceCode; - } - else - { - // var employeeObject = _employeeRepository.GetDetailsByADDate(item.EmployeeId); - employeeDetailsForInsuranceObj.InsuranceEmployeeInformationId = 0; - //employeeDetailsForInsuranceObj.EmployeeInsurancListDataId = 0; - employeeDetailsForInsuranceObj.EmployeeId = employeeObject.Id; - employeeDetailsForInsuranceObj.FName = employeeObject.FName; - employeeDetailsForInsuranceObj.LName = employeeObject.LName; - employeeDetailsForInsuranceObj.FatherName = employeeObject.FatherName; - employeeDetailsForInsuranceObj.DateOfBirth = (employeeObject.DateOfBirth == "1300/10/11" ? "" : employeeObject.DateOfBirth); - employeeDetailsForInsuranceObj.DateOfIssue = employeeObject.DateOfIssue; - employeeDetailsForInsuranceObj.PlaceOfIssue = employeeObject.PlaceOfIssue; - employeeDetailsForInsuranceObj.NationalCode = employeeObject.NationalCode; - employeeDetailsForInsuranceObj.IdNumber = employeeObject.IdNumber; - employeeDetailsForInsuranceObj.Gender = employeeObject.Gender; - employeeDetailsForInsuranceObj.InsuranceCode = employeeObject.InsuranceCode; - employeeDetailsForInsuranceObj.Nationality = employeeObject.Nationality; - } - #endregion - - //روزهای کارکرد پرسنل - #region ComputingWorkingDays - - int startWork = 0; - int endWork = 0; - - var year = Convert.ToInt32(searchModel.Year); - var month = Convert.ToInt32(searchModel.Month); - var day = 1; - var persianCurrentStartDate = new PersianDateTime(year, month, day); - var dayMonthCurrent = Convert.ToInt32(endMonthCurrent.Substring(8, 2)); - var persianCurrentEndDate = new PersianDateTime(year, month, dayMonthCurrent); - //آخرین روز ماه جاری - var endMonthCurrentDay = Convert.ToInt32(endMonthCurrent.Substring(8, 2)); - - var yearStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(0, 4)); - var monthStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(5, 2)); - var dayStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(8, 2)); - var persianStartDateUser = new PersianDateTime(yearStartDateUser, monthStartDateUser, dayStartDateUser); - - if (persianStartDateUser < persianCurrentStartDate) - employeeDetailsForInsuranceObj.HasStartWorkInMonth = false; - else - employeeDetailsForInsuranceObj.HasStartWorkInMonth = true; - - //اگر شروع به کار کاربر از ابتدای ماه جاری کمتر باشد - if (persianStartDateUser <= persianCurrentStartDate) - { - startWork = 1; - } - else - { - startWork = dayStartDateUser; - } - - if (!string.IsNullOrEmpty(item.LeftWorkDate)) - { - var yearEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(0, 4)); - var monthEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(5, 2)); - var dayEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(8, 2)); - var persianLeftDateUser = new PersianDateTime(yearEndDateUser, monthEndDateUser, dayEndDateUser); - var persianEndDateUser = persianLeftDateUser.AddDays(-1); - var persianEndDateUserStr = persianLeftDateUser.AddDays(-1).ToString("yyyy/MM/dd"); - - //if (persianLeftDateUser <= persianCurrentEndDate) - // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = true; - //else - // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = false; - - //ترک کارش در ماه و سال جاری بود نمایش داده شود - if (!item.LeftWorkDate.Contains(searchModel.Year + "/" + searchModel.Month)) - { - employeeDetailsForInsuranceObj.HasLeftWorkInMonth = false; - item.LeftWorkDate = string.Empty; - item.LeftWorkDateGr = null; - } - else - { - employeeDetailsForInsuranceObj.HasLeftWorkInMonth = true; - } - - //اگر پایان به کار کاربر از پایان ماه جاری بیشتر باشد - if (persianEndDateUser >= persianCurrentEndDate) - { - endWork = endMonthCurrentDay; - } - else - { - endWork = Convert.ToInt32(persianEndDateUserStr.Substring(8, 2)); - } - } - else - { - employeeDetailsForInsuranceObj.HasLeftWorkInMonth = false; - endWork = endMonthCurrentDay; - } - - int countWorkingDays = 0; - for (int i = startWork; i <= endWork; i++) - { - countWorkingDays = countWorkingDays + 1; - } - //farokhiChanges - //روزهای کارکرد پرسنل با آی دی های زیر دستی تعریف شد - switch (item.EmployeeId) - { - - //case 3812://ثابت- کسری حاجی پور - // countWorkingDays = 15; - // break; - case 40463://ثابت - countWorkingDays = 10; - break; - case 40469://ثابت - countWorkingDays = 7; - break; - case 9950://ثابت - countWorkingDays = 15; - break; - case 9640://ثابت - countWorkingDays = 15; - break; - case 40998://ثابت - countWorkingDays = 15; - break; - case 6219://ثابت - countWorkingDays = 15; - break; - //case 7897://ثابت - // countWorkingDays = 15; - break; - } - #endregion - - employeeDetailsForInsuranceObj.IncludeStatus = item.IncludeStatus; - #region InsuranceJob - double dailyWage = employeeDetailsForInsuranceObj.DailyWage; - if (searchModel.FixedSalary) - { - dailyWage = Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, workshopId,item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId)); - employeeDetailsForInsuranceObj.HasConfilictJobs = (dailyWage == 0 ? true : false); - } - #endregion - if (yearlysaleries != null) - { - if(!searchModel.FixedSalary ) - { - //dailyWage= yearlysalaryItem.ItemValue; - dailyWage = ComputeDailyWage(yearlysaleries.DayliWage, item.EmployeeId,workshopId, searchModel.Year) ; - //(double basic, int totalYears) basicResult = BasicYear(item.EmployeeId, workshopId, startDate); - //var basic = basicResult.basic; - - //if (basicResult.totalYears > 0) - //{ - // monthlybaseYear = GetMonthlyBaseYear(basicResult.basic, countWorkingDays); - //} - } - employeeDetailsForInsuranceObj.DailyWage = GetRoundValue(dailyWage); - employeeDetailsForInsuranceObj.BaseYears = "0"; - - employeeDetailsForInsuranceObj.DailyWageStr = employeeDetailsForInsuranceObj.DailyWage.ToMoney(); - employeeDetailsForInsuranceObj.DailyWagePlusBaseYears = "0"; - employeeDetailsForInsuranceObj.MonthlySalary = GetRoundValue(dailyWage * countWorkingDays); - employeeDetailsForInsuranceObj.HousingAllowance = yearlysaleries.HousingAllowance; - employeeDetailsForInsuranceObj.ConsumableItems = yearlysaleries.ConsumableItems; - employeeDetailsForInsuranceObj.EndMonthCurrentDay = endMonthCurrentDay; - employeeDetailsForInsuranceObj.YearlySalaryItem = yearlysaleries.DayliWage; - employeeDetailsForInsuranceObj.MonthlyBaseYearsStr = monthlybaseYear.ToMoney(); + //foreach (var item in leftWorkInsuranceViewModel) + //{ + // var employeeObject = _employeeRepository.GetDetailsByADDate(item.EmployeeId); - - - employeeDetailsForInsuranceObj.MarriedAllowance = 0; - - if (item.IncludeStatus) - { - var marital = employeeObject.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0; - employeeDetailsForInsuranceObj.MonthlyBenefits = GetMonthlyBenefits(endMonthCurrentDay, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marital, countWorkingDays); - } - else - { - employeeDetailsForInsuranceObj.MonthlyBenefits = 0; - } + // var employeeDetailsForInsuranceObj = new EmployeeDetailsForInsuranceListViewModel(); + // employeeDetailsForInsuranceObj.HasConfilictJobs = false; - if (searchModel.TypeOfInsuranceSendWorkshop == "Govermentlist" && item.JobId == 10) //کمک دولت - { - employeeDetailsForInsuranceObj.MonthlyBenefits = 0; - } - //farokhiChanges - if (item.EmployeeId == 42783) - employeeDetailsForInsuranceObj.MonthlyBenefits = 53082855; + // // آیا وضعیت تاهل پرسنل ست شده است + // employeeDetailsForInsuranceObj.IsMaritalStatusSet = + // !string.IsNullOrWhiteSpace(employeeObject.MaritalStatus); + // //دزیافت اطلاعات هویتی پرسنل + // //در صورت نداشن دیتا از جدول پرسنل پر می شود + // #region PersonnelInfo - employeeDetailsForInsuranceObj.BenefitsIncludedContinuous =employeeDetailsForInsuranceObj.MonthlyBenefits + employeeDetailsForInsuranceObj.MonthlySalary; - - - //حق بیمه سهم بیمه شده - var insuranceShare = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 7) / 100; - employeeDetailsForInsuranceObj.InsuranceShare = GetRoundValue(insuranceShare); //Math.Round(insuranceShare, MidpointRounding.ToPositiveInfinity); - - //حق بیمه سهم کارفرما - var employerShare = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 20) / 100; - employeeDetailsForInsuranceObj.EmployerShare = GetRoundValue(employerShare); //Math.Round(employerShare, MidpointRounding.ToPositiveInfinity); + // if (_insuranceEmployeeInfoRepository.Exists(x => x.EmployeeId == item.EmployeeId)) + // { + // var employeeInfoObject = _insuranceEmployeeInfoApplication.GetDetailsByEmployeeId(item.EmployeeId); + // employeeDetailsForInsuranceObj.InsuranceEmployeeInformationId = employeeInfoObject.Id; + // employeeDetailsForInsuranceObj.EmployeeId = employeeInfoObject.EmployeeId; + // employeeDetailsForInsuranceObj.FName = employeeInfoObject.FName; + // employeeDetailsForInsuranceObj.LName = employeeInfoObject.LName; + // employeeDetailsForInsuranceObj.FatherName = employeeInfoObject.FatherName; + // employeeDetailsForInsuranceObj.DateOfBirth = employeeInfoObject.DateOfBirth; + // employeeDetailsForInsuranceObj.DateOfIssue = employeeInfoObject.DateOfIssue; + // employeeDetailsForInsuranceObj.DateOfBirthGr = employeeInfoObject.DateOfBirthGr; + // employeeDetailsForInsuranceObj.DateOfIssueGr = employeeInfoObject.DateOfIssueGr; + // employeeDetailsForInsuranceObj.PlaceOfIssue = employeeInfoObject.PlaceOfIssue; + // employeeDetailsForInsuranceObj.IdNumber = employeeInfoObject.IdNumber; + // employeeDetailsForInsuranceObj.Gender = employeeInfoObject.Gender; + + // //از جدول پرسنل پر می شود + // employeeDetailsForInsuranceObj.NationalCode = employeeObject.NationalCode; //employeeInfoObject.NationalCode; + // employeeDetailsForInsuranceObj.Nationality = employeeObject.Nationality; + // employeeDetailsForInsuranceObj.InsuranceCode = employeeObject.InsuranceCode; //employeeInfoObject.InsuranceCode; + // } + // else + // { + // // var employeeObject = _employeeRepository.GetDetailsByADDate(item.EmployeeId); + // employeeDetailsForInsuranceObj.InsuranceEmployeeInformationId = 0; + // //employeeDetailsForInsuranceObj.EmployeeInsurancListDataId = 0; + // employeeDetailsForInsuranceObj.EmployeeId = employeeObject.Id; + // employeeDetailsForInsuranceObj.FName = employeeObject.FName; + // employeeDetailsForInsuranceObj.LName = employeeObject.LName; + // employeeDetailsForInsuranceObj.FatherName = employeeObject.FatherName; + // employeeDetailsForInsuranceObj.DateOfBirth = (employeeObject.DateOfBirth == "1300/10/11" ? "" : employeeObject.DateOfBirth); + // employeeDetailsForInsuranceObj.DateOfIssue = employeeObject.DateOfIssue; + // employeeDetailsForInsuranceObj.PlaceOfIssue = employeeObject.PlaceOfIssue; + // employeeDetailsForInsuranceObj.NationalCode = employeeObject.NationalCode; + // employeeDetailsForInsuranceObj.IdNumber = employeeObject.IdNumber; + // employeeDetailsForInsuranceObj.Gender = employeeObject.Gender; + // employeeDetailsForInsuranceObj.InsuranceCode = employeeObject.InsuranceCode; + // employeeDetailsForInsuranceObj.Nationality = employeeObject.Nationality; + // } + // #endregion + + // //روزهای کارکرد پرسنل + // #region ComputingWorkingDays + + // int startWork = 0; + // int endWork = 0; + + // var year = Convert.ToInt32(searchModel.Year); + // var month = Convert.ToInt32(searchModel.Month); + // var day = 1; + // var persianCurrentStartDate = new PersianDateTime(year, month, day); + // var dayMonthCurrent = Convert.ToInt32(endMonthCurrent.Substring(8, 2)); + // var persianCurrentEndDate = new PersianDateTime(year, month, dayMonthCurrent); + // //آخرین روز ماه جاری + // var endMonthCurrentDay = Convert.ToInt32(endMonthCurrent.Substring(8, 2)); + + // var yearStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(0, 4)); + // var monthStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(5, 2)); + // var dayStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(8, 2)); + // var persianStartDateUser = new PersianDateTime(yearStartDateUser, monthStartDateUser, dayStartDateUser); + + // if (persianStartDateUser < persianCurrentStartDate) + // employeeDetailsForInsuranceObj.HasStartWorkInMonth = false; + // else + // employeeDetailsForInsuranceObj.HasStartWorkInMonth = true; + + // //اگر شروع به کار کاربر از ابتدای ماه جاری کمتر باشد + // if (persianStartDateUser <= persianCurrentStartDate) + // { + // startWork = 1; + // } + // else + // { + // startWork = dayStartDateUser; + // } + + // if (!string.IsNullOrEmpty(item.LeftWorkDate)) + // { + // var yearEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(0, 4)); + // var monthEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(5, 2)); + // var dayEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(8, 2)); + // var persianLeftDateUser = new PersianDateTime(yearEndDateUser, monthEndDateUser, dayEndDateUser); + // var persianEndDateUser = persianLeftDateUser.AddDays(-1); + // var persianEndDateUserStr = persianLeftDateUser.AddDays(-1).ToString("yyyy/MM/dd"); + + // //if (persianLeftDateUser <= persianCurrentEndDate) + // // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = true; + // //else + // // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = false; + + // //ترک کارش در ماه و سال جاری بود نمایش داده شود + // if (!item.LeftWorkDate.Contains(searchModel.Year + "/" + searchModel.Month)) + // { + // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = false; + // item.LeftWorkDate = string.Empty; + // item.LeftWorkDateGr = null; + // } + // else + // { + // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = true; + // } + + // //اگر پایان به کار کاربر از پایان ماه جاری بیشتر باشد + // if (persianEndDateUser >= persianCurrentEndDate) + // { + // endWork = endMonthCurrentDay; + // } + // else + // { + // endWork = Convert.ToInt32(persianEndDateUserStr.Substring(8, 2)); + // } + // } + // else + // { + // employeeDetailsForInsuranceObj.HasLeftWorkInMonth = false; + // endWork = endMonthCurrentDay; + // } + + // int countWorkingDays = 0; + // for (int i = startWork; i <= endWork; i++) + // { + // countWorkingDays = countWorkingDays + 1; + // } + // //farokhiChanges + // //روزهای کارکرد پرسنل با آی دی های زیر دستی تعریف شد + // switch (item.EmployeeId) + // { + + // //case 3812://ثابت- کسری حاجی پور + // // countWorkingDays = 15; + // // break; + // case 40463://ثابت + // countWorkingDays = 10; + // break; + // case 40469://ثابت + // countWorkingDays = 7; + // break; + // case 9950://ثابت + // countWorkingDays = 15; + // break; + // case 9640://ثابت + // countWorkingDays = 15; + // break; + // case 40998://ثابت + // countWorkingDays = 15; + // break; + // case 6219://ثابت + // countWorkingDays = 15; + // break; + // //case 7897://ثابت + // // countWorkingDays = 15; + // break; + // } + // #endregion + + // employeeDetailsForInsuranceObj.IncludeStatus = item.IncludeStatus; - //if (searchModel.TypeOfInsuranceSendWorkshop == "Govermentlist" && item.JobId==10)//کمک دولت - //{employeeDetailsForInsuranceObj.InsuranceShare = 0;} + // #region InsuranceJob + // double dailyWage = employeeDetailsForInsuranceObj.DailyWage; + // if (searchModel.FixedSalary) + // { + // dailyWage = Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, workshopId, item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId)); + // employeeDetailsForInsuranceObj.HasConfilictJobs = (dailyWage == 0 ? true : false); + // } + // #endregion + + // if (yearlysaleries != null) + // { + // if (!searchModel.FixedSalary) + // { + // //dailyWage= yearlysalaryItem.ItemValue; + // dailyWage = ComputeDailyWage(yearlysaleries.DayliWage, item.EmployeeId, workshopId, searchModel.Year); + // //(double basic, int totalYears) basicResult = BasicYear(item.EmployeeId, workshopId, startDate); + // //var basic = basicResult.basic; + + // //if (basicResult.totalYears > 0) + // //{ + // // monthlybaseYear = GetMonthlyBaseYear(basicResult.basic, countWorkingDays); + // //} + // } + // employeeDetailsForInsuranceObj.DailyWage = GetRoundValue(dailyWage); + // employeeDetailsForInsuranceObj.BaseYears = 0; + + // employeeDetailsForInsuranceObj.DailyWageStr = employeeDetailsForInsuranceObj.DailyWage.ToMoney(); + // employeeDetailsForInsuranceObj.DailyWagePlusBaseYears = 0; + // employeeDetailsForInsuranceObj.MonthlySalary = GetRoundValue(dailyWage * countWorkingDays); + // employeeDetailsForInsuranceObj.HousingAllowance = yearlysaleries.HousingAllowance; + // employeeDetailsForInsuranceObj.ConsumableItems = yearlysaleries.ConsumableItems; + // employeeDetailsForInsuranceObj.EndMonthCurrentDay = endMonthCurrentDay; + // employeeDetailsForInsuranceObj.YearlySalaryItem = yearlysaleries.DayliWage; + // employeeDetailsForInsuranceObj.MonthlyBaseYearsStr = monthlybaseYear.ToMoney(); - var unEmploymentInsurance =(employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 3) / 100; - employeeDetailsForInsuranceObj.UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance); - employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous = employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous; - employeeDetailsForInsuranceObj.IncludedAndNotIncluded = employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous + employeeDetailsForInsuranceObj.BenefitsIncludedContinuous; + // employeeDetailsForInsuranceObj.MarriedAllowance = 0; - } + // if (item.IncludeStatus) + // { + // var marital = employeeObject.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0; + // employeeDetailsForInsuranceObj.MonthlyBenefits = GetMonthlyBenefits(endMonthCurrentDay, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marital, countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, item.JobId, item.EmployeeId); + // } + // else + // { + // employeeDetailsForInsuranceObj.MonthlyBenefits = 0; + // } - employeeDetailsForInsuranceObj.StartMonthCurrent = startMonthCurrent; - employeeDetailsForInsuranceObj.WorkingDays = countWorkingDays; - employeeDetailsForInsuranceObj.StartWorkDate = item.StartWorkDate; - employeeDetailsForInsuranceObj.LeftWorkDate = item.LeftWorkDate; - employeeDetailsForInsuranceObj.JobId = item.JobId; - employeeDetailsForInsuranceObj.JobName = item.JobName; - employeeDetailsForInsuranceObj.JobCode = item.JobCode; - if (!string.IsNullOrWhiteSpace(item.LeftWorkDate)) - employeeDetailsForInsuranceObj.LeftWorkDateGr = item.LeftWorkDateGr; + // if (searchModel.TypeOfInsuranceSendWorkshop == "Govermentlist" && item.JobId == 10) //کمک دولت + // { + // employeeDetailsForInsuranceObj.MonthlyBenefits = 0; + // } + // //farokhiChanges + // if (item.EmployeeId == 42783) + // employeeDetailsForInsuranceObj.MonthlyBenefits = 53082855; - employeeDetailsForInsuranceObj.StartWorkDateGr = item.StartWorkDateGr; - //farokhiChanges - if (item.EmployeeId == 42783) - employeeDetailsForInsuranceObj.MonthlyBenefits = 53082855; + // employeeDetailsForInsuranceObj.BenefitsIncludedContinuous = employeeDetailsForInsuranceObj.MonthlyBenefits + employeeDetailsForInsuranceObj.MonthlySalary; - list.Add(employeeDetailsForInsuranceObj); - } - list = list.OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth) + // //حق بیمه سهم بیمه شده + // var insuranceShare = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 7) / 100; + // employeeDetailsForInsuranceObj.InsuranceShare = GetRoundValue(insuranceShare); //Math.Round(insuranceShare, MidpointRounding.ToPositiveInfinity); + + // //حق بیمه سهم کارفرما + // var employerShare = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 20) / 100; + // employeeDetailsForInsuranceObj.EmployerShare = GetRoundValue(employerShare); //Math.Round(employerShare, MidpointRounding.ToPositiveInfinity); + + + // //if (searchModel.TypeOfInsuranceSendWorkshop == "Govermentlist" && item.JobId==10)//کمک دولت + // //{employeeDetailsForInsuranceObj.InsuranceShare = 0;} + + + // var unEmploymentInsurance = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 3) / 100; + // employeeDetailsForInsuranceObj.UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance); + + // employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous = employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous; + // employeeDetailsForInsuranceObj.IncludedAndNotIncluded = employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous + employeeDetailsForInsuranceObj.BenefitsIncludedContinuous; + + // } + + // employeeDetailsForInsuranceObj.StartMonthCurrent = startMonthCurrent; + // employeeDetailsForInsuranceObj.WorkingDays = countWorkingDays; + // employeeDetailsForInsuranceObj.StartWorkDate = item.StartWorkDate; + // employeeDetailsForInsuranceObj.LeftWorkDate = item.LeftWorkDate; + // employeeDetailsForInsuranceObj.JobId = item.JobId; + // employeeDetailsForInsuranceObj.JobName = item.JobName; + // employeeDetailsForInsuranceObj.JobCode = item.JobCode; + // if (!string.IsNullOrWhiteSpace(item.LeftWorkDate)) + // employeeDetailsForInsuranceObj.LeftWorkDateGr = item.LeftWorkDateGr; + + // employeeDetailsForInsuranceObj.StartWorkDateGr = item.StartWorkDateGr; + // //farokhiChanges + // if (item.EmployeeId == 42783) + // employeeDetailsForInsuranceObj.MonthlyBenefits = 53082855; + + // list.Add(employeeDetailsForInsuranceObj); + //} + + //result.EmployeeDetailsForInsuranceList = list.OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth) + // .ThenBy(x => x.LName).ToList(); + + + #endregion + + result.EmployeeDetailsForInsuranceList = computeResult.OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth) .ThenBy(x => x.LName).ToList(); - result.EmployeeDetailsForInsuranceList = list; + Console.WriteLine("ToList compute : " + watch.Elapsed); result.IsExist = false; result.IsBlock = isBolock; result.MaritalStatus = yearlysaleries.MarriedAllowance; - Console.WriteLine("old heydari compute : " + watch.Elapsed); - } + + } else { result.IsExist = true; @@ -1195,7 +1304,7 @@ public class InsuranceListApplication: IInsuranceListApplication if (item.IncludeStatus) { var marital = employeeObject.MaritalStatus == "متاهل" ? maritalStatus.ItemValue : 0; - item.MonthlyBenefits = GetMonthlyBenefits(dayMonthCurrent, consumableItems.ItemValue, housingAllowance.ItemValue, marital, countWorkingDays); + item.MonthlyBenefits = GetMonthlyBenefits(dayMonthCurrent, consumableItems.ItemValue, housingAllowance.ItemValue, marital, countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, item.JobId, item.EmployeeId); } else { @@ -1349,8 +1458,27 @@ public class InsuranceListApplication: IInsuranceListApplication return result; } - private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue,double maritalStatus, int countWorkingDays) + /// + /// محاسبه مزایای ماهانه + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue,double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId,long employeeId) { + //اگر پرسنل کارفرما بود و نوع لیست کارگاه کمک دولت بود مزایا محاسبه نشود + if (typeOfInsuranceSendWorkshop == "Govermentlist" && jobId == 10) + return 0; + //پرسنل استثناء + if (employeeId == 42783) + return 53082855; + //مزایای ماهانه با توجه به پایان ماه که 30 یا 31 روزه است، متفاوت می باشد //برای ماه 29 روزه هم تقسیم بر 30 می شود. if (countWorkingDays == endMonthCurrentDay) @@ -1378,6 +1506,8 @@ public class InsuranceListApplication: IInsuranceListApplication dailyWage=employeeInsurancListData.DailyWage; } } + + dailyWage = employeeId == 6536 ? 9399512 : dailyWage; return dailyWage; } public MainEmployeeDetailsViewModel GetEmployeeForInsuranceList(List leftWorkInsuranceViewModelList, EmployeeForEditInsuranceListSearchModel searchModel) @@ -1608,7 +1738,7 @@ public class InsuranceListApplication: IInsuranceListApplication if (item.IncludeStatus) { var marital = employeeObject.MaritalStatus == "متاهل" ? maritalStatus.ItemValue : 0; - employeeDetailsForInsuranceObj.MonthlyBenefits = GetMonthlyBenefits(endMonthCurrentDay, consumableItems.ItemValue, housingAllowance.ItemValue, marital, countWorkingDays); + employeeDetailsForInsuranceObj.MonthlyBenefits = GetMonthlyBenefits(endMonthCurrentDay, consumableItems.ItemValue, housingAllowance.ItemValue, marital, countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, item.JobId, item.EmployeeId); } else { diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index 3137ce50..c124cb24 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Text.RegularExpressions; using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.EmployeeChildrenAgg; using Company.Domain.EmployeeInsurancListDataAgg; using Company.Domain.InsuranceListAgg; using Company.Domain.InsuranceWorkshopAgg; +using Company.Domain.InsuranceYearlySalaryAgg; using Company.Domain.InsurancWorkshopInfoAgg; using CompanyManagment.App.Contracts.EmployeeInsurancListData; using CompanyManagment.App.Contracts.InsuranceList; @@ -15,6 +17,7 @@ using CompanyManagment.App.Contracts.InsuranceWorkshopInfo; using CompanyManagment.App.Contracts.PersonalContractingParty; using Microsoft.EntityFrameworkCore; using Microsoft.Identity.Client; +using PersianTools.Core; namespace CompanyManagment.EFCore.Repository; @@ -27,7 +30,8 @@ public class InsuranceListRepository : RepositoryBase, IIns private readonly IInsuranceWorkshopInfoRepository _insuranceWorkshopInfoRepository; private readonly IAuthHelper _authHelper; private readonly IPersonalContractingPartyApp _contractingPartyApp; - public InsuranceListRepository(CompanyContext context, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceListWorkshopRepository insuranceListWorkshopRepository , IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository, IAuthHelper authHelper, IPersonalContractingPartyApp contractingPartyApp) : base(context) + private readonly IInsuranceYearlySalaryRepository _insuranceYearlySalaryRepository; + public InsuranceListRepository(CompanyContext context, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceListWorkshopRepository insuranceListWorkshopRepository , IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository, IAuthHelper authHelper, IPersonalContractingPartyApp contractingPartyApp, IInsuranceYearlySalaryRepository insuranceYearlySalaryRepository) : base(context) { _context = context; _employeeInsurancListDataRepository = employeeInsurancListDataRepository; @@ -35,6 +39,7 @@ public class InsuranceListRepository : RepositoryBase, IIns _insuranceWorkshopInfoRepository = insuranceWorkshopInfoRepository; _authHelper = authHelper; _contractingPartyApp = contractingPartyApp; + _insuranceYearlySalaryRepository = insuranceYearlySalaryRepository; } public OperationResult CreateInsuranceListworkshop(long id, List workshopIds) { @@ -1178,13 +1183,53 @@ public class InsuranceListRepository : RepositoryBase, IIns #endregion - public (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay,DateTime listStartDate, DateTime endDate) + public (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay,DateTime listStartDate, DateTime listEndDate, DateTime startWorkDate, DateTime leftDate, bool hasLeft) { + + var lefts = _context.LeftWorkInsuranceList - .Where(x => x.EmployeeId == employeeId); - - + .Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x=> new + { + startWork = x.StartWorkDate, + leftWork = x.LeftWorkDate == null ? listEndDate : x.LeftWorkDate.Value, + }).OrderBy(x=>x.startWork).ToList(); + int countDay = 0; + foreach (var left in lefts) + { + var start = left.startWork.ToPersianDateTime(); + var end = left.leftWork.ToPersianDateTime(); + var count = (int)(end - start).TotalDays +1; + countDay += count; + } - return (0, 0); + if (countDay < 365) + return (0, 0); + + //تعداد سال های سابقه بیمه + int yearsCount = countDay / 365; + + //بدست آوردن مزد سنوات بر اساس سابقه به سال + var baseYear = _insuranceYearlySalaryRepository.GetBaseYearByDate(listStartDate, yearsCount); + if(baseYear == 0) + return (0, 0); + + + //اگر ترک کار کرده بود + //یا + //شروع به کارش بعد از یکم ماه بود + if (hasLeft || listStartDate < startWorkDate) + { + //تعداد روزهای ماه در این لیست بیمه + var monthDayCont = (int)(listEndDate - listStartDate).TotalDays + 1; + //پایه سنوات به ازای هر روز + var baseyarPerDay = baseYear / monthDayCont; + // پایه سنوات یک روز ضرب در روزهای کارکرد در ماه + baseYear = baseyarPerDay * countWorkingDay; + + + + } + + return (yearsCount, baseYear); } } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml index d7b9650b..c0b1f9f6 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Create.cshtml @@ -2,7 +2,7 @@ @Html.AntiForgeryToken() @{ - - } @if (Model.EmployeeDetailsForInsuranceList != null) { - var index = 1; + var index = 1; - if (Model.EmployeeDetailsForInsuranceList.Any(x => !x.IsMaritalStatusSet)) - { - - - + $('#maritalStatusErr').val(true); + +
+ - - - - - - - - + + + + + + + - - +

+ ابتدا وضعیت تاهل پرسنل در لیست زیر را مشخص نمایید +

+ + + - - - - + + + + - + - + - - @foreach (var item in Model.EmployeeDetailsForInsuranceList) - { - if (!item.IsMaritalStatusSet) - { - + + @foreach (var item in Model.EmployeeDetailsForInsuranceList) + { + if (!item.IsMaritalStatusSet) + { + - - - - - - index++; - } - } + + + + + + index++; + } + } - -
+
-

- ابتدا وضعیت تاهل پرسنل در لیست زیر را مشخص نمایید -

-
کدملی نام خانوادگی نام # کدملی نام خانوادگی نام #
@item.NationalCode@item.LName@item.FName@index
@item.NationalCode@item.LName@item.FName@index
- } - else - { - - } + $('#maritalStatusErr').val(false); + + } -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ +
+
تاریخ ترک کار تاریخ آغاز بکار شغل حق بیمه سهم بیمه شده حقوق و مزایای ماهیانه مشمول و غیر مشمول حقوق و مزایای ماهیانه مشمول مزایای ماهیانه مشمول حقوق ماهیانه مشمول دستمزد روزانه روزهای کارکرد ش شناسنامه تاریخ تولد محل صدور کدملی نام پدر جنسیت نام خانوادگی نام شماره بیمه #
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @foreach (var item in Model.EmployeeDetailsForInsuranceList) - { - if (item.LeftWorkDate == item.StartMonthCurrent) - { - - + - - - - - - - - - - - - - - - - - - - - - - } - else - { - - + + + + + + + + + + + + + + + + + + + + + + + + } + else + { + + - - - - - - - - - - - - - - - - - - - - - - } - index = index + 1; - } + + + + + + + + + + + + + + + + + + + + + + + + + } - -
تاریخ ترک کار تاریخ آغاز بکار شغل حق بیمه سهم بیمه شده حقوق و مزایای ماهیانه مشمول و غیر مشمول حقوق و مزایای ماهیانه مشمول مزایای ماهیانه مشمول حقوق ماهیانه مشمول حق تاهل پایه سنوات روزانه دستمزد روزانه روزهای کارکرد ش شناسنامه تاریخ تولد محل صدور کدملی نام پدر جنسیت نام خانوادگی نام شماره بیمه #
- - @* + @foreach (var item in Model.EmployeeDetailsForInsuranceList) + { + if (item.LeftWorkDate == item.StartMonthCurrent) + { +
+ + @* *@ - @item.LeftWorkDate@item.StartWorkDate@item.JobName00 0 0 000@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
- - @* + @item.LeftWorkDate@item.StartWorkDate@item.JobName00 0 0 00000@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
+ + @* *@ - @item.LeftWorkDate@item.StartWorkDate@item.JobName@item.InsuranceShare.ToMoney()@item.IncludedAndNotIncluded.ToMoney() @item.BenefitsIncludedContinuous.ToMoney() @item.MonthlyBenefits.ToMoney() @(item.HasConfilictJobs ? "" : item.MonthlySalary.ToMoney())@(item.HasConfilictJobs ? "" : item.DailyWageStr)@item.WorkingDays@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
@item.LeftWorkDate@item.StartWorkDate@item.JobName@item.InsuranceShare.ToMoney()@item.IncludedAndNotIncluded.ToMoney() @item.BenefitsIncludedContinuous.ToMoney() @item.MonthlyBenefits.ToMoney() @(item.HasConfilictJobs ? "" : item.MonthlySalary.ToMoney())@item.MarriedAllowance.ToMoney()@item.BaseYears.ToMoney()@(item.HasConfilictJobs ? "" : item.DailyWageStr)@item.WorkingDays@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
+ index = index + 1; + } + + + } @@ -226,14 +234,14 @@ $(document).ready(function(){ - + $(".ring").remove(); - $('#DSKWOR-datatable').dataTable({ - "lengthMenu": [[25, 10, 50, 100, -1], [25, 10, 50, 100, "All"]], - "pageLength": -1, // set the default page length to "All" - "ordering": false - }); + $('#DSKWOR-datatable').dataTable({ + "lengthMenu": [[25, 10, 50, 100, -1], [25, 10, 50, 100, "All"]], + "pageLength": -1, // set the default page length to "All" + "ordering": false + }); if($('#maritalStatusErr').val() == "true") { @@ -268,79 +276,79 @@ }); }); - @if (Model != null && Model.IsBlock) + @if (Model != null && Model.IsBlock) { - - $("#resultExistPersonel").show(); - $("#resultExistPersonel").html(' این کارگاه بلاک شده است '); + + $("#resultExistPersonel").show(); + $("#resultExistPersonel").html(' این کارگاه بلاک شده است '); } - else if (Model != null && Model.IsExist && Model.IsBlock != true) + else if (Model != null && Model.IsExist && Model.IsBlock != true) { - - $("#resultExistPersonel").show(); - $("#Year").addClass("errored"); - $("#ddlMonth").addClass("errored"); - $("#resultExistPersonel").html('برای این کارگاه در ماه و سال انتخاب شده لیست بیمه تنظیم گردیده است، در صورت نیاز به ثبت این لیست،لیست قبلی را حذف نمایید.'); + + $("#resultExistPersonel").show(); + $("#Year").addClass("errored"); + $("#ddlMonth").addClass("errored"); + $("#resultExistPersonel").html('برای این کارگاه در ماه و سال انتخاب شده لیست بیمه تنظیم گردیده است، در صورت نیاز به ثبت این لیست،لیست قبلی را حذف نمایید.'); } - else + else { - - $("#resultExistPersonel").hide(); - $("#Year").removeClass("errored"); - $("#ddlMonth").removeClass("errored"); - $("#resultExistPersonel").html(''); - document.getElementById("btnPrint").onclick = function () { - printElement(document.getElementById("DSKWOR-datatable")); - }; + + $("#resultExistPersonel").hide(); + $("#Year").removeClass("errored"); + $("#ddlMonth").removeClass("errored"); + $("#resultExistPersonel").html(''); + document.getElementById("btnPrint").onclick = function () { + printElement(document.getElementById("DSKWOR-datatable")); + }; - function printElement(elem) { - var domClone = elem.cloneNode(true); + function printElement(elem) { + var domClone = elem.cloneNode(true); - // create a new stylesheet to hide everything except the modal - var style = document.createElement("style"); - style.innerHTML = ` - @@media print { - body * { - visibility: hidden; - } - #printSection, #printSection * { - visibility: visible; - } - #printSection { - position: absolute; - left: 0; - top: 0; - } + // create a new stylesheet to hide everything except the modal + var style = document.createElement("style"); + style.innerHTML = ` + @@media print { + body * { + visibility: hidden; + } + #printSection, #printSection * { + visibility: visible; + } + #printSection { + position: absolute; + left: 0; + top: 0; + } + } + `; + document.head.appendChild(style); + + // create a new section to hold the modal for printing + var $printSection = document.getElementById("printSection"); + if (!$printSection) { + $printSection = document.createElement("div"); + $printSection.id = "printSection"; + document.body.appendChild($printSection); } - `; - document.head.appendChild(style); - // create a new section to hold the modal for printing - var $printSection = document.getElementById("printSection"); - if (!$printSection) { - $printSection = document.createElement("div"); - $printSection.id = "printSection"; - document.body.appendChild($printSection); + $printSection.innerHTML = ""; + $printSection.appendChild(domClone); + + window.print(); + + // remove the new stylesheet after printing + document.head.removeChild(style); } - $printSection.innerHTML = ""; - $printSection.appendChild(domClone); - - window.print(); - - // remove the new stylesheet after printing - document.head.removeChild(style); - } - } var jobName = $('#JobId option:selected').text(); - // console.log($("#EmployeeId").val(),jobName); + //شروع محاسبه کارگاه setDataTable($("#EmployeeId").val(),jobName); //$(function () { diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs index 154f63b8..3bf589a5 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs @@ -115,7 +115,9 @@ public class IndexModel : PageModel //ماه قبل BeforCurrentMonth = persianBeforeDate.Substring(5, 2), //سال جاری - CurrentYear = persianBeforeDate.Substring(0, 4) + CurrentYear = persianBeforeDate.Substring(0, 4), + + InsuranceWorkshopInfo = new InsuranceWorkshopInfoViewModel(), }; return Partial("./Create", command); } @@ -183,6 +185,8 @@ public class IndexModel : PageModel double sumOfIncludedKarfarma = 0; var hasKarfarma = false; double countWithoutLeft = 0; + double sumOfBaseYears = 0; + double sumOfMarriedAllowance = 0; for (var i = 0; i < employeeDetailsForInsuranceList.Count; i++) @@ -201,9 +205,17 @@ public class IndexModel : PageModel leftWorkDay = ""; } + //بدست آوردن جمع پایه سنواتی + var baseYear = employeeDetailsForInsuranceList[i].BaseYears * + employeeDetailsForInsuranceList[i].WorkingDays; + sumOfBaseYears += baseYear; - // if (employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobId == 10 || employeeDetailsForInsuranceList[i].JobId == 17 || employeeDetailsForInsuranceList[i].JobId == 18 || employeeDetailsForInsuranceList[i].JobId == 16))// 10 --> karfarma - if (!employeeDetailsForInsuranceList[i].IncludeStatus && + //بدست آوردن جمع حق تاهل + sumOfMarriedAllowance += employeeDetailsForInsuranceList[i].MarriedAllowance; + + + // if (employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobId == 10 || employeeDetailsForInsuranceList[i].JobId == 17 || employeeDetailsForInsuranceList[i].JobId == 18 || employeeDetailsForInsuranceList[i].JobId == 16))// 10 --> karfarma + if (!employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobCode == "027079" || employeeDetailsForInsuranceList[i].JobCode == "024398" || employeeDetailsForInsuranceList[i].JobCode == "011015" || @@ -373,8 +385,12 @@ public class IndexModel : PageModel //سهم حق کارفرما EmployerShare = employerShare.ToMoney(), //بیمه بیکاری - UnEmploymentInsurance = unEmploymentInsurance.ToMoney() - }); + UnEmploymentInsurance = unEmploymentInsurance.ToMoney(), + //جمع پایه سنواتی + SumOfBaseYears = sumOfBaseYears.ToMoney(), + //جمع حق تاهل + SumOfMarriedAllowance = sumOfMarriedAllowance.ToMoney(), + }); } @@ -555,7 +571,12 @@ public class IndexModel : PageModel odbf.Header.AddColumn(new DbfColumn("DSK_BIMH", DbfColumn.DbfColumnType.Number, 12, 0)); //ردیف پیمان odbf.Header.AddColumn(new DbfColumn("MON_PYM", DbfColumn.DbfColumnType.Character, 3, 0)); - var orec = new DbfRecord(odbf.Header); + + //مجموع پایه سنواتی ها + odbf.Header.AddColumn(new DbfColumn("DSK_INC", DbfColumn.DbfColumnType.Character, 12, 0)); + //مجموع حق تاهل ها + odbf.Header.AddColumn(new DbfColumn("DSK_SPOUSE", DbfColumn.DbfColumnType.Character, 12, 0)); + var orec = new DbfRecord(odbf.Header); //کد کارگاه orec[0] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.InsuranceCode, 10); @@ -603,7 +624,14 @@ public class IndexModel : PageModel orec[21] = createInsuranceList.DifficultJobsInsuranc.ToString(); //ردیف پیمان orec[22] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.AgreementNumber, 12); - odbf.Write(orec); + + //مجموع پایه سنواتی ها + orec[23] = createInsuranceList.SumOfBaseYears.ToString(); + + //مجموع حق تاهل ها + orec[24] = createInsuranceList.SumOfMarriedAllowance.ToString(); + + odbf.Write(orec); //odbf.Header.RecordCount = 50; odbf.WriteHeader(); odbf.Close(); @@ -670,7 +698,12 @@ public class IndexModel : PageModel // کد ملی dsw.Header.AddColumn(new DbfColumn("PER_NATCOD", DbfColumn.DbfColumnType.Character, 10, 0)); - foreach (var item in createInsuranceList.EmployeeInsurancListDataList) + // پایه سنوات + dsw.Header.AddColumn(new DbfColumn("DSW_INC", DbfColumn.DbfColumnType.Number, 12, 0)); + // حق تاهل + dsw.Header.AddColumn(new DbfColumn("DSW_SPOUSE", DbfColumn.DbfColumnType.Number, 12, 0)); + + foreach (var item in createInsuranceList.EmployeeInsurancListDataList) { var employee = createInsuranceList.EmployeeDetailsForInsuranceList .Where(p => p.EmployeeId == item.EmployeeId).FirstOrDefault(); @@ -749,7 +782,12 @@ public class IndexModel : PageModel //کد ملی dswrec[26] = employee.NationalCode; - dsw.Write(dswrec); + //پایه سنوات + dswrec[27] = item.BaseYears.ToString(); + //حق تاهل + dswrec[28] = item.MarriedAllowance.ToString(); + + dsw.Write(dswrec); }