diff --git a/CompanyManagment.App.Contracts/Leave/CheckIsInvalidLeaveDto.cs b/CompanyManagment.App.Contracts/Leave/CheckIsInvalidLeaveDto.cs
new file mode 100644
index 00000000..656e8e36
--- /dev/null
+++ b/CompanyManagment.App.Contracts/Leave/CheckIsInvalidLeaveDto.cs
@@ -0,0 +1,15 @@
+namespace CompanyManagment.App.Contracts.Leave;
+
+public class CheckIsInvalidLeaveDto
+{
+ ///
+ /// آیا تعطیل است
+ ///
+ public bool IsHoliday { get; set; }
+
+ ///
+ /// فاقد/دارای اعتبار فیش غیر رسمی
+ ///
+ public bool CanCreateInvalid { get; set; }
+
+}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/Leave/CreateLeaveDto.cs b/CompanyManagment.App.Contracts/Leave/CreateLeaveDto.cs
new file mode 100644
index 00000000..8f9c9f63
--- /dev/null
+++ b/CompanyManagment.App.Contracts/Leave/CreateLeaveDto.cs
@@ -0,0 +1,78 @@
+using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
+
+namespace CompanyManagment.App.Contracts.Leave;
+
+public class CreateLeaveDto
+{
+ ///
+ /// تاریخ شروع مرخصی
+ ///
+ [Required(ErrorMessage = "این مقدار نمی تواند خالی باشد")]
+ public string StartLeave { get; set; }
+
+
+ ///
+ /// تاریخ پایان مرخصی
+ ///
+ [Required(ErrorMessage = "این مقدار نمی تواند خالی باشد")]
+ public string EndLeave { get; set; }
+
+ ///
+ /// آی دی کارگاه
+ ///
+ public long WorkshopId { get; set; }
+
+ ///
+ /// آی دی پرسنل
+ ///
+ public long EmployeeId { get; set; }
+
+ ///
+ /// نوع مدت مرخص روزانه/ ساعتی
+ ///
+ public PaidLeaveType PaidLeaveType { get; set; }
+
+ ///
+ /// نوع مرخصی استحقاقی/استعلاجی
+ ///
+ public LeaveType LeaveType { get; set; }
+
+ ///
+ /// نام کامل کارگاه
+ ///
+ public string WorkshopName { get; set; }
+
+ ///
+ /// ساعت شروع مرخصی
+ ///
+ public string StartHoures { get; set; }
+
+ ///
+ /// ساعت پایان مرخصی
+ ///
+ public string EndHours { get; set; }
+
+ ///
+ /// موافقت / عدم موافقت کارفرما
+ ///
+ public bool IsAccepted { get; set; }
+
+ ///
+ /// توضیحات
+ ///
+ public string Decription { get; set; }
+
+
+ public List RotatingShifts { get; set; }
+
+ ///
+ /// دارای اعتبار / فاقد اعتبار فیش غیررسمی
+ ///
+ public bool IsInvallid { get; set; }
+ public CustomizeRotatingShiftsViewModel SelectedShift { get; set; }
+
+}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs b/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs
index 4185d007..3234526e 100644
--- a/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs
+++ b/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs
@@ -70,7 +70,33 @@ public interface ILeaveApplication
Task> PrintAllAsync(List ids, long workshopId);
Task PrintOneAsync(long id, long workshopId);
-
+
+ ///
+ /// چک میکند که تاریخ وارد شده در شروع مرخصی تعطیل است یا خیر
+ /// دارای/فاقد اعتبار فیش غیررسمی را چک میکند
+ ///
+ ///
+ ///
+ ///
+ Task> CheckIsInvalidLeave(string startLeaveDate, long workshopId);
+
+ ///
+ /// ایجاد مرخصی از ای پی آی
+ ///
+ ///
+ ///
+ Task CreateLeave(CreateLeaveDto command);
+
+ ///
+ /// چک میکند که آیا پرسنل حضور غیاب دارای شیفت گردشی دارد یا خیر
+ /// اگر داشت دریافت شیف گردشی
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> HasRotatingShift(long workshopId, long employeeId, string startLeaveDate);
+
}
public class LeavePrintResponseViewModel
diff --git a/CompanyManagment.App.Contracts/Leave/PaidLeaveType.cs b/CompanyManagment.App.Contracts/Leave/PaidLeaveType.cs
new file mode 100644
index 00000000..b77340bf
--- /dev/null
+++ b/CompanyManagment.App.Contracts/Leave/PaidLeaveType.cs
@@ -0,0 +1,17 @@
+namespace CompanyManagment.App.Contracts.Leave;
+
+///
+/// نوع مدت مرخصی
+///
+public enum PaidLeaveType
+{
+ ///
+ /// روزانه
+ ///
+ Daily,
+
+ ///
+ /// ساعتی
+ ///
+ Hourly,
+}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/Leave/RotatingShiftDto.cs b/CompanyManagment.App.Contracts/Leave/RotatingShiftDto.cs
new file mode 100644
index 00000000..b22120e6
--- /dev/null
+++ b/CompanyManagment.App.Contracts/Leave/RotatingShiftDto.cs
@@ -0,0 +1,17 @@
+using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
+using System.Collections.Generic;
+
+namespace CompanyManagment.App.Contracts.Leave;
+
+public class RotatingShiftDto
+{
+ ///
+ /// آیا حضورغیاب به همراه گروهبندی گردشی دارد
+ ///
+ public bool HasRollCall {get; set;}
+
+ ///
+ /// لیست شیفت های گردشی پرسنل
+ ///
+ public List RotatingShifts { get; set; }
+}
\ No newline at end of file
diff --git a/CompanyManagment.Application/LeaveApplication.cs b/CompanyManagment.Application/LeaveApplication.cs
index 63c50d32..1b3a998a 100644
--- a/CompanyManagment.Application/LeaveApplication.cs
+++ b/CompanyManagment.Application/LeaveApplication.cs
@@ -1,18 +1,25 @@
-using System;
+using _0_Framework.Application;
+using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
+using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
+using Company.Domain.EmployeeAgg;
+using Company.Domain.HolidayItemAgg;
+using Company.Domain.LeaveAgg;
+using Company.Domain.RollCallAgg;
+using Company.Domain.RollCallServiceAgg;
+using Company.Domain.WorkshopAgg;
+using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
+using CompanyManagment.App.Contracts.HolidayItem;
+using CompanyManagment.App.Contracts.Leave;
+using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
+using CompanyManagment.App.Contracts.RollCallService;
+using CompanyManagment.EFCore.Migrations;
+using Microsoft.AspNetCore.Mvc;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using _0_Framework.Application;
-using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
-using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
-using Company.Domain.EmployeeAgg;
-using Company.Domain.LeaveAgg;
-using Company.Domain.RollCallAgg;
-using Company.Domain.WorkshopAgg;
-using CompanyManagment.App.Contracts.Leave;
-using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
namespace CompanyManagment.Application;
@@ -24,9 +31,12 @@ public class LeaveApplication : ILeaveApplication
private readonly IRollCallRepository _rollCallRepository;
private readonly ICustomizeWorkshopEmployeeSettingsRepository _employeeSettingsRepository;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
+ private readonly IHolidayItemRepository _holidayItemRepository;
+ private readonly IRollCallServiceRepository _rollCallServiceRepository;
+
- public LeaveApplication(ILeaveRepository leaveRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workshopRepository, IRollCallRepository rollCallRepository, ICustomizeWorkshopEmployeeSettingsRepository employeeSettingsRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication)
+ public LeaveApplication(ILeaveRepository leaveRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workshopRepository, IRollCallRepository rollCallRepository, ICustomizeWorkshopEmployeeSettingsRepository employeeSettingsRepository, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IHolidayItemRepository holidayItemRepository, IRollCallServiceRepository rollCallServiceRepository)
{
_leaveRepository = leaveRepository;
_employeeRepository = employeeRepository;
@@ -34,6 +44,8 @@ public class LeaveApplication : ILeaveApplication
_rollCallRepository = rollCallRepository;
_employeeSettingsRepository = employeeSettingsRepository;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
+ _holidayItemRepository = holidayItemRepository;
+ _rollCallServiceRepository = rollCallServiceRepository;
}
public OperationResult Create(CreateLeave command)
@@ -238,7 +250,7 @@ public class LeaveApplication : ILeaveApplication
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
- var leave = new Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
+ var leave = new Company.Domain.LeaveAgg.Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
, command.PaidLeaveType, command.LeaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription,
year, month, shiftDuration, hasShiftDuration,command.IsInvallid);
_leaveRepository.Create(leave);
@@ -672,5 +684,280 @@ public class LeaveApplication : ILeaveApplication
return (await _leaveRepository.PrintAllAsync([id],workshopId)).FirstOrDefault();
}
+
+ public async Task> CheckIsInvalidLeave(string startLeaveDate, long workshopId)
+ {
+ var op = new OperationResult();
+ var result = new CheckIsInvalidLeaveDto();
+ if (startLeaveDate.TryToGeorgianDateTime(out var startLeaveDateGr) == false)
+ {
+ return op.Failed("تاریخ وارد شده صحیح نیست");
+ }
+
+ if (startLeaveDateGr.DayOfWeek == DayOfWeek.Friday || _holidayItemRepository.GetHoliday(startLeaveDateGr))
+ {
+ result.IsHoliday = true;
+ }
+
+ if (result.IsHoliday)
+ {
+ var rollCallService = _rollCallServiceRepository.GetActiveServiceByWorkshopId(workshopId);
+ if (rollCallService != null)
+ {
+ result.CanCreateInvalid = rollCallService.HasCustomizeCheckoutService == "true";
+ }
+ }
+
+ return op.Succcedded(result);
+ }
+
+
+ public async Task CreateLeave(CreateLeaveDto command)
+ {
+ TimeSpan shiftDuration = TimeSpan.Zero;
+ bool hasShiftDuration = false;
+ var startH = new TimeSpan();
+ var endH = new TimeSpan();
+ var op = new OperationResult();
+ if ((command.PaidLeaveType == PaidLeaveType.Daily && command.LeaveType == LeaveType.PaidLeave) || command.LeaveType == LeaveType.SickLeave)
+ {
+ if (string.IsNullOrWhiteSpace(command.StartLeave))
+ {
+ return op.Failed("لطفا تاریخ شروع را وارد کنید");
+ }
+ if (string.IsNullOrWhiteSpace(command.EndLeave))
+ {
+ return op.Failed("لطفا تاریخ پایان را وارد کنید");
+ }
+ }
+ else if (command.PaidLeaveType == PaidLeaveType.Hourly)
+ {
+ if (string.IsNullOrWhiteSpace(command.StartLeave))
+ return op.Failed("لطفا تاریخ شروع را وارد کنید");
+ if (string.IsNullOrWhiteSpace(command.StartHoures) || string.IsNullOrWhiteSpace(command.EndHours))
+ return op.Failed("ساعت شروع و پایان نمیتواند خالی باشد");
+
+ string pattern = @"^([01]\d|2[0-3]):[0-5]\d$";
+
+ if (!Regex.IsMatch(command.StartHoures, pattern))
+ return op.Failed("لطفا ساعت شروع را به درستی وارد کنید");
+
+ if (!Regex.IsMatch(command.EndHours, pattern))
+ return op.Failed("لطفا ساعت پایان را به درستی وارد کنید");
+
+ startH = TimeSpan.Parse(command.StartHoures);
+ endH = TimeSpan.Parse(command.EndHours);
+ if (startH == endH)
+ return op.Failed("ساعت شروع و پایان نباید برابر باشد");
+ }
+
+
+ //if (command.LeaveType == LeaveType.SickLeave && string.IsNullOrWhiteSpace(command.StartLeave))
+ // return op.Failed("لطفا تاریخ شروع را وارد کنید");
+ //if (command.LeaveType == LeaveType.SickLeave && string.IsNullOrWhiteSpace(command.EndLeave))
+ // return op.Failed("لطفا تاریخ پایان را وارد کنید");
+
+
+ if (command.StartLeave.TryToGeorgianDateTime(out var start) == false)
+ {
+ return op.Failed("تاریخ شروع صحیح نیست");
+ }
+
+ var end = new DateTime();
+ if (command.PaidLeaveType == PaidLeaveType.Daily)
+ {
+ if (command.EndLeave.TryToGeorgianDateTime(out end) == false)
+ {
+ return op.Failed("تاریخ پایان صحیح نیست");
+ }
+ }
+ end = start;
+
+
+ var checkErr = _leaveRepository.CheckErrors(start, end, command.EmployeeId, command.WorkshopId, command.IsInvallid);
+
+
+ if (checkErr.HasChekout)
+ return op.Failed(checkErr.CheckoutErrMessage);
+ if (checkErr.HasNotContract)
+ return op.Failed(checkErr.ContractErrMessage);
+ if (checkErr.HasLeftWork)
+ return op.Failed(checkErr.LeftWorlErrMessage);
+
+ if (start > end)
+ return op.Failed("تارخ شروع از پایان بزرگتر است");
+
+
+ var totalhourses = "-";
+ if (command.LeaveType == LeaveType.PaidLeave && command.PaidLeaveType == PaidLeaveType.Hourly)
+ {
+
+ start = new DateTime(start.Year, start.Month, start.Day, startH.Hours, startH.Minutes, startH.Seconds);
+ end = new DateTime(start.Year, start.Month, start.Day, endH.Hours, endH.Minutes, endH.Seconds);
+ if (start > end)
+ end = end.AddDays(1);
+
+ var totalLeavHourses = (end - start);
+ var h = totalLeavHourses.Hours < 10 ? $"0{totalLeavHourses.Hours}" : $"{totalLeavHourses.Hours}";
+ var m = totalLeavHourses.Minutes < 10 ? $"0{totalLeavHourses.Minutes}" : $"{totalLeavHourses.Minutes}";
+ totalhourses = $"{h}:{m}";
+
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
+ return op.Failed("برای ساعت شروع سابقه مرخصی وجود دارد");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
+ return op.Failed("برای ساعت پایان سابقه مرخصی وجود دارد");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
+ return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
+
+ var end24 = endH.Hours == 0 && endH.Minutes == 0 ? end.AddDays(-1) : end;
+ if (_leaveRepository.Exists(x =>
+ (x.StartLeave.Date == start.Date || x.EndLeave.Date == end24.Date) && (x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه")))
+ return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
+ }
+ else if (command.LeaveType == LeaveType.PaidLeave && command.PaidLeaveType == PaidLeaveType.Daily)
+ {
+ var totalLeavHourses = (end - start).TotalDays + 1;
+ totalhourses = $"{(int)totalLeavHourses}";
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
+ return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
+ return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
+ return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
+ return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
+
+ var employeeSettings = _employeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(command.WorkshopId, command.EmployeeId);
+
+ var isActive = _rollCallEmployeeStatusApplication.IsActiveInPeriod(command.EmployeeId, command.WorkshopId, start, end);
+ var hasRollCall = isActive && employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Rotating;
+ if (hasRollCall)
+ {
+
+ if ((end - start).TotalDays > 1 && employeeSettings.WorkshopShiftStatus != WorkshopShiftStatus.Regular)
+ {
+ return op.Failed("شما نمیتوانید بیشتر از یک روز مرخصی روزانه ثبت کنید");
+ }
+
+ if (employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Rotating &&
+ command.SelectedShift == null)
+ {
+ return op.Failed("لطفا شیفت پرسنل را انتخاب کنید");
+ }
+
+ if (command.SelectedShift != null)
+ {
+ var validShiftStart = TimeOnly.TryParse(command.SelectedShift.StartTime, out var shiftStart);
+ var validShiftEnd = TimeOnly.TryParse(command.SelectedShift.EndTime, out var shiftEnd);
+
+ if (validShiftStart == false && validShiftEnd == false)
+ {
+ return op.Failed("شیفت های انتخاب شده معتبر نمیباشد");
+ }
+
+ var shiftStartDateTime = new DateTime(new DateOnly(), shiftStart);
+ var shiftEndDateTime = new DateTime(new DateOnly(), shiftEnd);
+ if (shiftEndDateTime <= shiftStartDateTime)
+ shiftEndDateTime = shiftEndDateTime.AddDays(1);
+ shiftDuration = shiftEndDateTime - shiftStartDateTime;
+ hasShiftDuration = true;
+ }
+ else if (employeeSettings is { WorkshopShiftStatus: WorkshopShiftStatus.Irregular })
+ {
+ if ((end - start).TotalDays > 1)
+ {
+ return op.Failed("شما نمیتوانید بیشتر از یک روز مرخصی روزانه ثبت کنید");
+ }
+
+
+ if (isActive)
+ {
+ shiftDuration = employeeSettings.IrregularShift.WorkshopIrregularShifts switch
+ {
+ WorkshopIrregularShifts.TwelveThirtySix => TimeSpan.FromHours(12),
+ WorkshopIrregularShifts.TwelveTwentyFour => TimeSpan.FromHours(12),
+ WorkshopIrregularShifts.TwentyFourFortyEight => TimeSpan.FromHours(24),
+ WorkshopIrregularShifts.TwentyFourTwentyFour => TimeSpan.FromHours(24),
+ _ => new TimeSpan()
+ };
+ hasShiftDuration = true;
+ }
+
+ }
+ }
+
+
+ }
+
+ if (command.LeaveType == LeaveType.SickLeave)
+ {
+ var totalLeavHourses = (end - start).TotalDays + 1;
+ totalhourses = $"{(int)totalLeavHourses}";
+ command.PaidLeaveType = PaidLeaveType.Daily;
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave <= start && x.EndLeave >= start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
+ return op.Failed("برای تاریخ شروع سابقه مرخصی وجود دارد");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave <= end && x.EndLeave >= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
+ return op.Failed("برای تاریخ پایان سابقه مرخصی وجود دارد");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave >= start && x.EndLeave <= end && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "روزانه"))
+ return op.Failed("در بازه زمانی وارد شده مرخصی ثبت شده است");
+ if (_leaveRepository.Exists(x =>
+ x.StartLeave.Date >= start.Date && x.StartLeave.Date <= end.Date && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId && x.PaidLeaveType == "ساعتی"))
+ return op.Failed("دربازه تاریخ وارد شده مرخصی ساعتی ثبت شده است");
+ }
+ var year = Convert.ToInt32(command.StartLeave.Substring(0, 4));
+ var month = Convert.ToInt32(command.StartLeave.Substring(5, 2));
+ var paidLeaveType = command.PaidLeaveType == PaidLeaveType.Daily ? "روزانه" : "ساعتی";
+ var leaveType = command.LeaveType == LeaveType.PaidLeave ? "استحقاقی" : "استعلاجی";
+ var validation = ValidateNewLeaveWithExistingRollCalls(command.WorkshopId, command.EmployeeId, paidLeaveType, start, end);
+ if (validation.IsSuccedded == false)
+ return validation;
+
+ var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
+ var workshopName = _workshopRepository.GetDetails(command.WorkshopId).WorkshopName;
+ var leave = new Company.Domain.LeaveAgg.Leave(start, end, totalhourses, command.WorkshopId, command.EmployeeId
+ , paidLeaveType, leaveType, employeeFullName, workshopName, command.IsAccepted, command.Decription,
+ year, month, shiftDuration, hasShiftDuration, command.IsInvallid);
+ await _leaveRepository.CreateAsync(leave);
+ await _leaveRepository.SaveChangesAsync();
+ return op.Succcedded();
+ }
+
+
+ public async Task> HasRotatingShift(long workshopId,long employeeId, string startLeaveDate)
+ {
+ var op = new OperationResult();
+ var result = new RotatingShiftDto();
+ if (startLeaveDate.TryToGeorgianDateTime(out var startDateTimeGr) == false)
+ {
+ return op.Failed("تاریخ شروع صحیح نیست");
+ }
+ var employeeSettings = _employeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId, employeeId);
+ //اگر گروه بندی نداشت
+ if (employeeSettings == null)
+ {
+ return op.Succcedded(result);
+ }
+
+ var isActive = _rollCallEmployeeStatusApplication.IsActiveInPeriod(employeeId, workshopId, startDateTimeGr, startDateTimeGr);
+
+ result.HasRollCall = isActive && employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Rotating;
+ result.RotatingShifts = employeeSettings.CustomizeRotatingShifts.Select(x =>
+ new CustomizeRotatingShiftsViewModel()
+ {
+ EndTime = x.EndTime.ToString("HH:mm"),
+ StartTime = x.StartTime.ToString("HH:mm")
+ }).ToList();
+ return op.Succcedded(result);
+ }
#endregion
}
\ No newline at end of file
diff --git a/ServiceHost/Areas/Client/Controllers/LeaveController.cs b/ServiceHost/Areas/Client/Controllers/LeaveController.cs
index 8e94d7e1..255d5b0e 100644
--- a/ServiceHost/Areas/Client/Controllers/LeaveController.cs
+++ b/ServiceHost/Areas/Client/Controllers/LeaveController.cs
@@ -1,5 +1,6 @@
using _0_Framework.Application;
using Company.Domain.EmployeeAgg;
+using CompanyManagment.App.Contracts.InstitutionPlan;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.App.Contracts.Leave;
using Microsoft.AspNetCore.Mvc;
@@ -47,14 +48,61 @@ public class LeaveController : ClientBaseController
return Ok(result);
}
+ ///
+ /// چک کردن تاریخ شروع مرخصی
+ ///
+ ///
+ ///
+ [HttpGet("CheckIsInvalidLeave")]
+ public async Task> CheckIsInvalidLeave(string startLeaveDate)
+ {
+ return await _leaveApplication.CheckIsInvalidLeave(startLeaveDate, _workshopId);
+ }
+ ///
+ /// ایجاد مرخصی
+ ///
+ ///
+ ///
+ [HttpPost("CreateLeave")]
+ public async Task> CreateLeave([FromBody] CreateLeaveDto command)
+ {
+ command.WorkshopId = _workshopId;
+ var result = await _leaveApplication.CreateLeave(command);
+
+ return result;
+ }
+
+ ///
+ /// دریافت شیفت گردشی اگر داشت
+ ///
+ ///
+ ///
+ [HttpGet("GetRotatingShift")]
+ public async Task> GetRotatingShift(long employeeId, string startLeaveDate)
+ {
+
+ return await _leaveApplication.HasRotatingShift(_workshopId, employeeId, startLeaveDate);
+ }
+
+ ///
+ /// پرینت تکی
+ ///
+ ///
+ ///
[HttpGet("print/{id}")]
public async Task> PrintOneAsync(long id)
{
var leavePrint = await _leaveApplication.PrintOneAsync(id, _workshopId);
return leavePrint;
}
+
+ ///
+ /// پرینت گروهی
+ ///
+ ///
+ ///
[HttpGet("print")]
public async Task>> PrintAllAsync([FromQuery] List ids)
{