From 03ee772974c0b0cbbc9180c4dc2408e8283f042d Mon Sep 17 00:00:00 2001 From: SamSys Date: Wed, 9 Apr 2025 19:18:00 +0330 Subject: [PATCH] TemporaryClientRegister - Compelet edcreatWorkshopTemp --- .../IWorkshopServicesTempRepository.cs | 10 +- .../IYearlySalaryRepository.cs | 4 + ...ITemporaryClientRegistrationApplication.cs | 8 + .../ReviewAndPaymentViewModel.cs | 80 ++ .../WorkshopServicesTempViewModel.cs | 7 +- .../TemporaryClientRegistrationApplication.cs | 183 ++- .../WorkshopServicesTempRepository.cs | 28 + .../Repository/YearlySalaryRepository.cs | 1228 +++++++++-------- .../PersonalBootstrapper.cs | 3 + ServiceHost/Pages/Index.cshtml.cs | 7 +- 10 files changed, 943 insertions(+), 615 deletions(-) create mode 100644 CompanyManagment.App.Contracts/TemporaryClientRegistration/ReviewAndPaymentViewModel.cs create mode 100644 CompanyManagment.EFCore/Repository/WorkshopServicesTempRepository.cs diff --git a/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs b/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs index 5e66ba68..38aad4db 100644 --- a/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs +++ b/Company.Domain/TemporaryClientRegistrationAgg/IWorkshopServicesTempRepository.cs @@ -1,8 +1,14 @@ -using _0_Framework.Domain; +using System.Collections.Generic; +using _0_Framework.Domain; +using CompanyManagment.App.Contracts.TemporaryClientRegistration; namespace Company.Domain.TemporaryClientRegistrationAgg; public interface IWorkshopServicesTempRepository : IRepository { - + /// + /// حذف کامل سرویس های کارگاه + /// + /// + public void RemoveServices(long workshopTempId); } \ No newline at end of file diff --git a/Company.Domain/YearlySalaryAgg/IYearlySalaryRepository.cs b/Company.Domain/YearlySalaryAgg/IYearlySalaryRepository.cs index f7e28c28..97a42b0e 100644 --- a/Company.Domain/YearlySalaryAgg/IYearlySalaryRepository.cs +++ b/Company.Domain/YearlySalaryAgg/IYearlySalaryRepository.cs @@ -11,6 +11,10 @@ namespace Company.Domain.YearlySalaryAgg; public interface IYearlySalaryRepository : IRepository { + /// + /// تست محاسبه مزد پایه + /// + void TestDayliFeeCompute(); List GetYears(); List GetYearlySalary(); MontlywageBunosYearsViewModel GetMontlyBunosYears(TimeSpan weeklyTime, DateTime contractStart,DateTime contractEnd, double daylyWage, string weeklyWorkingTime, int officialholiday, int friday, string totalHoursH, string totalHorsM, string basic, int fridayStartToEnd, double dayliFeeComplete, bool hasRollCall, bool holidaysWorking); diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs index 8b4ab8c3..d749485a 100644 --- a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ITemporaryClientRegistrationApplication.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using _0_Framework.Application; +using CompanyManagment.App.Contracts.InstitutionPlan; namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; @@ -38,4 +39,11 @@ public interface ITemporaryClientRegistrationApplication /// /// Task CreateOrUpdateWorkshopTemp(List command); + + /// + /// دریافت جمع کل خدمات برای یک کارگاه + /// + /// + /// + InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel workshop); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/ReviewAndPaymentViewModel.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ReviewAndPaymentViewModel.cs new file mode 100644 index 00000000..a966ccf7 --- /dev/null +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/ReviewAndPaymentViewModel.cs @@ -0,0 +1,80 @@ +namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; + +public class ReviewAndPaymentViewModel +{ + /// + /// جمع کل برای یک ماه + /// double + /// + public double TotalPayment1MonthDouble { get; set; } + + /// + /// جمع کل برای یک ماه + /// string + /// + public string TotalPayment1MonthStr { get; set; } + + /// + /// آیا یک ماهه انتخاب شده است + /// + public bool IsSelected1 { get; set; } + + + + + /// + /// جمع کل برای 3 ماه + /// double + /// + public double TotalPayment3MonthsDouble { get; set; } + + /// + /// جمع کل برای 3 ماه + /// string + /// + public string TotalPayment3MonthsStr { get; set; } + + /// + /// آیا 3 ماهه انتخاب شده است + /// + public bool IsSelected3 { get; set; } + + + + /// + /// جمع کل برای 6 ماه + /// double + /// + public double TotalPayment6MonthsDouble { get; set; } + + /// + /// جمع کل برای 6 ماه + /// string + /// + public string TotalPayment6MonthsStr { get; set; } + + /// + /// آیا 6 ماهه انتخاب شده است + /// + public bool IsSelected6 { get; set; } + + + + + /// + /// جمع کل برای 12 ماه + /// double + /// + public double TotalPayment12MonthsDouble { get; set; } + + /// + /// جمع کل برای 12 ماه + /// string + /// + public string TotalPayment12MonthsStr { get; set; } + + /// + /// آیا 12 ماهه انتخاب شده است + /// + public bool IsSelected12 { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs index 7e4ee777..3216b362 100644 --- a/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/WorkshopServicesTempViewModel.cs @@ -1,6 +1,9 @@ -namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; +using System; -public class WorkshopServicesTempViewModel +namespace CompanyManagment.App.Contracts.TemporaryClientRegistration; + +public class WorkshopServicesTempViewModel : CreateWorkshopServicesTemp { public long Id { get; set; } + public DateTime CreationDate{ get; set; } } \ No newline at end of file diff --git a/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs b/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs index 7a5e903b..5095e290 100644 --- a/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs +++ b/CompanyManagment.Application/TemporaryClientRegistrationApplication.cs @@ -20,15 +20,17 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati private readonly IUidService _uidService; private readonly IWorkshopTempRepository _workshopTempRepository; private readonly IPlanPercentageRepository _planPercentageRepository; + private readonly IWorkshopServicesTempRepository _workshopServicesTempRepository; - public TemporaryClientRegistrationApplication(IContractingPartyTempRepository contractingPartyTempRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IUidService uidService, IWorkshopTempRepository workshopTempRepository, IPlanPercentageRepository planPercentageRepository) + public TemporaryClientRegistrationApplication(IContractingPartyTempRepository contractingPartyTempRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IUidService uidService, IWorkshopTempRepository workshopTempRepository, IPlanPercentageRepository planPercentageRepository, IWorkshopServicesTempRepository workshopServicesTempRepository) { _contractingPartyTempRepository = contractingPartyTempRepository; _personalContractingPartyRepository = personalContractingPartyRepository; _uidService = uidService; _workshopTempRepository = workshopTempRepository; _planPercentageRepository = planPercentageRepository; + _workshopServicesTempRepository = workshopServicesTempRepository; } /// @@ -38,7 +40,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati /// /// /// - public async Task> CreateContractingPartyTemp(string nationalCode , string dateOfBirth, string mobile) + public async Task> CreateContractingPartyTemp(string nationalCode, string dateOfBirth, string mobile) { var op = new OperationResult(); @@ -48,14 +50,14 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati string.IsNullOrWhiteSpace(mobile)) return op.Failed("هیچ یک از فیلد ها نمیتواند خالی باشد"); - + if (nationalCode.NationalCodeValid() != "valid") return op.Failed("کد ملی نا معتبر است"); - if(!dateOfBirth.IsPersianDateValid()) + if (!dateOfBirth.IsPersianDateValid()) return op.Failed("تاریخ تولد نا معتبر است"); - if(!mobile.IsMobileValid()) + if (!mobile.IsMobileValid()) return op.Failed("شماره همراه نا معتبر است"); #endregion @@ -79,8 +81,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati //اگر طرف حساب موقت قبلا ایجاد شده دیتای آن را برمیگرداند if (getExistTemp != null) { - - if(getExistTemp.DateOfBirth != dateOfBirthGr) + + if (getExistTemp.DateOfBirth != dateOfBirthGr) return op.Failed("تاریخ تولد مطابقت ندارد"); if (getExistTemp.Phone != mobile) return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید"); @@ -91,13 +93,13 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile); if (isMachMobilAndNationalCode == null) return op.Failed("خطا در سرویس احراز هویت"); - if(!isMachMobilAndNationalCode.IsMatched) + if (!isMachMobilAndNationalCode.IsMatched) return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد"); //دریافت اطلاعات احراز هویت var apiRespons = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth); - if(apiRespons == null) + if (apiRespons == null) return op.Failed("خطا در سرویس احراز هویت"); if (apiRespons.ResponseContext.Status.Code != 0) return op.Failed($"{apiRespons.ResponseContext.Status.Message}"); @@ -113,19 +115,19 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati apiRespons.IdentificationInformation.ShenasnameSeri, apiRespons.IdentificationInformation.ShenasnameSerial, apiRespons.BasicInformation.GenderEnum, dateOfBirthGr); - await _contractingPartyTempRepository.CreateAsync(createTemp); - await _contractingPartyTempRepository.SaveChangesAsync(); + await _contractingPartyTempRepository.CreateAsync(createTemp); + await _contractingPartyTempRepository.SaveChangesAsync(); - var result = new ContractingPartyTempViewModel(); - result.Id = createTemp.id; - result.FName = createTemp.FName; - result.LName = createTemp.LName; - result.DateOfBirthFa = dateOfBirth; - result.IdNumber = idNumber; + var result = new ContractingPartyTempViewModel(); + result.Id = createTemp.id; + result.FName = createTemp.FName; + result.LName = createTemp.LName; + result.DateOfBirthFa = dateOfBirth; + result.IdNumber = idNumber; - return op.Succcedded(result); + return op.Succcedded(result); } - + } @@ -142,15 +144,15 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati public async Task UpdateAddress(long id, string state, string city, string address) { var op = new OperationResult(); - var contractingPartyTemp = _contractingPartyTempRepository.Get(id); + var contractingPartyTemp = _contractingPartyTempRepository.Get(id); - if (string.IsNullOrWhiteSpace(state) || string.IsNullOrWhiteSpace(city) || string.IsNullOrWhiteSpace(address)) - return op.Failed("اطلاعات ادرس را تکمیل کنید"); + if (string.IsNullOrWhiteSpace(state) || string.IsNullOrWhiteSpace(city) || string.IsNullOrWhiteSpace(address)) + return op.Failed("اطلاعات ادرس را تکمیل کنید"); - contractingPartyTemp.UpdateAddress(state,city,address); - await _contractingPartyTempRepository.SaveChangesAsync(); + contractingPartyTemp.UpdateAddress(state, city, address); + await _contractingPartyTempRepository.SaveChangesAsync(); - return op.Succcedded(); + return op.Succcedded(); } /// @@ -174,13 +176,16 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati var updateWorkshopList = command.Where(x => x.Id > 0).ToList(); var createNewWorkshopList = command.Where(x => x.Id == 0).ToList(); - + if (updateWorkshopList.Count == 0 && createNewWorkshopList.Count == 0) + return op.Failed("هیچ مجموعه ای ایجاد نشده است"); + + #region Update if (updateWorkshopList.Count > 0) { - + foreach (var workshop in updateWorkshopList) { - + if (!string.IsNullOrWhiteSpace(workshop.WorkshopName)) return op.Failed("نام مجموعه نمی تواند خالی باشد"); if (workshop.CountPerson == 0) @@ -195,21 +200,133 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati workshop.ContractAndCheckoutInPerson = true; if (workshop.Insurance) workshop.InsuranceInPerson = true; + + //دریافت مبالغ سرویس ها var plan = _planPercentageRepository.GetInstitutionPlanForWorkshop(workshop); if (plan.OnlineAndInPersonSumAmountDouble > 0) { + //ویرایش مشخصات کارگاه existWorkshops.Edit(workshop.WorkshopName, workshop.CountPerson, plan.OnlineAndInPersonSumAmountDouble); await _workshopTempRepository.SaveChangesAsync(); - } - - } - + //حذف سرویس های قبلی + _workshopServicesTempRepository.RemoveServices(workshop.Id); + + //سرویس قرداد + if (workshop.ContractAndCheckout) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("ContractAndCheckout", workshop.CountPerson, workshop.Id)); + //سرویس خدمات حضوری قرارداد + if (workshop.ContractAndCheckoutInPerson) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("ContractAndCheckoutInPerson", workshop.CountPerson, workshop.Id)); + + //سرویس بیمه + if (workshop.Insurance) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("Insurance", workshop.CountPerson, workshop.Id)); + //سرویس خدمات حضوری بیمه + if (workshop.InsuranceInPerson) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("InsuranceInPerson", workshop.CountPerson, workshop.Id)); + + //سرویس حضورغیاب + if (workshop.RollCall) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("RollCall", workshop.CountPerson, workshop.Id)); + //سرویس فیش غیر رسمی + if (workshop.CustomizeCheckout) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("CustomizeCheckout", workshop.CountPerson, workshop.Id)); + } + + } } } + #endregion - return new OperationResult(); + #region Create + + if (createNewWorkshopList.Count > 0) + { + foreach (var workshop in createNewWorkshopList) + { + + if (!string.IsNullOrWhiteSpace(workshop.WorkshopName)) + return op.Failed("نام مجموعه نمی تواند خالی باشد"); + if (workshop.CountPerson == 0) + op.Failed($"تعداد پرسنل مجوعه {workshop.WorkshopName} صفر است"); + if (workshop.ContractAndCheckout == false && workshop.CustomizeCheckout == false && + workshop.RollCall == false && workshop.Insurance == false) + op.Failed($"برای مجموعه {workshop.WorkshopName} هیچ سرویسی انتخاب نشده است"); + + if (workshop.ContractAndCheckout) + workshop.ContractAndCheckoutInPerson = true; + if (workshop.Insurance) + workshop.InsuranceInPerson = true; + + //دریافت مبالغ سرویس ها + var plan = _planPercentageRepository.GetInstitutionPlanForWorkshop(workshop); + if (plan.OnlineAndInPersonSumAmountDouble > 0) + { + + + var createNewWorkshopTemp = new WorkshopTemp(workshop.WorkshopName, workshop.CountPerson, + workshop.ContractingPartyTempId, plan.OnlineAndInPersonSumAmountDouble); + await _workshopTempRepository.CreateAsync(createNewWorkshopTemp); + await _workshopTempRepository.SaveChangesAsync(); + + + + //سرویس قرداد + if (workshop.ContractAndCheckout) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("ContractAndCheckout", workshop.CountPerson, createNewWorkshopTemp.id)); + //سرویس خدمات حضوری قرارداد + if (workshop.ContractAndCheckoutInPerson) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("ContractAndCheckoutInPerson", workshop.CountPerson, createNewWorkshopTemp.id)); + + //سرویس بیمه + if (workshop.Insurance) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("Insurance", workshop.CountPerson, createNewWorkshopTemp.id)); + //سرویس خدمات حضوری بیمه + if (workshop.InsuranceInPerson) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("InsuranceInPerson", workshop.CountPerson, createNewWorkshopTemp.id)); + + //سرویس حضورغیاب + if (workshop.RollCall) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("RollCall", workshop.CountPerson, createNewWorkshopTemp.id)); + //سرویس فیش غیر رسمی + if (workshop.CustomizeCheckout) + await _workshopServicesTempRepository.CreateAsync( + new WorkshopServicesTemp("CustomizeCheckout", workshop.CountPerson, createNewWorkshopTemp.id)); + } + + } + } + + #endregion + + + return op.Succcedded(); } + + /// + /// دریافت جمع کل خدمات برای یک کارگاه + /// + /// + /// + public InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel workshop) + { + return _planPercentageRepository.GetInstitutionPlanForWorkshop(workshop); + } + + + public } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/WorkshopServicesTempRepository.cs b/CompanyManagment.EFCore/Repository/WorkshopServicesTempRepository.cs new file mode 100644 index 00000000..7250531c --- /dev/null +++ b/CompanyManagment.EFCore/Repository/WorkshopServicesTempRepository.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using System.Linq; +using _0_Framework.InfraStructure; +using Company.Domain.TemporaryClientRegistrationAgg; +using CompanyManagment.App.Contracts.TemporaryClientRegistration; +using Microsoft.EntityFrameworkCore; + +namespace CompanyManagment.EFCore.Repository; + +public class WorkshopServicesTempRepository : RepositoryBase, IWorkshopServicesTempRepository +{ + private readonly CompanyContext _context; + public WorkshopServicesTempRepository(CompanyContext context) : base(context) + { + _context = context; + } + + public void RemoveServices(long workshopTempId) + { + var getServices = _context.WorkshopServicesTemps.Where(x => x.WorkshopTempId == workshopTempId); + if (getServices.Any()) + { + _context.WorkshopServicesTemps.RemoveRange(getServices); + _context.SaveChanges(); + } + + } +} \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs index e5ac3f13..e8502055 100644 --- a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs +++ b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs @@ -14,6 +14,7 @@ using CompanyManagment.App.Contracts.Holiday; using CompanyManagment.App.Contracts.LeftWork; using CompanyManagment.App.Contracts.YearlySalary; using CompanyManagment.EFCore.Migrations; +using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using PersianTools.Core; @@ -45,7 +46,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var y = Convert.ToInt32(endDateNowFa.Substring(0, 4)); var m = Convert.ToInt32(endDateNowFa.Substring(5, 2)); var d = Convert.ToInt32(endDateNowFa.Substring(8, 2)); - + PersianDateTime endDate = new PersianDateTime(y, m, d); if (m == 12) @@ -120,7 +121,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl //var MandatoryDays = TotalDays - friday - officialholiday; var MandatoryDays = TotalDays - fridayStartToEnd; //اگر حضورغیاب داشت - if(hasRollCall) + if (hasRollCall) MandatoryDays = TotalDays - fridayStartToEnd - officialholiday; //بدست آوردن ساعت موظفی این ماه var TotalMandatoryHours = MandatoryDays * 7.33;//ساعت موظفی این ماه @@ -168,7 +169,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl daylyWage = basicDouble > 0 ? (daylyWage + basicDouble) : daylyWage; montlyResult = daylyWage * TotalDays;// مزد ماهانه با پایه سنوات bacicMontlyResult = BasicDayliFee * TotalDays;// مزد ماهانه بدون پایه سنوات - + if (montlyResult > bacicMontlyResult) { @@ -484,7 +485,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl double computeResult = 0; //تعداد روزهای قرارداد - + if (weeklyWorkingTime == "24 - 12" || weeklyWorkingTime == "24 - 24" || weeklyWorkingTime == "36 - 12" || weeklyWorkingTime == "48 - 24") @@ -592,7 +593,59 @@ public class YearlySalaryRepository : RepositoryBase, IYearl #endregion + public void TestDayliFeeCompute() + { + //مقادیر سالانه + var salary = _context.YearlySalaries.Include(i => i.YearlySalaryItemsList).OrderBy(x => x.StartDate).ToList(); + // یافتن مزد روزانه سال قبل از اولین شروع بکار + var DayliSalaryStep1 = salary.FirstOrDefault(x => x.Year == "1370")! + .YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault(); + var DayliSalaryStep1Fa = DayliSalaryStep1.ToMoney(); + double firstDayliSalary = DayliSalaryStep1Fa.MoneyToDouble(); + int counter = 0; + foreach (var item in salary) + { + var currentDayliFee = salary.FirstOrDefault(x => x.Year == item.Year)! + .YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault(); + var fixFeePercentage = salary.FirstOrDefault(x => x.Year == item.Year)! + .YearlySalaryItemsList.Where(x => x.ItemName == "درصد مزد ثابت").Select(x => x.ItemValue).FirstOrDefault(); + // مبلغ مزد ثابت سال جاری + var fixFeePrice = salary.FirstOrDefault(x => x.Year == item.Year)!.YearlySalaryItemsList + .Where(x => x.ItemName == "مبلغ مزد ثابت").Select(x => x.ItemValue).FirstOrDefault(); + if (counter > 0) + { + // مزد روزانه سال قبل ضربدر درصد مزد ثابت تقسیم بر صد + var percntSumDaylifee = (firstDayliSalary * fixFeePercentage) / 100; + // نتیجه عملیات بالا بعلاوه مزد سال قبل + var Sum = firstDayliSalary + percntSumDaylifee; + + //مزد پایه + var BaseResult = Sum + fixFeePrice; + var baseResultFa = BaseResult.ToMoney(); + var res = GetRoundValue(BaseResult); + if (currentDayliFee != res) + { + Console.BackgroundColor = ConsoleColor.DarkRed; + Console.WriteLine($"{item.Year} original : {currentDayliFee} Computed : {res} "); + Console.ResetColor(); + } + else + { + Console.WriteLine($"{item.Year} original : {currentDayliFee} Computed : {res} "); + } + + //Console.WriteLine($"{item.Year} defualtFa : {currentDayliFee.ToMoney()} dailFeeFa : {BaseResult.ToMoney()} "); + firstDayliSalary = GetRoundValue(currentDayliFee); + + } + + counter++; + } + + //مقدار اولیه مزد روزانه + + } //محاسبه حقوق روزانه #region DayliSalary public DayliFeeViewModel DayliFeeComputing(DateTime startDateW, DateTime contractStart, DateTime endDateW, long employeeId, long workshopId, List leftWorkList) @@ -764,12 +817,12 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var Sum = firstDayliSalary + percntSumDaylifee; //مزد پایه BaseResult = Sum + fixFeePrice; - //var rondUp = Convert.ToInt32(BaseResult); + //var rondUp = Convert.ToInt32(BaseResult); - Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]"); + Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]"); - //آی دی سال جاری - loopDateId = salary.Where(x => x.StartDate <= LoopDateGr && x.EndDate >= LoopDateGr && x.id != loopDateId).Select(x => x.id).FirstOrDefault(); + //آی دی سال جاری + loopDateId = salary.Where(x => x.StartDate <= LoopDateGr && x.EndDate >= LoopDateGr && x.id != loopDateId).Select(x => x.id).FirstOrDefault(); // ذخیره سال جاری بعنوان سال گذشته برای عملیات بعدی oldYear = loopdateYear; } @@ -792,12 +845,12 @@ public class YearlySalaryRepository : RepositoryBase, IYearl //مزد پایه BaseResult = Sum + fixFeePrice; - //var rondUp = Convert.ToInt32(BaseResult); + //var rondUp = Convert.ToInt32(BaseResult); - Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]"); + Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]"); - //آی دی سال جاری - loopDateId = salary.Where(x => x.StartDate <= LoopDateGr && x.EndDate >= LoopDateGr && x.id != loopDateId).Select(x => x.id).FirstOrDefault(); + //آی دی سال جاری + loopDateId = salary.Where(x => x.StartDate <= LoopDateGr && x.EndDate >= LoopDateGr && x.id != loopDateId).Select(x => x.id).FirstOrDefault(); // ذخیره سال جاری بعنوان سال گذشته برای عملیات بعدی oldYear = loopdateYear; } @@ -827,8 +880,8 @@ public class YearlySalaryRepository : RepositoryBase, IYearl Console.BackgroundColor = ConsoleColor.DarkYellow; Console.WriteLine($"{test} - mozd[{BaseResult}] - Basic[{Basic}]"); Console.ResetColor(); - //صفر نمودن شمارنده روزها - DayCounter = 0; + //صفر نمودن شمارنده روزها + DayCounter = 0; } //if (loopdateFa == "1398/12/29") @@ -923,7 +976,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // محاسبه حق عائله مندی پرسنل بر اساس تاریخ ورودی و آی دی پرسنل #region FamilyAllowance - public string FamilyAllowance(long personelID,DateTime startContract, DateTime endContract) + public string FamilyAllowance(long personelID, DateTime startContract, DateTime endContract) { //DateTime zeroTime = new DateTime(1, 1, 1); //TimeSpan Age = new TimeSpan(); @@ -937,7 +990,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl double sumOfFamilyAllowance = 0; DateTime firstDayOFContract = endContract.FindFirstDayOfMonthGr(); if (startContract < firstDayOFContract) - startContract = firstDayOFContract; + startContract = firstDayOFContract; var totalContractDays = Convert.ToInt32((endContract - startContract).TotalDays + 1); try { @@ -960,29 +1013,29 @@ public class YearlySalaryRepository : RepositoryBase, IYearl if (childAge.yearCount < 18 && insurancHistoey >= 720) { - sumOfFamilyAllowance += familyAllowance; + sumOfFamilyAllowance += familyAllowance; } else if (childAge.yearCount == 18 && childAge.monthCount == 0 && insurancHistoey >= 720) { - - if (childAge.dayCount > 0) - { - //به دست آوردن روزهای مجاز قبل از 18 سال + + if (childAge.dayCount > 0) + { + //به دست آوردن روزهای مجاز قبل از 18 سال var daysToPay = totalContractDays - childAge.dayCount; - + if (daysToPay > 0) { - //محاسبه مبلغ بر اساس تعداد روزهای مجاز - var payPerDay = (familyAllowance / 30) * daysToPay; - sumOfFamilyAllowance += payPerDay; + //محاسبه مبلغ بر اساس تعداد روزهای مجاز + var payPerDay = (familyAllowance / 30) * daysToPay; + sumOfFamilyAllowance += payPerDay; } - } - else - { - sumOfFamilyAllowance += familyAllowance; - } + } + else + { + sumOfFamilyAllowance += familyAllowance; + } } } @@ -990,7 +1043,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl } catch (Exception e) { - sumOfFamilyAllowance = 0; + sumOfFamilyAllowance = 0; } //var ress = dayliSalar3 * childeNumber; @@ -1003,50 +1056,50 @@ public class YearlySalaryRepository : RepositoryBase, IYearl public string FamilyAllowanceAutoExtention(long personelID, DateTime startContract) { - var endDateInput = _context.YearlySalaries - .SingleOrDefault(x => x.StartDate <= startContract && x.EndDate >= startContract); - var FirstItems = _context.YearlySalaryItems.SingleOrDefault(x => x.YearlySalaryId == endDateInput.id && x.ItemName == "مزد روزانه"); - var dayliSalary = FirstItems.ItemValue; - var familyAllowance = dayliSalary * 3; - double sumOfFamilyAllowance = 0; - try - { - var children = _context.EmployeeChildrenSet.Where(x => x.EmployeeId == personelID).ToList(); - var insuranceYearAndMonth = _context.Employees.SingleOrDefault(x => x.id == personelID); - var yearI = Convert.ToInt32(insuranceYearAndMonth.InsuranceHistoryByYear); - var monthI = Convert.ToInt32(insuranceYearAndMonth.InsuranceHistoryByMonth); - yearI *= 365; - monthI *= 30; - var insurancHistoey = yearI + monthI; + var endDateInput = _context.YearlySalaries + .SingleOrDefault(x => x.StartDate <= startContract && x.EndDate >= startContract); + var FirstItems = _context.YearlySalaryItems.SingleOrDefault(x => x.YearlySalaryId == endDateInput.id && x.ItemName == "مزد روزانه"); + var dayliSalary = FirstItems.ItemValue; + var familyAllowance = dayliSalary * 3; + double sumOfFamilyAllowance = 0; + try + { + var children = _context.EmployeeChildrenSet.Where(x => x.EmployeeId == personelID).ToList(); + var insuranceYearAndMonth = _context.Employees.SingleOrDefault(x => x.id == personelID); + var yearI = Convert.ToInt32(insuranceYearAndMonth.InsuranceHistoryByYear); + var monthI = Convert.ToInt32(insuranceYearAndMonth.InsuranceHistoryByMonth); + yearI *= 365; + monthI *= 30; + var insurancHistoey = yearI + monthI; - foreach (var item in children) - { - if (item.DateOfBirth < startContract) - { - + foreach (var item in children) + { + if (item.DateOfBirth < startContract) + { - var childAge = Tools.GetAge(item.DateOfBirth, startContract); - if (childAge.yearCount < 18 && insurancHistoey >= 720) - { - sumOfFamilyAllowance += familyAllowance; + var childAge = Tools.GetAge(item.DateOfBirth, startContract); - } - - } + if (childAge.yearCount < 18 && insurancHistoey >= 720) + { + sumOfFamilyAllowance += familyAllowance; - } - } - catch (Exception e) - { - sumOfFamilyAllowance = 0; - } + } + + } + + } + } + catch (Exception e) + { + sumOfFamilyAllowance = 0; + } - var result = sumOfFamilyAllowance.ToMoney(); + var result = sumOfFamilyAllowance.ToMoney(); - return result; + return result; } #endregion @@ -1067,7 +1120,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl public async Task FamilyAllowanceAsync(long personelID, DateTime EndCantract) { - var res = "FamilyAllowance(personelID, EndCantract);"; + var res = "FamilyAllowance(personelID, EndCantract);"; return res; } #endregion @@ -1197,8 +1250,8 @@ public class YearlySalaryRepository : RepositoryBase, IYearl public BunosesAndYearsPayStatus Years(DateTime separationStartDate, DateTime leftWorkDate, DateTime separationEndDate, double daylyWage, string yearsOptions, bool hasleft, DateTime startWorkDate, DateTime contractStart, DateTime contractEnd, long workshopId, long employeeId, bool isOldContract) { - BunosesAndYearsPayStatus finalResult = new BunosesAndYearsPayStatus(); - var startDateFa = separationEndDate.ToFarsi(); + BunosesAndYearsPayStatus finalResult = new BunosesAndYearsPayStatus(); + var startDateFa = separationEndDate.ToFarsi(); var checkoutMonth = startDateFa.Substring(5, 2); double result = 0; var start1403 = new DateTime(2024, 3, 20); @@ -1211,13 +1264,13 @@ public class YearlySalaryRepository : RepositoryBase, IYearl break; //محاسبه در پایان سال به شرطی که قرارداد منتهی به پایان سال باشد case "OnEndOfYear"://درپایان سال - + if (isOldContract && contractEnd < start1403) { var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } else if (isOldContract && contractEnd > start1403) { if ((hasleft && leftWorkDate <= separationEndDate) || (checkoutMonth == "12" && separationEndDate == contractEnd)) @@ -1229,72 +1282,72 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // اگر تاریخ شروع بکار بزرگتر مساوی روز اول همین سال بود از تازیخ شوع بکار استفاده میشود در غیر اینصورت از روز اول سال استفاده میشود var startComputeDay = startWorkDate >= startDayOfYearGr ? startWorkDate : startDayOfYearGr; - - - #region NewCompute - //شروع دوره - string st = startComputeDay.ToFarsi(); - int syear = Convert.ToInt32(st.Substring(0, 4)); - int smonth = Convert.ToInt32(st.Substring(5, 2)); - PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); - PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); - //پایان فیش حقوقی آخر - PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); - if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) - { - var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } - else - { - var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && - x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); - //پایان دوره - PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); - List nullDateList = new List(); - double sumOfOldYearsPay = 0; - var oldTotaldays = 0; - for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) - { - var searchStart = ($"{startDate}").ToGeorgianDateTime(); - var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); - var foundCheckout = checkoutList.FirstOrDefault(x => - x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); - if (foundCheckout == null) - { - nullDateList.Add(new BunosesAndYearsPayStatus() - { - ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, - ContractEnd = searchEnd - }); - finalResult.NotCompleted = true; - } - else - { - double foundMonthlySalary = foundCheckout.MonthlySalary; - int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); - double foundDayliWage = foundMonthlySalary / foundTotaldays; - double foundYearsPay = ((foundDayliWage * 30) / 365) * foundTotaldays; - oldTotaldays += foundTotaldays; - sumOfOldYearsPay += foundYearsPay; - } - } + #region NewCompute - var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; - double lastMonthYearsPay = ((daylyWage * 30) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotaldays); - finalResult.YearsPay = lastMonthYearsPay + sumOfOldYearsPay; - finalResult.BunosesStatusList = nullDateList; + //شروع دوره + string st = startComputeDay.ToFarsi(); + int syear = Convert.ToInt32(st.Substring(0, 4)); + int smonth = Convert.ToInt32(st.Substring(5, 2)); + PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); + PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); + //پایان فیش حقوقی آخر + PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); + if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) + { + var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays); + } + else + { + var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && + x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); + //پایان دوره + PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); + List nullDateList = new List(); + double sumOfOldYearsPay = 0; + var oldTotaldays = 0; + for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) + { + var searchStart = ($"{startDate}").ToGeorgianDateTime(); + var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); + var foundCheckout = checkoutList.FirstOrDefault(x => + x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); + if (foundCheckout == null) + { + nullDateList.Add(new BunosesAndYearsPayStatus() + { + ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, + ContractEnd = searchEnd + }); + finalResult.NotCompleted = true; + } + else + { + double foundMonthlySalary = foundCheckout.MonthlySalary; + int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); + double foundDayliWage = foundMonthlySalary / foundTotaldays; + double foundYearsPay = ((foundDayliWage * 30) / 365) * foundTotaldays; + oldTotaldays += foundTotaldays; + sumOfOldYearsPay += foundYearsPay; + } - } + } - #endregion - } - } + var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; + double lastMonthYearsPay = ((daylyWage * 30) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotaldays); + finalResult.YearsPay = lastMonthYearsPay + sumOfOldYearsPay; + finalResult.BunosesStatusList = nullDateList; + + } + + #endregion + } + } else if (!isOldContract) { @@ -1316,70 +1369,70 @@ public class YearlySalaryRepository : RepositoryBase, IYearl PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) { - var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays); + } else { - var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && - x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); - //پایان دوره - PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); - List nullDateList = new List(); - double sumOfOldYearsPay = 0; - var oldTotaldays = 0; - for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) - { - var searchStart = ($"{startDate}").ToGeorgianDateTime(); - var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); - var foundCheckout = checkoutList.FirstOrDefault(x => - x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); - if (foundCheckout == null) - { - nullDateList.Add(new BunosesAndYearsPayStatus() - { - ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, - ContractEnd = searchEnd - }); - finalResult.NotCompleted = true; - } - else - { - double foundMonthlySalary = foundCheckout.MonthlySalary; - int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); - double foundDayliWage = foundMonthlySalary / foundTotaldays; - double foundYearsPay = ((foundDayliWage * 30) / 365) * foundTotaldays; - oldTotaldays += foundTotaldays; - sumOfOldYearsPay += foundYearsPay; - } + var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && + x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); + //پایان دوره + PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); + List nullDateList = new List(); + double sumOfOldYearsPay = 0; + var oldTotaldays = 0; + for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) + { + var searchStart = ($"{startDate}").ToGeorgianDateTime(); + var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); + var foundCheckout = checkoutList.FirstOrDefault(x => + x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); + if (foundCheckout == null) + { + nullDateList.Add(new BunosesAndYearsPayStatus() + { + ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, + ContractEnd = searchEnd + }); + finalResult.NotCompleted = true; + } + else + { + double foundMonthlySalary = foundCheckout.MonthlySalary; + int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); + double foundDayliWage = foundMonthlySalary / foundTotaldays; + double foundYearsPay = ((foundDayliWage * 30) / 365) * foundTotaldays; + oldTotaldays += foundTotaldays; + sumOfOldYearsPay += foundYearsPay; + } - } + } - var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; - double lastMonthYearsPay = ((daylyWage * 30) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotaldays); - finalResult.YearsPay = lastMonthYearsPay + sumOfOldYearsPay; - finalResult.BunosesStatusList = nullDateList; + var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; + double lastMonthYearsPay = ((daylyWage * 30) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotaldays); + finalResult.YearsPay = lastMonthYearsPay + sumOfOldYearsPay; + finalResult.BunosesStatusList = nullDateList; - } + } #endregion - //var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - //result = (daylyWage * 30) / 365 * totalDays; - } - } - - break; + //var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + //result = (daylyWage * 30) / 365 * totalDays; + } + } + + break; //از شروع بکار تا ترک کار case "OnLeftWork"://درپایان همکاری - + if (isOldContract && contractEnd < start1403) { var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } else if (isOldContract && contractEnd > start1403) { @@ -1394,17 +1447,17 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } } else if (!isOldContract) { if ((hasleft && leftWorkDate <= separationEndDate)) { - + var totalDays = (separationEndDate - startWorkDate).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } } break; @@ -1416,7 +1469,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } else if (isOldContract && contractEnd > start1403) { if ((hasleft && leftWorkDate <= separationEndDate) || separationEndDate == contractEnd) @@ -1424,21 +1477,22 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var totalDays = (separationEndDate - contractStart).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } - }else if (!isOldContract) + } + else if (!isOldContract) { if ((hasleft && leftWorkDate <= separationEndDate) || separationEndDate == contractEnd) { var totalDays = (separationEndDate - contractStart).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } } - break; + break; case "EndOfContract1402LeftWork1403": //پایان قرارداد قبل 403 پایان همکاری بعد 403 - + if (contractStart >= start1403 && contractEnd > start1403)// بعد از 1403 { if (hasleft && leftWorkDate <= separationEndDate)//اگر ترک کار کرده بود @@ -1448,22 +1502,22 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } + } } else if (contractStart < start1403 && contractEnd < start1403)// قبل از 1403 { var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; finalResult.YearsPay = (daylyWage * 30) / 365 * totalDays; finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - //if ((hasleft && leftWorkDate <= separationEndDate) || separationEndDate == contractEnd)// اگر ترک کار کرده بود یا فیش آخر قراداد بود - //{ - // var totalDays = (separationEndDate - contractStart).TotalDays + 1; - // result = (daylyWage * 30) / 365 * totalDays; - //} - } + //if ((hasleft && leftWorkDate <= separationEndDate) || separationEndDate == contractEnd)// اگر ترک کار کرده بود یا فیش آخر قراداد بود + //{ + // var totalDays = (separationEndDate - contractStart).TotalDays + 1; + // result = (daylyWage * 30) / 365 * totalDays; + //} + } break; default: - finalResult.YearsPay = 0; + finalResult.YearsPay = 0; finalResult.TotalDayCompute = 0; break; } @@ -1587,20 +1641,20 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var resCanToLeave = OnCheckoutCantoleaveList(separationStartDate, separationEndDate, workshopId, employeeId, leaveHoursesPerDay, totalChekoutDays, hoursePerDay); - //وضعیت تصفیه مزد مرخصی - result.LeaveCheckout = true; - ////مدت طلب مرخصی - result.CreditLeaves = resCanToLeave.CanToLeave; - //مزد مرخصی - result.LeavPay = resCanToLeave.CanToLeave * leavePayPerHours; - //مدت غیبت - result.AbsencePeriod = resCanToLeave.PeriodOfAbsence; - //کسری غیبت - result.AbsenceDeduction = resCanToLeave.PeriodOfAbsence * absenceDeductionPerHourses; - //میانگین ساعت کار در یک روز - result.AverageHoursPerDay = hoursePerDay; - // تعداد روزهایی که برای پرسنل مرخصی حساب شده - result.TotalDayOfLeaveCompute = $"{(separationEndDate - separationStartDate).TotalDays + 1}"; + //وضعیت تصفیه مزد مرخصی + result.LeaveCheckout = true; + ////مدت طلب مرخصی + result.CreditLeaves = resCanToLeave.CanToLeave; + //مزد مرخصی + result.LeavPay = resCanToLeave.CanToLeave * leavePayPerHours; + //مدت غیبت + result.AbsencePeriod = resCanToLeave.PeriodOfAbsence; + //کسری غیبت + result.AbsenceDeduction = resCanToLeave.PeriodOfAbsence * absenceDeductionPerHourses; + //میانگین ساعت کار در یک روز + result.AverageHoursPerDay = hoursePerDay; + // تعداد روزهایی که برای پرسنل مرخصی حساب شده + result.TotalDayOfLeaveCompute = $"{(separationEndDate - separationStartDate).TotalDays + 1}"; break; //محاسبه در پایان سال به شرطی که قرارداد منتهی به پایان سال باشد @@ -1624,55 +1678,55 @@ public class YearlySalaryRepository : RepositoryBase, IYearl result.AverageHoursPerDay = hoursePerDay; // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{resEndOfYear.CountChekoutDays}"; - - } - else if(isOldContract && contractEnd > start1403) + + } + else if (isOldContract && contractEnd > start1403) { - var startDate = startWorkDate >= start1403 ? startWorkDate: start1403; - + var startDate = startWorkDate >= start1403 ? startWorkDate : start1403; + var endOfYearRes = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate) .FirstOrDefault(x => x.ContractStart == separationStartDate); if ((hasleft && leftWorkDate <= separationEndDate) || (separationEndDate == contractEnd && checkoutMonth == "12")) { - var end = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, - hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, - separationStartDate); - - //وضعیت تصفیه مزد مرخصی - result.LeaveCheckout = true; - + var end = EndOfYearCantoleaveList(startDate, separationEndDate, workshopId, employeeId, + hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, + separationStartDate); + + //وضعیت تصفیه مزد مرخصی + result.LeaveCheckout = true; + var canTolv = endOfYearRes.CanToLeave; var absence = end.Sum(x => x.PeriodOfAbsence); - + if (canTolv >= absence) { - canTolv -= absence; - absence = 0; + canTolv -= absence; + absence = 0; } else { - absence -= canTolv; - canTolv = 0; + absence -= canTolv; + canTolv = 0; } - //مزد مرخصی - //result.LeavPay = endOfYearRes.CanToLeave * leavePayPerHours; - result.LeavPay = canTolv * leavePayPerHours; - //مدت غیبت - result.AbsencePeriod = absence; - ////مدت طلب مرخصی - result.CreditLeaves = canTolv; - //کسری غیبت - result.AbsenceDeduction = absence * absenceDeductionPerHourses; + //مزد مرخصی + //result.LeavPay = endOfYearRes.CanToLeave * leavePayPerHours; + result.LeavPay = canTolv * leavePayPerHours; + //مدت غیبت + result.AbsencePeriod = absence; + ////مدت طلب مرخصی + result.CreditLeaves = canTolv; + //کسری غیبت + result.AbsenceDeduction = absence * absenceDeductionPerHourses; //میانگین ساعت کار در یک روز result.AverageHoursPerDay = end.FirstOrDefault()!.WorkingPerDayHourses; - // تعداد روزهایی که برای پرسنل مرخصی حساب شده - result.TotalDayOfLeaveCompute = $"{endOfYearRes.CountChekoutDays}"; + // تعداد روزهایی که برای پرسنل مرخصی حساب شده + result.TotalDayOfLeaveCompute = $"{endOfYearRes.CountChekoutDays}"; - } + } else { //وضعیت تصفیه مزد مرخصی @@ -1683,15 +1737,15 @@ public class YearlySalaryRepository : RepositoryBase, IYearl result.LeavPay = 0; //مدت غیبت result.AbsencePeriod = endOfYearRes.PeriodOfAbsence; - //کسری غیبت - //result.AbsenceDeduction = endOfYearRes.PeriodOfAbsence * absenceDeductionPerHourses; - result.AbsenceDeduction = 0; - //میانگین ساعت کار در یک روز - result.AverageHoursPerDay = endOfYearRes.WorkingPerDayHourses; - // تعداد روزهایی که برای پرسنل مرخصی حساب شده - result.TotalDayOfLeaveCompute ="0"; + //کسری غیبت + //result.AbsenceDeduction = endOfYearRes.PeriodOfAbsence * absenceDeductionPerHourses; + result.AbsenceDeduction = 0; + //میانگین ساعت کار در یک روز + result.AverageHoursPerDay = endOfYearRes.WorkingPerDayHourses; + // تعداد روزهایی که برای پرسنل مرخصی حساب شده + result.TotalDayOfLeaveCompute = "0"; - } + } } else if (!isOldContract) { @@ -1731,20 +1785,20 @@ public class YearlySalaryRepository : RepositoryBase, IYearl //وضعیت تصفیه مزد مرخصی result.LeaveCheckout = true; - // تعداد روزهایی که برای پرسنل مرخصی حساب شده - result.TotalDayOfLeaveCompute = $"{endOfYearRes.CountChekoutDays}"; + // تعداد روزهایی که برای پرسنل مرخصی حساب شده + result.TotalDayOfLeaveCompute = $"{endOfYearRes.CountChekoutDays}"; - //مزد مرخصی - //result.LeavPay = endOfYearRes.CanToLeave * leavePayPerHours; + //مزد مرخصی + //result.LeavPay = endOfYearRes.CanToLeave * leavePayPerHours; - //مدت غیبت - //result.AbsencePeriod = endOfYearRes.PeriodOfAbsence; - //کسری غیبت - //result.AbsenceDeduction = endOfYearRes.PeriodOfAbsence * absenceDeductionPerHourses; - //میانگین ساعت کار در یک روز - //result.AverageHoursPerDay = endOfYearRes.WorkingPerDayHourses; + //مدت غیبت + //result.AbsencePeriod = endOfYearRes.PeriodOfAbsence; + //کسری غیبت + //result.AbsenceDeduction = endOfYearRes.PeriodOfAbsence * absenceDeductionPerHourses; + //میانگین ساعت کار در یک روز + //result.AverageHoursPerDay = endOfYearRes.WorkingPerDayHourses; - } + } else { //وضعیت تصفیه مزد مرخصی @@ -1760,12 +1814,12 @@ public class YearlySalaryRepository : RepositoryBase, IYearl //میانگین ساعت کار در یک روز result.AverageHoursPerDay = endOfYearRes.WorkingPerDayHourses; // تعداد روزهایی که برای پرسنل مرخصی حساب شده - result.TotalDayOfLeaveCompute ="0"; + result.TotalDayOfLeaveCompute = "0"; - } + } } - break; + break; case "OnLeftWork"://درپایان همکاری if (isOldContract && contractEnd < start1403) { @@ -1810,7 +1864,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl result.AverageHoursPerDay = res.WorkingPerDayHourses; // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{res.CountChekoutDays}"; - } + } else { //وضعیت تصفیه مزد مرخصی @@ -1828,12 +1882,12 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"0"; - } + } } else if (!isOldContract) { - + var res = LeftWorkCantoleaveList(startWorkDate, separationEndDate, workshopId, employeeId, hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate) .FirstOrDefault(x => x.ContractStart == separationStartDate); @@ -1856,7 +1910,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{res.CountChekoutDays}"; - } + } else { //وضعیت تصفیه مزد مرخصی @@ -1874,10 +1928,10 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"0"; - } + } } - - break; + + break; case "OnEndOfContract"://در پایان قرارداد if (isOldContract && contractEnd < start1403) { @@ -1899,8 +1953,8 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{(separationEndDate - separationEndDate).TotalDays + 1}"; - } - else if ((isOldContract && contractEnd > start1403) || (!isOldContract)) + } + else if ((isOldContract && contractEnd > start1403) || (!isOldContract)) { var resEndOfContract = LeftWorkCantoleaveList(contractStart, separationEndDate, workshopId, employeeId, hasleft, leftWorkDate, fridayStartToEnd, officialHoliday, totalHoursH, totalHorsM, separationStartDate) .FirstOrDefault(x => x.ContractStart == separationStartDate); @@ -1923,8 +1977,8 @@ public class YearlySalaryRepository : RepositoryBase, IYearl //میانگین ساعت کار در یک روز result.AverageHoursPerDay = resEndOfContract.WorkingPerDayHourses; // تعداد روزهایی که برای پرسنل مرخصی حساب شده - result.TotalDayOfLeaveCompute = $"{resEndOfContract.CountChekoutDays}"; - } + result.TotalDayOfLeaveCompute = $"{resEndOfContract.CountChekoutDays}"; + } else { //وضعیت تصفیه مزد مرخصی @@ -1942,12 +1996,12 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"0"; - } + } } } break; case "EndOfContract1402LeftWork1403": //پایان قرارداد قبل 403 پایان همکاری بعد 403 - + if (contractStart >= start1403 && contractEnd > start1403)// بعد از 1403 { //تاریخ شروع یافتن قرادادها @@ -1978,7 +2032,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{ress.CountChekoutDays}"; - } + } else { //وضعیت تصفیه مزد مرخصی @@ -1996,7 +2050,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"0"; - } + } } else if (contractEnd < start1403)// قبل از 1403 { @@ -2018,7 +2072,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // تعداد روزهایی که برای پرسنل مرخصی حساب شده result.TotalDayOfLeaveCompute = $"{totalChekoutDays}"; - } + } break; default: result = new LeaveAndAbsenceViewModel(); @@ -2175,7 +2229,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl #endregion - + var leaveList = _context.LeaveList.AsSplitQuery() .Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId) .Where(x => x.LeaveType == "استحقاقی" && x.IsAccepted) @@ -2296,7 +2350,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl } } - + #endregion @@ -2307,7 +2361,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl .Where(x => x.CanToLeave == 0 && x.ContractStart >= contract.ContarctStart).MaxBy(x => x.ContractStart); if (checkAbsenceDeduction != null) { - + var startSerach = checkAbsenceDeduction.ContractEnd.AddDays(1); leaveList = _context.LeaveList.AsSplitQuery() .Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId) @@ -2405,14 +2459,14 @@ public class YearlySalaryRepository : RepositoryBase, IYearl else { periodOfAbsence = usedLeaves - canToLeave; - + #region AbsenceItemsCompute //var consumableItems = ConsumableItems(endMonthGr); //var housingAllowance = HousingAllowance(endMonthGr); //var familyAllowance = FamilyAllowance(employeeId, endMonthGr); //var marriedAllowance = MarriedAllowance(endMonthGr, employeeId); - + //var leftworkList = _leftWorkRepository.search(new LeftWorkSearchModel(){EmployeeId = employeeId,WorkshopId = workshopId}); //if (leftworkList == null) // leftworkList = new List(); @@ -2512,7 +2566,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var contactCanToleaveList = new List(); var allContractsBetween = _context.Contracts.AsSplitQuery().Include(x => x.WorkingHoursList) .Where(x => x.WorkshopIds == workshopId && x.EmployeeId == employeeId && - x.ContractEnd >= startDate && x.ContarctStart <= endDate).OrderBy(x=>x.ContarctStart).ToList(); + x.ContractEnd >= startDate && x.ContarctStart <= endDate).OrderBy(x => x.ContarctStart).ToList(); double canToLeave = 0; int contractCounter = 0; foreach (var contract in allContractsBetween) @@ -2574,9 +2628,9 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var sdate = contract.ContarctStart.ToFarsi(); var edate = contract.ContractEnd.ToFarsi(); - // اگر فیش در قرارداد جاری حلقه بود تا تاریخ پایان فیش برو - if (separationStartDate >= contract.ContarctStart && separationStartDate < contract.ContractEnd) - edate = endDate.ToFarsi(); + // اگر فیش در قرارداد جاری حلقه بود تا تاریخ پایان فیش برو + if (separationStartDate >= contract.ContarctStart && separationStartDate < contract.ContractEnd) + edate = endDate.ToFarsi(); var syear = Convert.ToInt32(sdate.Substring(0, 4)); var smonth = Convert.ToInt32(sdate.Substring(5, 2)); var sday = Convert.ToInt32(sdate.Substring(8, 2)); @@ -2628,7 +2682,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var sumCounDays = countChekoutDays + beforeCountDays.CountChekoutDays; if (sumCounDays > 365) { - + is365 = true; countChekoutDays = sumCounDays - 365; @@ -2727,7 +2781,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var check365 = contactCanToleaveList.FirstOrDefault(x => x.ContractStart >= contract.ContarctStart && x.Is365); - + if (check365 != null) { var startAfter365 = check365.ContractEnd.AddDays(1); @@ -2831,7 +2885,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl } } } - + #endregion } @@ -2913,38 +2967,38 @@ public class YearlySalaryRepository : RepositoryBase, IYearl bool lastChekout = endMonthGr == contract.ContractEnd; bool endOfyear = lastChekout && isEndOfYear; - - #region NewcChanges - var has365B = contactCanToleaveList.Any(x => x.Is365); - creditLeaves = canToLeave; - //اگر از 365 روز تجاوز کرد و باقی مانده مرخصی بیشتر از 9 روز بود فقط 9 روز بماند - if (is365 && !has365B && creditLeaves > canToLeavAfter365 && !left && !endOfyear) - { - creditLeaves = canToLeavAfter365; + #region NewcChanges - } + var has365B = contactCanToleaveList.Any(x => x.Is365); + creditLeaves = canToLeave; + //اگر از 365 روز تجاوز کرد و باقی مانده مرخصی بیشتر از 9 روز بود فقط 9 روز بماند + if (is365 && !has365B && creditLeaves > canToLeavAfter365 && !left && !endOfyear) + { + creditLeaves = canToLeavAfter365; - if (is365 && has365B && !left && !endOfyear) - { - var last365 = contactCanToleaveList - .Where(x => x.Is365) - .MaxBy(x => x.ContractStart); - canToLeavAfter365 += last365.CanToLeave; - if (creditLeaves > canToLeavAfter365) - { - creditLeaves = canToLeavAfter365; - } + } - } + if (is365 && has365B && !left && !endOfyear) + { + var last365 = contactCanToleaveList + .Where(x => x.Is365) + .MaxBy(x => x.ContractStart); + canToLeavAfter365 += last365.CanToLeave; + if (creditLeaves > canToLeavAfter365) + { + creditLeaves = canToLeavAfter365; + } - periodOfAbsence = usedLeaves; + } - #endregion + periodOfAbsence = usedLeaves; - contactCanToleaveList.Add(new ContractsCanToLeave() + #endregion + + contactCanToleaveList.Add(new ContractsCanToLeave() { ContractCounter = contractCounter, WorkingPerDayHourses = workingHoursePerDay, @@ -2966,7 +3020,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl return contactCanToleaveList; } - + public ContractsCanToLeave OnCheckoutCantoleaveList(DateTime startDate, DateTime endDate, long workshopId, long employeeId, double leaveHoursesPerDay, double totalChekoutDays, double hoursePerDay) @@ -3039,13 +3093,13 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var result = new ContractsCanToLeave() { - + CanToLeave = creditLeaves, PeriodOfAbsence = periodOfAbsence, - + }; return result; - + } public async Task HolidayGregorian(DateTime gregorianDate) @@ -3107,7 +3161,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl bool hasleft, DateTime startWorkDate, DateTime contractStart, DateTime contractEnd, long workshopId, long employeeId, bool isOldContract) { - BunosesAndYearsPayStatus finalResult = new BunosesAndYearsPayStatus(); + BunosesAndYearsPayStatus finalResult = new BunosesAndYearsPayStatus(); double result = 0; // ماه فیش آخر var checkoutMonth = startDateFa.Substring(5, 2); @@ -3120,95 +3174,95 @@ public class YearlySalaryRepository : RepositoryBase, IYearl finalResult.Bunoses = ((daylyWage * 60) / 365) * totalCheckoutDays; finalResult.TotalDayCompute = Convert.ToInt32(totalCheckoutDays); - break; + break; case "OnEndOfYear"://درپایان سال - + if (isOldContract && contractEnd < start1403) { var totaltDays = (separationEndDate - separationStartDate).TotalDays + 1; finalResult.Bunoses = ((daylyWage * 60) / 365) * totaltDays; finalResult.TotalDayCompute = Convert.ToInt32(totaltDays); - } + } else if (isOldContract && contractEnd > start1403) { - - if ((hasleft && leftWorkDate <= separationEndDate) || checkoutMonth == "12") + + if ((hasleft && leftWorkDate <= separationEndDate) || checkoutMonth == "12") { //بدست آوردن اولین روز سال string startDayOfYear = $"{startDateFa.Substring(0, 4)}/01/01"; DateTime startDayOfYearGr = startDayOfYear.ToGeorgianDateTime(); - // اگر تاریخ شروع بکار بزرگتر مساوی روز اول همین سال بود از تازیخ شوع بکار استفاده میشود در غیر اینصورت از روز اول سال استفاده میشود - DateTime startComputeDay = startWorkDate >= startDayOfYearGr ? startWorkDate : startDayOfYearGr; + // اگر تاریخ شروع بکار بزرگتر مساوی روز اول همین سال بود از تازیخ شوع بکار استفاده میشود در غیر اینصورت از روز اول سال استفاده میشود + DateTime startComputeDay = startWorkDate >= startDayOfYearGr ? startWorkDate : startDayOfYearGr; - #region NewCompute + #region NewCompute - //شروع دوره - string st = startComputeDay.ToFarsi(); - int syear = Convert.ToInt32(st.Substring(0, 4)); - int smonth = Convert.ToInt32(st.Substring(5, 2)); - PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); - PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); - //پایان فیش حقوقی آخر - PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); - if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) - { - var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } - else - { - var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && - x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); - //پایان دوره - PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); - List nullDateList = new List(); - double sumOfOldBonuses = 0; - var oldTotalDays = 0; - for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) - { - var searchStart = ($"{startDate}").ToGeorgianDateTime(); - var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); - var foundCheckout = checkoutList.FirstOrDefault(x => - x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); - if (foundCheckout == null) - { - nullDateList.Add(new BunosesAndYearsPayStatus() - { - ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, - ContractEnd = searchEnd - }); - finalResult.NotCompleted = true; - } - else - { - double foundMonthlySalary = foundCheckout.MonthlySalary; - int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); - double foundDayliWage = foundMonthlySalary / foundTotaldays; - double foundYearsPay = ((foundDayliWage * 60) / 365) * foundTotaldays; - oldTotalDays += foundTotaldays; - sumOfOldBonuses += foundYearsPay; - } + //شروع دوره + string st = startComputeDay.ToFarsi(); + int syear = Convert.ToInt32(st.Substring(0, 4)); + int smonth = Convert.ToInt32(st.Substring(5, 2)); + PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); + PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); + //پایان فیش حقوقی آخر + PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); + if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) + { + var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays); + } + else + { + var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && + x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); + //پایان دوره + PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); + List nullDateList = new List(); + double sumOfOldBonuses = 0; + var oldTotalDays = 0; + for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) + { + var searchStart = ($"{startDate}").ToGeorgianDateTime(); + var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); + var foundCheckout = checkoutList.FirstOrDefault(x => + x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); + if (foundCheckout == null) + { + nullDateList.Add(new BunosesAndYearsPayStatus() + { + ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, + ContractEnd = searchEnd + }); + finalResult.NotCompleted = true; + } + else + { + double foundMonthlySalary = foundCheckout.MonthlySalary; + int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); + double foundDayliWage = foundMonthlySalary / foundTotaldays; + double foundYearsPay = ((foundDayliWage * 60) / 365) * foundTotaldays; + oldTotalDays += foundTotaldays; + sumOfOldBonuses += foundYearsPay; + } - } + } - var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; - double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); - finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; - finalResult.BunosesStatusList = nullDateList; - } + var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; + double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); + finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; + finalResult.BunosesStatusList = nullDateList; + } - #endregion + #endregion - } + } } - else if(!isOldContract) + else if (!isOldContract) { if ((hasleft && leftWorkDate <= separationEndDate) || checkoutMonth == "12") { @@ -3216,72 +3270,72 @@ public class YearlySalaryRepository : RepositoryBase, IYearl var startDayOfYear = $"{startDateFa.Substring(0, 4)}/01/01"; var startDayOfYearGr = startDayOfYear.ToGeorgianDateTime(); var startComputeDay = startWorkDate >= startDayOfYearGr ? startWorkDate : startDayOfYearGr; - #region NewCompute + #region NewCompute - //شروع دوره - string st = startComputeDay.ToFarsi(); - int syear = Convert.ToInt32(st.Substring(0, 4)); - int smonth = Convert.ToInt32(st.Substring(5, 2)); - PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); - PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); - //پایان فیش حقوقی آخر - PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); - if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) - { - var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; - } - else - { - var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && - x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); - //پایان دوره - PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); - List nullDateList = new List(); - double sumOfOldBonuses = 0; - var oldTotalDays = 0; - for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) - { - var searchStart = ($"{startDate}").ToGeorgianDateTime(); - var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); - var foundCheckout = checkoutList.FirstOrDefault(x => - x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); - if (foundCheckout == null) - { - nullDateList.Add(new BunosesAndYearsPayStatus() - { - ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, - ContractEnd = searchEnd - }); - finalResult.NotCompleted = true; - } - else - { - double foundMonthlySalary = foundCheckout.MonthlySalary; - int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); - double foundDayliWage = foundMonthlySalary / foundTotaldays; - double foundYearsPay = ((foundDayliWage * 60) / 365) * foundTotaldays; - oldTotalDays += foundTotaldays; - sumOfOldBonuses += foundYearsPay; - } + //شروع دوره + string st = startComputeDay.ToFarsi(); + int syear = Convert.ToInt32(st.Substring(0, 4)); + int smonth = Convert.ToInt32(st.Substring(5, 2)); + PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); + PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); + //پایان فیش حقوقی آخر + PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); + if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) + { + var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; + } + else + { + var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && + x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); + //پایان دوره + PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); + List nullDateList = new List(); + double sumOfOldBonuses = 0; + var oldTotalDays = 0; + for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) + { + var searchStart = ($"{startDate}").ToGeorgianDateTime(); + var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); + var foundCheckout = checkoutList.FirstOrDefault(x => + x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); + if (foundCheckout == null) + { + nullDateList.Add(new BunosesAndYearsPayStatus() + { + ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, + ContractEnd = searchEnd + }); + finalResult.NotCompleted = true; + } + else + { + double foundMonthlySalary = foundCheckout.MonthlySalary; + int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); + double foundDayliWage = foundMonthlySalary / foundTotaldays; + double foundYearsPay = ((foundDayliWage * 60) / 365) * foundTotaldays; + oldTotalDays += foundTotaldays; + sumOfOldBonuses += foundYearsPay; + } - } + } - var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; - double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); - finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; - finalResult.BunosesStatusList = nullDateList; - } + var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; + double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); + finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; + finalResult.BunosesStatusList = nullDateList; + } + + #endregion + } + } - #endregion - } - } - break; case "OnEndOfContract"://در پایان قرارداد - + if (isOldContract && contractEnd < start1403) { var totaltDays = (separationEndDate - separationStartDate).TotalDays + 1; @@ -3300,141 +3354,141 @@ public class YearlySalaryRepository : RepositoryBase, IYearl //var totalDays = (separationEndDate - contractStart).TotalDays + 1; //result = (daylyWage * 60) / 365 * totalDays; - #region NewCompute + #region NewCompute - //شروع دوره - string st = startComputeDay.ToFarsi(); - int syear = Convert.ToInt32(st.Substring(0, 4)); - int smonth = Convert.ToInt32(st.Substring(5, 2)); - PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); - PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); - //پایان فیش حقوقی آخر - PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); - if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) - { - var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays); - } - else - { - var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && - x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); - //پایان دوره - PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); - List nullDateList = new List(); - double sumOfOldBonuses = 0; - var oldTotalDays = 0; - for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) - { - var searchStart = ($"{startDate}").ToGeorgianDateTime(); - var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); - var foundCheckout = checkoutList.FirstOrDefault(x => - x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); - if (foundCheckout == null) - { - nullDateList.Add(new BunosesAndYearsPayStatus() - { - ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, - ContractEnd = searchEnd - }); - finalResult.NotCompleted = true; - } - else - { - double foundMonthlySalary = foundCheckout.MonthlySalary; - int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); - double foundDayliWage = foundMonthlySalary / foundTotaldays; - double foundBonuses = ((foundDayliWage * 60) / 365) * foundTotaldays; - oldTotalDays += foundTotaldays; - sumOfOldBonuses += foundBonuses; - } + //شروع دوره + string st = startComputeDay.ToFarsi(); + int syear = Convert.ToInt32(st.Substring(0, 4)); + int smonth = Convert.ToInt32(st.Substring(5, 2)); + PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); + PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); + //پایان فیش حقوقی آخر + PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); + if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) + { + var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays); + } + else + { + var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && + x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); + //پایان دوره + PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); + List nullDateList = new List(); + double sumOfOldBonuses = 0; + var oldTotalDays = 0; + for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) + { + var searchStart = ($"{startDate}").ToGeorgianDateTime(); + var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); + var foundCheckout = checkoutList.FirstOrDefault(x => + x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); + if (foundCheckout == null) + { + nullDateList.Add(new BunosesAndYearsPayStatus() + { + ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, + ContractEnd = searchEnd + }); + finalResult.NotCompleted = true; + } + else + { + double foundMonthlySalary = foundCheckout.MonthlySalary; + int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); + double foundDayliWage = foundMonthlySalary / foundTotaldays; + double foundBonuses = ((foundDayliWage * 60) / 365) * foundTotaldays; + oldTotalDays += foundTotaldays; + sumOfOldBonuses += foundBonuses; + } - } + } - var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; - double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); - finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; - finalResult.BunosesStatusList = nullDateList; - } + var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; + double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); + finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; + finalResult.BunosesStatusList = nullDateList; + } - #endregion - } - } - else if(!isOldContract) + #endregion + } + } + else if (!isOldContract) { if ((hasleft && leftWorkDate <= separationEndDate) || separationEndDate == contractEnd) { - var startComputeDay = contractStart; - //var totalDays = (separationEndDate - contractStart).TotalDays + 1; + var startComputeDay = contractStart; + //var totalDays = (separationEndDate - contractStart).TotalDays + 1; // finalResult.Bunoses = (daylyWage * 60) / 365 * totalDays; - #region NewCompute + #region NewCompute - //شروع دوره - string st = startComputeDay.ToFarsi(); - int syear = Convert.ToInt32(st.Substring(0, 4)); - int smonth = Convert.ToInt32(st.Substring(5, 2)); - PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); - PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); - //پایان فیش حقوقی آخر - PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); - if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) - { - var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; - finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; - } - else - { - var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && - x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); - //پایان دوره - PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); - List nullDateList = new List(); - double sumOfOldBonuses = 0; - var oldTotalDays = 0; - for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) - { - var searchStart = ($"{startDate}").ToGeorgianDateTime(); - var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); - var foundCheckout = checkoutList.FirstOrDefault(x => - x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); - if (foundCheckout == null) - { - nullDateList.Add(new BunosesAndYearsPayStatus() - { - ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, - ContractEnd = searchEnd - }); - finalResult.NotCompleted = true; - } - else - { - double foundMonthlySalary = foundCheckout.MonthlySalary; - int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); - double foundDayliWage = foundMonthlySalary / foundTotaldays; - double foundBonuses = ((foundDayliWage * 60) / 365) * foundTotaldays; - oldTotalDays += foundTotaldays; - sumOfOldBonuses += foundBonuses; - } + //شروع دوره + string st = startComputeDay.ToFarsi(); + int syear = Convert.ToInt32(st.Substring(0, 4)); + int smonth = Convert.ToInt32(st.Substring(5, 2)); + PersianDateTime startPeriod = new PersianDateTime(syear, smonth, 1); + PersianDateTime startPeriodGr = new PersianDateTime(syear, smonth, 1); + //پایان فیش حقوقی آخر + PersianDateTime endCheckout = separationEndDate.ToPersianDateTime(); + if (startPeriod.Year == endCheckout.Year && startPeriod.Month == endCheckout.Month) + { + var totalDays = (separationEndDate - startComputeDay).TotalDays + 1; + finalResult.Bunoses = ((daylyWage * 60) / 365) * totalDays; + } + else + { + var checkoutList = _context.CheckoutSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && + x.ContractStart >= startComputeDay && x.ContractEnd < separationStartDate).AsEnumerable(); + //پایان دوره + PersianDateTime endPeriod = (separationStartDate.AddDays(-1)).ToPersianDateTime(); + List nullDateList = new List(); + double sumOfOldBonuses = 0; + var oldTotalDays = 0; + for (var startDate = startPeriod; startDate <= endPeriod; startDate = startDate.AddMonths(1)) + { + var searchStart = ($"{startDate}").ToGeorgianDateTime(); + var searchEnd = (($"{startDate}").FindeEndOfMonth()).ToGeorgianDateTime(); + var foundCheckout = checkoutList.FirstOrDefault(x => + x.ContractStart >= searchStart && x.ContractEnd <= searchEnd); + if (foundCheckout == null) + { + nullDateList.Add(new BunosesAndYearsPayStatus() + { + ContractStart = startDate == startPeriodGr ? startComputeDay : searchStart, + ContractEnd = searchEnd + }); + finalResult.NotCompleted = true; + } + else + { + double foundMonthlySalary = foundCheckout.MonthlySalary; + int foundTotaldays = Convert.ToInt32(foundCheckout.SumOfWorkingDays); + double foundDayliWage = foundMonthlySalary / foundTotaldays; + double foundBonuses = ((foundDayliWage * 60) / 365) * foundTotaldays; + oldTotalDays += foundTotaldays; + sumOfOldBonuses += foundBonuses; + } - } + } - var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; - double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; - finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); - finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; - finalResult.BunosesStatusList = nullDateList; - } + var totalDays = (separationEndDate - separationStartDate).TotalDays + 1; + double lastMonthBonuses = ((daylyWage * 60) / 365) * totalDays; + finalResult.TotalDayCompute = Convert.ToInt32(totalDays + oldTotalDays); + finalResult.Bunoses = lastMonthBonuses + sumOfOldBonuses; + finalResult.BunosesStatusList = nullDateList; + } + + #endregion + } + } - #endregion - } - } - break; //case "EndOfContract1402LeftWork1403": //پایان قرارداد قبل 403 پایان همکاری بعد 403 - + // if (contractStart >= start1403 && contractEnd > start1403)// بعد از 1403 // { // if (hasleft && leftWorkDate <= separationEndDate) @@ -3465,10 +3519,10 @@ public class YearlySalaryRepository : RepositoryBase, IYearl // //} // } // break; - + default: - finalResult.Bunoses = 0; - finalResult.TotalDayCompute = 0; + finalResult.Bunoses = 0; + finalResult.TotalDayCompute = 0; break; } @@ -3484,21 +3538,43 @@ public class YearlySalaryRepository : RepositoryBase, IYearl public InsuranceYearlySalaryModel GetInsuranceItems(DateTime startDate, DateTime endDate, string year) { - var query = _context.YearlySalaries - .Where(x => x.StartDate <= startDate && x.EndDate >= endDate && x.Year == year) - .Include(x => x.YearlySalaryItemsList) - .Select(x=> new InsuranceYearlySalaryModel - { - DayliWage = x.YearlySalaryItemsList.FirstOrDefault(item=>item.ItemName == "مزد روزانه").ItemValue, + var query = _context.YearlySalaries + .Where(x => x.StartDate <= startDate && x.EndDate >= endDate && x.Year == year) + .Include(x => x.YearlySalaryItemsList) + .Select(x => new InsuranceYearlySalaryModel + { + DayliWage = x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "مزد روزانه").ItemValue, ConsumableItems = x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "کمک هزینه اقلام").ItemValue, HousingAllowance = x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "کمک هزینه مسکن").ItemValue, - MarriedAllowance = x.YearlySalaryItemsList.Any(item => item.ItemName == "حق تاهل")? x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "حق تاهل").ItemValue : 0, + MarriedAllowance = x.YearlySalaryItemsList.Any(item => item.ItemName == "حق تاهل") ? x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "حق تاهل").ItemValue : 0, - }).FirstOrDefault(); + }).FirstOrDefault(); - return query; + return query; } - #endregion + #endregion + + + private double GetRoundValue(double value) + { + string strValue = value.ToString(); + if (strValue.IndexOf('.') > -1) + { + + + string a = strValue.Substring(strValue.IndexOf('.') + 1, 1); + if (int.Parse(a) > 3) + { + return (Math.Round(value, MidpointRounding.ToPositiveInfinity)); + } + else + { + return (Math.Round(value, MidpointRounding.ToNegativeInfinity)); + } + } + + return value; + } } diff --git a/PersonalContractingParty.Config/PersonalBootstrapper.cs b/PersonalContractingParty.Config/PersonalBootstrapper.cs index c103d89e..6102bfd9 100644 --- a/PersonalContractingParty.Config/PersonalBootstrapper.cs +++ b/PersonalContractingParty.Config/PersonalBootstrapper.cs @@ -452,6 +452,9 @@ public class PersonalBootstrapper services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + #endregion services.AddTransient(); diff --git a/ServiceHost/Pages/Index.cshtml.cs b/ServiceHost/Pages/Index.cshtml.cs index 7f3a2972..e59ead35 100644 --- a/ServiceHost/Pages/Index.cshtml.cs +++ b/ServiceHost/Pages/Index.cshtml.cs @@ -14,6 +14,7 @@ using Company.Domain.EmployeeAgg; using Company.Domain.ReportAgg; using Company.Domain.RollCallAgg; using Company.Domain.RollCallAgg.DomainService; +using Company.Domain.YearlySalaryAgg; using CompanyManagment.App.Contracts.AndroidApkVersion; using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.TemporaryClientRegistration; @@ -49,14 +50,14 @@ namespace ServiceHost.Pages private readonly IWebHostEnvironment _webHostEnvironment; private readonly IAndroidApkVersionApplication _androidApkVersionApplication; private readonly ITemporaryClientRegistrationApplication _clientRegistrationApplication; - + private readonly IYearlySalaryRepository _yearlySalaryRepository; public IndexModel(ILogger logger, IAccountApplication accountApplication, IGoogleRecaptcha googleRecaptcha, ISmsService smsService, IWorker worker, IAuthHelper authHelper, ICameraAccountApplication cameraAccountApplication, IWebHostEnvironment webHostEnvironment, - IAndroidApkVersionApplication androidApkVersionApplication, ITemporaryClientRegistrationApplication clientRegistrationApplication) + IAndroidApkVersionApplication androidApkVersionApplication, ITemporaryClientRegistrationApplication clientRegistrationApplication, IYearlySalaryRepository yearlySalaryRepository) { _logger = logger; _accountApplication = accountApplication; @@ -68,10 +69,12 @@ namespace ServiceHost.Pages _webHostEnvironment = webHostEnvironment; _androidApkVersionApplication = androidApkVersionApplication; _clientRegistrationApplication = clientRegistrationApplication; + _yearlySalaryRepository = yearlySalaryRepository; } public IActionResult OnGet() { + //_yearlySalaryRepository.TestDayliFeeCompute(); bool ex = false; //while (!ex) //{