diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 0fffff4f..3290fed4 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -3929,8 +3929,18 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos foreach (var contract in seprationData) { + var leftWork = leftWorks.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId && contract.ContarctStart <= x.LeftWorkDate && contract.ContractEnd >= x.StartWorkDate); var start = new DateTime(); var end = new DateTime(); + if (leftWork == null) + { + separation.Add(new ContractSeparationViewModel() + { + checker = false, + EmployeeId = contract.EmployeeId + }); + continue; + } for (var current = contract.ContarctStart; current <= contract.ContractEnd; current=current.AddDays(1)) { if (start == new DateTime() && current >= checkoutSelectedStart && current <= checkoutSelectedEnd) @@ -3942,6 +3952,27 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { end = current; } + + + } + + var leftFirstDayOfNextMonth = end.AddDays(1); + if (leftWork.HasLeft && (leftWork.LeftWorkDate <= == leftFirstDayOfNextMonth) && + leftWork.LeftWorkDate > start) + { + var ContractEnd = leftWork.LeftWorkDate.AddDays(-1); + separation.Add(new ContractSeparationViewModel() + { + StartWorkDate = leftWork.StartWorkDate, + LeftWorkDate = leftWork.LeftWorkDate, + HasLeft = true, + ContarctStart = start.ToFarsi(), + ContractEnd = ContractEnd.ToFarsi(), + ContractStartGr = start, + ContractEndGr = ContractEnd, + checker = true, + EmployeeId = contract.EmployeeId + }); } }