From a4aff718dc576f3a0500bfc85cbb02a99d246f2f Mon Sep 17 00:00:00 2001 From: Mahan Ch Date: Mon, 24 Mar 2025 18:59:30 +0330 Subject: [PATCH 1/3] fix bug --- .../Repository/CustomizeCheckoutRepository.cs | 4 +- .../Repository/RollCallRepository.cs | 87 +++++++++++-------- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs index c98c56a3..ad25bc24 100644 --- a/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs @@ -168,9 +168,9 @@ namespace CompanyManagment.EFCore.Repository SalaryAidDateTimeGe = s.SalaryAidDateTime }).ToList(), - LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{x.LateToWorkValue.Minutes:D2}" + LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{Convert.ToInt32(x.LateToWorkValue.TotalHours)}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}" - }).ToList(); + }).ToList(); List workshopsList = workshopsQuery.Select(x => new WorkshopViewModel { WorkshopFullName = x.WorkshopFullName, diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 1f59e614..b3a8ecef 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -1791,43 +1791,62 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos IsBirthDay = isBirthday }; }); - var presentDays = rollCalls.Where(x => x.EmployeeId == employeeId).GroupBy(x => x.ShiftDate.Date).Select(x => - { - var orderedRollcalls = x.OrderBy(y => y.StartDate!.Value).ToList(); - return new CheckoutDailyRollCallViewModel() - { - StartDate1 = orderedRollcalls.FirstOrDefault()?.StartDate?.ToString("HH:mm"), - EndDate1 = orderedRollcalls.FirstOrDefault()?.EndDate?.ToString("HH:mm"), + var presentDays = rollCalls.Where(x => x.EmployeeId == employeeId).GroupBy(x => x.ShiftDate.Date).Select(x => + { + var orderedRollcalls = x.OrderBy(y => y.StartDate!.Value).ToList(); + var firstRollCall = orderedRollcalls.FirstOrDefault(); + var secondRollCall = orderedRollcalls.Skip(1).FirstOrDefault(); + return new CheckoutDailyRollCallViewModel() + { + StartDate1 = orderedRollcalls.FirstOrDefault()?.StartDate?.ToString("HH:mm"), + EndDate1 = orderedRollcalls.FirstOrDefault()?.EndDate?.ToString("HH:mm"), - StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "", - EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "", + StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "", + EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "", - TotalhourseSpan = - new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks)), - DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(), - RollCallDateFa = x.Key.Date.ToFarsi(), - DateTimeGr = x.Key.Date, - IsSliced = x.Count() > 2, - IsAbsent = false, - IsBirthDay = pc.GetMonth(x.Key) == pc.GetMonth(birthDay) && pc.GetDayOfMonth(x.Key) == pc.GetDayOfMonth(birthDay) - }; - }); - presentDays = presentDays.Select(x => new CheckoutDailyRollCallViewModel - { - StartDate1 = x.StartDate1, - EndDate1 = x.EndDate1, - EndDate2 = x.EndDate2, - StartDate2 = x.StartDate2, - TotalWorkingHours = $"{(int)(x.TotalhourseSpan.TotalHours)}:{x.TotalhourseSpan.Minutes.ToString("00")}", - DayOfWeek = x.DayOfWeek, - RollCallDateFa = x.RollCallDateFa, - DateTimeGr = x.DateTimeGr, - IsSliced = x.IsSliced, - IsAbsent = false, - IsBirthDay = x.IsBirthDay - }); + TotalhourseSpan = + new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks)), + DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(), + RollCallDateFa = x.Key.Date.ToFarsi(), + DateTimeGr = x.Key.Date, + IsSliced = x.Count() > 2, + IsAbsent = false, + IsBirthDay = pc.GetMonth(x.Key) == pc.GetMonth(birthDay) && pc.GetDayOfMonth(x.Key) == pc.GetDayOfMonth(birthDay), - List checkoutDailyRollCalls = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList(); + EnterDifferencesMinutes1 = firstRollCall != null && firstRollCall.LateEntryDuration > TimeSpan.Zero && workshopId == 170 + ? CalculateEntryMinuteDifference(firstRollCall.EarlyEntryDuration, + firstRollCall.LateEntryDuration) + : "", + ExitDifferencesMinutes1 = "", + + EnterDifferencesMinutes2 = secondRollCall != null && secondRollCall.LateEntryDuration > TimeSpan.Zero && workshopId == 170 + ? CalculateEntryMinuteDifference(secondRollCall.EarlyEntryDuration, + secondRollCall.LateEntryDuration) + : "", + ExitDifferencesMinutes2 = "" + }; + }); + presentDays = presentDays.Select(x => new CheckoutDailyRollCallViewModel + { + StartDate1 = x.StartDate1, + EndDate1 = x.EndDate1, + EndDate2 = x.EndDate2, + StartDate2 = x.StartDate2, + TotalWorkingHours = $"{(int)(x.TotalhourseSpan.TotalHours)}:{x.TotalhourseSpan.Minutes.ToString("00")}", + DayOfWeek = x.DayOfWeek, + RollCallDateFa = x.RollCallDateFa, + DateTimeGr = x.DateTimeGr, + IsSliced = x.IsSliced, + IsAbsent = false, + IsBirthDay = x.IsBirthDay, + EnterDifferencesMinutes1 = x.EnterDifferencesMinutes1, + ExitDifferencesMinutes1 = x.ExitDifferencesMinutes1, + EnterDifferencesMinutes2 = x.EnterDifferencesMinutes2, + ExitDifferencesMinutes2 = x.ExitDifferencesMinutes2, + }); + + + List checkoutDailyRollCalls = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList(); checkoutDailyRollCalls.ForEach(x => { From 99bfb472b086af929e301e15fa9ba209e52d905d Mon Sep 17 00:00:00 2001 From: Mahan Ch Date: Mon, 24 Mar 2025 19:11:47 +0330 Subject: [PATCH 2/3] fix search bug --- .../Repository/CustomizeCheckoutRepository.cs | 218 ++++++++--------- .../CustomizeCheckoutTempRepository.cs | 230 +++++++++--------- ServiceHost/appsettings.Development.json | 4 +- 3 files changed, 226 insertions(+), 226 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs index ad25bc24..37f15b47 100644 --- a/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CustomizeCheckoutRepository.cs @@ -256,138 +256,138 @@ namespace CompanyManagment.EFCore.Repository return _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId==workshopId && ids.Contains(x.id)).AsEnumerable(); } - #endregion + #endregion - public IEnumerable Search(SearchCustomizeCheckout searchModel) - { - OperationResult op = new(); - var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee) - .ThenInclude(x => x.PersonnelCodeList). - Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList) - .AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId); - #region parameters initialize + public IEnumerable Search(SearchCustomizeCheckout searchModel) + { + OperationResult op = new(); + var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee) + .ThenInclude(x => x.PersonnelCodeList). + Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList) + .AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId); + #region parameters initialize - ////start of search is the first day of the current month by default and end of search is today - //var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date; - //var endSearchDate = DateTime.Today; + ////start of search is the first day of the current month by default and end of search is today + //var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date; + //var endSearchDate = DateTime.Today; - var pc = new PersianCalendar(); - var currentYear = pc.GetYear(DateTime.Now); - var currentMonth = pc.GetMonth(DateTime.Now); + var pc = new PersianCalendar(); + var currentYear = pc.GetYear(DateTime.Now); + var currentMonth = pc.GetMonth(DateTime.Now); - if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) && - searchModel.Year == 0 && searchModel.Month == 0) - { - var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date; - var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date; + if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) && + searchModel.Year == 0 && searchModel.Month == 0) + { + var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date; + var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date; - //if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today) - //{ - // startSearchDate = queryStartDate; - // endSearchDate = queryEndDate; - //} - //query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate); - query = query.Where(x => x.ContractEnd.Date >= queryStartDate && x.ContractStart.Date <= queryEndDate); - } + //if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today) + //{ + // startSearchDate = queryStartDate; + // endSearchDate = queryEndDate; + //} + //query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate); + query = query.Where(x => x.ContractEnd.Date >= queryStartDate && x.ContractStart.Date <= queryEndDate); + } - if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 12) - { - var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime(); - queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate); - queryEndDate = queryEndDate.Date.AddTicks(-1); + if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13) + { + var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime(); + queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate); + queryEndDate = queryEndDate.Date.AddTicks(-1); - if (queryEndDate >= DateTime.Today) - { - queryEndDate = DateTime.Now.AddDays(-1).Date; - } + //if (queryEndDate >= DateTime.Today) + //{ + // queryEndDate = DateTime.Now.AddDays(-1).Date; + //} - else if (searchModel.Year == currentYear && searchModel.Month == currentMonth) - { - queryEndDate = DateTime.Now.AddDays(-1).Date; - } + if (searchModel.Year == currentYear && searchModel.Month == currentMonth) + { + queryEndDate = DateTime.Now.AddDays(-1).Date; + } - query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate); - } + query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate); + } - ////Month Index operations - //startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate); - //startSearchDate.FindFirstDayOfNextMonth(out endSearchDate); - //endSearchDate = endSearchDate.AddDays(-1); + ////Month Index operations + //startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate); + //startSearchDate.FindFirstDayOfNextMonth(out endSearchDate); + //endSearchDate = endSearchDate.AddDays(-1); - #endregion + #endregion - if (searchModel.EmployeeId > 0) - query = query.Where(x => x.EmployeeId == searchModel.EmployeeId); + if (searchModel.EmployeeId > 0) + query = query.Where(x => x.EmployeeId == searchModel.EmployeeId); - if (searchModel.BankId > 0) - query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId)); + if (searchModel.BankId > 0) + query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId)); - switch (searchModel.OrderBy) - { - case CustomizeCheckoutOrderByEnum.ContractStartDesc: - query = query.OrderByDescending(x => x.ContractStart.Date); - break; - case CustomizeCheckoutOrderByEnum.ContractStart: - query = query.OrderBy(x => x.ContractStart.Date); - break; - case CustomizeCheckoutOrderByEnum.ContractNoDesc: - query = query.OrderByDescending(x => x.ContractNo); - break; - case CustomizeCheckoutOrderByEnum.ContractNo: - query = query.OrderBy(x => x.ContractNo); - break; - default: - query = query.OrderByDescending(x => x.ContractStart.Date); - break; + switch (searchModel.OrderBy) + { + case CustomizeCheckoutOrderByEnum.ContractStartDesc: + query = query.OrderByDescending(x => x.ContractStart.Date); + break; + case CustomizeCheckoutOrderByEnum.ContractStart: + query = query.OrderBy(x => x.ContractStart.Date); + break; + case CustomizeCheckoutOrderByEnum.ContractNoDesc: + query = query.OrderByDescending(x => x.ContractNo); + break; + case CustomizeCheckoutOrderByEnum.ContractNo: + query = query.OrderBy(x => x.ContractNo); + break; + default: + query = query.OrderByDescending(x => x.ContractStart.Date); + break; - } - if (searchModel.Year == 0 || searchModel.Month == 0) - query = query.Skip(searchModel.PageIndex).Take(30); + } + if (searchModel.Year == 0 || searchModel.Month == 0) + query = query.Skip(searchModel.PageIndex).Take(30); - return query.Select(x => new CustomizeCheckoutViewModel() - { - Id = x.id, - ContractEndFa = x.ContractEnd.ToFarsi(), - ContractStartFa = x.ContractStart.ToFarsi(), - ContractNo = x.ContractNo, - EmployeeFName = x.Employee.FName, - EmployeeLName = x.Employee.LName, - PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode, - Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(), - Year = pc.GetYear(x.ContractStart).ToString(), - BaseYearsPay = x.BaseYearsPay.ToMoney(), - BonusesPay = x.BonusesPay.ToMoney(), - EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(), - FamilyAllowance = x.FamilyAllowance.ToMoney(), - AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(), - FineDeduction = x.FineDeduction.ToMoney(), - FridayPay = x.FridayPay.ToMoney(), - InstallmentDeduction = x.InstallmentDeduction.ToMoney(), - InsuranceDeduction = x.InsuranceDeduction.ToMoney(), - LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), - LeavePay = x.LeavePay.ToMoney(), - MarriedAllowance = x.MarriedAllowance.ToMoney(), - MonthlySalary = x.MonthlySalary.ToMoney(), - NightworkPay = x.NightWorkPay.ToMoney(), - OvertimePay = x.OverTimePay.ToMoney(), - RewardPay = x.RewardPay.ToMoney(), - SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(), - ShiftPay = x.ShiftPay.ToMoney(), - SumOfWorkingDays = x.SumOfWorkingDays.ToString(), - TaxDeducation = x.TaxDeduction.ToMoney(), - TotalPayment = x.TotalPayment.ToMoney(), - TotalPaymentD = x.TotalPayment, - TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), + return query.Select(x => new CustomizeCheckoutViewModel() + { + Id = x.id, + ContractEndFa = x.ContractEnd.ToFarsi(), + ContractStartFa = x.ContractStart.ToFarsi(), + ContractNo = x.ContractNo, + EmployeeFName = x.Employee.FName, + EmployeeLName = x.Employee.LName, + PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode, + Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(), + Year = pc.GetYear(x.ContractStart).ToString(), + BaseYearsPay = x.BaseYearsPay.ToMoney(), + BonusesPay = x.BonusesPay.ToMoney(), + EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(), + FamilyAllowance = x.FamilyAllowance.ToMoney(), + AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(), + FineDeduction = x.FineDeduction.ToMoney(), + FridayPay = x.FridayPay.ToMoney(), + InstallmentDeduction = x.InstallmentDeduction.ToMoney(), + InsuranceDeduction = x.InsuranceDeduction.ToMoney(), + LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), + LeavePay = x.LeavePay.ToMoney(), + MarriedAllowance = x.MarriedAllowance.ToMoney(), + MonthlySalary = x.MonthlySalary.ToMoney(), + NightworkPay = x.NightWorkPay.ToMoney(), + OvertimePay = x.OverTimePay.ToMoney(), + RewardPay = x.RewardPay.ToMoney(), + SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(), + ShiftPay = x.ShiftPay.ToMoney(), + SumOfWorkingDays = x.SumOfWorkingDays.ToString(), + TaxDeducation = x.TaxDeduction.ToMoney(), + TotalPayment = x.TotalPayment.ToMoney(), + TotalPaymentD = x.TotalPayment, + TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), - }).ToList(); + }).ToList(); - } - } + } + } } diff --git a/CompanyManagment.EFCore/Repository/CustomizeCheckoutTempRepository.cs b/CompanyManagment.EFCore/Repository/CustomizeCheckoutTempRepository.cs index f45548f6..79ca1503 100644 --- a/CompanyManagment.EFCore/Repository/CustomizeCheckoutTempRepository.cs +++ b/CompanyManagment.EFCore/Repository/CustomizeCheckoutTempRepository.cs @@ -65,151 +65,151 @@ namespace CompanyManagment.EFCore.Repository }).ToList(); } - #endregion + #endregion - public IEnumerable Search(SearchCustomizeCheckout searchModel) - { + public IEnumerable Search(SearchCustomizeCheckout searchModel) + { - var query = _companyContext.CustomizeCheckoutTemps.Include(x => x.Employee) - .ThenInclude(x => x.PersonnelCodeList) - .Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList) - .AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId); - #region parameters initialize + var query = _companyContext.CustomizeCheckoutTemps.Include(x => x.Employee) + .ThenInclude(x => x.PersonnelCodeList) + .Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList) + .AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId); + #region parameters initialize - //start of search is the first day of the current month by default and end of search is today - var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date; - var endSearchDate = DateTime.Today; + //start of search is the first day of the current month by default and end of search is today + var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date; + var endSearchDate = DateTime.Today; - var pc = new PersianCalendar(); - var currentYear = pc.GetYear(DateTime.Now); - var currentMonth = pc.GetMonth(DateTime.Now); + var pc = new PersianCalendar(); + var currentYear = pc.GetYear(DateTime.Now); + var currentMonth = pc.GetMonth(DateTime.Now); - if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) && - searchModel.Year == 0 && searchModel.Month == 0) - { - var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date; - var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date; + if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) && + searchModel.Year == 0 && searchModel.Month == 0) + { + var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date; + var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date; - if (queryEndDate > queryStartDate) - { - startSearchDate = queryStartDate; - endSearchDate = queryEndDate; - } - query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate); - } + if (queryEndDate > queryStartDate) + { + startSearchDate = queryStartDate; + endSearchDate = queryEndDate; + } + query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate); + } - if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13) - { - var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime(); - queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate); - queryEndDate = queryEndDate.AddDays(-1); + if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13) + { + var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime(); + queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate); + queryEndDate = queryEndDate.AddDays(-1); - //if (queryEndDate < DateTime.Today) - //{ - // startSearchDate = queryStartDate; - // endSearchDate = queryEndDate; - //} + //if (queryEndDate < DateTime.Today) + //{ + // startSearchDate = queryStartDate; + // endSearchDate = queryEndDate; + //} - if (searchModel.Year == currentYear && searchModel.Month == currentMonth) - { - queryEndDate = DateTime.Today.AddDays(-1); + if (searchModel.Year == currentYear && searchModel.Month == currentMonth) + { + queryEndDate = DateTime.Today.AddDays(-1); - startSearchDate = queryStartDate; - endSearchDate = queryEndDate; - } - else - { - startSearchDate = queryStartDate; - endSearchDate = queryEndDate; - } - query = query.Where(x => x.ContractEnd.Date <= endSearchDate && x.ContractEnd.Date >= startSearchDate); + startSearchDate = queryStartDate; + endSearchDate = queryEndDate; + } + else + { + startSearchDate = queryStartDate; + endSearchDate = queryEndDate; + } + query = query.Where(x => x.ContractEnd.Date <= endSearchDate && x.ContractEnd.Date >= startSearchDate); - } + } - ////Month Index operations - //startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate); - //startSearchDate.FindFirstDayOfNextMonth(out endSearchDate); - //endSearchDate = endSearchDate.AddDays(-1); + ////Month Index operations + //startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate); + //startSearchDate.FindFirstDayOfNextMonth(out endSearchDate); + //endSearchDate = endSearchDate.AddDays(-1); - #endregion + #endregion - if (searchModel.EmployeeId > 0) - query = query.Where(x => x.EmployeeId == searchModel.EmployeeId); + if (searchModel.EmployeeId > 0) + query = query.Where(x => x.EmployeeId == searchModel.EmployeeId); - if (searchModel.BankId > 0) - query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId)); + if (searchModel.BankId > 0) + query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId)); - switch (searchModel.OrderBy) - { - case CustomizeCheckoutOrderByEnum.ContractStartDesc: - query = query.OrderByDescending(x => x.ContractStart.Date); - break; - case CustomizeCheckoutOrderByEnum.ContractStart: - query = query.OrderBy(x => x.ContractStart.Date); - break; - case CustomizeCheckoutOrderByEnum.ContractNoDesc: - query = query.OrderByDescending(x => x.ContractNo); - break; - case CustomizeCheckoutOrderByEnum.ContractNo: - query = query.OrderBy(x => x.ContractNo); - break; - default: - query = query.OrderByDescending(x => x.ContractStart.Date); - break; + switch (searchModel.OrderBy) + { + case CustomizeCheckoutOrderByEnum.ContractStartDesc: + query = query.OrderByDescending(x => x.ContractStart.Date); + break; + case CustomizeCheckoutOrderByEnum.ContractStart: + query = query.OrderBy(x => x.ContractStart.Date); + break; + case CustomizeCheckoutOrderByEnum.ContractNoDesc: + query = query.OrderByDescending(x => x.ContractNo); + break; + case CustomizeCheckoutOrderByEnum.ContractNo: + query = query.OrderBy(x => x.ContractNo); + break; + default: + query = query.OrderByDescending(x => x.ContractStart.Date); + break; - } + } - if (searchModel.Month == 0 || searchModel.Year == 0) - query = query.Skip(searchModel.PageIndex).Take(30); + if (searchModel.Month == 0 || searchModel.Year == 0) + query = query.Skip(searchModel.PageIndex).Take(30); - return query.Select(x => new CustomizeCheckoutViewModel() - { - Id = x.id, - ContractEndFa = x.ContractEnd.ToFarsi(), - ContractStartFa = x.ContractStart.ToFarsi(), - ContractNo = x.ContractNo, - EmployeeFName = x.EmployeeFName, - EmployeeLName = x.EmployeeLName, + return query.Select(x => new CustomizeCheckoutViewModel() + { + Id = x.id, + ContractEndFa = x.ContractEnd.ToFarsi(), + ContractStartFa = x.ContractStart.ToFarsi(), + ContractNo = x.ContractNo, + EmployeeFName = x.EmployeeFName, + EmployeeLName = x.EmployeeLName, - PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode, - Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(), - Year = pc.GetYear(x.ContractStart).ToString(), - BaseYearsPay = x.BaseYearsPay.ToMoney(), - BonusesPay = x.BonusesPay.ToMoney(), - EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(), - FamilyAllowance = x.FamilyAllowance.ToMoney(), - AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(), - FineDeduction = x.FineDeduction.ToMoney(), - FridayPay = x.FridayPay.ToMoney(), - InstallmentDeduction = x.InstallmentDeduction.ToMoney(), - InsuranceDeduction = x.InsuranceDeduction.ToMoney(), - LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), - LeavePay = x.LeavePay.ToMoney(), - MarriedAllowance = x.MarriedAllowance.ToMoney(), - MonthlySalary = x.MonthlySalary.ToMoney(), - NightworkPay = x.NightWorkPay.ToMoney(), - OvertimePay = x.OverTimePay.ToMoney(), - RewardPay = x.RewardPay.ToMoney(), - SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(), - ShiftPay = x.ShiftPay.ToMoney(), - SumOfWorkingDays = x.SumOfWorkingDays.ToString(), - TaxDeducation = x.TaxDeduction.ToMoney(), - TotalPayment = x.TotalPayment.ToMoney(), - TotalPaymentD = x.TotalPayment, - TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), - }).ToList(); + PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode, + Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(), + Year = pc.GetYear(x.ContractStart).ToString(), + BaseYearsPay = x.BaseYearsPay.ToMoney(), + BonusesPay = x.BonusesPay.ToMoney(), + EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(), + FamilyAllowance = x.FamilyAllowance.ToMoney(), + AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(), + FineDeduction = x.FineDeduction.ToMoney(), + FridayPay = x.FridayPay.ToMoney(), + InstallmentDeduction = x.InstallmentDeduction.ToMoney(), + InsuranceDeduction = x.InsuranceDeduction.ToMoney(), + LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), + LeavePay = x.LeavePay.ToMoney(), + MarriedAllowance = x.MarriedAllowance.ToMoney(), + MonthlySalary = x.MonthlySalary.ToMoney(), + NightworkPay = x.NightWorkPay.ToMoney(), + OvertimePay = x.OverTimePay.ToMoney(), + RewardPay = x.RewardPay.ToMoney(), + SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(), + ShiftPay = x.ShiftPay.ToMoney(), + SumOfWorkingDays = x.SumOfWorkingDays.ToString(), + TaxDeducation = x.TaxDeduction.ToMoney(), + TotalPayment = x.TotalPayment.ToMoney(), + TotalPaymentD = x.TotalPayment, + TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(), + }).ToList(); - } - public List PrintAll(long workshopId, IEnumerable customizeCheckoutIds) + } + public List PrintAll(long workshopId, IEnumerable customizeCheckoutIds) { //var pc = new PersianCalendar(); diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json index 3e31959e..00c1bb97 100644 --- a/ServiceHost/appsettings.Development.json +++ b/ServiceHost/appsettings.Development.json @@ -15,10 +15,10 @@ //"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]is[3019]#@ATt;TrustServerCertificate=true;" //local - "MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;" + //"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;" //mahan Docker - //"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;" + "MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;" }, "GoogleRecaptchaV3": { "SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH", From 7f14c14589661a2d99ed6693c196e5da58518861 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 24 Mar 2025 19:27:52 +0330 Subject: [PATCH 3/3] appsetting fix to original --- ServiceHost/appsettings.Development.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json index 00c1bb97..3e31959e 100644 --- a/ServiceHost/appsettings.Development.json +++ b/ServiceHost/appsettings.Development.json @@ -15,10 +15,10 @@ //"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]is[3019]#@ATt;TrustServerCertificate=true;" //local - //"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;" + "MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;" //mahan Docker - "MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;" + //"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;" }, "GoogleRecaptchaV3": { "SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH",