diff --git a/Company.Domain/CheckoutAgg/ICheckoutRepository.cs b/Company.Domain/CheckoutAgg/ICheckoutRepository.cs index 48293370..1d67c406 100644 --- a/Company.Domain/CheckoutAgg/ICheckoutRepository.cs +++ b/Company.Domain/CheckoutAgg/ICheckoutRepository.cs @@ -18,7 +18,8 @@ public interface ICheckoutRepository : IRepository /// /// /// - bool HasCheckout(long workshopId, long employeId, string year, string month); + (bool hasChekout, double FamilyAlloance, double OverTimePay) HasCheckout(long workshopId, long employeId, + string year, string month); EditCheckout GetDetails(long id); void CreateCkeckout(Checkout command); diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index 8b15afb3..510a5bdf 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -425,10 +425,23 @@ public class InsuranceListApplication: IInsuranceListApplication //این مورد زمانی چک می شود که تیک محاسبه در کارگاه زده شده باشد // در غیر اینصورت بصورت پیشفرض دارای فیش حقوق در نظر گرفته می شود bool employeeHasCheckout = true; + double familyAllowance = 0; + double overTimePay = 0; if (hasWorkshopOverTimeOrFamilyAllowance && (leftDate >= startDateGr || employee.LeftWorkDateGr == null)) { - employeeHasCheckout = _checkoutRepository.HasCheckout(workshopId, employee.EmployeeId, + var checkout = _checkoutRepository.HasCheckout(workshopId, employee.EmployeeId, searchModel.Year, searchModel.Month); + if (checkout.hasChekout) + { + + familyAllowance = checkout.FamilyAlloance; + overTimePay = checkout.OverTimePay; + + } + else + { + employeeHasCheckout = false; + } } @@ -487,6 +500,17 @@ public class InsuranceListApplication: IInsuranceListApplication //مزیای عیر مشمول لیست قبل var benefitsIncludedNonContinuous = employeeListData != null ? employeeListData.BenefitsIncludedNonContinuous : 0; + if (workshop.InsuranceCheckoutFamilyAllowance && employeeHasCheckout) + { + + benefitsIncludedNonContinuous = benefitsIncludedNonContinuous + familyAllowance; + } + + if (workshop.InsuranceCheckoutOvertime && employeeHasCheckout) + { + + benefitsIncludedContinuous = benefitsIncludedContinuous + overTimePay; + } var includedAndNotIncluded = benefitsIncludedContinuous + benefitsIncludedNonContinuous; return new EmployeeDetailsForInsuranceListViewModel @@ -1462,8 +1486,16 @@ public class InsuranceListApplication: IInsuranceListApplication bool employeeHasCheckout = true; if (hasWorkshopOverTimeOrFamilyAllowance && (leftDate >= startDateGr || employeeData.LeftWorkDateGr == null)) { - employeeHasCheckout = _checkoutRepository.HasCheckout(workshopId, employeeData.EmployeeId, + var checkout = _checkoutRepository.HasCheckout(workshopId, employeeData.EmployeeId, searchModel.Year, searchModel.Month); + if (checkout.hasChekout) + { + + } + else + { + employeeHasCheckout = false; + } } return new EmployeeDetailsForInsuranceListViewModel { diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 64d57f17..7c43f3a9 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -55,13 +55,17 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos /// /// /// - public bool HasCheckout(long workshopId, long employeId, string year, string month) + public (bool hasChekout, double FamilyAlloance, double OverTimePay) HasCheckout(long workshopId, long employeId, string year, string month) { var farisMonthName = Tools.ToFarsiMonthByNumber(month); - return _context.CheckoutSet.Any(x => + var res = _context.CheckoutSet.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeId && x.Year == year && x.Month == farisMonthName && x.IsActiveString == "true"); + if (res == null) + return (false, 0, 0); + + return (true, res.FamilyAllowance, res.OvertimePay); } public EditCheckout GetDetails(long id)