diff --git a/0_Framework/0_Framework.csproj b/0_Framework/0_Framework.csproj
index 66522232..a77e5547 100644
--- a/0_Framework/0_Framework.csproj
+++ b/0_Framework/0_Framework.csproj
@@ -21,6 +21,7 @@
+
diff --git a/0_Framework/Application/Tools.cs b/0_Framework/Application/Tools.cs
index b2355432..c4c10bdc 100644
--- a/0_Framework/Application/Tools.cs
+++ b/0_Framework/Application/Tools.cs
@@ -70,6 +70,33 @@ public static class Tools
return Regex.IsMatch(mobileNo, "^((09))(\\d{9})$");
}
+ ///
+ /// متد رند کننده مبلغ
+ /// استفاده شده در بیمه
+ ///
+ ///
+ ///
+ public static double GetRoundDoubleValue(double value)
+ {
+ string strValue = value.ToString();
+ if (strValue.IndexOf('.') > -1)
+ {
+
+
+ string a = strValue.Substring(strValue.IndexOf('.') + 1, 1);
+ if (int.Parse(a) > 5)
+ {
+ return (Math.Round(value, MidpointRounding.ToPositiveInfinity));
+ }
+ else
+ {
+ return (Math.Round(value, MidpointRounding.ToNegativeInfinity));
+ }
+ }
+
+ return value;
+ }
+
///
/// تاریخ شروع و تعداد ماه را میگیرد و تاریخ پایان قراردا را بر میگرداند
///
@@ -679,7 +706,115 @@ public static class Tools
return y2;
}
+ ///
+ /// تاریخ شمسی میگیرد و پایان ماه را به میلادی برمیگرداند
+ ///
+ ///
+ ///
+ public static DateTime FindeEndOfMonthReturnGr(this string date)
+ {
+ string y2 = string.Empty;
+ var year = Convert.ToInt32(date.Substring(0, 4));
+ var month = Convert.ToInt32(date.Substring(5, 2));
+ var YearD = date.Substring(0, 4);
+ var MonthD = date.Substring(5, 2);
+ if (month <= 6)
+ {
+ y2 = $"{YearD}/{MonthD}/31";
+ }
+ else if (month > 6 && month < 12)
+ {
+ y2 = $"{YearD}/{MonthD}/30";
+ }
+ else if (month == 12)
+ {
+ switch (year)
+ {
+ case 1346:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1350:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1354:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1358:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1362:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1366:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1370:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1375:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1379:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1383:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1387:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1391:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1395:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1399:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1403:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1408:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1412:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1416:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1420:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1424:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1428:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1432:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1436:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1441:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ case 1445:
+ y2 = $"{YearD}/{MonthD}/30";
+ break;
+ default:
+ y2 = $"{YearD}/{MonthD}/29";
+ break;
+
+ }
+ }
+
+ return y2.ToGeorgianDateTime();
+ }
///
/// تعداد روزهای سال را برمیگرداند
/// اگر کبیسهد بود سال 366 روزه برمیگرداند
diff --git a/Company.Domain/CheckoutAgg/ICheckoutRepository.cs b/Company.Domain/CheckoutAgg/ICheckoutRepository.cs
index c479e3d9..a4b0932a 100644
--- a/Company.Domain/CheckoutAgg/ICheckoutRepository.cs
+++ b/Company.Domain/CheckoutAgg/ICheckoutRepository.cs
@@ -23,7 +23,7 @@ public interface ICheckoutRepository : IRepository
string year, string month);
EditCheckout GetDetails(long id);
- Task CreateCkeckout(Checkout command);
+ Task CreateCheckout(Checkout command);
///
/// لود لیست اولیه جهت ایجاد فیش حقوقی
///
@@ -109,5 +109,16 @@ public interface ICheckoutRepository : IRepository
///
Task> CheckoutPrint(List ids);
+ ///
+ /// دریافت قردادها و جداول وابسته برای ایجاد فیش
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> GetContractsAndIncludeDataDataToCreateCheckout(
+ List ids, string year, string month, long workshopId);
+
#endregion
}
\ No newline at end of file
diff --git a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs
index f7bec585..d5af76a7 100644
--- a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs
+++ b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs
@@ -16,7 +16,7 @@ namespace Company.Domain.RollCallAgg;
public interface IRollCallMandatoryRepository : IRepository
{
- ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute);
+ Task MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute);
///
/// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب
diff --git a/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs b/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs
index 3c164b50..537db5c7 100644
--- a/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs
+++ b/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Threading.Tasks;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.RollCallEmployee;
@@ -7,7 +8,7 @@ namespace Company.Domain.RollCallEmployeeAgg;
public interface IRollCallEmployeeRepository : IRepository
{
- bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd);
+ Task HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd);
List GetByWorkshopId(long workshopId);
EditRollCallEmployee GetDetails(long id);
RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId);
diff --git a/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs b/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs
new file mode 100644
index 00000000..bb2dc6b4
--- /dev/null
+++ b/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs
@@ -0,0 +1,210 @@
+using System;
+using CompanyManagment.App.Contracts.Contract;
+using CompanyManagment.App.Contracts.EmployeeComputeOptions;
+using CompanyManagment.App.Contracts.WorkingHoursTemp;
+using System.Collections.Generic;
+
+namespace CompanyManagment.App.Contracts.Checkout.Dto;
+
+public class GetContractAndIncludesDataToCreateDto
+{
+
+
+ ///
+ /// آی دی کارگاه
+ ///
+ public long WorkshopId { get; set; }
+
+ ///
+ /// نام کارگاه
+ ///
+ public string WorkshopName { get; set; }
+
+
+ ///
+ /// کد بایگانی کارگاه
+ ///
+ public string ArchiveCode { get; set; }
+
+ ///
+ /// آیا تنظیمات کارگاه بر رو ایجاد فیش استاتیک است
+ ///
+ public bool IsStaticCheckout { get; set; }
+
+ ///
+ /// آیا کارگاه در تعطیلات رسمی باز است
+ ///
+ public bool WorkshopHolidayWorking { get; set; }
+
+ ///
+ /// محاسبه نوبت کاری در فیش حقوقی
+ ///
+ public bool RotatingShiftCompute { get; set; }
+
+
+ ///
+ /// آیا پاداش در فیش حقوقی محاسبه شود
+ ///
+ public bool RewardComputeOnCheckout { get; set; }
+
+ ///
+ /// آیا اضافه کار فیش حقوقی در بیمه محاسبه شود
+ ///
+ public bool HasInsuranceCheckoutOverTime { get; set; }
+
+ ///
+ /// آی دی صنف بیمه کارگاه
+ ///
+ public long? InsuranceJobId { get; set; }
+
+ ///
+ /// آیا کارگاه مشاغل مقطوع است
+ ///
+ public bool FixedSalary { get; set; }
+
+ ///
+ /// جمعیت شهر کارگاه
+ ///
+ public string Population { get; set; }
+
+ ///
+ /// نوع ارسال لیست بیمه
+ ///
+ public string TypeOfInsuranceSend { get; set; }
+
+
+ ///
+ /// قرارداد قدیمی است؟
+ ///
+ public bool IsOldContract { get; set; }
+
+
+
+
+
+ public List ContractIncludedData { get; set; }
+
+}
+
+
+public class ContractIncludedData
+{
+ ///
+ /// شماره قرارداد
+ ///
+ public string ContractNo { get; set; }
+
+ ///
+ /// آی دی پرسنل
+ ///
+ public long EmployeeId { get; set; }
+ ///
+ /// نام کامل پرسنل
+ ///
+ public string EmployeeFullName { get; set; }
+
+ ///
+ /// نام پدر
+ ///
+ public string FathersName { get; set; }
+
+ ///
+ /// کد ملی
+ ///
+ public string NationalCode { get; set; }
+
+ ///
+ /// تاریخ تولد
+ ///
+ public string DateOfBirth { get; set; }
+
+
+ ///
+ /// کد پرسنلس
+ ///
+ public string PersonnelCode { get; set; }
+
+
+ ///
+ /// وضعیت تاهل
+ ///
+
+ public string MaritalStatus { get; set; }
+
+
+ ///
+ /// ساعت کاری پرسنل
+ ///
+ public CreateWorkingHoursTemp WorkingHours { get; set; }
+
+ ///
+ /// اطلاعات جداسازی تاریخ فیش
+ ///
+ public ContractSeparationViewModel Separation { get; set; }
+
+ ///
+ /// تنظیمات فنی پرسنل
+ /// سنوات
+ ///
+ public string YearsOption { get; set; }
+
+
+ ///
+ /// تنظیمات فنی پرسنل
+ /// عیدی و پاداش
+ ///
+ public string BonusesOption { get; set; }
+
+
+
+ ///
+ /// تنظیمات فنی پرسنل
+ /// مزد مرخصی
+ ///
+ public string ComputeOption { get; set; }
+
+
+ ///
+ /// ترایخ شروع قراداد
+ /// شمسی
+ ///
+ public string ContractStart { get; set; }
+
+ ///
+ /// تاریخ پایان قرارداد
+ /// شمسی
+ ///
+ public string ContractEnd { get; set; }
+
+ ///
+ /// ترایخ شروع قراداد
+ /// میلادی
+ ///
+ public DateTime ContractStartGr { get; set; }
+
+ ///
+ /// تاریخ پایان قرارداد
+ /// میلادی
+ ///
+ public DateTime ContractEndGr { get; set; }
+
+ ///
+ /// آی دی قراداد
+ ///
+ public long ContractId { get; set; }
+
+ ///
+ /// مزد روزانه قرداد بدون تاثیر ساعات کار
+ ///
+ public double DailySalaryUnAffected { get; set; }
+
+ ///
+ /// نوع مزد روزانه
+ ///
+ public string DailyWageType { get; set; }
+
+ ///
+ /// اولین شروع بکار پرسنل
+ ///
+ public string FirstGetWorkingDay { get; set; }
+}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs
index 8f65581c..1aeeab81 100644
--- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs
+++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs
@@ -108,6 +108,14 @@ public interface ICheckoutApplication
///
Task>> GetContractToCreateCheckout(long workshopId,
string year, string month, long employeeId);
+ ///
+ /// ایجاد فیش حقوقی
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task CreateCheckoutApi(List ids, string year, string month, long workshopId);
#endregion
}
diff --git a/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs b/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs
index b83f6b32..63175ca5 100644
--- a/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs
+++ b/CompanyManagment.App.Contracts/Contract/ContractSeparationViewModel.cs
@@ -19,4 +19,6 @@ public class ContractSeparationViewModel
public string ConsumableItems { get; set; }
public bool checker { get; set; }
public bool HasLeft { get; set; }
+
+ public long EmployeeId { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs b/CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs
new file mode 100644
index 00000000..8c876cac
--- /dev/null
+++ b/CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs
@@ -0,0 +1,18 @@
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.SignalR;
+
+namespace CompanyManagment.App.Contracts.Hubs;
+
+public class CheckoutHub : Hub
+{
+
+ public async Task send(long id)
+ {
+ await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(id));
+ }
+
+ public static string GetGroupName(long id)
+ {
+ return $"group-Checkout-{id}";
+ }
+}
\ No newline at end of file
diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs
index 27ce4454..173258fe 100644
--- a/CompanyManagment.Application/CheckoutApplication.cs
+++ b/CompanyManagment.Application/CheckoutApplication.cs
@@ -2,11 +2,15 @@
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
using Company.Domain.CheckoutAgg;
using Company.Domain.CheckoutAgg.ValueObjects;
+using Company.Domain.ContractAgg;
using Company.Domain.EmployeeAgg;
using Company.Domain.empolyerAgg;
+using Company.Domain.InsuranceListAgg;
using Company.Domain.LeaveAgg;
using Company.Domain.LeftWorkAgg;
+using Company.Domain.LeftWorkInsuranceAgg;
using Company.Domain.RollCallAgg;
+using Company.Domain.RollCallEmployeeAgg;
using Company.Domain.WorkingHoursTempAgg;
using Company.Domain.WorkshopAgg;
using Company.Domain.YearlySalaryAgg;
@@ -14,17 +18,23 @@ using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.Contract;
using CompanyManagment.App.Contracts.HolidayItem;
+using CompanyManagment.App.Contracts.Hubs;
+using CompanyManagment.App.Contracts.InstitutionContract;
+using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.App.Contracts.Leave;
using CompanyManagment.App.Contracts.MandantoryHours;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using CompanyManagment.App.Contracts.RollCall;
using CompanyManagment.App.Contracts.WorkingHoursTemp;
using CompanyManagment.App.Contracts.Workshop;
+using CompanyManagment.App.Contracts.YearlySalary;
using CompanyManagment.EFCore.Migrations;
using CompanyManagment.EFCore.Repository;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
@@ -48,12 +58,18 @@ public class CheckoutApplication : ICheckoutApplication
private readonly IWorkingHoursTempRepository _workingHoursTempRepository;
private readonly IWorkshopRepository _workshopRepository;
private readonly IAuthHelper _authHelper;
+ private readonly IHubContext _hubContext;
+ private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
+ private readonly IContractRepository _contractRepository;
+ private readonly IInsuranceListRepository _insuranceListRepository;
+ private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
+ private readonly IInsuranceListApplication _insuranceListApplication;
public CheckoutApplication(ICheckoutRepository checkoutRepository, IYearlySalaryRepository yearlySalaryRepository,
ILeftWorkRepository leftWorkRepository,
- IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper)
+ IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper, IHubContext hubContext, IRollCallEmployeeRepository rollCallEmployeeRepository, IContractRepository contractRepository, IInsuranceListRepository insuranceListRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceListApplication insuranceListApplication)
{
_checkoutRepository = checkoutRepository;
_yearlySalaryRepository = yearlySalaryRepository;
@@ -68,6 +84,12 @@ public class CheckoutApplication : ICheckoutApplication
_workingHoursTempRepository = workingHoursTempRepository;
_workshopRepository = workshopRepository;
_authHelper = authHelper;
+ _hubContext = hubContext;
+ _rollCallEmployeeRepository = rollCallEmployeeRepository;
+ _contractRepository = contractRepository;
+ _insuranceListRepository = insuranceListRepository;
+ _leftWorkInsuranceRepository = leftWorkInsuranceRepository;
+ _insuranceListApplication = insuranceListApplication;
}
[SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 241")]
@@ -263,12 +285,12 @@ public class CheckoutApplication : ICheckoutApplication
rewardPay = rewards.Sum(x => x.AmountDouble);
}
-
-
- var firstDayOfMonth = $"{command.ContractStart.Substring(0, 8)}01".ToGeorgianDateTime();
- var firstDayOfCurrentMonth = new DateTime(syear, smonth, 1, new PersianCalendar());
+
+
+ var firstDayOfMonth = $"{command.ContractStart.Substring(0, 8)}01".ToGeorgianDateTime();
+ var firstDayOfCurrentMonth = new DateTime(syear, smonth, 1, new PersianCalendar());
LeaveSearchModel sickLeaveSearch = new LeaveSearchModel()
{
@@ -384,12 +406,12 @@ public class CheckoutApplication : ICheckoutApplication
- var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
- command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay + rewardPay;
- var totalClaims = totalClaimsDouble.ToMoney();
- var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
- var totalDeductions = totalDeductionDouble.ToMoney();
- var totalPayment = totalClaimsDouble - totalDeductionDouble;
+ var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
+ command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay + rewardPay;
+ var totalClaims = totalClaimsDouble.ToMoney();
+ var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
+ var totalDeductions = totalDeductionDouble.ToMoney();
+ var totalPayment = totalClaimsDouble - totalDeductionDouble;
if (_checkoutRepository.Exists(x =>
x.Month == command.Month && x.Year == command.Year && x.ContractNo == command.ContractNo))
@@ -404,15 +426,15 @@ public class CheckoutApplication : ICheckoutApplication
}
- var checkout = new Checkout(command.EmployeeFullName, command.FathersName, command.NationalCode
- , command.DateOfBirth, command.EmployeeId, command.WorkshopName, command.WorkshopId, command.ContractNo, command.ContractStartGr, command.ContractEndGr, month, year,
- command.ContractId, command.WorkingHoursId, monthlyWage, bacicYears, consumableItem, housingAllowance
- , command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
- command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
- , command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
- loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList, rewards, rewardPay);
+ var checkout = new Checkout(command.EmployeeFullName, command.FathersName, command.NationalCode
+ , command.DateOfBirth, command.EmployeeId, command.WorkshopName, command.WorkshopId, command.ContractNo, command.ContractStartGr, command.ContractEndGr, month, year,
+ command.ContractId, command.WorkingHoursId, monthlyWage, bacicYears, consumableItem, housingAllowance
+ , command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
+ command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
+ , command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
+ loanInstallments, salaryAids, checkoutRollCall, command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList, rewards, rewardPay);
- _checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
+ _checkoutRepository.CreateCheckout(checkout).GetAwaiter().GetResult();
//_checkoutRepository.SaveChanges();
//var employeeFullName = new SqlParameter("@EmployeeFullName", SqlDbType.NVarChar, 50);
@@ -780,11 +802,11 @@ public class CheckoutApplication : ICheckoutApplication
year = "0";
month = "0";
}
-
+
var result = await GetContractResultToCreateCheckout(workshopId, employeeId, year, month, null,
null);
- if(result.CreateCheckoutList.Count == 0)
+ if (result.CreateCheckoutList.Count == 0)
return op.Failed("موردی یافت نشد");
var finalResult = result.CreateCheckoutList.Select(x => new ContractsListToCreateCheckoutDto
{
@@ -805,46 +827,705 @@ public class CheckoutApplication : ICheckoutApplication
}
- public async Task CreateCheckoutApi(List ContractsId, string ConvertYear, string ConvertMonth)
+ public async Task CreateCheckoutApi(List ids, string year, string month, long workshopId)
{
+
var op = new OperationResult();
//آی دی کاربر لاگین شده برای استفاده در signalR
- var currentAcc = _authHelper.CurrentAccountId();
+ var currntAcc = _authHelper.CurrentAccountId();
- #region Validation
+ var signalR = _hubContext.Clients.Group(CheckoutHub.GetGroupName(currntAcc));
- if (!string.IsNullOrWhiteSpace(ConvertYear) && string.IsNullOrWhiteSpace(ConvertMonth))
- return op.Failed("ماه را انتخاب کنید");
- if (string.IsNullOrWhiteSpace(ConvertYear) && !string.IsNullOrWhiteSpace(ConvertMonth))
- return op.Failed("سال را انتخاب کنید");
- if (string.IsNullOrWhiteSpace(ConvertYear) && string.IsNullOrWhiteSpace(ConvertMonth))
- {
- ConvertYear = "0";
- ConvertMonth = "0";
- var today = DateTime.Now;
- var FaToday = today.ToFarsi();
- var year = FaToday.Substring(0, 4);
- var month = FaToday.Substring(5, 2);
- ConvertYear = year;
- ConvertMonth = month;
- }
-
- if (ContractsId.Count == 0)
- return op.Failed("هیچ موردی انتخاب نشده اشت");
-
- #endregion
+ var getContractsData = await
+ _checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, year, month, workshopId);
#region GetInsuranceData
-
+
+
+ var startMonthFa = $"{year}/{month.PadLeft(2, '0')}/01";
+ DateTime startDateGr = startMonthFa.ToGeorgianDateTime();
+ DateTime endDateGr = startMonthFa.FindeEndOfMonth().ToGeorgianDateTime();
+ int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2));
+
+
+ var insuranceListData =
+ _insuranceListRepository.EmployeeInsuranceDataBy(startDateGr, getContractsData.Data.WorkshopId);
+ var yearlysaleries = _yearlySalaryRepository.GetInsuranceItems(startDateGr, endDateGr, year);
+
+ var insuranceEmployeeData =
+ _leftWorkInsuranceRepository.GetEmployeeInsuranceLeftWorksAndInformation(getContractsData.Data.WorkshopId, startDateGr,
+ endDateGr);
+
+
#endregion
+
+ if (!getContractsData.IsSuccedded)
+ {
+
+ await signalR.SendAsync("StartProcessingFailed", getContractsData.Message);
+ return op.Failed(getContractsData.Message);
+ }
+
+
+ var timer = new Stopwatch();
+ timer.Start();
+
+ int successProcess = 1;
+ int countList = getContractsData.Data.ContractIncludedData.Count;
+ List createFailedList = [];
+ int createSuccessCount = 0;
+ int createFailedCount = 0;
+ foreach (var item in getContractsData.Data.ContractIncludedData)
+ {
+
+ try
+ {
+ //آیا کل مرخصی به ساعت کاراضافه شود؟
+ bool totalLeaveCompute = false;
+ //آیا غیبت محاسبه شود؟
+ bool abcenseDeductionCompute = false;
+ switch (item.ComputeOption)
+ {
+ case "OnEndOfYear":
+ var endOfYearCheckout = item.Separation.ContractEnd.Substring(5, 2);
+
+ totalLeaveCompute = true;
+ abcenseDeductionCompute = item.Separation.HasLeft || endOfYearCheckout == "12";
+ break;
+ case "OnLeftWork":
+
+ totalLeaveCompute = true;
+ abcenseDeductionCompute = item.Separation.HasLeft;
+ break;
+ case "OnEndOfContract":
+ var startMonth = item.ContractStart.Substring(5, 2);
+ var endMonth = item.ContractEnd.Substring(5, 2);
+
+ totalLeaveCompute = startMonth != endMonth;
+ abcenseDeductionCompute = (startMonth != endMonth && item.Separation.HasLeft) || (startMonth != endMonth && item.ContractEndGr == item.Separation.ContractEndGr);
+ break;
+ }
+
+
+ //دستمزد روزانه بدون تاثیر ساعت کار
+ #region DailyWageCommpute
+
+ var contract = new EditContract()
+ {
+ ContractStartGr = item.ContractStartGr,
+ ContractEndGr = item.ContractEndGr,
+ DailySalaryUnAffected = item.DailySalaryUnAffected,
+ DailyWageType = item.DailyWageType,
+ ContarctStart = item.ContractStart,
+ ContractEnd = item.ContractEnd,
+ GetWorkDate = item.FirstGetWorkingDay,
+ GetWorkDateHide = item.FirstGetWorkingDay,
+
+ };
+
+ //دستمزد روزانه بدون تاثیر ساعت کار
+ var dailyWageUnAffected = await _yearlySalaryRepository.GetCheckoutDailyWage(contract,
+ item.Separation.ContractStartGr, item.Separation.ContractEndGr);
+
+ #endregion
+
+
+
+
+ var hasRollCall = await _rollCallEmployeeRepository.HasRollCallRecord(item.EmployeeId, workshopId, item.Separation.ContractStartGr, item.Separation.ContractEndGr);
+ if (getContractsData.Data.IsStaticCheckout)
+ hasRollCall = false;
+
+ var isStaticCheckout = hasRollCall == false;
+ //محاسبه موظفی
+ #region MandatoryCompute
+ var mandatoryCompute = new ComputingViewModel();
+
+ item.WorkingHours.ContractStartGr = item.Separation.ContractStartGr;
+ item.WorkingHours.ContractEndGr = item.Separation.ContractEndGr;
+ item.WorkingHours.ContarctStart = item.Separation.ContarctStart;
+ item.WorkingHours.ContractEnd = item.Separation.ContractEnd;
+ item.WorkingHours.GetWorkDate = contract.GetWorkDate;
+ item.WorkingHours.GetWorkDateHide = contract.GetWorkDate;
+ item.WorkingHours.WorkshopId = workshopId;
+ item.WorkingHours.EmployeeId = item.EmployeeId;
+
+ mandatoryCompute = await _rollCallMandatoryRepository.MandatoryCompute(item.EmployeeId, workshopId,
+ item.Separation.ContractStartGr, item.Separation.ContractEndGr, item.WorkingHours, getContractsData.Data.WorkshopHolidayWorking,
+ isStaticCheckout, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
+
+ #endregion
+
+
+ if (contract.EmployeeId == 9659)
+ mandatoryCompute.SumTime44 = "48 - 24";
+
+ var officialHoliday = mandatoryCompute.OfficialHoliday;
+ var Friday = int.Parse(mandatoryCompute.NumberOfFriday);
+ var fridayStartToEnd = mandatoryCompute.FridayStartToEnd;
+
+ var totalHoursH = mandatoryCompute.TotalHoursesH;
+ var totalHoursM = mandatoryCompute.TotalHoursesM;
+ var dayliWage = mandatoryCompute.SalaryCompute.MoneyToDouble();
+ var consumableItemDouble = mandatoryCompute.ConsumableItems.MoneyToDouble();
+ var housingAllowanceDouble = mandatoryCompute.HousingAllowance.MoneyToDouble();
+ var familyAllowanceDouble = mandatoryCompute.FamilyAllowance.MoneyToDouble();
+ var marriedAllowanceDouble = mandatoryCompute.MarriedAllowance.MoneyToDouble();
+
+ //اضافه کاری
+ var overTimePay = _yearlySalaryRepository.GetOverTimeWorking(dayliWage,
+ mandatoryCompute.OverTimeWorkH, mandatoryCompute.OverTimeWorkM);
+ //شبکاری
+ var overNightPay = _yearlySalaryRepository.GetOverNightWorking(dayliWage,
+ mandatoryCompute.OverNightWorkH, mandatoryCompute.OverNightWorkM, mandatoryCompute.SumTime44,
+ officialHoliday, Friday, item.Separation.ContractStartGr, item.Separation.ContractEndGr, totalHoursH,
+ totalHoursM);
+
+
+ //سنوات
+ var yearsPay = _yearlySalaryRepository.Years(item.Separation.ContractStartGr, item.Separation.LeftWorkDate,
+ item.Separation.ContractEndGr,
+ dayliWage, item.YearsOption, item.Separation.HasLeft, item.Separation.StartWorkDate, contract.ContractStartGr,
+ contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, getContractsData.Data.IsOldContract);
+ //عیدی
+ #region BonusesPay
+ var bunosesPay = _yearlySalaryRepository.Bunoses(item.Separation.ContarctStart, item.Separation.LeftWorkDate,
+ item.Separation.ContractStartGr, item.Separation.ContractEndGr,
+ dayliWage, item.BonusesOption, item.Separation.HasLeft, item.Separation.StartWorkDate,
+ contract.ContractStartGr,
+ contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, getContractsData.Data.IsOldContract);
+ //اگر تصفیه حساب پاک شده برای عیدی یا سنوات وجود داشت
+ if (bunosesPay.NotCompleted || yearsPay.NotCompleted)
+ {
+
+ List lostCheckoutsDates = new List();
+ if ((bunosesPay.NotCompleted && yearsPay.NotCompleted) || (bunosesPay.NotCompleted && !yearsPay.NotCompleted))
+ lostCheckoutsDates = bunosesPay.BunosesStatusList;
+ if (!bunosesPay.NotCompleted && yearsPay.NotCompleted)
+ lostCheckoutsDates = yearsPay.BunosesStatusList;
+
+ foreach (var found in lostCheckoutsDates)
+ {
+ ComputingViewModel foundMandatoryCompute = new ComputingViewModel();
+ var foundContract = _contractRepository.GetContractByStartEnd(found.ContractStart,
+ found.ContractEnd, contract.WorkshopIds, contract.EmployeeId);
+
+ if (foundContract.Id > 0)
+ {
+ var foundWorkingHours = _workingHoursTempRepository.GetByContractIdConvertToShiftwork4(foundContract.Id);
+ foundWorkingHours.ContractStartGr = found.ContractStart;
+ foundWorkingHours.ContractEndGr = found.ContractEnd;
+ foundWorkingHours.ContarctStart = found.ContractStart.ToFarsi();
+ foundWorkingHours.ContractEnd = found.ContractEnd.ToFarsi();
+ foundWorkingHours.GetWorkDate = foundContract.GetWorkDate;
+ foundWorkingHours.GetWorkDateHide = foundContract.GetWorkDate;
+ foundWorkingHours.WorkshopId = contract.WorkshopIds;
+ foundWorkingHours.EmployeeId = contract.EmployeeId;
+ bool foundHasRollCall = await _rollCallEmployeeRepository.HasRollCallRecord(item.EmployeeId, workshopId, found.ContractStart, found.ContractEnd);
+
+ if (getContractsData.Data.IsStaticCheckout)
+ foundHasRollCall = false;
+
+ foundMandatoryCompute = await _rollCallMandatoryRepository.MandatoryCompute(contract.EmployeeId,
+ contract.WorkshopIds,
+ found.ContractStart, found.ContractEnd, foundWorkingHours, getContractsData.Data.WorkshopHolidayWorking, foundHasRollCall, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
+
+
+
+
+
+ var MontlyYearsBunos =
+ _yearlySalaryRepository.GetMontlyBunosYears(foundMandatoryCompute.weeklyTime, found.ContractStart, found.ContractEnd,
+ foundMandatoryCompute.SalaryCompute.MoneyToDouble(), foundMandatoryCompute.SumTime44, foundMandatoryCompute.OfficialHoliday,
+ int.Parse(foundMandatoryCompute.NumberOfFriday), foundMandatoryCompute.TotalHolidayAndNotH, foundMandatoryCompute.TotalHolidayAndNotM,
+ foundMandatoryCompute.Basic, foundMandatoryCompute.FridayStartToEnd, foundMandatoryCompute.DayliFeeComplete, hasRollCall, getContractsData.Data.WorkshopHolidayWorking, item.WorkingHours.ShiftWork);
+ double foundMontlySalary = MontlyYearsBunos.MontlyWage + MontlyYearsBunos.BasicYears;
+ int foundTotaldays = Convert.ToInt32(MontlyYearsBunos.SumOfWorkingDay);
+ double foundDayliWage = foundMontlySalary / foundTotaldays;
+ if (bunosesPay.NotCompleted)
+ {
+ double foundBonuses = ((foundDayliWage * 60) / 365) * foundTotaldays;
+ bunosesPay.Bunoses += foundBonuses;
+ bunosesPay.TotalDayCompute += foundTotaldays;
+ }
+
+ if (yearsPay.NotCompleted)
+ {
+ double foundBonuses = ((foundDayliWage * 30) / 365) * foundTotaldays;
+ yearsPay.YearsPay += foundBonuses;
+ yearsPay.TotalDayCompute += foundTotaldays;
+ }
+
+ }
+ }
+ }
+
+ #endregion
+
+ //مزد مرخصی جدید
+ var leavePayNew = _yearlySalaryRepository.LeavePay(item.Separation.ContarctStart,
+ item.Separation.LeftWorkDate, item.Separation.ContractStartGr, item.Separation.ContractEndGr,
+ dayliWage, item.ComputeOption, item.Separation.HasLeft, item.Separation.StartWorkDate,
+ contract.ContractStartGr,
+ contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, fridayStartToEnd,
+ officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble,
+ familyAllowanceDouble, marriedAllowanceDouble, getContractsData.Data.IsOldContract);
+
+
+
+
+ #region Insurance
+
+ double insuranceShare = 0;
+ //اگر پرسنل داری شروع بکار بیمه بود
+ var insuranceEmployeeDataItem =
+ insuranceEmployeeData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
+
+ //اگر لیست بیمه برای پرسنل ساخته شده بود
+ var insuranceListDataWithDetails =
+ insuranceListData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
+ if (insuranceListDataWithDetails != null)
+ {
+ insuranceShare = insuranceListDataWithDetails.InsuranceShare;
+ }
+ else
+ {
+ if (insuranceEmployeeDataItem != null && insuranceEmployeeDataItem.StartWorkDateGr <= item.Separation.ContractEndGr)
+ {
+ var workingDays = Tools.GetEmployeeInsuranceWorkingDays(insuranceEmployeeDataItem.StartWorkDateGr, item.Separation.LeftWorkDate, startDateGr, endDateGr, insuranceEmployeeDataItem.EmployeeId);
+ var leftWorkFa = workingDays.hasLeftWorkInMonth ? item.Separation.LeftWorkDate.ToFarsi() : "";
+
+ //به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
+
+ double dailyWage = 0;
+ if (getContractsData.Data.FixedSalary)
+ {
+ var res = _insuranceListApplication.GetDailyWageFixedSalary(year, getContractsData.Data.WorkshopId, insuranceEmployeeDataItem.EmployeeId, startDateGr,
+ endDateGr, insuranceEmployeeDataItem.JobId, getContractsData.Data.Population, getContractsData.Data.InsuranceJobId);
+ dailyWage = res ?? 0;
+
+ }
+ else
+ {
+ var res = _insuranceListApplication.ComputeDailyWage(yearlysaleries.DayliWage, insuranceEmployeeDataItem.EmployeeId, getContractsData.Data.WorkshopId, year);
+ dailyWage = res;
+ }
+
+ //بدست آوردن پایه سنوات
+ var baseYears = _insuranceListRepository.GetEmployeeInsuranceBaseYear(insuranceEmployeeDataItem.EmployeeId, getContractsData.Data.WorkshopId,
+ workingDays.countWorkingDays, startDateGr, endDateGr, workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
+
+ //جمع مزد روزانه و پایه سنوات
+ var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
+
+
+ //دستمزد ماهانه با محاسبه پایه سنوات
+ var monthlySalary = Tools.GetRoundDoubleValue(dailyWagePlusBaseYears * workingDays.countWorkingDays);
+
+ //حق تاهل
+ var marriedAllowanceForInsurance = item.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0;
+
+ //محاسبه مزایای ماهانه
+ var monthlyBenefits = _insuranceListApplication.GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowanceForInsurance, workingDays.countWorkingDays, getContractsData.Data.TypeOfInsuranceSend, insuranceEmployeeDataItem.JobId, insuranceEmployeeDataItem.EmployeeId, insuranceEmployeeDataItem.IncludeStatus);
+ if (getContractsData.Data.HasInsuranceCheckoutOverTime)
+ {
+
+ monthlyBenefits = Tools.GetRoundDoubleValue(monthlyBenefits += overTimePay);
+ }
+
+ //محاسبه جمع مزایای مشمول و دستمزد ماهانه
+ var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
+
+ //محاسبه حق بیمه سهم بیمه شده
+ insuranceShare = (benefitsIncludedContinuous * 7) / 100;
+ }
+ }
+
+
+
+ #endregion
+
+ #region ResultToSave
+
+ var syear = Convert.ToInt32(item.ContractStart.Substring(0, 4));
+ var smonth = Convert.ToInt32(item.ContractStart.Substring(5, 2));
+
+ string monthfarsiName = (item.ContractStart.Substring(5, 2)).ToFarsiMonthByNumber();
+
+ var yearShamsi = item.ContractStart.Substring(0, 4);
+
+
+ var dayliWageDouble = mandatoryCompute.SalaryCompute.MoneyToDouble();
+ // کمک هزینه اقلام
+ var consumableItem = mandatoryCompute.ConsumableItems.MoneyToDouble();
+ //حق اولاد
+ var familyAllowance = mandatoryCompute.FamilyAllowance.MoneyToDouble();
+ //کمک هزینه مسکن
+ var housingAllowance = mandatoryCompute.HousingAllowance.MoneyToDouble();
+ //حق تاهل
+ var marriedAllowance = mandatoryCompute.MarriedAllowance.MoneyToDouble();
+
+ #region Salary
+
+ var totalDays = (item.Separation.ContractEndGr - item.Separation.ContractStartGr).TotalDays + 1;
+
+ //حقوق ماهانه
+ var monthlyWage = mandatoryCompute.DailySalaryAffected * totalDays;
+ //پایه سنوات
+ var bacicYears = mandatoryCompute.BaseYearAffected * totalDays;
+ #endregion
+
+
+ //سنوات
+ var years = yearsPay.YearsPay;
+ //عیدی و پاداش
+ var bunos = bunosesPay.Bunoses;
+
+ //فاطمه احمدژاد === موقت عیدی و پاداش و سنوات حساب نشه
+ if (item.EmployeeId == 45104 && getContractsData.Data.WorkshopId == 315)
+ {
+ years = 0;
+
+ bunos = 0;
+ }
+
+ //تعداد زروز های فیش
+ var sumOfWorkingDays = $"{totalDays}";
+
+ //مبلغ جمعه کاری
+ double fridayPay = 0;
+ if (Friday > 0)
+ {
+ var fridayPercent = dayliWageDouble * 40 / 100;
+ //فوق العاده جمعه کاری
+ fridayPay = fridayPercent * Friday;
+ }
+
+
+ //حق بیمه سهم کارگر
+ #region InsuranceDeduction
+
+ double insuranceDeduction = 0;
+ bool hasInsuranceShareTheSameAsList = false;
+ var inshuranceShareRound = Tools.GetRoundDoubleValue(insuranceShare);
+ if (inshuranceShareRound == 0)
+ {
+ var insuranceOverTime = getContractsData.Data.HasInsuranceCheckoutOverTime ? overTimePay : 0;
+ insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
+ }
+ else
+ {
+ insuranceDeduction = inshuranceShareRound;
+ hasInsuranceShareTheSameAsList = true;
+ }
+
+
+ #endregion
+
+ //مقادیر - روز - تعداد - ساعت
+ #region Values
+
+ //مدت شب کاری
+ var overNightWorkValue =
+ $"{Convert.ToInt32(mandatoryCompute.OverNightWorkH):00}:{Convert.ToInt32(mandatoryCompute.OverNightWorkM):00}";
+ //تعداد جمعه کاری
+ var fridayWorkValue = $"{Friday}";
+ //نوع نوبت کاری
+ var rotatingShiftValue = mandatoryCompute.RotatingShiftValue;
+ // تعداد سال های سنوات
+ var totalDayOfYearsCompute = yearsPay.YearsPay > 0 ? $"{yearsPay.TotalDayCompute}" : "0";
+ //تعداد روز های عیدی و پاداش
+ var totalDayOfBunosesCompute = bunosesPay.Bunoses > 0 ? $"{bunosesPay.TotalDayCompute}" : "0";
+ //مدت اضافه کارس
+ var overTimeWorkValue =
+ $"{Convert.ToInt32(mandatoryCompute.OverTimeWorkH):00}:{Convert.ToInt32(mandatoryCompute.OverTimeWorkM):00}";
+
+
+ #endregion
+
+ //کسر اضافه کار از غیبت یا بلعکس
+ #region OverTimeAndAbsencSubtraction
+ var absenceDeduction = abcenseDeductionCompute ? leavePayNew.AbsenceDeduction : 0;
+
+ if (overTimePay > 0 && absenceDeduction > 0)
+ {
+ if (absenceDeduction >= overTimePay)
+ {
+ absenceDeduction -= overTimePay;
+ overTimePay = 0;
+ overTimeWorkValue = "00:00";
+ }
+ else
+ {
+ overTimePay -= absenceDeduction;
+ absenceDeduction = 0;
+ }
+
+ }
+ #endregion
+
+ //مساعده
+ #region SalaryAid
+
+ var salaryAids =
+ _rollCallMandatoryRepository.SalaryAidsForCheckout(contract.EmployeeId, contract.WorkshopIds, startDateGr, endDateGr)
+ .Select(x => new CheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa, x.CalculationDateTimeGe, x.CalculationDateTimeFa, x.Id)).ToList();
+
+ var salaryAidDeduction = salaryAids.Sum(x => x.Amount.MoneyToDouble());
+
+ #endregion
+
+ //اقساط وام
+ #region LoanInstallment
+
+ var loanInstallments = _rollCallMandatoryRepository.LoanInstallmentForCheckout(contract.EmployeeId, contract.WorkshopIds,
+ item.Separation.ContractStartGr, item.Separation.HasLeft ? DateTime.MaxValue : item.Separation.ContractEndGr)
+ .Select(x =>
+ new CheckoutLoanInstallment(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount, x.LoanAmount, x.Id)).ToList();
+
+ var installmentDeduction = loanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble());
+
+ #endregion
+
+ //پاداش
+ #region Reward
+
+
+ var rewards = new List();
+ double rewardPay = 0;
+ if (getContractsData.Data.RewardComputeOnCheckout)
+ {
+ rewards = _rollCallMandatoryRepository.RewardForCheckout(contract.EmployeeId, contract.WorkshopIds, startDateGr, endDateGr)
+ .Select(x => new CheckoutReward(x.Amount, x.AmountDouble, x.GrantDateFa, x.GrantDateGr, x.Description, x.Title, x.Id)).ToList();
+
+ rewardPay = rewards.Sum(x => x.AmountDouble);
+ }
+
+ #endregion
+
+ //جدول حضورغیاب پرسنل
+ #region CheckoutRollCall
+
+ //کارکرد واقعی - محاسبات شامل مرخصی افزوده شده
+ var totalWorkingTimeSpan = mandatoryCompute.TotalWorkingTimeSpan;
+ //ساعت استراحت
+ var totalBreakTimeSpan = mandatoryCompute.TotalBreakTimeSpan;
+ // ساعت حضور - بدون مرخصی افزده شده
+ var totalPresentTimeSpan = mandatoryCompute.TotalPresentTimeSpan;
+ //مدت مرخصی استحقاقی
+ var totalPaidLeave = mandatoryCompute.TotalPaidLeave;
+ //مدت مرخصی استعلاجی
+ var totalSickLeave = mandatoryCompute.TotalSickLeave;
+
+
+ var firstDayOfMonth = startDateGr;
+ var firstDayOfCurrentMonth = new DateTime(syear, smonth, 1, new PersianCalendar());
+
+ LeaveSearchModel sickLeaveSearch = new LeaveSearchModel()
+ {
+ EmployeeId = contract.EmployeeId,
+ WorkshopId = contract.WorkshopIds,
+ StartLeaveGr = item.Separation.ContractStartGr,
+ EndLeaveGr = item.Separation.ContractEndGr,
+ IsAccepted = true,
+ };
+ var leaves = _leaveApplication.search(sickLeaveSearch);
+
+ firstDayOfMonth.AddMonthsFa(1, out var lastDayOfCurrentMonth);
+
+ lastDayOfCurrentMonth = lastDayOfCurrentMonth.AddDays(-1);
+
+ int dateRange = (int)(lastDayOfCurrentMonth - firstDayOfCurrentMonth).TotalDays + 1;
+
+ var holidays = _holidayItemApplication.Search(new HolidayItemSearchModel()
+ {
+ HolidayYear = item.Separation.ContractStartGr.ToFarsiYear()
+ });
+ //all the dates from start to end, to be compared with present days to get absent dates
+ var completeDaysList = Enumerable.Range(0, dateRange).Select(offset => firstDayOfCurrentMonth.AddDays(offset).Date).ToList();
+
+ var absentRecords = completeDaysList
+ .ExceptBy(mandatoryCompute.GroupedRollCalls.Select(x => x.CreationDate.Date), y => y.Date)
+ .Select(x =>
+ {
+ var leave = leaves.FirstOrDefault(y =>
+ y.EmployeeId == contract.EmployeeId && y.EndLeaveGr.Date >= x.Date && y.StartLeaveGr.Date <= x.Date);
+ var isHoliday = holidays.Any(y => y.HolidaydateGr == x.Date);
+ var isFriday = x.Date.DayOfWeek == DayOfWeek.Friday;
+ var isNormalWorkingDay = isHoliday == false && isFriday == false;
+ return new CheckoutDailyRollCallViewModel()
+ {
+ StartDate1 = null,
+ EndDate1 = null,
+ DateTimeGr = x.Date,
+ DayOfWeek = x.Date.DayOfWeek.ToString(),
+ RollCallDateFa = x.Date.ToFarsi(),
+ LeaveType = leave != null ? leave.LeaveType : "",
+ IsAbsent = leave == null && isNormalWorkingDay
+ };
+ });
+
+
+ var presentDays = mandatoryCompute.GroupedRollCalls.Select(x =>
+ {
+
+ var orderedRollcalls = x.ShiftList.OrderBy(y => y.Start);
+
+ var rollCallTimeSpanPerDay = x.SumOneDaySpan;
+ TimeSpan breakTimePerDay = x.BreakTime;
+
+ return new CheckoutDailyRollCallViewModel()
+ {
+ StartDate1 = orderedRollcalls.FirstOrDefault().Start.ToString("HH:mm"),
+ EndDate1 = orderedRollcalls.FirstOrDefault().EndWithOutResTime.ToString("HH:mm"),
+
+ StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.Start.ToString("HH:mm") ?? "",
+ EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndWithOutResTime.ToString("HH:mm") ?? "",
+
+ TotalhourseSpan = rollCallTimeSpanPerDay,
+
+ BreakTimeTimeSpan = breakTimePerDay,
+
+ DayOfWeek = x.CreationDate.DayOfWeek.DayOfWeeKToPersian(),
+ RollCallDateFa = x.CreationDate.Date.ToFarsi(),
+ DateTimeGr = x.CreationDate.Date,
+ IsSliced = x.ShiftList.Count() > 2,
+ IsAbsent = false
+ };
+ });
+
+
+ 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:00}",
+ BreakTimeString = $"{(int)(x.BreakTimeTimeSpan.TotalHours)}:{x.BreakTimeTimeSpan.Minutes:00}",
+ TotalhourseSpan = x.TotalhourseSpan,
+ BreakTimeTimeSpan = x.BreakTimeTimeSpan,
+ DayOfWeek = x.DayOfWeek,
+ RollCallDateFa = x.RollCallDateFa,
+ DateTimeGr = x.DateTimeGr,
+ IsSliced = x.IsSliced,
+ IsAbsent = false
+ });
+
+ var result = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList();
+ result.ForEach(x =>
+ {
+ x.IsHoliday = holidays.Any(y => x.DateTimeGr.Date == y.HolidaydateGr.Date);
+ x.IsFriday = x.DateTimeGr.DayOfWeek == DayOfWeek.Friday;
+ });
+
+ var checkoutRollCallDays = result.Select(x => new CheckoutRollCallDay(x.DateTimeGr,
+ x.StartDate1, x.EndDate1, x.StartDate2, x.EndDate2,
+ x.BreakTimeTimeSpan, x.IsSliced, x.TotalhourseSpan, x.IsAbsent, x.IsFriday, x.IsHoliday, x.LeaveType))
+ .ToList();
+
+
+ double mandatoryHours = _mandatoryHoursApplication.GetMandatoryHoursByYearAndMonth(syear, smonth);
+ int mandatoryWholeHours = (int)mandatoryHours;
+ int mandatoryMinutes = (int)((mandatoryHours - mandatoryWholeHours) * 60);
+
+ var totalMandatoryHours = TimeSpan.FromHours(mandatoryWholeHours).Add(TimeSpan.FromMinutes(mandatoryMinutes));
+ var checkoutRollCall = new CheckoutRollCall(totalMandatoryHours, totalPresentTimeSpan, totalBreakTimeSpan,
+ totalWorkingTimeSpan, totalPaidLeave, totalSickLeave, checkoutRollCallDays);
+ #endregion
+
+ //مقادیر پرداخت نهایی - مطالبات - کسورات
+ #region TotalPayment
+
+ var shiftPay = contract.WorkshopIds == 552 && hasRollCall ? 0 : mandatoryCompute.ShiftPay;
+
+
+ var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + overTimePay +
+ overNightPay + familyAllowance + bunos + years + leavePayNew.LeavPay + fridayPay + shiftPay + rewardPay;
+ var totalDeductionDouble = insuranceDeduction + absenceDeduction + installmentDeduction + salaryAidDeduction;
+
+ //مطالبات
+ var totalClaims = totalClaimsDouble.ToMoney();
+ //کسورات
+ var totalDeductions = totalDeductionDouble.ToMoney();
+
+ //مبلغ قابل پرداخت
+ var totalPayment = totalClaimsDouble - totalDeductionDouble;
+
+ #endregion
+
+
+ #region CreateCheckoutModel
+
+ var checkout = new Checkout(item.EmployeeFullName, item.FathersName, item.NationalCode
+ , item.DateOfBirth, item.EmployeeId, getContractsData.Data.WorkshopName, getContractsData.Data.WorkshopId, item.ContractNo, item.Separation.ContractStartGr, item.Separation.ContractEndGr, monthfarsiName, yearShamsi,
+ item.ContractId, item.WorkingHours.WorknigHoursId, monthlyWage, bacicYears, consumableItem, housingAllowance
+ , overTimePay, overNightPay, fridayPay, 0, shiftPay, familyAllowance, bunos, years, leavePayNew.LeavPay, insuranceDeduction, 0, installmentDeduction, salaryAidDeduction, absenceDeduction, sumOfWorkingDays,
+ getContractsData.Data.ArchiveCode, item.PersonnelCode, totalClaims, totalDeductions, totalPayment, "0", marriedAllowance, leavePayNew.LeaveCheckout, leavePayNew.CreditLeaves, leavePayNew.AbsencePeriod, leavePayNew.AverageHoursPerDay, hasRollCall, overTimeWorkValue, overNightWorkValue
+ , fridayWorkValue, rotatingShiftValue, "0", leavePayNew.TotalDayOfLeaveCompute, totalDayOfYearsCompute, totalDayOfBunosesCompute,
+ loanInstallments, salaryAids, checkoutRollCall, mandatoryCompute.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList, rewards, rewardPay);
+
+ #endregion
+
+
+ #endregion
+
+
+
+
+ #region SaveToDb
+
+
+ var saveToDb = await _checkoutRepository.CreateCheckout(checkout);
+ if (!saveToDb)
+ {
+ createFailedCount += 1;
+ createFailedList.Add(item.EmployeeFullName);
+ }
+ else
+ {
+ createSuccessCount += 1;
+ }
+ #endregion
+ }
+ catch (Exception)
+ {
+ createFailedCount += 1;
+ createFailedList.Add(item.EmployeeFullName);
+
+ }
+
+
+ var percent = (successProcess / (double)countList) * 100;
+ // await signalR.SendAsync("showStatus", countList, createFailedCount, createSuccessCount, (int)percent, createFailedList);
+ await signalR.SendAsync("all", countList);
+ await signalR.SendAsync("failed", createFailedCount);
+ await signalR.SendAsync("Success", createSuccessCount);
+ await signalR.SendAsync("percent", (int)percent);
+ await signalR.SendAsync("failedList", createFailedList);
+
+ successProcess += 1;
+
+ Console.ForegroundColor = ConsoleColor.Cyan;
+ Console.WriteLine("================================================================== ");
+ Console.WriteLine("======================================== Counter " + successProcess + " ================== ");
+ Console.WriteLine("================================================================== ");
+ Console.ResetColor();
+
+ }
+
+
+ Console.ForegroundColor = ConsoleColor.Yellow;
+ Console.WriteLine("after GetData To mandatoryCompute" + timer.Elapsed);
+ Console.ResetColor();
return op.Succcedded();
}
#endregion
diff --git a/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs b/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs
index 44acfd3e..596fa3e9 100644
--- a/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs
+++ b/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs
@@ -90,7 +90,7 @@ namespace CompanyManagment.Application
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
- return _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, contractStart, contractEnd);
+ return _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, contractStart, contractEnd).GetAwaiter().GetResult();
}
public List GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr)
diff --git a/CompanyManagment.Application/RollCallMandatoryApplication.cs b/CompanyManagment.Application/RollCallMandatoryApplication.cs
index dd9bbd39..ea16f367 100644
--- a/CompanyManagment.Application/RollCallMandatoryApplication.cs
+++ b/CompanyManagment.Application/RollCallMandatoryApplication.cs
@@ -24,7 +24,7 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication
public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute)
{
- return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
+ return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute).GetAwaiter().GetResult();
}
diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs
index b9e4416f..35c7e742 100644
--- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs
+++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs
@@ -2,6 +2,7 @@
using _0_Framework.Exceptions;
using _0_Framework.InfraStructure;
using Company.Domain.CheckoutAgg;
+using Company.Domain.EmployeeAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.RollCallAgg;
using Company.Domain.RollCallEmployeeAgg;
@@ -11,6 +12,7 @@ using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Checkout.Dto;
using CompanyManagment.App.Contracts.Contract;
using CompanyManagment.App.Contracts.Employee;
+using CompanyManagment.App.Contracts.EmployeeComputeOptions;
using CompanyManagment.App.Contracts.HolidayItem;
using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.InsuranceList;
@@ -36,6 +38,7 @@ using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Threading.Tasks;
using System.Xml.XPath;
+using static CompanyManagment.EFCore.Repository.ContractRepository;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace CompanyManagment.EFCore.Repository;
@@ -299,7 +302,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos
: startSreach;
bool hasRollCall =
_rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startStatusSearch,
- endStatusSearch);
+ endStatusSearch).GetAwaiter().GetResult();
bool extension = true;
bool laterThanEnd = false;
@@ -319,7 +322,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos
{
// اگر ترک کار کرده بود
// اگر ترک کارش در بازه انتخاب شده بود
- if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch)
+ var leftFirstDayOfNextMonth = endSearch.AddDays(1);
+ if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= leftFirstDayOfNextMonth)
{
//اگر بازه انتخاب شده در تاریخ جاری بود
if (startSreach == currentStart && endSearch == currentEnd)
@@ -515,27 +519,40 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos
};
}
- public async Task CreateCkeckout(Checkout command)
+ public async Task CreateCheckout(Checkout command)
{
- var creationDates = DateTime.Now;
- //var result = await _context.Database.ExecuteSqlInterpolatedAsync($"EXEC InsertQuery_Checkout {id},{employeeFullName},{isActiveString},{signature},{fathersName},{nationalCode},{dateOfBirth},{employeeId},{workshopName},{workshopId},{contractNo},{contractStart},{contractEnd},{month},{year},{contractId},{workingHoursId},{monthlySalary},{baseYearsPay},{consumableItems},{housingAllowance},{overtimePay},{nightworkPay},{fridayPay},{missionPay},{shiftPay},{familyAllowance},{bonusesPay},{yearsPay},{leavePay},{insuranceDeduction},{taxDeducation},{installmentDeduction},{salaryAidDeduction},{absenceDeduction},{creationDate},{archiveCode},{personnelCode},{sumOfWorkingDays},{totalClaims},{taxDeducation},{totalPayment}");
- var result = (_context.Database
- .SqlQuery(
- $"EXEC InsertQuery_CreateChekoute {command.EmployeeFullName},{"true"},{command.Signature},{command.FathersName},{command.NationalCode},{command.DateOfBirth},{command.EmployeeId},{command.WorkshopName},{command.WorkshopId},{command.ContractNo},{command.ContractStart},{command.ContractEnd},{command.Month},{command.Year},{command.ContractId},{command.WorkingHoursId},{command.MonthlySalary},{command.BaseYearsPay},{command.ConsumableItems},{command.HousingAllowance},{command.OvertimePay},{command.NightworkPay},{command.FridayPay},{command.MissionPay},{command.ShiftPay},{command.FamilyAllowance},{command.BonusesPay},{command.YearsPay},{command.LeavePay},{command.InsuranceDeduction},{command.TaxDeducation},{command.InstallmentDeduction},{command.SalaryAidDeduction},{command.AbsenceDeduction},{creationDates},{command.ArchiveCode},{command.PersonnelCode},{command.SumOfWorkingDays},{command.TotalClaims},{command.TotalDeductions},{command.TotalPayment},{0},{command.MarriedAllowance},{command.AbsencePeriod},{command.AverageHoursPerDay},{command.CreditLeaves},{command.LeaveCheckout},{command.HasRollCall},{command.OverTimeWorkValue},{command.OverNightWorkValue},{command.FridayWorkValue},{command.RotatingShiftValue},{command.AbsenceValue}, {command.TotalDayOfLeaveCompute},{command.TotalDayOfYearsCompute},{command.TotalDayOfBunosesCompute}")
- .AsEnumerable()) // این قسمت مهمه!
- .FirstOrDefault();
+ try
+ {
+ var creationDates = DateTime.Now;
- var entity = await _context.CheckoutSet.FirstOrDefaultAsync(x => x.id == result);
+ //var result = await _context.Database.ExecuteSqlInterpolatedAsync($"EXEC InsertQuery_Checkout {id},{employeeFullName},{isActiveString},{signature},{fathersName},{nationalCode},{dateOfBirth},{employeeId},{workshopName},{workshopId},{contractNo},{contractStart},{contractEnd},{month},{year},{contractId},{workingHoursId},{monthlySalary},{baseYearsPay},{consumableItems},{housingAllowance},{overtimePay},{nightworkPay},{fridayPay},{missionPay},{shiftPay},{familyAllowance},{bonusesPay},{yearsPay},{leavePay},{insuranceDeduction},{taxDeducation},{installmentDeduction},{salaryAidDeduction},{absenceDeduction},{creationDate},{archiveCode},{personnelCode},{sumOfWorkingDays},{totalClaims},{taxDeducation},{totalPayment}");
+ var result = (_context.Database
+ .SqlQuery(
+ $"EXEC InsertQuery_CreateChekoute {command.EmployeeFullName},{"true"},{command.Signature},{command.FathersName},{command.NationalCode},{command.DateOfBirth},{command.EmployeeId},{command.WorkshopName},{command.WorkshopId},{command.ContractNo},{command.ContractStart},{command.ContractEnd},{command.Month},{command.Year},{command.ContractId},{command.WorkingHoursId},{command.MonthlySalary},{command.BaseYearsPay},{command.ConsumableItems},{command.HousingAllowance},{command.OvertimePay},{command.NightworkPay},{command.FridayPay},{command.MissionPay},{command.ShiftPay},{command.FamilyAllowance},{command.BonusesPay},{command.YearsPay},{command.LeavePay},{command.InsuranceDeduction},{command.TaxDeducation},{command.InstallmentDeduction},{command.SalaryAidDeduction},{command.AbsenceDeduction},{creationDates},{command.ArchiveCode},{command.PersonnelCode},{command.SumOfWorkingDays},{command.TotalClaims},{command.TotalDeductions},{command.TotalPayment},{0},{command.MarriedAllowance},{command.AbsencePeriod},{command.AverageHoursPerDay},{command.CreditLeaves},{command.LeaveCheckout},{command.HasRollCall},{command.OverTimeWorkValue},{command.OverNightWorkValue},{command.FridayWorkValue},{command.RotatingShiftValue},{command.AbsenceValue}, {command.TotalDayOfLeaveCompute},{command.TotalDayOfYearsCompute},{command.TotalDayOfBunosesCompute}")
+ .AsEnumerable()) // این قسمت مهمه!
+ .FirstOrDefault();
- entity.SetSalaryAid(command.SalaryAids, command.SalaryAidDeduction);
- entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
- entity.SetReward(command.Rewards,command.RewardPay);
- entity.SetCheckoutRollCall(command.CheckoutRollCall);
- entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
- if (command.HasInsuranceShareTheSameAsList)
- entity.SetInsuranceShare();
- await _context.SaveChangesAsync();
+ var entity = await _context.CheckoutSet.FirstOrDefaultAsync(x => x.id == result);
+
+ entity.SetSalaryAid(command.SalaryAids, command.SalaryAidDeduction);
+ entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
+ entity.SetReward(command.Rewards, command.RewardPay);
+ entity.SetCheckoutRollCall(command.CheckoutRollCall);
+ entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
+ if (command.HasInsuranceShareTheSameAsList)
+ entity.SetInsuranceShare();
+ await _context.SaveChangesAsync();
+
+ return true;
+ }
+ catch (Exception)
+ {
+
+ return false;
+ }
+
+
}
@@ -2843,7 +2860,1665 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos
return employees;
}
+ public async Task> GetContractsAndIncludeDataDataToCreateCheckout(List ids,string year, string month, long workshopId)
+ {
+ var checkoutSelectedStartFa = $"{year}/{month}/01";
+ var checkoutSelectedStart = checkoutSelectedStartFa.ToGeorgianDateTime();
+ var checkoutSelectedEnd = checkoutSelectedStartFa.FindeEndOfMonthReturnGr();
+ var op = new OperationResult();
+ var watcher = new Stopwatch();
+ watcher.Start();
+ var test = _context.Contracts.FirstOrDefault(x => x.id == 290499);
+ //دریافت قراداد ها
+ var getContracts =await _context.Contracts.Where(x => ids.Contains(x.id)).Include(e=>e.Employee).AsNoTracking().ToListAsync();
+ if (!getContracts.Any())
+ return op.Failed("قرادادی یافت نشد");
+ var employeeIds = getContracts.Select(x => x.EmployeeId).ToList();
+
+ //دریافت اطلاعات کارگاه
+ var workshop = await _context.Workshops.FirstAsync(x => x.id == workshopId);
+ var GetContractsTime = watcher.Elapsed;
+ watcher.Reset();
+ watcher.Start();
+ //دریافت اطلاعات پرسنل ها
+ // var employees = await _context.Employees.Where(x => employeeIds.Contains(x.id)).AsNoTracking().ToListAsync();
+ //دریافت اطلاعت ساعت کاری
+ #region WorkingHours
+ var getWorkingHours = await _context.WorkingHoursSet.Where(x => ids.Contains(x.ContractId))
+ .Include(x => x.WorkingHoursItemsList)
+ .AsNoTracking()
+ .ToListAsync();
+ if (!getWorkingHours.Any())
+ return op.Failed("ساعات کاری قراداد یافت نشد");
+
+ var workingHoursList = new List();
+ foreach (var workingHours in getWorkingHours)
+ {
+ if (workingHours != null)
+ {
+ var items = workingHours?.WorkingHoursItemsList;
+
+ if (workingHours.ShiftWork == "1" || workingHours.ShiftWork == "2")
+ {
+ var shanbeh = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "0") ? true : false;
+ var yekshanbeh = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "0") ? true : false;
+ var doshanbeh = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "0") ? true : false;
+ var seshanbeh = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "0") ? true : false;
+ var cheharshanbeh = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "0") ? true : false;
+ var pangshanbeh = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "0") ? true : false;
+ var jomeh = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "0") ? true : false;
+
+ var RestTime = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0")?.RestTime
+ : null;
+ var RestTimeYekshanbeh = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1")?.RestTime
+ : null;
+ var RestTimeDoshanbeh = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2")?.RestTime
+ : null;
+ var RestTimeSeshanbeh = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3")?.RestTime
+ : null;
+ var RestTimeCheharshanbeh = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4")?.RestTime
+ : null;
+ var RestTimePanjshanbeh = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5")?.RestTime
+ : null;
+ var RestTimeJomeh = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6")?.RestTime
+ : null;
+
+ var SingleShift1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0")?.Start1
+ : null;
+ var SingleShift2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0")?.End1
+ : null;
+ var TowShifts1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0")?.Start2
+ : null;
+ var TowShifts2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0")?.End2
+ : null;
+
+ var SingleShift1Yekshanbeh = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1")?.Start1
+ : null;
+ var SingleShift2Yekshanbeh = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1")?.End1
+ : null;
+ var TowShifts1Yekshanbeh = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1")?.Start2
+ : null;
+ var TowShifts2Yekshanbeh = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1")?.End2
+ : null;
+
+ var SingleShift1Doshanbeh = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2")?.Start1
+ : null;
+ var SingleShift2Doshanbeh = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2")?.End1
+ : null;
+ var TowShifts1Doshanbeh = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2")?.Start2
+ : null;
+ var TowShifts2Doshanbeh = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2")?.End2
+ : null;
+
+ var SingleShift1Seshanbeh = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3")?.Start1
+ : null;
+ var SingleShift2Seshanbeh = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3")?.End1
+ : null;
+ var TowShifts1Seshanbeh = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3")?.Start2
+ : null;
+ var TowShifts2Seshanbeh = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3")?.End2
+ : null;
+
+ var SingleShift1Cheharshanbeh = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4")?.Start1
+ : null;
+ var SingleShift2Cheharshanbeh = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4")?.End1
+ : null;
+ var TowShifts1Cheharshanbeh = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4")?.Start2
+ : null;
+ var TowShifts2Cheharshanbeh = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4")?.End2
+ : null;
+
+ var SingleShift1Panjshanbeh = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5")?.Start1
+ : null;
+ var SingleShift2Panjshanbeh = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5")?.End1
+ : null;
+ var TowShifts1Panjshanbeh = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5")?.Start2
+ : null;
+ var TowShifts2Panjshanbeh = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5")?.End2
+ : null;
+
+ var SingleShift1Jomeh = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6")?.Start1
+ : null;
+ var SingleShift2Jomeh = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6")?.End1
+ : null;
+ var TowShifts1Jomeh = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6")?.Start2
+ : null;
+ var TowShifts2Jomeh = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "0")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6")?.End2
+ : null;
+
+ var result = new CreateWorkingHoursTemp
+ {
+ EmployeeId = getContracts.First(x=>x.id == workingHours.ContractId).EmployeeId,
+ WorknigHoursId = workingHours.id,
+ ShiftWork = "4",
+ ShiftWorkTemp = "1",
+
+ #region week1
+
+ //week1
+ Shanbe1 = shanbeh,
+ YekShanbe1 = yekshanbeh,
+ DoShanbe1 = doshanbeh,
+ SeShanbe1 = seshanbeh,
+ CheharShanbe1 = cheharshanbeh,
+ PanjShanbe1 = pangshanbeh,
+ Jome1 = jomeh,
+
+ RestTimeShanbe1 = RestTime,
+ RestTimeYekShanbe1 = RestTimeYekshanbeh,
+ RestTimeDoShanbe1 = RestTimeDoshanbeh,
+ RestTimeSeShanbe1 = RestTimeSeshanbeh,
+ RestTimeCheharShanbe1 = RestTimeCheharshanbeh,
+ RestTimePanjShanbe1 = RestTimePanjshanbeh,
+ RestTimeJome1 = RestTimeJomeh,
+
+ SingleShift1Shanbe1 = SingleShift1,
+ SingleShift2Shanbe1 = SingleShift2,
+ TowShifts1Shanbe1 = TowShifts1,
+ TowShifts2Shanbe1 = TowShifts2,
+
+ SingleShift1YekShanbe1 = SingleShift1Yekshanbeh,
+ SingleShift2YekShanbe1 = SingleShift2Yekshanbeh,
+ TowShifts1YekShanbe1 = TowShifts1Yekshanbeh,
+ TowShifts2YekShanbe1 = TowShifts2Yekshanbeh,
+
+ SingleShift1DoShanbe1 = SingleShift1Doshanbeh,
+ SingleShift2DoShanbe1 = SingleShift2Doshanbeh,
+ TowShifts1DoShanbe1 = TowShifts1Doshanbeh,
+ TowShifts2DoShanbe1 = TowShifts2Doshanbeh,
+
+ SingleShift1SeShanbe1 = SingleShift1Seshanbeh,
+ SingleShift2SeShanbe1 = SingleShift2Seshanbeh,
+ TowShifts1SeShanbe1 = TowShifts1Seshanbeh,
+ TowShifts2SeShanbe1 = TowShifts2Seshanbeh,
+
+ SingleShift1CheharShanbe1 = SingleShift1Cheharshanbeh,
+ SingleShift2CheharShanbe1 = SingleShift2Cheharshanbeh,
+ TowShifts1CheharShanbe1 = TowShifts1Cheharshanbeh,
+ TowShifts2CheharShanbe1 = TowShifts2Cheharshanbeh,
+
+ SingleShift1PanjShanbe1 = SingleShift1Panjshanbeh,
+ SingleShift2PanjShanbe1 = SingleShift2Panjshanbeh,
+ TowShifts1PanjShanbe1 = TowShifts1Panjshanbeh,
+ TowShifts2PanjShanbe1 = TowShifts2Panjshanbeh,
+
+ SingleShift1Jome1 = SingleShift1Jomeh,
+ SingleShift2Jome1 = SingleShift2Jomeh,
+ TowShifts1Jome1 = TowShifts1Jomeh,
+ TowShifts2Jome1 = TowShifts2Jomeh,
+
+ #endregion
+
+ #region week2
+
+ //week2
+ Shanbe2 = shanbeh,
+ YekShanbe2 = yekshanbeh,
+ DoShanbe2 = doshanbeh,
+ SeShanbe2 = seshanbeh,
+ CheharShanbe2 = cheharshanbeh,
+ PanjShanbe2 = pangshanbeh,
+ Jome2 = jomeh,
+
+ RestTimeShanbe2 = RestTime,
+ RestTimeYekShanbe2 = RestTimeYekshanbeh,
+ RestTimeDoShanbe2 = RestTimeDoshanbeh,
+ RestTimeSeShanbe2 = RestTimeSeshanbeh,
+ RestTimeCheharShanbe2 = RestTimeCheharshanbeh,
+ RestTimePanjShanbe2 = RestTimePanjshanbeh,
+ RestTimeJome2 = RestTimeJomeh,
+
+
+ SingleShift1Shanbe2 = SingleShift1,
+ SingleShift2Shanbe2 = SingleShift2,
+ TowShifts1Shanbe2 = TowShifts1,
+ TowShifts2Shanbe2 = TowShifts2,
+
+ SingleShift1YekShanbe2 = SingleShift1Yekshanbeh,
+ SingleShift2YekShanbe2 = SingleShift2Yekshanbeh,
+ TowShifts1YekShanbe2 = TowShifts1Yekshanbeh,
+ TowShifts2YekShanbe2 = TowShifts2Yekshanbeh,
+
+ SingleShift1DoShanbe2 = SingleShift1Doshanbeh,
+ SingleShift2DoShanbe2 = SingleShift2Doshanbeh,
+ TowShifts1DoShanbe2 = TowShifts1Doshanbeh,
+ TowShifts2DoShanbe2 = TowShifts2Doshanbeh,
+
+ SingleShift1SeShanbe2 = SingleShift1Seshanbeh,
+ SingleShift2SeShanbe2 = SingleShift2Seshanbeh,
+ TowShifts1SeShanbe2 = TowShifts1Seshanbeh,
+ TowShifts2SeShanbe2 = TowShifts2Seshanbeh,
+
+ SingleShift1CheharShanbe2 = SingleShift1Cheharshanbeh,
+ SingleShift2CheharShanbe2 = SingleShift2Cheharshanbeh,
+ TowShifts1CheharShanbe2 = TowShifts1Cheharshanbeh,
+ TowShifts2CheharShanbe2 = TowShifts2Cheharshanbeh,
+
+ SingleShift1PanjShanbe2 = SingleShift1Panjshanbeh,
+ SingleShift2PanjShanbe2 = SingleShift2Panjshanbeh,
+ TowShifts1PanjShanbe2 = TowShifts1Panjshanbeh,
+ TowShifts2PanjShanbe2 = TowShifts2Panjshanbeh,
+
+ SingleShift1Jome2 = SingleShift1Jomeh,
+ SingleShift2Jome2 = SingleShift2Jomeh,
+ TowShifts1Jome2 = TowShifts1Jomeh,
+ TowShifts2Jome2 = TowShifts2Jomeh,
+
+ #endregion
+
+
+ #region week3
+
+ //week3
+ Shanbe3 = shanbeh,
+ YekShanbe3 = yekshanbeh,
+ DoShanbe3 = doshanbeh,
+ SeShanbe3 = seshanbeh,
+ CheharShanbe3 = cheharshanbeh,
+ PanjShanbe3 = pangshanbeh,
+ Jome3 = jomeh,
+
+ RestTimeShanbe3 = RestTime,
+ RestTimeYekShanbe3 = RestTimeYekshanbeh,
+ RestTimeDoShanbe3 = RestTimeDoshanbeh,
+ RestTimeSeShanbe3 = RestTimeSeshanbeh,
+ RestTimeCheharShanbe3 = RestTimeCheharshanbeh,
+ RestTimePanjShanbe3 = RestTimePanjshanbeh,
+ RestTimeJome3 = RestTimeJomeh,
+
+
+ SingleShift1Shanbe3 = SingleShift1,
+ SingleShift2Shanbe3 = SingleShift2,
+ TowShifts1Shanbe3 = TowShifts1,
+ TowShifts2Shanbe3 = TowShifts2,
+
+ SingleShift1YekShanbe3 = SingleShift1Yekshanbeh,
+ SingleShift2YekShanbe3 = SingleShift2Yekshanbeh,
+ TowShifts1YekShanbe3 = TowShifts1Yekshanbeh,
+ TowShifts2YekShanbe3 = TowShifts2Yekshanbeh,
+
+ SingleShift1DoShanbe3 = SingleShift1Doshanbeh,
+ SingleShift2DoShanbe3 = SingleShift2Doshanbeh,
+ TowShifts1DoShanbe3 = TowShifts1Doshanbeh,
+ TowShifts2DoShanbe3 = TowShifts2Doshanbeh,
+
+ SingleShift1SeShanbe3 = SingleShift1Seshanbeh,
+ SingleShift2SeShanbe3 = SingleShift2Seshanbeh,
+ TowShifts1SeShanbe3 = TowShifts1Seshanbeh,
+ TowShifts2SeShanbe3 = TowShifts2Seshanbeh,
+
+ SingleShift1CheharShanbe3 = SingleShift1Cheharshanbeh,
+ SingleShift2CheharShanbe3 = SingleShift2Cheharshanbeh,
+ TowShifts1CheharShanbe3 = TowShifts1Cheharshanbeh,
+ TowShifts2CheharShanbe3 = TowShifts2Cheharshanbeh,
+
+ SingleShift1PanjShanbe3 = SingleShift1Panjshanbeh,
+ SingleShift2PanjShanbe3 = SingleShift2Panjshanbeh,
+ TowShifts1PanjShanbe3 = TowShifts1Panjshanbeh,
+ TowShifts2PanjShanbe3 = TowShifts2Panjshanbeh,
+
+ SingleShift1Jome3 = SingleShift1Jomeh,
+ SingleShift2Jome3 = SingleShift2Jomeh,
+ TowShifts1Jome3 = TowShifts1Jomeh,
+ TowShifts2Jome3 = TowShifts2Jomeh,
+
+ #endregion
+
+ #region week4
+
+ //week4
+ Shanbe4 = shanbeh,
+ YekShanbe4 = yekshanbeh,
+ DoShanbe4 = doshanbeh,
+ SeShanbe4 = seshanbeh,
+ CheharShanbe4 = cheharshanbeh,
+ PanjShanbe4 = pangshanbeh,
+ Jome4 = jomeh,
+
+ RestTimeShanbe4 = RestTime,
+ RestTimeYekShanbe4 = RestTimeYekshanbeh,
+ RestTimeDoShanbe4 = RestTimeDoshanbeh,
+ RestTimeSeShanbe4 = RestTimeSeshanbeh,
+ RestTimeCheharShanbe4 = RestTimeCheharshanbeh,
+ RestTimePanjShanbe4 = RestTimePanjshanbeh,
+ RestTimeJome4 = RestTimeJomeh,
+
+
+ SingleShift1Shanbe4 = SingleShift1,
+ SingleShift2Shanbe4 = SingleShift2,
+ TowShifts1Shanbe4 = TowShifts1,
+ TowShifts2Shanbe4 = TowShifts2,
+
+ SingleShift1YekShanbe4 = SingleShift1Yekshanbeh,
+ SingleShift2YekShanbe4 = SingleShift2Yekshanbeh,
+ TowShifts1YekShanbe4 = TowShifts1Yekshanbeh,
+ TowShifts2YekShanbe4 = TowShifts2Yekshanbeh,
+
+ SingleShift1DoShanbe4 = SingleShift1Doshanbeh,
+ SingleShift2DoShanbe4 = SingleShift2Doshanbeh,
+ TowShifts1DoShanbe4 = TowShifts1Doshanbeh,
+ TowShifts2DoShanbe4 = TowShifts2Doshanbeh,
+
+ SingleShift1SeShanbe4 = SingleShift1Seshanbeh,
+ SingleShift2SeShanbe4 = SingleShift2Seshanbeh,
+ TowShifts1SeShanbe4 = TowShifts1Seshanbeh,
+ TowShifts2SeShanbe4 = TowShifts2Seshanbeh,
+
+ SingleShift1CheharShanbe4 = SingleShift1Cheharshanbeh,
+ SingleShift2CheharShanbe4 = SingleShift2Cheharshanbeh,
+ TowShifts1CheharShanbe4 = TowShifts1Cheharshanbeh,
+ TowShifts2CheharShanbe4 = TowShifts2Cheharshanbeh,
+
+ SingleShift1PanjShanbe4 = SingleShift1Panjshanbeh,
+ SingleShift2PanjShanbe4 = SingleShift2Panjshanbeh,
+ TowShifts1PanjShanbe4 = TowShifts1Panjshanbeh,
+ TowShifts2PanjShanbe4 = TowShifts2Panjshanbeh,
+
+ SingleShift1Jome4 = SingleShift1Jomeh,
+ SingleShift2Jome4 = SingleShift2Jomeh,
+ TowShifts1Jome4 = TowShifts1Jomeh,
+ TowShifts2Jome4 = TowShifts2Jomeh,
+
+ #endregion
+ };
+ //تفکیک ساعت استراحت
+
+ #region TafkikRest
+
+ #region Week1
+
+ var restTimeShanbe1 = result.RestTimeShanbe1;
+ result.RestTimeShanbe1 = restTimeShanbe1.RestTimeSplit();
+ result.RestTimeShanbe1Min = restTimeShanbe1.RestTimeMinSplit();
+ var restTimeYekShanbe1 = result.RestTimeYekShanbe1;
+ result.RestTimeYekShanbe1 = restTimeYekShanbe1.RestTimeSplit();
+ result.RestTimeYekShanbe1Min = restTimeYekShanbe1.RestTimeMinSplit();
+ var restTimeDoShanbe1 = result.RestTimeDoShanbe1;
+ result.RestTimeDoShanbe1 = restTimeDoShanbe1.RestTimeSplit();
+ result.RestTimeDoShanbe1Min = restTimeDoShanbe1.RestTimeMinSplit();
+ var restTimeSeShanbe1 = result.RestTimeSeShanbe1;
+ result.RestTimeSeShanbe1 = restTimeSeShanbe1.RestTimeSplit();
+ result.RestTimeSeShanbe1Min = restTimeSeShanbe1.RestTimeMinSplit();
+ var restTimeCheharShanbe1 = result.RestTimeCheharShanbe1;
+ result.RestTimeCheharShanbe1 = restTimeCheharShanbe1.RestTimeSplit();
+ result.RestTimeCheharShanbe1Min = restTimeCheharShanbe1.RestTimeMinSplit();
+ var restTimePanjShanbe1 = result.RestTimePanjShanbe1;
+ result.RestTimePanjShanbe1 = restTimePanjShanbe1.RestTimeSplit();
+ result.RestTimePanjShanbe1Min = restTimePanjShanbe1.RestTimeMinSplit();
+ var restTimeJome1 = result.RestTimeJome1;
+ result.RestTimeJome1 = restTimeJome1.RestTimeSplit();
+ result.RestTimeJome1Min = restTimeJome1.RestTimeMinSplit();
+
+ #endregion
+
+ #region week2
+
+ var restTimeShanbe2 = result.RestTimeShanbe2;
+ result.RestTimeShanbe2 = restTimeShanbe2.RestTimeSplit();
+ result.RestTimeShanbe2Min = restTimeShanbe2.RestTimeMinSplit();
+ var restTimeYekShanbe2 = result.RestTimeYekShanbe2;
+ result.RestTimeYekShanbe2 = restTimeYekShanbe2.RestTimeSplit();
+ result.RestTimeYekShanbe2Min = restTimeYekShanbe2.RestTimeMinSplit();
+ var restTimeDoShanbe2 = result.RestTimeDoShanbe2;
+ result.RestTimeDoShanbe2 = restTimeDoShanbe2.RestTimeSplit();
+ result.RestTimeDoShanbe2Min = restTimeDoShanbe2.RestTimeMinSplit();
+ var restTimeSeShanbe2 = result.RestTimeSeShanbe2;
+ result.RestTimeSeShanbe2 = restTimeSeShanbe2.RestTimeSplit();
+ result.RestTimeSeShanbe2Min = restTimeSeShanbe2.RestTimeMinSplit();
+ var restTimeCheharShanbe2 = result.RestTimeCheharShanbe2;
+ result.RestTimeCheharShanbe2 = restTimeCheharShanbe2.RestTimeSplit();
+ result.RestTimeCheharShanbe2Min = restTimeCheharShanbe2.RestTimeMinSplit();
+ var restTimePanjShanbe2 = result.RestTimePanjShanbe2;
+ result.RestTimePanjShanbe2 = restTimePanjShanbe2.RestTimeSplit();
+ result.RestTimePanjShanbe2Min = restTimePanjShanbe2.RestTimeMinSplit();
+ var restTimeJome2 = result.RestTimeJome2;
+ result.RestTimeJome2 = restTimeJome2.RestTimeSplit();
+ result.RestTimeJome2Min = restTimeJome2.RestTimeMinSplit();
+
+ #endregion
+
+ #region week3
+
+ var restTimeShanbe3 = result.RestTimeShanbe3;
+ result.RestTimeShanbe3 = restTimeShanbe3.RestTimeSplit();
+ result.RestTimeShanbe3Min = restTimeShanbe3.RestTimeMinSplit();
+ var restTimeYekShanbe3 = result.RestTimeYekShanbe3;
+ result.RestTimeYekShanbe3 = restTimeYekShanbe3.RestTimeSplit();
+ result.RestTimeYekShanbe3Min = restTimeYekShanbe3.RestTimeMinSplit();
+ var restTimeDoShanbe3 = result.RestTimeDoShanbe3;
+ result.RestTimeDoShanbe3 = restTimeDoShanbe3.RestTimeSplit();
+ result.RestTimeDoShanbe3Min = restTimeDoShanbe3.RestTimeMinSplit();
+ var restTimeSeShanbe3 = result.RestTimeSeShanbe3;
+ result.RestTimeSeShanbe3 = restTimeSeShanbe3.RestTimeSplit();
+ result.RestTimeSeShanbe3Min = restTimeSeShanbe3.RestTimeMinSplit();
+ var restTimeCheharShanbe3 = result.RestTimeCheharShanbe3;
+ result.RestTimeCheharShanbe3 = restTimeCheharShanbe3.RestTimeSplit();
+ result.RestTimeCheharShanbe3Min = restTimeCheharShanbe3.RestTimeMinSplit();
+ var restTimePanjShanbe3 = result.RestTimePanjShanbe3;
+ result.RestTimePanjShanbe3 = restTimePanjShanbe3.RestTimeSplit();
+ result.RestTimePanjShanbe3Min = restTimePanjShanbe3.RestTimeMinSplit();
+ var restTimeJome3 = result.RestTimeJome3;
+ result.RestTimeJome3 = restTimeJome3.RestTimeSplit();
+ result.RestTimeJome3Min = restTimeJome3.RestTimeMinSplit();
+
+ #endregion
+
+ #region week4
+
+ var restTimeShanbe4 = result.RestTimeShanbe4;
+ result.RestTimeShanbe4 = restTimeShanbe4.RestTimeSplit();
+ result.RestTimeShanbe4Min = restTimeShanbe4.RestTimeMinSplit();
+ var restTimeYekShanbe4 = result.RestTimeYekShanbe4;
+ result.RestTimeYekShanbe4 = restTimeYekShanbe4.RestTimeSplit();
+ result.RestTimeYekShanbe4Min = restTimeYekShanbe4.RestTimeMinSplit();
+ var restTimeDoShanbe4 = result.RestTimeDoShanbe4;
+ result.RestTimeDoShanbe4 = restTimeDoShanbe4.RestTimeSplit();
+ result.RestTimeDoShanbe4Min = restTimeDoShanbe4.RestTimeMinSplit();
+ var restTimeSeShanbe4 = result.RestTimeSeShanbe4;
+ result.RestTimeSeShanbe4 = restTimeSeShanbe4.RestTimeSplit();
+ result.RestTimeSeShanbe4Min = restTimeSeShanbe4.RestTimeMinSplit();
+ var restTimeCheharShanbe4 = result.RestTimeCheharShanbe4;
+ result.RestTimeCheharShanbe4 = restTimeCheharShanbe4.RestTimeSplit();
+ result.RestTimeCheharShanbe4Min = restTimeCheharShanbe4.RestTimeMinSplit();
+ var restTimePanjShanbe4 = result.RestTimePanjShanbe4;
+ result.RestTimePanjShanbe4 = restTimePanjShanbe4.RestTimeSplit();
+ result.RestTimePanjShanbe4Min = restTimePanjShanbe4.RestTimeMinSplit();
+ var restTimeJome4 = result.RestTimeJome4;
+ result.RestTimeJome4 = restTimeJome4.RestTimeSplit();
+ result.RestTimeJome4Min = restTimeJome4.RestTimeMinSplit();
+
+ #endregion
+
+ #endregion
+
+ workingHoursList.Add(result); ;
+ }
+
+ if (workingHours.ShiftWork == "4")
+ {
+ var result = new CreateWorkingHoursTemp
+ {
+ EmployeeId = getContracts.First(x => x.id == workingHours.ContractId).EmployeeId,
+ WorknigHoursId = workingHours.id,
+ ShiftWork = workingHours.ShiftWork,
+ ShiftWorkTemp = "4",
+
+ //week1
+ Shanbe1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "1") ? true : false,
+ YekShanbe1 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "1") ? true : false,
+ DoShanbe1 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "1") ? true : false,
+ SeShanbe1 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "1") ? true : false,
+ CheharShanbe1 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "1") ? true : false,
+ PanjShanbe1 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "1") ? true : false,
+ Jome1 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "1") ? true : false,
+
+ RestTimeShanbe1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "1")?.RestTime
+ : null,
+ RestTimeYekShanbe1 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "1")?.RestTime
+ : null,
+ RestTimeDoShanbe1 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "1")?.RestTime
+ : null,
+ RestTimeSeShanbe1 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "1")?.RestTime
+ : null,
+ RestTimeCheharShanbe1 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "1")?.RestTime
+ : null,
+ RestTimePanjShanbe1 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "1")?.RestTime
+ : null,
+ RestTimeJome1 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "1")?.RestTime
+ : null,
+
+ SingleShift1Shanbe1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2Shanbe1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1Shanbe1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2Shanbe1 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "1")?.End2
+ : null,
+
+ SingleShift1YekShanbe1 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2YekShanbe1 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1YekShanbe1 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2YekShanbe1 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "1")?.End2
+ : null,
+
+ SingleShift1DoShanbe1 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2DoShanbe1 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1DoShanbe1 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2DoShanbe1 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "1")?.End2
+ : null,
+
+ SingleShift1SeShanbe1 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2SeShanbe1 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1SeShanbe1 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2SeShanbe1 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "1")?.End2
+ : null,
+
+ SingleShift1CheharShanbe1 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2CheharShanbe1 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1CheharShanbe1 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2CheharShanbe1 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "1")?.End2
+ : null,
+
+ SingleShift1PanjShanbe1 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2PanjShanbe1 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1PanjShanbe1 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2PanjShanbe1 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "1")?.End2
+ : null,
+
+ SingleShift1Jome1 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "1")?.Start1
+ : null,
+ SingleShift2Jome1 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "1")?.End1
+ : null,
+ TowShifts1Jome1 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "1")?.Start2
+ : null,
+ TowShifts2Jome1 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "1")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "1")?.End2
+ : null,
+
+ //week2
+ Shanbe2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "2") ? true : false,
+ YekShanbe2 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "2") ? true : false,
+ DoShanbe2 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "2") ? true : false,
+ SeShanbe2 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "2") ? true : false,
+ CheharShanbe2 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "2") ? true : false,
+ PanjShanbe2 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "2") ? true : false,
+ Jome2 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "2") ? true : false,
+
+ RestTimeShanbe2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "2")?.RestTime
+ : null,
+ RestTimeYekShanbe2 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "2")?.RestTime
+ : null,
+ RestTimeDoShanbe2 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "2")?.RestTime
+ : null,
+ RestTimeSeShanbe2 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "2")?.RestTime
+ : null,
+ RestTimeCheharShanbe2 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "2")?.RestTime
+ : null,
+ RestTimePanjShanbe2 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "2")?.RestTime
+ : null,
+ RestTimeJome2 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "2")?.RestTime
+ : null,
+
+ SingleShift1Shanbe2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2Shanbe2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1Shanbe2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2Shanbe2 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "2")?.End2
+ : null,
+
+ SingleShift1YekShanbe2 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2YekShanbe2 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1YekShanbe2 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2YekShanbe2 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "2")?.End2
+ : null,
+
+ SingleShift1DoShanbe2 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2DoShanbe2 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1DoShanbe2 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2DoShanbe2 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "2")?.End2
+ : null,
+
+ SingleShift1SeShanbe2 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2SeShanbe2 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1SeShanbe2 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2SeShanbe2 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "2")?.End2
+ : null,
+
+ SingleShift1CheharShanbe2 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2CheharShanbe2 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1CheharShanbe2 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2CheharShanbe2 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "2")?.End2
+ : null,
+
+ SingleShift1PanjShanbe2 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2PanjShanbe2 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1PanjShanbe2 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2PanjShanbe2 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "2")?.End2
+ : null,
+
+ SingleShift1Jome2 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "2")?.Start1
+ : null,
+ SingleShift2Jome2 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "2")?.End1
+ : null,
+ TowShifts1Jome2 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "2")?.Start2
+ : null,
+ TowShifts2Jome2 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "2")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "2")?.End2
+ : null,
+
+ //week3
+ Shanbe3 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "3") ? true : false,
+ YekShanbe3 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "3") ? true : false,
+ DoShanbe3 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "3") ? true : false,
+ SeShanbe3 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "3") ? true : false,
+ CheharShanbe3 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "3") ? true : false,
+ PanjShanbe3 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "3") ? true : false,
+ Jome3 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "3") ? true : false,
+
+ RestTimeShanbe3 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "3")?.RestTime
+ : null,
+ RestTimeYekShanbe3 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "3")?.RestTime
+ : null,
+ RestTimeDoShanbe3 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "3")?.RestTime
+ : null,
+ RestTimeSeShanbe3 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "3")?.RestTime
+ : null,
+ RestTimeCheharShanbe3 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "3")?.RestTime
+ : null,
+ RestTimePanjShanbe3 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "3")?.RestTime
+ : null,
+ RestTimeJome3 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "3")?.RestTime
+ : null,
+
+ SingleShift1Shanbe3 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2Shanbe3 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1Shanbe3 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2Shanbe3 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "3")?.End2
+ : null,
+
+ SingleShift1YekShanbe3 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2YekShanbe3 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1YekShanbe3 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2YekShanbe3 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "3")?.End2
+ : null,
+
+ SingleShift1DoShanbe3 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2DoShanbe3 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1DoShanbe3 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2DoShanbe3 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "3")?.End2
+ : null,
+
+ SingleShift1SeShanbe3 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2SeShanbe3 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1SeShanbe3 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2SeShanbe3 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "3")?.End2
+ : null,
+
+ SingleShift1CheharShanbe3 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2CheharShanbe3 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1CheharShanbe3 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2CheharShanbe3 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "3")?.End2
+ : null,
+
+ SingleShift1PanjShanbe3 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2PanjShanbe3 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1PanjShanbe3 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2PanjShanbe3 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "3")?.End2
+ : null,
+
+ SingleShift1Jome3 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "3")?.Start1
+ : null,
+ SingleShift2Jome3 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "3")?.End1
+ : null,
+ TowShifts1Jome3 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "3")?.Start2
+ : null,
+ TowShifts2Jome3 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "3")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "3")?.End2
+ : null,
+
+
+ //week4
+ Shanbe4 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "4") ? true : false,
+ YekShanbe4 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "4") ? true : false,
+ DoShanbe4 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "4") ? true : false,
+ SeShanbe4 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "4") ? true : false,
+ CheharShanbe4 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "4") ? true : false,
+ PanjShanbe4 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "4") ? true : false,
+ Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4") ? true : false,
+
+ RestTimeShanbe4 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "4")?.RestTime
+ : null,
+ RestTimeYekShanbe4 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "4")?.RestTime
+ : null,
+ RestTimeDoShanbe4 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "4")?.RestTime
+ : null,
+ RestTimeSeShanbe4 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "4")?.RestTime
+ : null,
+ RestTimeCheharShanbe4 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "4")?.RestTime
+ : null,
+ RestTimePanjShanbe4 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "4")?.RestTime
+ : null,
+ RestTimeJome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.RestTime
+ : null,
+
+ SingleShift1Shanbe4 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2Shanbe4 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1Shanbe4 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2Shanbe4 = items.Any(x => x.DayOfWork == "0" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "0" && x.WeekNumber == "4")?.End2
+ : null,
+
+ SingleShift1YekShanbe4 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2YekShanbe4 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1YekShanbe4 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2YekShanbe4 = items.Any(x => x.DayOfWork == "1" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "1" && x.WeekNumber == "4")?.End2
+ : null,
+
+ SingleShift1DoShanbe4 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2DoShanbe4 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1DoShanbe4 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2DoShanbe4 = items.Any(x => x.DayOfWork == "2" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "2" && x.WeekNumber == "4")?.End2
+ : null,
+
+ SingleShift1SeShanbe4 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2SeShanbe4 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1SeShanbe4 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2SeShanbe4 = items.Any(x => x.DayOfWork == "3" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "3" && x.WeekNumber == "4")?.End2
+ : null,
+
+ SingleShift1CheharShanbe4 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2CheharShanbe4 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1CheharShanbe4 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2CheharShanbe4 = items.Any(x => x.DayOfWork == "4" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "4" && x.WeekNumber == "4")?.End2
+ : null,
+
+ SingleShift1PanjShanbe4 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2PanjShanbe4 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1PanjShanbe4 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2PanjShanbe4 = items.Any(x => x.DayOfWork == "5" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "5" && x.WeekNumber == "4")?.End2
+ : null,
+
+ SingleShift1Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.Start1
+ : null,
+ SingleShift2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End1
+ : null,
+ TowShifts1Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.Start2
+ : null,
+ TowShifts2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
+ ? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End2
+ : null
+ };
+ //تفکیک ساعت استراحت
+
+ #region TafkikRest
+
+ #region Week1
+
+ var restTimeShanbe1 = result.RestTimeShanbe1;
+ result.RestTimeShanbe1 = restTimeShanbe1.RestTimeSplit();
+ result.RestTimeShanbe1Min = restTimeShanbe1.RestTimeMinSplit();
+ var restTimeYekShanbe1 = result.RestTimeYekShanbe1;
+ result.RestTimeYekShanbe1 = restTimeYekShanbe1.RestTimeSplit();
+ result.RestTimeYekShanbe1Min = restTimeYekShanbe1.RestTimeMinSplit();
+ var restTimeDoShanbe1 = result.RestTimeDoShanbe1;
+ result.RestTimeDoShanbe1 = restTimeDoShanbe1.RestTimeSplit();
+ result.RestTimeDoShanbe1Min = restTimeDoShanbe1.RestTimeMinSplit();
+ var restTimeSeShanbe1 = result.RestTimeSeShanbe1;
+ result.RestTimeSeShanbe1 = restTimeSeShanbe1.RestTimeSplit();
+ result.RestTimeSeShanbe1Min = restTimeSeShanbe1.RestTimeMinSplit();
+ var restTimeCheharShanbe1 = result.RestTimeCheharShanbe1;
+ result.RestTimeCheharShanbe1 = restTimeCheharShanbe1.RestTimeSplit();
+ result.RestTimeCheharShanbe1Min = restTimeCheharShanbe1.RestTimeMinSplit();
+ var restTimePanjShanbe1 = result.RestTimePanjShanbe1;
+ result.RestTimePanjShanbe1 = restTimePanjShanbe1.RestTimeSplit();
+ result.RestTimePanjShanbe1Min = restTimePanjShanbe1.RestTimeMinSplit();
+ var restTimeJome1 = result.RestTimeJome1;
+ result.RestTimeJome1 = restTimeJome1.RestTimeSplit();
+ result.RestTimeJome1Min = restTimeJome1.RestTimeMinSplit();
+
+ #endregion
+
+ #region week2
+
+ var restTimeShanbe2 = result.RestTimeShanbe2;
+ result.RestTimeShanbe2 = restTimeShanbe2.RestTimeSplit();
+ result.RestTimeShanbe2Min = restTimeShanbe2.RestTimeMinSplit();
+ var restTimeYekShanbe2 = result.RestTimeYekShanbe2;
+ result.RestTimeYekShanbe2 = restTimeYekShanbe2.RestTimeSplit();
+ result.RestTimeYekShanbe2Min = restTimeYekShanbe2.RestTimeMinSplit();
+ var restTimeDoShanbe2 = result.RestTimeDoShanbe2;
+ result.RestTimeDoShanbe2 = restTimeDoShanbe2.RestTimeSplit();
+ result.RestTimeDoShanbe2Min = restTimeDoShanbe2.RestTimeMinSplit();
+ var restTimeSeShanbe2 = result.RestTimeSeShanbe2;
+ result.RestTimeSeShanbe2 = restTimeSeShanbe2.RestTimeSplit();
+ result.RestTimeSeShanbe2Min = restTimeSeShanbe2.RestTimeMinSplit();
+ var restTimeCheharShanbe2 = result.RestTimeCheharShanbe2;
+ result.RestTimeCheharShanbe2 = restTimeCheharShanbe2.RestTimeSplit();
+ result.RestTimeCheharShanbe2Min = restTimeCheharShanbe2.RestTimeMinSplit();
+ var restTimePanjShanbe2 = result.RestTimePanjShanbe2;
+ result.RestTimePanjShanbe2 = restTimePanjShanbe2.RestTimeSplit();
+ result.RestTimePanjShanbe2Min = restTimePanjShanbe2.RestTimeMinSplit();
+ var restTimeJome2 = result.RestTimeJome2;
+ result.RestTimeJome2 = restTimeJome2.RestTimeSplit();
+ result.RestTimeJome2Min = restTimeJome2.RestTimeMinSplit();
+
+ #endregion
+
+ #region week3
+
+ var restTimeShanbe3 = result.RestTimeShanbe3;
+ result.RestTimeShanbe3 = restTimeShanbe3.RestTimeSplit();
+ result.RestTimeShanbe3Min = restTimeShanbe3.RestTimeMinSplit();
+ var restTimeYekShanbe3 = result.RestTimeYekShanbe3;
+ result.RestTimeYekShanbe3 = restTimeYekShanbe3.RestTimeSplit();
+ result.RestTimeYekShanbe3Min = restTimeYekShanbe3.RestTimeMinSplit();
+ var restTimeDoShanbe3 = result.RestTimeDoShanbe3;
+ result.RestTimeDoShanbe3 = restTimeDoShanbe3.RestTimeSplit();
+ result.RestTimeDoShanbe3Min = restTimeDoShanbe3.RestTimeMinSplit();
+ var restTimeSeShanbe3 = result.RestTimeSeShanbe3;
+ result.RestTimeSeShanbe3 = restTimeSeShanbe3.RestTimeSplit();
+ result.RestTimeSeShanbe3Min = restTimeSeShanbe3.RestTimeMinSplit();
+ var restTimeCheharShanbe3 = result.RestTimeCheharShanbe3;
+ result.RestTimeCheharShanbe3 = restTimeCheharShanbe3.RestTimeSplit();
+ result.RestTimeCheharShanbe3Min = restTimeCheharShanbe3.RestTimeMinSplit();
+ var restTimePanjShanbe3 = result.RestTimePanjShanbe3;
+ result.RestTimePanjShanbe3 = restTimePanjShanbe3.RestTimeSplit();
+ result.RestTimePanjShanbe3Min = restTimePanjShanbe3.RestTimeMinSplit();
+ var restTimeJome3 = result.RestTimeJome3;
+ result.RestTimeJome3 = restTimeJome3.RestTimeSplit();
+ result.RestTimeJome3Min = restTimeJome3.RestTimeMinSplit();
+
+ #endregion
+
+ #region week4
+
+ var restTimeShanbe4 = result.RestTimeShanbe4;
+ result.RestTimeShanbe4 = restTimeShanbe4.RestTimeSplit();
+ result.RestTimeShanbe4Min = restTimeShanbe4.RestTimeMinSplit();
+ var restTimeYekShanbe4 = result.RestTimeYekShanbe4;
+ result.RestTimeYekShanbe4 = restTimeYekShanbe4.RestTimeSplit();
+ result.RestTimeYekShanbe4Min = restTimeYekShanbe4.RestTimeMinSplit();
+ var restTimeDoShanbe4 = result.RestTimeDoShanbe4;
+ result.RestTimeDoShanbe4 = restTimeDoShanbe4.RestTimeSplit();
+ result.RestTimeDoShanbe4Min = restTimeDoShanbe4.RestTimeMinSplit();
+ var restTimeSeShanbe4 = result.RestTimeSeShanbe4;
+ result.RestTimeSeShanbe4 = restTimeSeShanbe4.RestTimeSplit();
+ result.RestTimeSeShanbe4Min = restTimeSeShanbe4.RestTimeMinSplit();
+ var restTimeCheharShanbe4 = result.RestTimeCheharShanbe4;
+ result.RestTimeCheharShanbe4 = restTimeCheharShanbe4.RestTimeSplit();
+ result.RestTimeCheharShanbe4Min = restTimeCheharShanbe4.RestTimeMinSplit();
+ var restTimePanjShanbe4 = result.RestTimePanjShanbe4;
+ result.RestTimePanjShanbe4 = restTimePanjShanbe4.RestTimeSplit();
+ result.RestTimePanjShanbe4Min = restTimePanjShanbe4.RestTimeMinSplit();
+ var restTimeJome4 = result.RestTimeJome4;
+ result.RestTimeJome4 = restTimeJome4.RestTimeSplit();
+ result.RestTimeJome4Min = restTimeJome4.RestTimeMinSplit();
+
+ #endregion
+
+ #endregion
+
+ workingHoursList.Add(result);
+ }
+ else
+ {
+ var result = new CreateWorkingHoursTemp
+ {
+ EmployeeId = getContracts.First(x => x.id == workingHours.ContractId).EmployeeId,
+ WorknigHoursId = workingHours.id,
+ ShiftWork = workingHours.ShiftWork,
+ ShiftWorkTemp = "5",
+ StartComplex = items.FirstOrDefault()?.ComplexStart,
+ EndComplex = items.FirstOrDefault()?.ComplexEnd,
+ WeeklyWorkingTime = workingHours.WeeklyWorkingTime
+ };
+ workingHoursList.Add(result);
+ }
+ }
+ }
+
+
+
+ #endregion
+
+
+ var workingHoursTime = watcher.Elapsed;
+ watcher.Reset();
+ watcher.Start();
+ //دریافت اطلاعات شروع بکار/ترک کار
+ #region LeftWorks
+
+ var leftWorks = await _context.LeftWorkList
+ .Where(x => x.WorkshopId == workshopId)
+ .Where(x => employeeIds.Contains(x.EmployeeId)).AsNoTracking().ToListAsync();
+
+ #endregion
+
+ var leftWorkTime = watcher.Elapsed;
+ watcher.Reset();
+ watcher.Stop();
+
+ //جداسازی شروع و پایان فیش از قراداد با توجه به شروع بکار و ترک کار
+ #region Separation
+
+ var timer = new Stopwatch();
+ timer.Start();
+ var separation = new List();
+ var seprationData = getContracts.Select(x => new { x.EmployeeId, x.ContarctStart, x.ContractEnd }).ToList();
+
+ 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)
+ {
+ start = current;
+ }
+
+ if (end == new DateTime() && current == checkoutSelectedEnd)
+ {
+ 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 = ContractEnd,
+ HasLeft = true,
+ ContarctStart = start.ToFarsi(),
+ ContractEnd = ContractEnd.ToFarsi(),
+ ContractStartGr = start,
+ ContractEndGr = ContractEnd,
+ checker = true,
+ EmployeeId = contract.EmployeeId
+ });
+ }
+ else if(leftWork.HasLeft && leftWork.LeftWorkDate > leftFirstDayOfNextMonth)
+ {
+ separation.Add(new ContractSeparationViewModel()
+ {
+ StartWorkDate = leftWork.StartWorkDate,
+ LeftWorkDate = leftWork.LeftWorkDate.AddDays(-1),
+ HasLeft = false,
+ ContarctStart = start.ToFarsi(),
+ ContractEnd = end.ToFarsi(),
+ ContractStartGr = start,
+ ContractEndGr = end,
+ checker = true,
+ EmployeeId = contract.EmployeeId
+ });
+ }
+ else if(!leftWork.HasLeft)
+ {
+ separation.Add(new ContractSeparationViewModel()
+ {
+ StartWorkDate = leftWork.StartWorkDate,
+ LeftWorkDate = new DateTime(2121, 3, 21),
+ HasLeft = false,
+ ContarctStart = start.ToFarsi(),
+ ContractEnd = end.ToFarsi(),
+ ContractStartGr = start,
+ ContractEndGr = end,
+ checker = true,
+ EmployeeId = contract.EmployeeId
+ });
+ }
+ }
+
+
+ //foreach (var item in seprationData)
+ //{
+ // bool hasLeft = false;
+ // var ContractEnd = item.ContractEnd;
+ // var contractStart = item.ContarctStart;
+ // var leftWork = leftWorks.FirstOrDefault(x => x.EmployeeId == item.EmployeeId && item.ContarctStart <= x.LeftWorkDate && item.ContractEnd >= x.StartWorkDate);
+ // if (leftWork == null)
+ // {
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // checker = false,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+
+ // if (leftWork.HasLeft && leftWork.LeftWorkDate < item.ContractEnd &&
+ // leftWork.LeftWorkDate >= item.ContarctStart)
+ // {
+ // ContractEnd = leftWork.LeftWorkDate.AddDays(-1);
+ // hasLeft = true;
+ // var start = contractStart.ToFarsi();
+ // var end = ContractEnd.ToFarsi();
+ // var ContractPreiodsList = new List();
+ // var CheckoutMonth = int.Parse(month);
+
+ // var syear = Convert.ToInt32(start.Substring(0, 4));
+ // var smonth = Convert.ToInt32(start.Substring(5, 2));
+ // var sday = Convert.ToInt32(start.Substring(8, 2));
+
+ // var eyear = Convert.ToInt32(end.Substring(0, 4));
+ // var emonth = Convert.ToInt32(end.Substring(5, 2));
+ // var eday = Convert.ToInt32(end.Substring(8, 2));
+
+ // var PersianStartDate = new PersianDateTime(syear, smonth, sday);
+ // var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1);
+ // var PersianEndDate = new PersianDateTime(eyear, emonth, eday);
+
+
+ // var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1;
+ // for (int i = 0; i < totalmonth; i++)
+ // {
+
+
+ // var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1);
+ // if (currentEndDate > PersianEndDate)
+ // {
+ // currentEndDate = PersianEndDate;
+ // }
+
+ // var period = new PeriodStartEnd
+ // {
+ // startC = PersianStartDate.ToString("yyyy/MM/dd"),
+ // endC = currentEndDate.ToString("yyyy/MM/dd"),
+ // monthC = currentEndDate.Month
+ // };
+ // ContractPreiodsList.Add(period);
+ // //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}");
+
+ // PersianStartDate = PersianStartDate.AddMonths(1);
+ // PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1);
+
+
+ // }
+
+ // var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth);
+ // if (periodSelect != null)
+ // {
+ // var startDate = periodSelect.startC.ToGeorgianDateTime();
+ // var endDate = periodSelect.endC.ToGeorgianDateTime();
+
+
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // StartWorkDate = leftWork.StartWorkDate,
+ // LeftWorkDate = ContractEnd,
+ // HasLeft = hasLeft,
+ // ContarctStart = periodSelect.startC,
+ // ContractEnd = periodSelect.endC,
+ // ContractStartGr = startDate,
+ // ContractEndGr = endDate,
+ // checker = true,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ // else
+ // {
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // checker = false,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ // }
+
+ // if (leftWork.HasLeft && leftWork.LeftWorkDate >= item.ContractEnd &&
+ // leftWork.LeftWorkDate > item.ContarctStart)
+ // {
+ // var lastWorkDay = leftWork.LeftWorkDate.AddDays(-1);
+
+ // if (leftWork.LeftWorkDate == ContractEnd)
+ // {
+ // ContractEnd = lastWorkDay;
+ // hasLeft = true;
+ // }
+
+ // if (lastWorkDay == ContractEnd)
+ // {
+ // hasLeft = true;
+ // }
+
+ // var start = contractStart.ToFarsi();
+ // var end = ContractEnd.ToFarsi();
+ // var ContractPreiodsList = new List();
+ // var CheckoutMonth = int.Parse(month);
+
+ // var syear = Convert.ToInt32(start.Substring(0, 4));
+ // var smonth = Convert.ToInt32(start.Substring(5, 2));
+ // var sday = Convert.ToInt32(start.Substring(8, 2));
+
+ // var eyear = Convert.ToInt32(end.Substring(0, 4));
+ // var emonth = Convert.ToInt32(end.Substring(5, 2));
+ // var eday = Convert.ToInt32(end.Substring(8, 2));
+
+ // var PersianStartDate = new PersianDateTime(syear, smonth, sday);
+ // var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1);
+ // var PersianEndDate = new PersianDateTime(eyear, emonth, eday);
+
+
+
+ // var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1;
+ // for (int i = 0; i < totalmonth; i++)
+ // {
+
+
+ // var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1);
+ // if (currentEndDate > PersianEndDate)
+ // {
+ // currentEndDate = PersianEndDate;
+ // }
+
+ // var period = new PeriodStartEnd
+ // {
+ // startC = PersianStartDate.ToString("yyyy/MM/dd"),
+ // endC = currentEndDate.ToString("yyyy/MM/dd"),
+ // monthC = currentEndDate.Month
+ // };
+ // ContractPreiodsList.Add(period);
+ // //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}");
+
+ // PersianStartDate = PersianStartDate.AddMonths(1);
+ // PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1);
+
+
+ // }
+
+ // var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth);
+ // if (periodSelect != null)
+ // {
+ // var startDate = periodSelect.startC.ToGeorgianDateTime();
+ // var endDate = periodSelect.endC.ToGeorgianDateTime();
+
+
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // StartWorkDate = leftWork.StartWorkDate,
+ // LeftWorkDate = ContractEnd,
+ // HasLeft = hasLeft,
+ // ContarctStart = periodSelect.startC,
+ // ContractEnd = periodSelect.endC,
+ // ContractStartGr = startDate,
+ // ContractEndGr = endDate,
+ // checker = true,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ // else
+ // {
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // checker = false,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ // }
+ // else if (leftWork.HasLeft && contractStart > leftWork.LeftWorkDate)
+ // {
+
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // checker = false,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ // else if (!leftWork.HasLeft)
+ // {
+ // var start = contractStart.ToFarsi();
+ // var end = ContractEnd.ToFarsi();
+ // var ContractPreiodsList = new List();
+ // var CheckoutMonth = int.Parse(month);
+
+ // var syear = Convert.ToInt32(start.Substring(0, 4));
+ // var smonth = Convert.ToInt32(start.Substring(5, 2));
+ // var sday = Convert.ToInt32(start.Substring(8, 2));
+
+ // var eyear = Convert.ToInt32(end.Substring(0, 4));
+ // var emonth = Convert.ToInt32(end.Substring(5, 2));
+ // var eday = Convert.ToInt32(end.Substring(8, 2));
+
+ // var PersianStartDate = new PersianDateTime(syear, smonth, sday);
+ // var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1);
+ // var PersianEndDate = new PersianDateTime(eyear, emonth, eday);
+
+ // var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1;
+ // for (int i = 0; i < totalmonth; i++)
+ // {
+
+
+ // var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1);
+ // if (currentEndDate > PersianEndDate)
+ // {
+ // currentEndDate = PersianEndDate;
+ // }
+
+ // var period = new PeriodStartEnd
+ // {
+ // startC = PersianStartDate.ToString("yyyy/MM/dd"),
+ // endC = currentEndDate.ToString("yyyy/MM/dd"),
+ // monthC = currentEndDate.Month
+ // };
+ // ContractPreiodsList.Add(period);
+ // //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}");
+
+ // PersianStartDate = PersianStartDate.AddMonths(1);
+ // PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1);
+
+
+ // }
+
+ // var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth);
+ // if (periodSelect != null)
+ // {
+ // var startDate = periodSelect.startC.ToGeorgianDateTime();
+ // var endDate = periodSelect.endC.ToGeorgianDateTime();
+
+
+
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // StartWorkDate = leftWork.StartWorkDate,
+ // HasLeft = hasLeft,
+ // ContarctStart = periodSelect.startC,
+ // ContractEnd = periodSelect.endC,
+ // ContractStartGr = startDate,
+ // ContractEndGr = endDate,
+ // checker = true,
+ // LeftWorkDate = new DateTime(2121, 3, 21),
+ // EmployeeId = item.EmployeeId
+ // });
+
+
+ // }
+ // else
+ // {
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // checker = false,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ // }
+ // else
+ // {
+ // separation.Add(new ContractSeparationViewModel()
+ // {
+ // checker = false,
+ // EmployeeId = item.EmployeeId
+ // });
+
+ // }
+ //}
+
+
+
+ #endregion
+
+
+ var SeparationTime = timer.Elapsed;
+ timer.Stop();
+ var optionTimer = new Stopwatch();
+ optionTimer.Start();
+ //دریافت تنظیمات فنی پرسنل ها
+ #region EmployeeOptions
+
+ var employeeOptions = await _context.EmployeeComputeOptionsSet.Where(x => x.WorkshopId == workshopId).Select(x => new EmployeeComputeOptionsViewModel
+ {
+ Id = x.id,
+ WorkshopId = x.WorkshopId,
+ EmployeeId = x.EmployeeId,
+ ComputeOptions = x.ComputeOptions,
+ YearsOptions = x.YearsOptions,
+ BonusesOptions = x.BonusesOptions,
+ }).AsNoTracking().ToListAsync();
+
+ #endregion
+
+ var optionTime = optionTimer.Elapsed;
+ optionTimer.Stop();
+
+
+ var toListTimer = new Stopwatch();
+ toListTimer.Start();
+ var yearsOption = workshop.YearsOptions;
+ var bonusesOption = workshop.BonusesOptions;
+ var computeOption = workshop.ComputeOptions;
+ var incloudedData = getContracts.Select(x =>
+ {
+
+ var employeeOption = employeeOptions.FirstOrDefault(option => option.EmployeeId == x.EmployeeId);
+ if(employeeOption != null)
+ {
+ yearsOption = employeeOption.YearsOptions;
+ bonusesOption = employeeOption.BonusesOptions;
+ computeOption = employeeOption.ComputeOptions;
+ }
+ return new ContractIncludedData
+ {
+ //اطلاعات هویتی پرسنل
+ #region EmployeeData
+ EmployeeId = x.EmployeeId,
+ EmployeeFullName = x.Employee.FullName,
+ FathersName = x.Employee.FatherName,
+ NationalCode = x.Employee.NationalCode,
+ DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
+ PersonnelCode = $"{x.PersonnelCode}",
+ MaritalStatus = x.Employee.MaritalStatus,
+ #endregion
+
+ //ساعت کاری پرسنل
+ #region WorkingHours
+ WorkingHours = workingHoursList.FirstOrDefault(wh => wh.EmployeeId == x.EmployeeId),
+ #endregion
+
+ //اطلاعات جداسازی تاریخ فیش از قرارداد
+ #region Saparation
+ Separation = separation.FirstOrDefault(sep => sep.EmployeeId == x.EmployeeId),
+ #endregion
+
+ //تنظیمات فنی پرسنل
+ #region EmployeeOption
+
+ YearsOption = yearsOption,
+ BonusesOption = bonusesOption,
+ ComputeOption = computeOption,
+
+ #endregion
+
+ //اطلاعات قراداد
+ #region ContractData
+
+ ContractNo = x.ContractNo,
+ ContractStart = x.ContarctStart.ToFarsi(),
+ ContractEnd = x.ContractEnd.ToFarsi(),
+ ContractStartGr = x.ContarctStart,
+ ContractEndGr = x.ContractEnd,
+ ContractId = x.id,
+ DailySalaryUnAffected = x.DailySalaryUnAffected,
+ DailyWageType = x.DailyWageType,
+ FirstGetWorkingDay = x.GetWorkDate.ToFarsi(),
+ #endregion
+ };
+ }).ToList();
+
+ var finalResult = new GetContractAndIncludesDataToCreateDto()
+ {
+ //اطلاعات کارگاه
+ #region WorkshopData
+
+ WorkshopId = workshop.id,
+ ArchiveCode = workshop.ArchiveCode,
+ WorkshopName = workshop.WorkshopName,
+ IsStaticCheckout = workshop.IsStaticCheckout,
+ HasInsuranceCheckoutOverTime = workshop.InsuranceCheckoutOvertime,
+ FixedSalary = workshop.FixedSalary,
+ InsuranceJobId = workshop.InsuranceJobId,
+ Population = workshop.Population,
+ TypeOfInsuranceSend = workshop.TypeOfInsuranceSend,
+
+ #endregion
+
+
+ ContractIncludedData = incloudedData,
+ };
+
+ var tolistTime = toListTimer.Elapsed;
+ Console.WriteLine("GetContracts - employeeIds - workshop: " + GetContractsTime);
+ Console.WriteLine("workingHours " + workingHoursTime);
+ Console.WriteLine("leftWork " + leftWorkTime);
+ Console.WriteLine("Separation " + SeparationTime);
+ Console.WriteLine("EmployeeOptions : " + optionTime);
+ Console.WriteLine("TolistTime : " + tolistTime);
+ Console.WriteLine("===================== sum : " + (GetContractsTime + workingHoursTime + leftWorkTime + SeparationTime + optionTime + tolistTime) + "===================");
+
+
+ return op.Succcedded(finalResult);
+
+ }
#endregion
diff --git a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs
index b0832169..bbc15222 100644
--- a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs
+++ b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using _0_Framework.Application;
+using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.RollCallEmployeeAgg;
using Company.Domain.RollCallEmployeeStatusAgg;
@@ -13,6 +8,12 @@ using CompanyManagment.App.Contracts.RollCallEmployee;
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace CompanyManagment.EFCore.Repository;
@@ -39,7 +40,7 @@ public class RollCallEmployeeRepository : RepositoryBase
}
- public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
+ public async Task HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
//موقت
// دادمهرگستر 11 *
@@ -89,8 +90,8 @@ public class RollCallEmployeeRepository : RepositoryBase
//if (rollCallEmployee == null)
// return false;
- var rollCallEmployee = _context.RollCallEmployees.Include(xs => xs.EmployeesStatus)
- .FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
+ var rollCallEmployee =await _context.RollCallEmployees.Include(xs => xs.EmployeesStatus)
+ .FirstOrDefaultAsync(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
//اگر تنظیمات حضور غیاب نداشت
if (rollCallEmployee == null)
return false;
@@ -99,8 +100,8 @@ public class RollCallEmployeeRepository : RepositoryBase
if (!rollCallEmployee.EmployeesStatus.Any())
return false;
- var leftWork =
- _context.LeftWorkList.FirstOrDefault(x =>
+ var leftWork = await
+ _context.LeftWorkList.FirstOrDefaultAsync(x =>
x.StartWorkDate <= contractEnd.Date && x.LeftWorkDate > contractStart);
if (leftWork == null)
return false;
diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs
index 7b6d8a7e..ee367bc9 100644
--- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs
+++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs
@@ -65,7 +65,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll
#region OfficialChckout
- public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart,
+ public async Task MandatoryCompute(long employeeId, long workshopId, DateTime contractStart,
DateTime contractEnd,
CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute,
double dailyWageUnAffected, bool totalLeaveCompute)
@@ -86,7 +86,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll
int TotalContractDays = (int)(contractEnd - contractStart).TotalDays + 1;
int fridays = 0;
- int holiday = _context.HolidayItems.Count(x => x.Holidaydate >= contractStart && x.Holidaydate <= contractEnd);
+ int holiday =await _context.HolidayItems.CountAsync(x => x.Holidaydate >= contractStart && x.Holidaydate <= contractEnd);
;
for (var gDate = contractStart; gDate <= contractEnd; gDate = gDate.AddDays(1))
{
@@ -117,8 +117,8 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll
#region breakTime
- BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery()
- .Include(x => x.CustomizeWorkshopGroupSettings).FirstOrDefault(x =>
+ BaseCustomizeEntity settings =await _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery()
+ .Include(x => x.CustomizeWorkshopGroupSettings).FirstOrDefaultAsync(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
//اگر ساعت استراحت پرسنل وجود نداشت صفر است
var breakTimeEntity = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
@@ -196,7 +196,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll
}
else
{
- rollCallResult = _context.RollCalls.Where(x =>
+ rollCallResult =await _context.RollCalls.Where(x =>
x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
x.StartDate.Value.Date >= contractStart.Date &&
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel()
@@ -206,7 +206,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll
ShiftSpan = (x.EndDate.Value - x.StartDate.Value),
CreationDate = x.ShiftDate,
BreakTimeSpan = x.BreakTimeSpan
- }).ToList();
+ }).ToListAsync();
groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x =>
{
diff --git a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs
index 158a3de6..91609dbe 100644
--- a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs
+++ b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs
@@ -2789,7 +2789,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl
private (bool hasRollCall, double WorkingTotalHours) GetTotalWorkingHoursIfHasRollCall(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
bool hasRollCall = _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId,
- contractStart, contractEnd);
+ contractStart, contractEnd).GetAwaiter().GetResult();
double totalWorkingHours = 0;
if (!hasRollCall)
return (false, 0);
diff --git a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs
index 295d50b7..f572d293 100644
--- a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs
+++ b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs
@@ -6,6 +6,7 @@ using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.App.Contracts.Workshop.DTOs;
using Microsoft.AspNetCore.Mvc;
using NuGet.Packaging.Signing;
+using NuGet.Protocol;
using ServiceHost.BaseControllers;
using WorkFlow.Application.Contracts.WorkFlow;
@@ -108,16 +109,84 @@ public class CheckoutController : AdminBaseController
[HttpGet("GetContractsToCreateCheckout")]
public async Task>> GetContractsToCreateCheckout(long workshopId, string year, string month, long employeeId)
{
-
+
var result =await _checkoutApplication.GetContractToCreateCheckout(workshopId, year, month, employeeId);
if (!result.IsSuccedded)
return result;
- var hasWorkFlow =await _workFlowApplication.HasWorkFlow(workshopId, year, month);
+ //var hasWorkFlow =await _workFlowApplication.HasWorkFlow(workshopId, year, month);
- if (hasWorkFlow)
- return new OperationResult>().Failed(
- "این کارگاه به دلیل داشتن کارپوشه مجاز به ایجاد تصفیه حساب نمی باشد");
+ //if (hasWorkFlow)
+ // return new OperationResult>().Failed(
+ // "این کارگاه به دلیل داشتن کارپوشه مجاز به ایجاد تصفیه حساب نمی باشد");
+
+
+ return result;
+
+ }
+
+ ///
+ /// ایجاد فیش حقوقی
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> CreateCheckout([FromBody] CreateCheckoutDto command)
+ {
+ var op = new OperationResult();
+ //var ids = new
+ // List()
+ // {
+ // 283652, 290314, 290315, 290316, 290317, 290318, 290319, 290320, 290321, 290322, 290323, 290324, 290325,
+ // 290326, 290327, 290328, 290329, 290330, 290331, 290332, 290333, 290334, 290335, 290336, 290337, 290338,
+ // 290339, 290340, 290341, 290342, 290343, 290344, 290345, 290346, 290347, 290348, 290349, 290350, 290351,
+ // 290352, 290353, 290354, 290355, 290356, 290357, 290358, 290359, 290360, 290361, 290362, 290363, 290364,
+ // 290365, 290366, 290367, 290368, 290369, 290370, 290371, 290372, 290373, 290374, 290375, 290376, 290377,
+ // 290378, 290379, 290380, 290381, 290382, 290383, 290384, 290385, 290386, 290387, 290388, 290389, 290390,
+ // 290391, 290392, 290393, 290394, 290395, 290396, 290397, 290398, 290399, 290400, 290401, 290402, 290403,
+ // 290404, 290405, 290406, 290407, 290408, 290409, 290410, 290411, 290412, 290413, 290414, 290415, 290416,
+ // 290417, 290418, 290419, 290420, 290421, 290422, 290423, 290424, 290425, 290426, 290427, 290428, 290429,
+ // 290430, 290431, 290432, 290433, 290434, 290435, 290436, 290437, 290438, 290439, 290440, 290441, 290442,
+ // 290443, 290444, 290445, 290446, 290447, 290448, 290449, 290450, 290451, 290452, 290453, 290454, 290455,
+ // 290456, 290457, 290458, 290459, 290460, 290461, 290462, 290463, 290464, 290465, 290466, 290467, 290468,
+ // 290469, 290470, 290471, 290472, 290473, 290474, 290475, 290476, 290477, 290478, 290479, 290480, 290481,
+ // 290482, 290483, 290484, 290485, 290486, 290487, 290488, 290489, 290490, 290491, 290492, 290493, 290494,
+ // 290495, 290496, 290497, 290498, 290499, 290500, 290501, 290502, 290503, 290504, 290505, 290506, 290507,
+ // 290508, 290509, 290510, 290511, 290512, 290513, 290514, 290515, 290516, 290517, 290518, 290519, 290520,
+ // 290521, 290522, 290523, 290524, 290525, 290526, 290527, 290528, 290529, 290530, 290531, 290532, 290533,
+ // 290534, 290535, 290536, 290537, 290538, 290539, 290540, 290541, 290542, 290543, 290544, 290545, 290546,
+ // 290547, 290548, 290549, 290550, 290551, 290552, 290553, 290554, 290555, 290556, 290557, 290558, 290559,
+ // 290560, 290561, 290562, 290563, 290564, 290565, 290566, 290567, 290568, 290569, 290570, 290571, 290572,
+ // 290573, 290574, 290575, 290576, 290577, 290578, 290579, 290580, 290581, 290582, 290583, 290584, 290585,
+ // 299612, 290587, 290588
+ // };
+ //command.Ids = new List(){ 290449 };
+
+ if (!string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month))
+ return op.Failed("ماه را انتخاب کنید");
+ if (string.IsNullOrWhiteSpace(command.year) && !string.IsNullOrWhiteSpace(command.Month))
+ return op.Failed("سال را انتخاب کنید");
+
+ if (string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month))
+ {
+
+
+ var today = DateTime.Now;
+ var FaToday = today.ToFarsi();
+ var convertedYear = FaToday.Substring(0, 4);
+ var convertedMonth = FaToday.Substring(5, 2);
+
+ command.year = convertedYear;
+ command.Month = convertedMonth;
+ }
+
+ if (command.WorkshopId == 0)
+ return op.Failed("کارگاه انتخاب نشده است");
+ if (command.Ids.Count == 0)
+ return op.Failed("هیچ موردی انتخاب نشده است");
+
+
+ var result = await _checkoutApplication.CreateCheckoutApi(command.Ids, command.year, command.Month, command.WorkshopId);
return result;
}
@@ -125,3 +194,12 @@ public class CheckoutController : AdminBaseController
}
+public class CreateCheckoutDto
+{
+ public List Ids { get; set; }
+ public string year { get; set; }
+ public string Month { get; set; }
+ public long WorkshopId { get; set; }
+}
+
+
diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs
index 548c701d..732608e0 100644
--- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs
+++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs
@@ -38,6 +38,7 @@ using Company.Domain.InsuranceListAgg;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.EFCore.Repository;
using System.Linq;
+using CompanyManagment.App.Contracts.Hubs;
namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts;
@@ -7853,6 +7854,8 @@ public class IndexModel : PageModel
}
#endregion
+
+
}
diff --git a/ServiceHost/Hubs/CheckoutHub.cs b/ServiceHost/Hubs/CheckoutHub.cs
deleted file mode 100644
index 3d688680..00000000
--- a/ServiceHost/Hubs/CheckoutHub.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Microsoft.AspNetCore.SignalR;
-
-namespace ServiceHost.Hubs
-{
- public class CheckoutHub : Hub
- {
-
- public async Task send(long id)
- {
- await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(id));
- }
-
- public static string GetGroupName(long id)
- {
- return $"group-Checkout-{id}";
- }
- }
-}