diff --git a/CompanyManagment.Application/CustomizeCheckoutApplication.cs b/CompanyManagment.Application/CustomizeCheckoutApplication.cs index 7e325e2c..b82e3be1 100644 --- a/CompanyManagment.Application/CustomizeCheckoutApplication.cs +++ b/CompanyManagment.Application/CustomizeCheckoutApplication.cs @@ -319,7 +319,10 @@ namespace CompanyManagment.Application if (workshopId == 170) { - var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(117).Select(x => x.EmployeeId).ToList(); + var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository + .GetEmployeeSettingsByGroupSettingsId(117) + .Select(x => x.EmployeeId) + .Where(x=> workshopLeftWorksInMonth.Select(l=>l.EmployeeId).Contains(x)).ToList(); foreach (var employeesId in exceptionEmployeeIds) { diff --git a/CompanyManagment.Application/CustomizeCheckoutTempApplication.cs b/CompanyManagment.Application/CustomizeCheckoutTempApplication.cs index a6fb6511..750e9a96 100644 --- a/CompanyManagment.Application/CustomizeCheckoutTempApplication.cs +++ b/CompanyManagment.Application/CustomizeCheckoutTempApplication.cs @@ -249,7 +249,10 @@ namespace CompanyManagment.Application if (workshopId == 170) { - var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(117).Select(x => x.EmployeeId).ToList(); + var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository + .GetEmployeeSettingsByGroupSettingsId(117) + .Select(x => x.EmployeeId) + .Where(x=> workshopLeftWorksInMonth.Select(l=>l.EmployeeId).Contains(x)).ToList(); foreach (var employeesId in exceptionEmployeeIds) { diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index 0ecbe40a..1419fd36 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1345,8 +1345,12 @@ public class InsuranceListRepository : RepositoryBase, IIns public List GetEmployeeInsuranceDataForEdit(long insuranceListId, DateTime startDate, DateTime endDate) { - var res = _context.EmployeeInsurancListDataSet + var employeeDataQuery = _context.EmployeeInsurancListDataSet .Where(x => x.InsuranceListId == insuranceListId) + .Join(_context.InsuranceListSet, + employeeInsurancListData => employeeInsurancListData.InsuranceListId, + insuranceList => insuranceList.id, + (employeeInsurancListData, insuranceList) => new{employeeInsurancListData,insuranceList}) .Join(_context.LeftWorkInsuranceList .Where(x => ((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) && @@ -1357,14 +1361,18 @@ public class InsuranceListRepository : RepositoryBase, IIns (x.LeftWorkDate == null || x.LeftWorkDate == DateTime.MinValue)) .Where(x => x.StartWorkDate <= endDate) .Include(x => x.Employee), - employeeData => employeeData.EmployeeId, - leftwork => leftwork.EmployeeId, - (employeeData, leftwork) => new { employeeData, leftwork }) - .Join(_context.Jobs, + employeeData =>new { employeeData.employeeInsurancListData.EmployeeId,employeeData.insuranceList.WorkshopId}, + leftwork => new {leftwork.EmployeeId,leftwork.WorkshopId}, + (employeeData, leftwork) + => new { employeeData = employeeData.employeeInsurancListData, leftwork }); + + var employeeJobs =employeeDataQuery.Join(_context.Jobs, result => result.leftwork.JobId, job => job.id, - (result, job) => new { result, job }) - .GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(), + (result, job) => new { result, job }); + + + var res =employeeJobs.GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(), allResult => allResult.result.employeeData.EmployeeId, employeeInfo => employeeInfo.EmployeeId, (allResult, employeeInfo) => new diff --git a/CompanyManagment.EFCore/Repository/LoanRepository.cs b/CompanyManagment.EFCore/Repository/LoanRepository.cs index 6f23763e..92efc586 100644 --- a/CompanyManagment.EFCore/Repository/LoanRepository.cs +++ b/CompanyManagment.EFCore/Repository/LoanRepository.cs @@ -35,9 +35,18 @@ public class LoanRepository : RepositoryBase, ILoanRepository var startDate = loan.LoanInstallments.MinBy(x => x.InstallmentDate).InstallmentDate; var endDate = loan.LoanInstallments.MaxBy(x => x.InstallmentDate).InstallmentDate; - - var customizeCheckouts =await _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId == loan.WorkshopId && x.EmployeeId == loan.EmployeeId && - x.ContractStart <= endDate && x.ContractEnd >= startDate).Select(x=> new {x.MonthInt, x.YearInt}).ToListAsync(); + var pc = new PersianCalendar(); + var customizeCheckouts = (await _companyContext.CheckoutSet + .Where(x => x.WorkshopId == loan.WorkshopId && x.EmployeeId == loan.EmployeeId && + startDate<=x.ContractEnd && endDate>=x.ContractEnd) + .Select(x => x.ContractStart).ToListAsync()) + .Select(x => + { + + var year = pc.GetYear(x); + var month = pc.GetMonth(x); + return new { Month = month, Year = year }; + }); var result = new LoanDetailsViewModel() { @@ -51,7 +60,7 @@ public class LoanRepository : RepositoryBase, ILoanRepository Id = x.Id, InstallmentAmount = x.AmountForMonth.ToMoney(), InstallmentDate = x.InstallmentDate.ToFarsi(), - IsPaid = customizeCheckouts.Any(c => c.MonthInt.ToString() == x.Month && c.YearInt.ToString() == x.Year) + IsPaid = customizeCheckouts.Any(c => c.Month.ToString("00") == x.Month && c.Year.ToString() == x.Year), }).ToList() }; diff --git a/ServiceHost/Areas/Client/Controllers/FinancialController.cs b/ServiceHost/Areas/Client/Controllers/FinancialController.cs index d45266f8..cdae7c2d 100644 --- a/ServiceHost/Areas/Client/Controllers/FinancialController.cs +++ b/ServiceHost/Areas/Client/Controllers/FinancialController.cs @@ -52,6 +52,7 @@ public class FinancialController : ClientBaseController /// /// [HttpPost("CreatePay")] + [AllowAnonymous] public async Task>> CreatePay([FromForm] CreateFinancialPayRequest request, CancellationToken cancellationToken) { var op = new OperationResult();