RollCall domain changed to early and late enter exit
This commit is contained in:
18
0_Framework/Exceptions/BadRequestException.cs
Normal file
18
0_Framework/Exceptions/BadRequestException.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace _0_Framework.Exceptions;
|
||||
|
||||
public class BadRequestException:Exception
|
||||
{
|
||||
public BadRequestException(string message):base(message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BadRequestException(string message, string details) : base(message)
|
||||
{
|
||||
Details = details;
|
||||
}
|
||||
|
||||
public string Details { get; }
|
||||
}
|
||||
18
0_Framework/Exceptions/InternalServerException.cs
Normal file
18
0_Framework/Exceptions/InternalServerException.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace _0_Framework.Exceptions;
|
||||
|
||||
public class InternalServerException:Exception
|
||||
{
|
||||
public InternalServerException(string message):base(message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public InternalServerException(string message , string details):base(message)
|
||||
{
|
||||
Details = details;
|
||||
}
|
||||
|
||||
public string Details { get; }
|
||||
}
|
||||
15
0_Framework/Exceptions/NotFoundException.cs
Normal file
15
0_Framework/Exceptions/NotFoundException.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace _0_Framework.Exceptions;
|
||||
|
||||
public class NotFoundException:Exception
|
||||
{
|
||||
public NotFoundException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public NotFoundException(string name, object key) : base($"Entity \"{name}\" ({key}) was not found.")
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
16
0_Framework/InfraStructure/PropertyBuilderExtensions.cs
Normal file
16
0_Framework/InfraStructure/PropertyBuilderExtensions.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
|
||||
namespace _0_Framework.InfraStructure;
|
||||
|
||||
public static class PropertyBuilderExtensions
|
||||
{
|
||||
public static PropertyBuilder<TimeSpan> HasTimeSpanConversion(this PropertyBuilder<TimeSpan> builder)
|
||||
{
|
||||
return builder.HasConversion(
|
||||
v => v == TimeSpan.Zero ? "" : v.ToString(),
|
||||
v => string.IsNullOrWhiteSpace(v) ? TimeSpan.Zero : TimeSpan.Parse(v)
|
||||
).HasMaxLength(30);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
||||
using Company.Domain.CustomizeWorkshopSettingsAgg;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Drawing.Chart;
|
||||
@@ -14,9 +20,16 @@ namespace Company.Domain.RollCallAgg.DomainService;
|
||||
|
||||
public interface IRollCallDomainService
|
||||
{
|
||||
(WorkshopShiftStatus shiftType, IrregularShift irregularShift, ICollection<CustomizeSifts> regularShifts, ICollection<CustomizeRotatingShift> rotatingShifts, TimeSpan BreakTime) GetEmployeeShiftDetails(long employeeId, long workshopId);
|
||||
(WorkshopShiftStatus shiftType, IrregularShift irregularShift, ICollection<CustomizeSifts> regularShifts,
|
||||
ICollection<CustomizeRotatingShift> rotatingShifts, TimeSpan BreakTime) GetEmployeeShiftDetails(long employeeId,
|
||||
long workshopId);
|
||||
|
||||
TimeOnly GetEmployeeOffSetForRegularSettings(long employeeId, long workshopId);
|
||||
DateTime GetEmployeeShiftDateByRollCallStartDate(long workshopId, long employeeId, DateTime rollCallStartDate);
|
||||
|
||||
void CalculateTimeDifferences(RollCall rollCall);
|
||||
|
||||
(DateTime start, DateTime end) FindRotatingShift(DateTime startRollCall, DateTime endRollCall, ICollection<CustomizeRotatingShift> rotatingShifts);
|
||||
}
|
||||
|
||||
public class RollCallDomainService : IRollCallDomainService
|
||||
@@ -25,17 +38,23 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
|
||||
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
|
||||
public RollCallDomainService(IRollCallRepository rollCallRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository)
|
||||
|
||||
public RollCallDomainService(IRollCallRepository rollCallRepository,
|
||||
ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository,
|
||||
ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository)
|
||||
{
|
||||
_rollCallRepository = rollCallRepository;
|
||||
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
}
|
||||
|
||||
public (WorkshopShiftStatus shiftType, IrregularShift irregularShift, ICollection<CustomizeSifts> regularShifts, ICollection<CustomizeRotatingShift> rotatingShifts, TimeSpan BreakTime) GetEmployeeShiftDetails(long employeeId,
|
||||
long workshopId)
|
||||
public (WorkshopShiftStatus shiftType, IrregularShift irregularShift, ICollection<CustomizeSifts> regularShifts,
|
||||
ICollection<CustomizeRotatingShift> rotatingShifts, TimeSpan BreakTime) GetEmployeeShiftDetails(long employeeId,
|
||||
long workshopId)
|
||||
{
|
||||
var employeeSettings = _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId, employeeId);
|
||||
var employeeSettings =
|
||||
_customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId,
|
||||
employeeId);
|
||||
|
||||
var offset = TimeOnly.MinValue;
|
||||
WorkshopShiftStatus shiftType;
|
||||
@@ -44,6 +63,8 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
{
|
||||
|
||||
var workshopSettings = _customizeWorkshopSettingsRepository.GetBy(workshopId);
|
||||
|
||||
|
||||
shiftType = workshopSettings.WorkshopShiftStatus;
|
||||
|
||||
return (shiftType, null,
|
||||
@@ -71,7 +92,9 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
public TimeOnly GetEmployeeOffSetForRegularSettings(long employeeId, long workshopId)
|
||||
{
|
||||
var workshopSettings = _customizeWorkshopSettingsRepository.GetBy(workshopId);
|
||||
var employeeSettings = _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId, employeeId);
|
||||
var employeeSettings =
|
||||
_customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId,
|
||||
employeeId);
|
||||
|
||||
if (workshopSettings == null)
|
||||
return TimeOnly.MinValue;
|
||||
@@ -80,18 +103,21 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
return Tools.CalculateOffset(workshopSettings.CustomizeWorkshopSettingsShifts
|
||||
.Select(x => (CustomizeSifts)x).ToList());
|
||||
|
||||
if (employeeSettings == null)
|
||||
return Tools.CalculateOffset(workshopSettings.CustomizeWorkshopSettingsShifts.Select(x => (CustomizeSifts)x).ToList());
|
||||
|
||||
|
||||
if (workshopSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular && employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
|
||||
if (workshopSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular &&
|
||||
employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
|
||||
{
|
||||
// تعریف بازههای زمانی
|
||||
var workshopStartTime = workshopSettings.CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime; // شروع کارگاه
|
||||
var workshopEndTime = workshopSettings.CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime; // پایان کارگاه
|
||||
var workshopStartTime =
|
||||
workshopSettings.CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime; // شروع کارگاه
|
||||
var workshopEndTime =
|
||||
workshopSettings.CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime; // پایان کارگاه
|
||||
|
||||
var employeeStartTime = employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.MinBy(x => x.Placement).StartTime; // شروع بازه پرسنل
|
||||
var employeeEndTime = employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.MaxBy(x => x.Placement).EndTime; // پایان پرسنل
|
||||
var employeeStartTime = employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.MinBy(x => x.Placement)
|
||||
.StartTime; // شروع بازه پرسنل
|
||||
var employeeEndTime = employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.MaxBy(x => x.Placement)
|
||||
.EndTime; // پایان پرسنل
|
||||
|
||||
// تبدیل زمانها به TimeSpan برای مقایسه
|
||||
var workshopStartTimeSpan = workshopStartTime.ToTimeSpan();
|
||||
@@ -108,12 +134,14 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
|
||||
// محاسبه بزرگترین زمان شروع و کوچکترین زمان پایان
|
||||
var overlapStart = workshopStartTimeSpan > employeeStartTimeSpan ? workshopStartTimeSpan : employeeStartTimeSpan;
|
||||
var overlapStart = workshopStartTimeSpan > employeeStartTimeSpan
|
||||
? workshopStartTimeSpan
|
||||
: employeeStartTimeSpan;
|
||||
var overlapEnd = workshopEndTimeSpan < employeeEndTimeSpan ? workshopEndTimeSpan : employeeEndTimeSpan;
|
||||
|
||||
if (overlapStart >= overlapEnd) // اگر بازه همپوشانی وجود ندارد
|
||||
return Tools.CalculateOffset(employeeSettings.CustomizeWorkshopEmployeeSettingsShifts
|
||||
.Select(x => (CustomizeSifts)x).ToList());
|
||||
.Select(x => (CustomizeSifts)x).ToList());
|
||||
|
||||
|
||||
|
||||
@@ -144,35 +172,382 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime GetEmployeeShiftDateByRollCallStartDate(long workshopId, long employeeId, DateTime rollCallStartDate)
|
||||
public DateTime GetEmployeeShiftDateByRollCallStartDate(long workshopId, long employeeId,
|
||||
DateTime rollCallStartDate)
|
||||
{
|
||||
var shiftDetails = GetEmployeeShiftDetails(employeeId, workshopId);
|
||||
var shiftDetails = GetEmployeeShiftDetails(employeeId, workshopId);
|
||||
|
||||
var offset = GetEmployeeOffSetForRegularSettings(employeeId, workshopId);
|
||||
var offset = GetEmployeeOffSetForRegularSettings(employeeId, workshopId);
|
||||
|
||||
return shiftDetails.shiftType switch
|
||||
{
|
||||
WorkshopShiftStatus.Regular => CalculateRegularShiftDate(rollCallStartDate, offset),
|
||||
WorkshopShiftStatus.Rotating => rollCallStartDate.Date,
|
||||
WorkshopShiftStatus.Irregular => rollCallStartDate.Date,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
return shiftDetails.shiftType switch
|
||||
{
|
||||
WorkshopShiftStatus.Regular => CalculateRegularShiftDate(rollCallStartDate, offset),
|
||||
WorkshopShiftStatus.Rotating => rollCallStartDate.Date,
|
||||
WorkshopShiftStatus.Irregular => rollCallStartDate.Date,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void CalculateTimeDifferences(RollCall rollCall)
|
||||
{
|
||||
var employeeId = rollCall.EmployeeId;
|
||||
var workshopId = rollCall.WorkshopId;
|
||||
var shiftDate = rollCall.ShiftDate;
|
||||
var starDateTime = rollCall.StartDate.Value;
|
||||
var endDateTime = rollCall.EndDate.Value;
|
||||
|
||||
//Todo: Get RollCalls in this shift date
|
||||
//گرفتن حضور غیاب ها در این شیفت دیت
|
||||
//در ادامه باید بگردم رول کال اول رو پر کنم رول کال های غیره باید بررسی بشه ببینیم که این رول کال ها کدومش مناسب تره
|
||||
|
||||
// و بررسی کنیم چند تا رول کال باید
|
||||
|
||||
|
||||
|
||||
|
||||
var shiftDetails = GetEmployeeShiftDetails(employeeId, workshopId);
|
||||
|
||||
|
||||
List<RollCall> rollCalls = GetRollCallsInShiftDate(rollCall.ShiftDate,employeeId, workshopId).GetAwaiter().GetResult();
|
||||
var deletedRollCall = rollCalls.FirstOrDefault(x => x.id == rollCall.id);
|
||||
|
||||
rollCalls.Remove(deletedRollCall);
|
||||
rollCalls.Add(rollCall);
|
||||
|
||||
switch (shiftDetails.shiftType)
|
||||
{
|
||||
case WorkshopShiftStatus.Regular:
|
||||
var employeeShifts = shiftDetails.regularShifts.Select(x =>
|
||||
{
|
||||
var start = new DateTime(DateOnly.FromDateTime(shiftDate), x.StartTime);
|
||||
var end = new DateTime(DateOnly.FromDateTime(shiftDate), x.EndTime);
|
||||
if (x.EndTime < x.StartTime)
|
||||
end = end.AddDays(1);
|
||||
return new { start, end };
|
||||
}).ToList();
|
||||
|
||||
foreach (var employeeShift in employeeShifts)
|
||||
{
|
||||
|
||||
TimeSpan lateEntryDuration = new TimeSpan();
|
||||
TimeSpan earlyEntryDuration = new TimeSpan();
|
||||
TimeSpan lateExitDuration = new TimeSpan();
|
||||
TimeSpan earlyExitDuration = new TimeSpan();
|
||||
|
||||
var shiftStart = employeeShift.start;
|
||||
var shiftEnd = employeeShift.end;
|
||||
|
||||
var rollCallsInShift = rollCalls.Where(a =>
|
||||
(a.StartDate <= shiftStart && a.EndDate >= shiftStart) ||
|
||||
(a.StartDate <= shiftEnd && a.EndDate >= shiftEnd) ||
|
||||
(a.StartDate >= shiftStart && a.StartDate <= shiftEnd) ||
|
||||
(a.EndDate >= shiftStart && a.EndDate <= shiftEnd) // خروج در شیفت باشد
|
||||
|
||||
).ToList();
|
||||
|
||||
#region ورود
|
||||
|
||||
//RollCall entryRollCall;
|
||||
// تعجیل در ورود - زود اومدن
|
||||
|
||||
var earlyEntryRollCall = rollCallsInShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate < employeeShift.start);
|
||||
|
||||
var lateEntryRollCall = rollCallsInShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate > employeeShift.start);
|
||||
|
||||
|
||||
|
||||
var previousShift = employeeShifts.OrderByDescending(x => x.start)
|
||||
.FirstOrDefault(x => x.end < employeeShift.start);
|
||||
|
||||
if (earlyEntryRollCall != null)
|
||||
{
|
||||
if (previousShift != null)
|
||||
{
|
||||
if (earlyEntryRollCall.StartDate > previousShift.end)
|
||||
{
|
||||
earlyEntryDuration = shiftStart - earlyEntryRollCall.StartDate!.Value;
|
||||
earlyEntryRollCall.SetEarlyEnter(earlyEntryDuration);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
earlyEntryDuration = shiftStart - earlyEntryRollCall.StartDate!.Value;
|
||||
earlyEntryRollCall.SetEarlyEnter(earlyEntryDuration);
|
||||
}
|
||||
}
|
||||
// تاخیر در ورود - دیر اومدن
|
||||
else
|
||||
{
|
||||
if (lateEntryRollCall != null && (rollCallsInShift.Any(x =>
|
||||
x.EndDate > shiftStart && x.EndDate < lateEntryRollCall.StartDate) == false))
|
||||
{
|
||||
lateEntryDuration = lateEntryRollCall.StartDate!.Value - shiftStart;
|
||||
lateEntryRollCall.SetLateEnter(lateEntryDuration);
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region خروج
|
||||
|
||||
RollCall exitRollCall;
|
||||
|
||||
|
||||
var earlyExitRollCall = rollCallsInShift.OrderByDescending(x => x.EndDate).FirstOrDefault(x => x.EndDate < employeeShift.end);
|
||||
|
||||
var lateExitRollCall = rollCallsInShift.OrderBy(x => x.EndDate).FirstOrDefault(x => x.EndDate > employeeShift.end);
|
||||
|
||||
// تعجیل در خروج - زود رفتن
|
||||
var nextShift = employeeShifts.OrderBy(x => x.start)
|
||||
.FirstOrDefault(x => x.start > employeeShift.end);
|
||||
|
||||
if (earlyExitRollCall != null && (rollCallsInShift.Any(x =>
|
||||
x.StartDate < shiftEnd && x.StartDate > earlyExitRollCall.EndDate) == false))
|
||||
{
|
||||
var earlyExit = (shiftEnd - earlyExitRollCall.EndDate!.Value);
|
||||
earlyExitRollCall.SetEarlyExit(earlyExit);
|
||||
|
||||
}
|
||||
// تاخیر در خروج - دیر رفتن
|
||||
else
|
||||
{
|
||||
if (lateExitRollCall != null)
|
||||
{
|
||||
if (nextShift != null)
|
||||
{
|
||||
if (lateExitRollCall.EndDate < nextShift.start)
|
||||
{
|
||||
lateExitDuration = lateExitRollCall.EndDate!.Value - shiftEnd;
|
||||
lateExitRollCall.SetLateExit(lateExitDuration);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lateExitDuration = lateExitRollCall.EndDate!.Value - shiftEnd;
|
||||
lateExitRollCall.SetLateExit(lateExitDuration);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WorkshopShiftStatus.Rotating:
|
||||
|
||||
TimeSpan lateEntryDurationRotating = new TimeSpan();
|
||||
TimeSpan earlyEntryDurationRotating = new TimeSpan();
|
||||
TimeSpan lateExitDurationRotating = new TimeSpan();
|
||||
TimeSpan earlyExitDurationRotating = new TimeSpan();
|
||||
|
||||
var rotatingShifts = shiftDetails.rotatingShifts;
|
||||
|
||||
var shift = FindRotatingShift(starDateTime, endDateTime, rotatingShifts);
|
||||
|
||||
var rotatingShiftStart = shift.start;
|
||||
var rotatingShiftEnd = shift.end;
|
||||
|
||||
var rollCallsInRotatingShift = rollCalls.Where(a =>
|
||||
(a.StartDate <= rotatingShiftStart && a.EndDate >= rotatingShiftStart) ||
|
||||
(a.StartDate <= rotatingShiftEnd && a.EndDate >= rotatingShiftEnd) ||
|
||||
(a.StartDate >= rotatingShiftStart && a.StartDate <= rotatingShiftEnd) ||
|
||||
(a.EndDate >= rotatingShiftStart && a.EndDate <= rotatingShiftEnd) // خروج در شیفت باشد
|
||||
|
||||
).ToList();
|
||||
|
||||
#region ورود
|
||||
|
||||
// تعجیل در ورود - زود اومدن
|
||||
|
||||
var earlyEntryRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate < shift.start);
|
||||
|
||||
var lateEntryRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate > shift.start);
|
||||
|
||||
|
||||
|
||||
|
||||
if (earlyEntryRollCallRotating != null)
|
||||
{
|
||||
|
||||
earlyEntryDurationRotating = rotatingShiftStart - earlyEntryRollCallRotating.StartDate!.Value;
|
||||
earlyEntryRollCallRotating.SetEarlyEnter(earlyEntryDurationRotating);
|
||||
|
||||
}
|
||||
// تاخیر در ورود - دیر اومدن
|
||||
else
|
||||
{
|
||||
if (lateEntryRollCallRotating != null && (rollCallsInRotatingShift.Any(x =>
|
||||
x.EndDate > rotatingShiftStart && x.EndDate < lateEntryRollCallRotating.StartDate) == false))
|
||||
{
|
||||
lateEntryDurationRotating = lateEntryRollCallRotating.StartDate!.Value - rotatingShiftStart;
|
||||
lateEntryRollCallRotating.SetLateEnter(lateEntryDurationRotating);
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region خروج
|
||||
|
||||
|
||||
|
||||
var earlyExitRollCallRotating = rollCallsInRotatingShift.OrderByDescending(x => x.EndDate).FirstOrDefault(x => x.EndDate < shift.end);
|
||||
|
||||
var lateExitRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.EndDate).FirstOrDefault(x => x.EndDate > shift.end);
|
||||
|
||||
|
||||
|
||||
if (earlyExitRollCallRotating != null && (rollCallsInRotatingShift.Any(x =>
|
||||
x.StartDate < rotatingShiftEnd && x.StartDate > earlyExitRollCallRotating.EndDate) == false))
|
||||
{
|
||||
var earlyExit = (rotatingShiftEnd - earlyExitRollCallRotating.EndDate!.Value);
|
||||
earlyExitRollCallRotating.SetEarlyExit(earlyExit);
|
||||
|
||||
}
|
||||
// تاخیر در خروج - دیر رفتن
|
||||
else
|
||||
{
|
||||
if (lateExitRollCallRotating != null)
|
||||
{
|
||||
|
||||
lateExitDurationRotating = lateExitRollCallRotating.EndDate!.Value - rotatingShiftEnd;
|
||||
lateExitRollCallRotating.SetLateExit(lateExitDurationRotating);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
|
||||
case WorkshopShiftStatus.Irregular:
|
||||
break;
|
||||
}
|
||||
|
||||
_rollCallRepository.SaveChanges();
|
||||
}
|
||||
|
||||
private async Task<List<RollCall>> GetRollCallsInShiftDate(DateTime rollCallShiftDate,long employeeId,long workshopId)
|
||||
{
|
||||
return await _rollCallRepository.GetRollCallsInShiftDate(rollCallShiftDate, employeeId, workshopId);
|
||||
}
|
||||
|
||||
public (DateTime start, DateTime end) FindRotatingShift(DateTime startRollCall, DateTime endRollCall,
|
||||
ICollection<CustomizeRotatingShift> rotatingShifts)
|
||||
{
|
||||
DateTime startDate = startRollCall.Date;
|
||||
DateTime endDate = endRollCall.Date;
|
||||
|
||||
|
||||
|
||||
DateTime startEntryWithDate = startDate.Add(startRollCall.TimeOfDay);
|
||||
DateTime endEntryWithDate = endDate.Add(endRollCall.TimeOfDay);
|
||||
|
||||
DateTime oneHourBeforeStart = startEntryWithDate.AddHours(-1);
|
||||
DateTime oneHourAfterStart = startEntryWithDate.AddHours(1);
|
||||
DateTime oneHourBeforeEnd = endEntryWithDate.AddHours(-1);
|
||||
DateTime oneHourAfterEnd = endEntryWithDate.AddHours(1);
|
||||
|
||||
|
||||
var shiftDateTimes = rotatingShifts.SelectMany(shift =>
|
||||
{
|
||||
var shifts = new List<(DateTime Start, DateTime End)>();
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
var shiftStart = startDate.AddDays(i).Date;
|
||||
shiftStart = shiftStart.Add(shift.StartTime.ToTimeSpan());
|
||||
var shiftEnd = shift.StartTime < shift.EndTime
|
||||
? startDate.AddDays(i).Date.Add(shift.EndTime.ToTimeSpan())
|
||||
: startDate.AddDays(i + 1).Date.Add(shift.EndTime.ToTimeSpan());
|
||||
shifts.Add((shiftStart, shiftEnd));
|
||||
}
|
||||
|
||||
return shifts;
|
||||
}).ToList();
|
||||
|
||||
#region مقایسه شروع حضور غیاب با شیفت
|
||||
|
||||
var startFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
(oneHourBeforeStart <= shift.Start && oneHourAfterStart >= shift.Start) ||
|
||||
(oneHourBeforeStart <= shift.End && oneHourAfterStart >= shift.End)).ToList();
|
||||
|
||||
if (startFilteredTimes.Count == 0)
|
||||
{
|
||||
startFilteredTimes = shiftDateTimes;
|
||||
}
|
||||
else if (startFilteredTimes.Count == 1)
|
||||
{
|
||||
var startChosenShift = startFilteredTimes.First();
|
||||
|
||||
if (startChosenShift.End < startChosenShift.Start)
|
||||
startChosenShift.End = startChosenShift.End.AddDays(1);
|
||||
|
||||
return startChosenShift;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region مقایسه پایان حضورغیاب با شیفت
|
||||
|
||||
var endFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
(oneHourBeforeEnd <= shift.Start && oneHourAfterEnd >= shift.Start) ||
|
||||
(oneHourBeforeEnd <= shift.End && oneHourAfterEnd >= shift.End)).ToList();
|
||||
if (endFilteredTimes.Count == 0)
|
||||
{
|
||||
endFilteredTimes = startFilteredTimes;
|
||||
}
|
||||
else if (endFilteredTimes.Count == 1)
|
||||
{
|
||||
var endChosenShift = endFilteredTimes.First();
|
||||
return endChosenShift;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region اشتراک حضور غیاب و شیفت
|
||||
|
||||
var overlapChosenShift = endFilteredTimes.Select(shift => new
|
||||
{
|
||||
Shift = shift,
|
||||
Overlap = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, oneHourAfterEnd.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, oneHourBeforeEnd.Ticks)))
|
||||
}).MaxBy(s => s.Overlap);
|
||||
|
||||
|
||||
var end = overlapChosenShift.Shift.End;
|
||||
if (overlapChosenShift.Shift.End < overlapChosenShift.Shift.Start)
|
||||
end = overlapChosenShift.Shift.End.AddDays(1);
|
||||
|
||||
|
||||
return (overlapChosenShift.Shift.Start, end);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
private DateTime CalculateRegularShiftDate(DateTime startDate, TimeOnly offset)
|
||||
{
|
||||
DateTime nextOffSetDateTime;
|
||||
if (startDate.TimeOfDay >= offset.ToTimeSpan())
|
||||
{
|
||||
nextOffSetDateTime = startDate.AddDays(1).Date + offset.ToTimeSpan();
|
||||
}
|
||||
else
|
||||
nextOffSetDateTime = startDate.Date + offset.ToTimeSpan();
|
||||
DateTime nextOffSetDateTime;
|
||||
if (startDate.TimeOfDay >= offset.ToTimeSpan())
|
||||
{
|
||||
nextOffSetDateTime = startDate.AddDays(1).Date + offset.ToTimeSpan();
|
||||
}
|
||||
else
|
||||
nextOffSetDateTime = startDate.Date + offset.ToTimeSpan();
|
||||
|
||||
if (nextOffSetDateTime.TimeOfDay >= TimeSpan.FromHours(12))
|
||||
return nextOffSetDateTime.Date;
|
||||
if (nextOffSetDateTime.TimeOfDay >= TimeSpan.FromHours(12))
|
||||
return nextOffSetDateTime.Date;
|
||||
|
||||
|
||||
return nextOffSetDateTime.AddDays(-1).Date;
|
||||
return nextOffSetDateTime.AddDays(-1).Date;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace Company.Domain.RollCallAgg
|
||||
List<PersonnelCheckoutDailyRollCallViewModel> GetEmployeeRollCallsForCustomizeCheckoutTemp(IEnumerable<long> customizeCheckoutIds,
|
||||
long workshopId);
|
||||
|
||||
|
||||
Task<List<RollCall>> GetRollCallsInShiftDate(DateTime rollCallShiftDate, long employeeId, long workshopId);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using System;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using System.Linq;
|
||||
using _0_Framework.Exceptions;
|
||||
|
||||
namespace Company.Domain.RollCallAgg
|
||||
{
|
||||
@@ -15,7 +12,10 @@ namespace Company.Domain.RollCallAgg
|
||||
private RollCall()
|
||||
{
|
||||
}
|
||||
public RollCall(long workshopId, long employeeId, string employeeFullName, DateTime startDate, DateTime? endDate, int year, int month,
|
||||
|
||||
|
||||
public RollCall(long workshopId, long employeeId, string employeeFullName, DateTime startDate,
|
||||
DateTime? endDate, int year, int month,
|
||||
IRollCallDomainService service, RollCallModifyType rollCallModifyType = RollCallModifyType.None)
|
||||
{
|
||||
WorkshopId = workshopId;
|
||||
@@ -29,43 +29,483 @@ namespace Company.Domain.RollCallAgg
|
||||
|
||||
SetShiftDate(service);
|
||||
|
||||
var shiftDetails = service.GetEmployeeShiftDetails(employeeId, workshopId);
|
||||
|
||||
if (shiftDetails is { shiftType: WorkshopShiftStatus.Irregular, irregularShift: null } or
|
||||
{ shiftType: WorkshopShiftStatus.Rotating, rotatingShifts: null })
|
||||
{
|
||||
throw new NotFoundException("اطلاعات گروهبندی شخص نامعتبر است");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long WorkshopId { get; private set; }
|
||||
|
||||
public long EmployeeId { get; private set; }
|
||||
|
||||
public string EmployeeFullName { get; private set; }
|
||||
public DateTime? StartDate { get; private set; }
|
||||
public DateTime? EndDate { get; private set; }
|
||||
public int Year { get; private set; }
|
||||
public int Month { get; private set; }
|
||||
public RollCallModifyType RollCallModifyType { get; private set; }
|
||||
|
||||
public DateTime ShiftDate { get; set; }
|
||||
/// <summary>
|
||||
/// ورود
|
||||
/// </summary>
|
||||
private DateTime? _startDate;
|
||||
|
||||
public void SetEndDateTime(DateTime? endDate)
|
||||
public DateTime? StartDate
|
||||
{
|
||||
EndDate = endDate;
|
||||
get => _startDate;
|
||||
private set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
_startDate = TruncateDateTime(value.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_startDate = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Edit(DateTime start, DateTime end)
|
||||
/// <summary>
|
||||
/// خروج
|
||||
/// </summary>
|
||||
private DateTime? _endDate;
|
||||
|
||||
public DateTime? EndDate
|
||||
{
|
||||
get => _endDate;
|
||||
private set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
_endDate = TruncateDateTime(value.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_endDate = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ماه
|
||||
/// </summary>
|
||||
public int Year { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// سال
|
||||
/// </summary>
|
||||
public int Month { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع حضور غیاب
|
||||
/// </summary>
|
||||
public RollCallModifyType RollCallModifyType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// روز کاری
|
||||
/// </summary>
|
||||
public DateTime ShiftDate { get; set; }
|
||||
|
||||
private TimeSpan _shiftDurationTimeSpan;
|
||||
/// <summary>
|
||||
/// مقدار تایم شیفت (مدت زمان شیفت کاری)
|
||||
/// </summary>
|
||||
public TimeSpan ShiftDurationTimeSpan
|
||||
{
|
||||
get => _shiftDurationTimeSpan;
|
||||
set => _shiftDurationTimeSpan = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _breakTimeSpan;
|
||||
/// <summary>
|
||||
/// مقدار تایم استراحت (مدت زمان استراحت در شیفت کاری)
|
||||
/// </summary>
|
||||
public TimeSpan BreakTimeSpan
|
||||
{
|
||||
get => _breakTimeSpan;
|
||||
set => _breakTimeSpan = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _nightWorkTimeSpan;
|
||||
/// <summary>
|
||||
/// مقدار شبکاری (مدت زمان کار در شیفت شب)
|
||||
/// </summary>
|
||||
public TimeSpan NightWorkTimeSpan
|
||||
{
|
||||
get => _nightWorkTimeSpan;
|
||||
set => _nightWorkTimeSpan = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _fridayWorkTimeSpan;
|
||||
/// <summary>
|
||||
/// مقدار تایم جمعه (مدت زمان کار در روز جمعه)
|
||||
/// </summary>
|
||||
public TimeSpan FridayWorkTimeSpan
|
||||
{
|
||||
get => _fridayWorkTimeSpan;
|
||||
set => _fridayWorkTimeSpan = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _lateEntryDuration;
|
||||
/// <summary>
|
||||
/// تاخیر در ورود (مدت زمانی که کارمند با تأخیر وارد شده است)
|
||||
/// </summary>
|
||||
public TimeSpan LateEntryDuration
|
||||
{
|
||||
get => _lateEntryDuration;
|
||||
set => _lateEntryDuration = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _earlyEntryDuration;
|
||||
/// <summary>
|
||||
/// تعجیل در ورود (مدت زمانی که کارمند زودتر از زمان مشخص وارد شده است)
|
||||
/// </summary>
|
||||
public TimeSpan EarlyEntryDuration
|
||||
{
|
||||
get => _earlyEntryDuration;
|
||||
set => _earlyEntryDuration = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _lateExitDuration;
|
||||
/// <summary>
|
||||
/// تاخیر در خروج (مدت زمانی که کارمند با تأخیر از کار خارج شده است)
|
||||
/// </summary>
|
||||
public TimeSpan LateExitDuration
|
||||
{
|
||||
get => _lateExitDuration;
|
||||
set => _lateExitDuration = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
private TimeSpan _earlyExitDuration;
|
||||
/// <summary>
|
||||
/// تعجیل در خروج (مدت زمانی که کارمند زودتر از زمان مشخص از کار خارج شده است)
|
||||
/// </summary>
|
||||
public TimeSpan EarlyExitDuration
|
||||
{
|
||||
get => _earlyExitDuration;
|
||||
set => _earlyExitDuration = TruncateTimeSpan(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نوع شیفت
|
||||
/// </summary>
|
||||
public WorkshopShiftStatus ShiftType { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the TimeSpan to only include days, hours, and minutes.
|
||||
/// Removes seconds, milliseconds, and smaller units.
|
||||
/// </summary>
|
||||
/// <param name="time">The original TimeSpan value.</param>
|
||||
/// <returns>A truncated TimeSpan with only days, hours, and minutes.</returns>
|
||||
private TimeSpan TruncateTimeSpan(TimeSpan time)
|
||||
{
|
||||
return new TimeSpan(time.Days, time.Hours, time.Minutes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the DateTime to only include Years,Month,days,Hours and Minutes.
|
||||
/// Removes seconds, milliseconds, and smaller units.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The original DateTime value.</param>
|
||||
/// <returns>A truncated DateTime with only days, hours, and minutes.</returns>
|
||||
private DateTime TruncateDateTime(DateTime dateTime)
|
||||
{
|
||||
return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour,
|
||||
dateTime.Minute, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetEndDateTime(DateTime endDate, IRollCallDomainService service)
|
||||
{
|
||||
EndDate = endDate;
|
||||
|
||||
ShiftDurationTimeSpan = CalculateShiftDuration(StartDate!.Value, EndDate.Value, service);
|
||||
|
||||
NightWorkTimeSpan = CalculateNightWorkDuration(StartDate.Value, endDate);
|
||||
|
||||
FridayWorkTimeSpan = CalculateFridayWorkDuration(StartDate.Value, endDate);
|
||||
|
||||
////محاسبه اختلاف زمانی(تاخیر و تعجیل)ء
|
||||
service.CalculateTimeDifferences(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Edit(DateTime start, DateTime end, IRollCallDomainService service)
|
||||
{
|
||||
StartDate = start;
|
||||
EndDate = end;
|
||||
|
||||
SetShiftDate(service);
|
||||
|
||||
ShiftDurationTimeSpan = CalculateShiftDuration(StartDate.Value, EndDate.Value, service);
|
||||
|
||||
NightWorkTimeSpan = CalculateNightWorkDuration(StartDate.Value, EndDate.Value);
|
||||
|
||||
FridayWorkTimeSpan = CalculateFridayWorkDuration(StartDate.Value, EndDate.Value);
|
||||
|
||||
//محاسبه اختلاف زمانی(تاخیر و تعجیل)ء
|
||||
service.CalculateTimeDifferences(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void SetStartAgain(DateTime startDateTime)
|
||||
{
|
||||
StartDate = startDateTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public RollCall SetModifyType(RollCallModifyType modifyType)
|
||||
{
|
||||
RollCallModifyType = modifyType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void SetShiftDate(IRollCallDomainService service)
|
||||
private void SetShiftDate(IRollCallDomainService service)
|
||||
{
|
||||
ShiftDate = service.GetEmployeeShiftDateByRollCallStartDate(WorkshopId, EmployeeId, StartDate!.Value);
|
||||
}
|
||||
|
||||
private TimeSpan CalculateShiftDuration(DateTime startRollCall, DateTime endRollCall, IRollCallDomainService service)
|
||||
{
|
||||
var shiftDetails = service.GetEmployeeShiftDetails(EmployeeId, WorkshopId);
|
||||
|
||||
switch (shiftDetails.shiftType)
|
||||
{
|
||||
case WorkshopShiftStatus.Regular:
|
||||
|
||||
var employeeShiftsSpans = shiftDetails.regularShifts.Select(x =>
|
||||
{
|
||||
|
||||
var start = new DateTime(new DateOnly(), x.StartTime);
|
||||
var end = new DateTime(new DateOnly(), x.EndTime);
|
||||
if (x.EndTime < x.StartTime)
|
||||
end = end.AddDays(1);
|
||||
var span = end - start;
|
||||
return new
|
||||
{
|
||||
Placement = x.Placement,
|
||||
ShiftSpan = span
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
|
||||
return new TimeSpan(employeeShiftsSpans.Sum(x => (x.ShiftSpan).Ticks));
|
||||
|
||||
case WorkshopShiftStatus.Rotating:
|
||||
|
||||
var rotatingShifts = shiftDetails.rotatingShifts;
|
||||
|
||||
var res = service.FindRotatingShift(startRollCall, endRollCall, rotatingShifts);
|
||||
|
||||
return res.end - res.start;
|
||||
|
||||
break;
|
||||
case WorkshopShiftStatus.Irregular:
|
||||
return shiftDetails.irregularShift.WorkshopIrregularShifts switch
|
||||
{
|
||||
WorkshopIrregularShifts.TwelveThirtySix => TimeSpan.FromHours(6),
|
||||
WorkshopIrregularShifts.TwelveTwentyFour => TimeSpan.FromHours(8),
|
||||
WorkshopIrregularShifts.TwentyFourFortyEight => TimeSpan.FromHours(8),
|
||||
WorkshopIrregularShifts.TwentyFourTwentyFour => TimeSpan.FromHours(12),
|
||||
_ => new TimeSpan()
|
||||
};
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
//private static (DateTime start, DateTime end) FindRotatingShift(DateTime startRollCall, DateTime endRollCall, ICollection<CustomizeRotatingShift> rotatingShifts)
|
||||
//{
|
||||
|
||||
|
||||
// DateTime startDate = startRollCall.Date;
|
||||
// DateTime endDate = endRollCall.Date;
|
||||
|
||||
|
||||
|
||||
// DateTime startEntryWithDate = startDate.Add(startDate.TimeOfDay);
|
||||
// DateTime endEntryWithDate = endDate.Add(endRollCall.TimeOfDay);
|
||||
|
||||
// DateTime oneHourBeforeStart = startEntryWithDate.AddHours(-1);
|
||||
// DateTime oneHourAfterStart = startEntryWithDate.AddHours(1);
|
||||
// DateTime oneHourBeforeEnd = endEntryWithDate.AddHours(-1);
|
||||
// DateTime oneHourAfterEnd = endEntryWithDate.AddHours(1);
|
||||
|
||||
|
||||
// var shiftDateTimes = rotatingShifts.SelectMany(shift =>
|
||||
// {
|
||||
// var shifts = new List<(DateTime Start, DateTime End)>();
|
||||
// for (int i = -1; i <= 1; i++)
|
||||
// {
|
||||
// var shiftStart = startDate.AddDays(i).Date.Add(shift.StartTime.ToTimeSpan());
|
||||
// var shiftEnd = shift.StartTime < shift.EndTime
|
||||
// ? startDate.AddDays(i).Date.Add(shift.EndTime.ToTimeSpan())
|
||||
// : startDate.AddDays(i + 1).Date.Add(shift.EndTime.ToTimeSpan());
|
||||
// shifts.Add((shiftStart, shiftEnd));
|
||||
// }
|
||||
|
||||
// return shifts;
|
||||
// }).ToList();
|
||||
|
||||
// #region مقایسه شروع حضور غیاب با شیفت
|
||||
|
||||
// var startFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
// (oneHourBeforeStart <= shift.Start && oneHourAfterStart >= shift.Start) ||
|
||||
// (oneHourBeforeStart <= shift.End && oneHourAfterStart >= shift.End)).ToList();
|
||||
|
||||
// if (startFilteredTimes.Count == 0)
|
||||
// {
|
||||
// startFilteredTimes = shiftDateTimes;
|
||||
// }
|
||||
// else if (startFilteredTimes.Count == 1)
|
||||
// {
|
||||
// var startChosenShift = startFilteredTimes.First();
|
||||
|
||||
// if (startChosenShift.End < startChosenShift.Start)
|
||||
// startChosenShift.End = startChosenShift.End.AddDays(1);
|
||||
|
||||
// return startChosenShift;
|
||||
// }
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region مقایسه پایان حضورغیاب با شیفت
|
||||
|
||||
// var endFilteredTimes = shiftDateTimes.Where(shift => (oneHourBeforeEnd <= shift.Start && oneHourAfterEnd >= shift.Start) ||
|
||||
// (oneHourBeforeEnd <= shift.End && oneHourAfterEnd >= shift.End)).ToList();
|
||||
// if (endFilteredTimes.Count == 0)
|
||||
// {
|
||||
// endFilteredTimes = startFilteredTimes;
|
||||
// }
|
||||
// else if (endFilteredTimes.Count == 1)
|
||||
// {
|
||||
// var endChosenShift = endFilteredTimes.First();
|
||||
// return endChosenShift;
|
||||
// }
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region اشتراک حضور غیاب و شیفت
|
||||
|
||||
// var overlapChosenShift = endFilteredTimes.Select(shift => new
|
||||
// {
|
||||
// Shift = shift,
|
||||
// Overlap = new TimeSpan(Math.Max(0,
|
||||
// Math.Min(shift.End.Ticks, oneHourAfterEnd.Ticks) -
|
||||
// Math.Max(shift.Start.Ticks, oneHourBeforeEnd.Ticks)))
|
||||
// }).MaxBy(s => s.Overlap);
|
||||
|
||||
|
||||
// var end = overlapChosenShift.Shift.End;
|
||||
// if (overlapChosenShift.Shift.End < overlapChosenShift.Shift.Start)
|
||||
// end = overlapChosenShift.Shift.End.AddDays(1);
|
||||
|
||||
|
||||
// return (overlapChosenShift.Shift.Start, end);
|
||||
// #endregion
|
||||
//}
|
||||
|
||||
|
||||
|
||||
private static TimeSpan CalculateNightWorkDuration(DateTime start, DateTime end)
|
||||
{
|
||||
// مدت زمان کل را روی صفر تنظیم کنید
|
||||
TimeSpan totalDuration = TimeSpan.Zero;
|
||||
|
||||
// تا زمانی که تاریخ شروع کمتر از تاریخ پایان است، حلقه اجرا شود
|
||||
while (start < end)
|
||||
{
|
||||
// محاسبه زمان شروع دوره شبانه بعدی (22:00) ء
|
||||
DateTime nextStart = new DateTime(start.Year, start.Month, start.Day, 22, 0, 0);
|
||||
|
||||
// اگر زمان شروع فعلی قبل از دوره شبانه بعدی و زمان شروع بعدی درون تاریخ پایان باشد
|
||||
if (start < nextStart && nextStart < end)
|
||||
{
|
||||
// محاسبه زمان پایان دوره شبانه (6:00 روز بعد)
|
||||
DateTime nextEnd = nextStart.AddHours(8);
|
||||
|
||||
// تنظیم زمان پایان بعدی در صورتی که بیشتر از تاریخ پایان باشد
|
||||
nextEnd = nextEnd > end ? end : nextEnd;
|
||||
|
||||
// افزودن مدت زمان این دوره شبانه به مدت زمان کل
|
||||
totalDuration += nextEnd - nextStart;
|
||||
|
||||
// جابهجایی زمان شروع به پایان دوره شبانه فعلی
|
||||
start = nextEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
// اگر هنوز زمان شروع دوره شبانه بعدی نرسیده، به روز بعد جابهجا شوید (6:00)ء
|
||||
start = start.Date.AddDays(1).AddHours(6);
|
||||
|
||||
}
|
||||
}
|
||||
return totalDuration;
|
||||
}
|
||||
|
||||
private static TimeSpan CalculateFridayWorkDuration(DateTime start, DateTime end)
|
||||
{
|
||||
if (start.DayOfWeek == DayOfWeek.Friday || end.DayOfWeek == DayOfWeek.Friday ||
|
||||
(start.DayOfWeek == DayOfWeek.Thursday && end.DayOfWeek == DayOfWeek.Saturday))
|
||||
{
|
||||
var startPeriod = start.DayOfWeek == DayOfWeek.Thursday ? start.AddDays(1).Date : start;
|
||||
var endPeriod = end.DayOfWeek == DayOfWeek.Saturday ? end.Date : end;
|
||||
|
||||
return endPeriod - startPeriod;
|
||||
}
|
||||
|
||||
return TimeSpan.Zero;
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal void SetEarlyEnter(TimeSpan earlyEntryDuration)
|
||||
{
|
||||
EarlyEntryDuration = earlyEntryDuration;
|
||||
}
|
||||
|
||||
internal void SetLateEnter(TimeSpan lateEntryDuration)
|
||||
{
|
||||
LateEntryDuration = lateEntryDuration;
|
||||
}
|
||||
|
||||
internal void SetEarlyExit(TimeSpan earlyExit)
|
||||
{
|
||||
EarlyExitDuration = earlyExit;
|
||||
}
|
||||
|
||||
internal void SetLateExit(TimeSpan lateExitDuration)
|
||||
{
|
||||
LateExitDuration = lateExitDuration;
|
||||
}
|
||||
|
||||
public void setStartAndEnd(DateTime start, DateTime end, IRollCallDomainService service)
|
||||
{
|
||||
StartDate = start;
|
||||
EndDate = end;
|
||||
|
||||
SetShiftDate(service);
|
||||
|
||||
ShiftDurationTimeSpan = CalculateShiftDuration(StartDate.Value, EndDate.Value, service);
|
||||
|
||||
NightWorkTimeSpan = CalculateNightWorkDuration(StartDate.Value, EndDate.Value);
|
||||
|
||||
FridayWorkTimeSpan = CalculateFridayWorkDuration(StartDate.Value, EndDate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public enum RollCallModifyType
|
||||
|
||||
@@ -86,6 +86,8 @@ namespace CompanyManagment.App.Contracts.CustomizeCheckout
|
||||
public List<LoanInstallmentViewModel> InstallmentViewModels { get; set; }
|
||||
public List<SalaryAidViewModel> SalaryAidViewModels { get; set; }
|
||||
public bool TotalPaymentHide { get; set; }
|
||||
public double TotalPaymentD { get; set; }
|
||||
|
||||
public PersonnelCheckoutDailyRollCallViewModel MonthlyRollCall { get; set; }
|
||||
|
||||
//public bool HasLeft { get; set; }
|
||||
|
||||
@@ -13,4 +13,29 @@ public class GroupedRollCalls
|
||||
public TimeSpan BreakTime { get; set; }
|
||||
public DateTime ShiftDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاخیر در ورود (مدت زمانی که کارمند با تأخیر وارد شده است)
|
||||
/// </summary>
|
||||
public TimeSpan TotalLateEntryDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعجیل در ورود (مدت زمانی که کارمند زودتر از زمان مشخص وارد شده است)
|
||||
/// </summary>
|
||||
public TimeSpan TotalEarlyEntryDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاخیر در خروج (مدت زمانی که کارمند با تأخیر از کار خارج شده است)
|
||||
/// </summary>
|
||||
public TimeSpan TotalLateExitDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعجیل در خروج (مدت زمانی که کارمند زودتر از زمان مشخص از کار خارج شده است)
|
||||
/// </summary>
|
||||
public TimeSpan TotalEarlyExitDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مقدار تایم شیفت (مدت زمان شیفت کاری)
|
||||
/// </summary>
|
||||
public TimeSpan TotalShiftDurationTimeSpan { get; set; }
|
||||
|
||||
}
|
||||
@@ -35,4 +35,30 @@ public class RollCallViewModel
|
||||
public bool IsHoliday { get; set; }
|
||||
public string EndTimeString { get; set; }
|
||||
public string StartTimeString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاخیر در ورود (مدت زمانی که کارمند با تأخیر وارد شده است)
|
||||
/// </summary>
|
||||
|
||||
public TimeSpan LateEntryDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعجیل در ورود (مدت زمانی که کارمند زودتر از زمان مشخص وارد شده است)
|
||||
/// </summary>
|
||||
public TimeSpan EarlyEntryDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاخیر در خروج (مدت زمانی که کارمند با تأخیر از کار خارج شده است)
|
||||
/// </summary>
|
||||
public TimeSpan LateExitDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعجیل در خروج (مدت زمانی که کارمند زودتر از زمان مشخص از کار خارج شده است)
|
||||
/// </summary>
|
||||
public TimeSpan EarlyExitDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مقدار تایم شیفت (مدت زمان شیفت کاری)
|
||||
/// </summary>
|
||||
public TimeSpan ShiftDurationTimeSpan { get; set; }
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
if (personRollCall == null)
|
||||
opration.Failed("رکورد مورد نظر وجود ندارد");
|
||||
var now = DateTime.Now;
|
||||
personRollCall.SetEndDateTime(now);
|
||||
personRollCall.SetEndDateTime(now, _rollCallDomainService);
|
||||
_rollCallRepository.SaveChanges();
|
||||
return opration.Succcedded();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Company.Domain.RollCallAgg;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
@@ -19,5 +20,17 @@ public class RollCallMapping : IEntityTypeConfiguration<RollCall>
|
||||
builder.Property(x => x.Year);
|
||||
builder.Property(x => x.Month);
|
||||
builder.Property(x => x.RollCallModifyType).HasConversion<string>().HasMaxLength(50);
|
||||
}
|
||||
builder.Property(x => x.ShiftDate);
|
||||
builder.Property(x => x.BreakTimeSpan).HasTimeSpanConversion();
|
||||
|
||||
builder.Property(x => x.NightWorkTimeSpan).HasTimeSpanConversion();
|
||||
builder.Property(x => x.FridayWorkTimeSpan).HasTimeSpanConversion();
|
||||
builder.Property(x => x.ShiftDurationTimeSpan).HasTimeSpanConversion();
|
||||
|
||||
builder.Property(x => x.LateEntryDuration).HasTimeSpanConversion();
|
||||
builder.Property(x => x.EarlyEntryDuration).HasTimeSpanConversion();
|
||||
builder.Property(x => x.LateExitDuration).HasTimeSpanConversion();
|
||||
builder.Property(x => x.EarlyExitDuration).HasTimeSpanConversion();
|
||||
builder.Property(x => x.ShiftType).HasConversion<string>().HasMaxLength(22);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addFridayDurationAndNightDurationAndTimeDifferences : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BreakTimeSpan",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "EarlyEntryDuration",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "EarlyExitDuration",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FridayWorkTimeSpan",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "LateEntryDuration",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "LateExitDuration",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "NightWorkTimeSpan",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ShiftDurationTimeSpan",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ShiftType",
|
||||
table: "RollCall",
|
||||
type: "nvarchar(22)",
|
||||
maxLength: 22,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BreakTimeSpan",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EarlyEntryDuration",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EarlyExitDuration",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FridayWorkTimeSpan",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LateEntryDuration",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LateExitDuration",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NightWorkTimeSpan",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ShiftDurationTimeSpan",
|
||||
table: "RollCall");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ShiftType",
|
||||
table: "RollCall");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4201,9 +4201,24 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<string>("BreakTimeSpan")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("EarlyEntryDuration")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<string>("EarlyExitDuration")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<string>("EmployeeFullName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
@@ -4214,9 +4229,29 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<DateTime?>("EndDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FridayWorkTimeSpan")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<string>("LateEntryDuration")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<string>("LateExitDuration")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<int>("Month")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("NightWorkTimeSpan")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<string>("RollCallModifyType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
@@ -4225,6 +4260,16 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<DateTime>("ShiftDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ShiftDurationTimeSpan")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("nvarchar(30)");
|
||||
|
||||
b.Property<string>("ShiftType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(22)
|
||||
.HasColumnType("nvarchar(22)");
|
||||
|
||||
b.Property<DateTime?>("StartDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
|
||||
@@ -257,6 +257,7 @@ namespace CompanyManagment.EFCore.Repository
|
||||
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee).ThenInclude(x => x.PersonnelCodeList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
@@ -373,6 +374,8 @@ namespace CompanyManagment.EFCore.Repository
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment
|
||||
}).ToList();
|
||||
|
||||
|
||||
|
||||
@@ -70,8 +70,6 @@ namespace CompanyManagment.EFCore.Repository
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var query = _companyContext.CustomizeCheckoutTemps.Include(x => x.Employee).ThenInclude(x => x.PersonnelCodeList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
@@ -90,7 +88,7 @@ namespace CompanyManagment.EFCore.Repository
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
|
||||
if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today)
|
||||
if (queryEndDate > queryStartDate)
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
@@ -99,7 +97,7 @@ namespace CompanyManagment.EFCore.Repository
|
||||
}
|
||||
|
||||
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 12)
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
@@ -108,19 +106,24 @@ namespace CompanyManagment.EFCore.Repository
|
||||
|
||||
|
||||
|
||||
if (queryEndDate < DateTime.Today)
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
//if (queryEndDate < DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
|
||||
else if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Today.AddDays(-1);
|
||||
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd.Date <= endSearchDate && x.ContractEnd.Date >= startSearchDate);
|
||||
|
||||
}
|
||||
@@ -161,10 +164,10 @@ namespace CompanyManagment.EFCore.Repository
|
||||
}
|
||||
|
||||
if (searchModel.Month == 0 || searchModel.Year == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
|
||||
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
@@ -196,6 +199,8 @@ namespace CompanyManagment.EFCore.Repository
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment
|
||||
}).ToList();
|
||||
|
||||
|
||||
|
||||
@@ -1686,17 +1686,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
});
|
||||
|
||||
var sumOfEmployeeShiftSpan = new TimeSpan(employeeShiftsSpans.Sum(x => x.ShiftSpan.Ticks));
|
||||
|
||||
if (customizeWorkshopEmployeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Irregular)
|
||||
{
|
||||
sumOfEmployeeShiftSpan = CalculateIrregularShift(customizeWorkshopEmployeeSettings.IrregularShift);
|
||||
}
|
||||
|
||||
if (customizeWorkshopEmployeeSettings.BreakTime.BreakTimeType == BreakTimeType.WithTime)
|
||||
{
|
||||
sumOfEmployeeShiftSpan -= customizeWorkshopEmployeeSettings.BreakTime.BreakTimeValue.ToTimeSpan();
|
||||
}
|
||||
#endregion
|
||||
|
||||
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
|
||||
@@ -1708,8 +1698,12 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
EndDate = x.EndDate,
|
||||
ShiftSpan = (x.EndDate.Value - x.StartDate.Value),
|
||||
CreationDate = x.CreationDate,
|
||||
ShiftDate = x.ShiftDate
|
||||
|
||||
ShiftDate = x.ShiftDate,
|
||||
EarlyEntryDuration = x.EarlyEntryDuration,
|
||||
LateEntryDuration = x.LateEntryDuration,
|
||||
EarlyExitDuration = x.EarlyExitDuration,
|
||||
LateExitDuration = x.LateExitDuration,
|
||||
ShiftDurationTimeSpan = x.ShiftDurationTimeSpan
|
||||
}).ToList();
|
||||
|
||||
|
||||
@@ -1725,11 +1719,22 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
|
||||
|
||||
BreakTime = CalculateBreakTime(customizeWorkshopEmployeeSettings.BreakTime, new TimeSpan(x.Sum(shift => shift.ShiftSpan.Ticks))),
|
||||
ShiftDate = x.Key
|
||||
ShiftDate = x.Key,
|
||||
TotalEarlyEntryDuration = new TimeSpan(x.Sum(rollCall => rollCall.EarlyEntryDuration.Ticks)),
|
||||
TotalLateEntryDuration = new TimeSpan(x.Sum(rollCall => rollCall.LateEntryDuration.Ticks)),
|
||||
TotalEarlyExitDuration = new TimeSpan(x.Sum(rollCall => rollCall.EarlyExitDuration.Ticks)),
|
||||
TotalLateExitDuration = new TimeSpan(x.Sum(rollCall => rollCall.LateExitDuration.Ticks)),
|
||||
TotalShiftDurationTimeSpan = x.FirstOrDefault() == null ? TimeSpan.Zero : x.First().ShiftDurationTimeSpan
|
||||
}).ToList();
|
||||
|
||||
var sumOfEmployeeShiftSpan = groupedRollCall.Any() ? groupedRollCall.First().TotalShiftDurationTimeSpan : TimeSpan.Zero;
|
||||
|
||||
|
||||
if (customizeWorkshopEmployeeSettings.BreakTime.BreakTimeType == BreakTimeType.WithTime && sumOfEmployeeShiftSpan != TimeSpan.Zero)
|
||||
{
|
||||
sumOfEmployeeShiftSpan -= customizeWorkshopEmployeeSettings.BreakTime.BreakTimeValue.ToTimeSpan();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TimeSpan sumSpans = new TimeSpan(groupedRollCall.Sum(x => x.SumOneDaySpan.Ticks));
|
||||
@@ -1902,7 +1907,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
var birthdayDay = pc.GetDayOfMonth(employee.DateOfBirth);
|
||||
if (birthdayMonth == 12 && birthdayDay == 30)
|
||||
{
|
||||
//چک کن که آیا سال قرارداد کبیسه هست یا نه
|
||||
//چک کن که آیا سال قرارداد کبیسه هست یا نه
|
||||
var leap =
|
||||
pc.IsLeapYear(pc.GetYear(contractStart));
|
||||
if (!leap)
|
||||
@@ -1925,7 +1930,6 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
|
||||
|
||||
|
||||
Console.WriteLine(sumSpans);
|
||||
#endregion
|
||||
|
||||
@@ -1938,7 +1942,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
|
||||
|
||||
#region Deductionsذ
|
||||
#region Deductions
|
||||
|
||||
//غیبت
|
||||
|
||||
@@ -2327,6 +2331,15 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
select stepFine * earlyExitFine.FineMoney).Sum();
|
||||
}
|
||||
|
||||
lateToWorkDeduction = 0;
|
||||
|
||||
foreach (var rollCall in groupedRollCall)
|
||||
{
|
||||
var rollCallShift = rollCall.TotalShiftDurationTimeSpan;
|
||||
var dayMinuteWage = rollCallShift.TotalMinutes == 0 ? 0 : (dailyWage / rollCallShift.TotalMinutes);
|
||||
lateToWorkDeduction += dayMinuteWage * rollCall.TotalLateEntryDuration.TotalMinutes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -15,7 +15,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
@@ -1588,6 +1588,11 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<RollCall>> GetRollCallsInShiftDate(DateTime rollCallShiftDate, long employeeId, long workshopId)
|
||||
{
|
||||
return await _context.RollCalls.Where(x => x.ShiftDate.Date == rollCallShiftDate.Date && x.WorkshopId == workshopId && x.EmployeeId == employeeId).ToListAsync();
|
||||
}
|
||||
|
||||
//حضور غیاب گروهی از پرسنل برای پرینت گروهی فیش حقوقی غیر رسمی نهایی
|
||||
public List<PersonnelCheckoutDailyRollCallViewModel> GetEmployeeRollCallsForMonthForKababMahdi(IEnumerable<long> employeeIds, long workshopId, DateTime start, DateTime end)
|
||||
{
|
||||
|
||||
@@ -5,19 +5,29 @@
|
||||
}
|
||||
|
||||
<h1>Upload File</h1>
|
||||
<form asp-page-handler="Upload" id="1" method="post" enctype="multipart/form-data">
|
||||
@* <form asp-page-handler="Upload" id="1" method="post" enctype="multipart/form-data">
|
||||
<div>
|
||||
<label asp-for="File">Choose a file:</label>
|
||||
<input asp-for="File" type="file" required>
|
||||
</div>
|
||||
<button type="submit">Upload</button>
|
||||
</form>
|
||||
</form> *@
|
||||
|
||||
<form asp-page-handler="ShiftDate" id="8" method="post" enctype="multipart/form-data">
|
||||
<form asp-page-handler="ShiftDate" id="8" method="post">
|
||||
|
||||
<button type="submit">افزودن شیفت دیت</button>
|
||||
</form>
|
||||
|
||||
<form asp-page-handler="ShiftDateNew" id="9" method="post">
|
||||
|
||||
<button type="submit">ست شیفت 1 </button>
|
||||
</form>
|
||||
<form asp-page-handler="ShiftDateNew2" id="10" method="post">
|
||||
|
||||
<button type="submit">ست شیفت 2 </button>
|
||||
</form>
|
||||
|
||||
|
||||
@if (ViewData["message"] != null)
|
||||
{
|
||||
<p>@ViewData["message"]</p>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using AccountManagement.Domain.AccountLeftWorkAgg;
|
||||
using AccountManagement.Domain.AccountLeftWorkAgg;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using CompanyManagment.App.Contracts.AndroidApkVersion;
|
||||
@@ -43,11 +43,52 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
|
||||
public IActionResult OnPostShiftDate()
|
||||
{
|
||||
//RefactorAllTheRollCallsOnEsfand();
|
||||
// AddToAccountLeftWork();
|
||||
ViewData["message"] = "ÊæãÇã";
|
||||
//var startRollCall = new DateTime(2025, 2, 19);
|
||||
//var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall);
|
||||
|
||||
//var endedRollCalls = rollCalls.Where(x => x.EndDate != null).ToList();
|
||||
|
||||
//var notEndedRollCalls = rollCalls.Where(x => x.EndDate == null).ToList();
|
||||
//RefactorAllTheRollCallsOnEsfand(endedRollCalls, notEndedRollCalls);
|
||||
ViewData["message"] = "تومام Refactor";
|
||||
return Page();
|
||||
|
||||
}
|
||||
|
||||
public IActionResult OnPostShiftDateNew()
|
||||
{
|
||||
//var startRollCall = new DateTime(2025, 2, 19);
|
||||
//var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall).ToList();
|
||||
//var r1 = rollCalls.Take(3000).ToList();
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
//Console.WriteLine("endStep 1 ============");
|
||||
//SetRollCall(r1);
|
||||
|
||||
|
||||
ViewData["message"] = "تومام یک";
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnPostShiftDateNew2()
|
||||
{
|
||||
//var startRollCall = new DateTime(2025, 2, 19);
|
||||
//var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall).ToList();
|
||||
|
||||
//var r2 = rollCalls.Skip(3000).ToList();
|
||||
|
||||
//Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
//Console.WriteLine("endStep 2 ============");
|
||||
//SetRollCall2(r2);
|
||||
|
||||
ViewData["message"] = "تومام دو";
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region AccountLeftwork
|
||||
|
||||
private void AddToAccountLeftWork()
|
||||
@@ -116,7 +157,68 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
|
||||
#endregion
|
||||
|
||||
#region RefactorRollcall
|
||||
|
||||
private void RefactorAllTheRollCallsOnEsfand(List<global::Company.Domain.RollCallAgg.RollCall> endedRollCalls,List<global::Company.Domain.RollCallAgg.RollCall> notEndedRollCalls)
|
||||
{
|
||||
var countEndedRollCalls = endedRollCalls.Count;
|
||||
var countNotEndedRollCalls = notEndedRollCalls.Count;
|
||||
|
||||
var step1 = 1;
|
||||
foreach (var rollCall in endedRollCalls)
|
||||
{
|
||||
rollCall.setStartAndEnd(rollCall.StartDate.Value, rollCall.EndDate.Value, _rollCallDomainService);
|
||||
Console.WriteLine($"{step1} - {countEndedRollCalls} ended Edit {rollCall.id}");
|
||||
step1 += 1;
|
||||
}
|
||||
|
||||
var step2 = 1;
|
||||
foreach (var notEndedRollCall in notEndedRollCalls)
|
||||
{
|
||||
notEndedRollCall.SetStartAgain(notEndedRollCall.StartDate.Value);
|
||||
Console.WriteLine($"{step2} - {countNotEndedRollCalls} not ended startAgain {notEndedRollCall.id}");
|
||||
step2 += 1;
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetRollCall(List<global::Company.Domain.RollCallAgg.RollCall> r1)
|
||||
{
|
||||
|
||||
var endedRollCalls2 = r1.Where(x => x.EndDate != null).ToList();
|
||||
var countSetTDRollCall = endedRollCalls2.Count;
|
||||
var stepSetTDRollCal = 1;
|
||||
foreach (var endedRollCall in endedRollCalls2)
|
||||
{
|
||||
endedRollCall.SetEndDateTime(endedRollCall.EndDate.Value, _rollCallDomainService);
|
||||
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
|
||||
stepSetTDRollCal += 1;
|
||||
}
|
||||
|
||||
//_context.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
private void SetRollCall2(List<global::Company.Domain.RollCallAgg.RollCall> r2)
|
||||
{
|
||||
|
||||
|
||||
var endedRollCalls2 = r2.Where(x => x.EndDate != null).ToList();
|
||||
var countSetTDRollCall = endedRollCalls2.Count;
|
||||
var stepSetTDRollCal = 1;
|
||||
foreach (var endedRollCall in endedRollCalls2)
|
||||
{
|
||||
endedRollCall.SetEndDateTime(endedRollCall.EndDate.Value, _rollCallDomainService);
|
||||
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
|
||||
stepSetTDRollCal += 1;
|
||||
}
|
||||
|
||||
//_context.SaveChanges();
|
||||
}
|
||||
#endregion
|
||||
//public async Task<IActionResult> OnPostShiftDate()
|
||||
//{
|
||||
// var customizeWorkshopSettings = _context.CustomizeWorkshopSettings.AsSplitQuery();
|
||||
@@ -135,7 +237,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
// }
|
||||
|
||||
// await _context.SaveChangesAsync();
|
||||
// ViewData["message"] = "ÊæãÇã";
|
||||
// ViewData["message"] = "تومام";
|
||||
// return Page();
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@
|
||||
</svg>
|
||||
<span>پرینت گروهی</span>
|
||||
</button>
|
||||
<button onclick="downloadExcelAll()" class="btn-excel text-nowrap" type="button" Permission="@SubAccountPermissionHelper.ExcelCustomizeCheckoutTempPermissionCode">
|
||||
<button onclick="showExcelAllModal()" class="btn-excel text-nowrap" type="button" Permission="@SubAccountPermissionHelper.ExcelCustomizeCheckoutTempPermissionCode">
|
||||
<svg width="20" height="20" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" fill="#000000">
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="1"></g>
|
||||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
|
||||
@@ -314,7 +314,7 @@
|
||||
</svg>
|
||||
<span>پرینت گروهی</span>
|
||||
</button>
|
||||
<button onclick="downloadExcelAll()" class="btn-excel text-nowrap" type="button" Permission="@SubAccountPermissionHelper.ExcelCustomizeCheckoutTempPermissionCode">
|
||||
<button onclick="showExcelAllModal()" class="btn-excel text-nowrap" type="button" Permission="@SubAccountPermissionHelper.ExcelCustomizeCheckoutTempPermissionCode">
|
||||
<svg width="20" height="20" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" fill="#000000">
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="1"></g>
|
||||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
|
||||
@@ -357,6 +357,7 @@
|
||||
<div class="Rtable-cell column-heading width7">آغاز قرارداد</div>
|
||||
<div class="Rtable-cell column-heading width8">پایان قرارداد</div>
|
||||
<div class="Rtable-cell column-heading width9">روزهای کارکرد</div>
|
||||
<div class="Rtable-cell column-heading width9">مبلغ قابل پرداخت</div>
|
||||
<div class="Rtable-cell column-heading width10 text-end">عملیات</div>
|
||||
</div>
|
||||
|
||||
@@ -406,8 +407,14 @@
|
||||
<div class="Rtable-cell--content ">@item.ContractEndFa</div>
|
||||
</div>
|
||||
<div class="Rtable-cell d-md-flex d-none width9">
|
||||
<div class="Rtable-cell--heading">روزهای کارکرد</div>
|
||||
<div class="Rtable-cell--content ">@item.SumOfWorkingDays</div>
|
||||
<div class="Rtable-cell--heading">روزهای کارکرد</div>
|
||||
<div class="Rtable-cell--content ">@item.SumOfWorkingDays</div>
|
||||
</div>
|
||||
<div class="Rtable-cell d-md-flex d-none width9">
|
||||
<div class="@(item.TotalPaymentD < 0 ? "bgColorMonthlySalaryMinus" : "bgColorMonthlySalaryPlus")">
|
||||
<div class="Rtable-cell--heading">مبلغ قابل پرداخت</div>
|
||||
<div class="Rtable-cell--content ">@(item.TotalPayment + " ریال")</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Rtable-cell d-md-flex d-none width10">
|
||||
<div class="Rtable-cell--content align-items-center d-flex d-md-block text-end">
|
||||
@@ -717,6 +724,7 @@
|
||||
var PrintOneUrl = `#showmodal=@Url.Page("/Company/CustomizeCheckout/CheckoutTemporary", "PrintOne")`;
|
||||
var CheckoutPrintAllUrl = `@Url.Page("/Company/CustomizeCheckout/PrintAllCheckoutTemporary")`;
|
||||
var CheckoutExcelAllUrl = `@Url.Page("/Company/CustomizeCheckout/PrintAllCheckoutTemporary", "DownloadExcelAll")`;
|
||||
var showCheckoutExcelModalUrl = `#showmodal=@Url.Page("./CheckoutTemporary", "ExcelModal")`;
|
||||
|
||||
var deleteOneAjax = `@Url.Page("/Company/CustomizeCheckout/CheckoutTemporary", "DeleteOne")`;
|
||||
var deleteAllAjax = `@Url.Page("/Company/CustomizeCheckout/CheckoutTemporary", "DeleteAll")`;
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
//"MesbahDb": "Data Source=DESKTOP-NUE119G\\MSNEW;Initial Catalog=Mesbah_db;Integrated Security=True"
|
||||
|
||||
//server
|
||||
//"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]is[3019]#@ATt;TrustServerCertificate=true;"
|
||||
"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]is[3019]#@ATt;TrustServerCertificate=true;"
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
},
|
||||
"GoogleRecaptchaV3": {
|
||||
"SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH",
|
||||
|
||||
@@ -81,6 +81,29 @@
|
||||
outline: 1px solid #81d1ff;
|
||||
}
|
||||
|
||||
|
||||
.bgColorMonthlySalaryPlus {
|
||||
background-color: #c8e0eb;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.bgColorMonthlySalaryMinus {
|
||||
background-color: #FFCECE;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
.goToTop {
|
||||
position: fixed;
|
||||
|
||||
@@ -40,6 +40,28 @@
|
||||
background-color: #72b112;
|
||||
}
|
||||
|
||||
.bgColorMonthlySalaryPlus {
|
||||
background-color: #D9EBEB;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.bgColorMonthlySalaryMinus {
|
||||
background-color: #FFCECE;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
.goToTop {
|
||||
position: fixed;
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
// *************************** عملیت مربوط اسکرول کردن مربوط به سال و ماه در دسکتاپ ********************************
|
||||
$(document).ready(function () {
|
||||
let $checkAll = $("#checkAll2");
|
||||
let $checkboxes = $(".foo");
|
||||
|
||||
$checkAll.on("change", function () {
|
||||
$checkboxes.prop("checked", this.checked);
|
||||
});
|
||||
|
||||
$checkboxes.on("change", function () {
|
||||
let allChecked = $checkboxes.length === $checkboxes.filter(":checked").length;
|
||||
let someChecked = $checkboxes.filter(":checked").length > 0;
|
||||
$checkAll.prop("checked", allChecked);
|
||||
$checkAll.prop("indeterminate", !allChecked && someChecked);
|
||||
});
|
||||
});
|
||||
|
||||
// *************************** عملیت مربوط اسکرول کردن مربوط به سال و ماه در دسکتاپ ********************************
|
||||
var Scrollbar = window.Scrollbar;
|
||||
Scrollbar.init(document.querySelector('#my-scrollbar'), {
|
||||
alwaysShowTracks: true
|
||||
@@ -55,11 +71,7 @@ $(document).ready(function () {
|
||||
datePattern: ['Y', 'm', 'd']
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var filterEmployeeId = $('#employeeId').val();
|
||||
var filterYear = $('#Year').val();
|
||||
var filterMonth = $('#Month').val();
|
||||
@@ -77,13 +89,6 @@ $(document).ready(function () {
|
||||
$('#end-date').text(filterEnd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($(window).width() < 768) {
|
||||
$('#search-theme-form1').remove();
|
||||
|
||||
@@ -1376,6 +1381,12 @@ function loadMore() {
|
||||
<div class="Rtable-cell--heading">ساعات کارکرد</div>
|
||||
<div class="Rtable-cell--content ">${item.sumOfWorkingDays}</div>
|
||||
</div>
|
||||
<div class="Rtable-cell d-md-flex d-none width9">
|
||||
<div class="${item.totalPaymentD < 0 ? "bgColorMonthlySalaryMinus" : "bgColorMonthlySalaryPlus"}">
|
||||
<div class="Rtable-cell--heading">مبلغ قابل پرداخت</div>
|
||||
<div class="Rtable-cell--content ">${item.totalPayment} ریال</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="Rtable-contract w-100 d-flex d-md-none align-items-center justify-content-between printAllTd">
|
||||
<div class="d-flex justify-content-center align-items-center justify-content-between">
|
||||
@@ -1556,14 +1567,10 @@ function printAll() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function downloadExcelAll() {
|
||||
var idlist = "";
|
||||
function showExcelAllModal() {
|
||||
var year = $('#Year').val();
|
||||
var month = $('#Month').val();
|
||||
|
||||
|
||||
if (year === '0' || month === '0') {
|
||||
$('#dropdown-year').addClass("errored");
|
||||
$('#dropdown-month').addClass("errored");
|
||||
@@ -1578,7 +1585,7 @@ function downloadExcelAll() {
|
||||
return
|
||||
}
|
||||
|
||||
if (!($('input:checkbox').is(":checked"))) {
|
||||
if (!($('.foo:checkbox').is(":checked"))) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('هیچ موردی انتخاب نشده است.');
|
||||
setTimeout(function () {
|
||||
@@ -1587,7 +1594,12 @@ function downloadExcelAll() {
|
||||
}, 3500);
|
||||
return
|
||||
}
|
||||
|
||||
window.location.href = showCheckoutExcelModalUrl;
|
||||
}
|
||||
|
||||
function downloadExcelAll() {
|
||||
var idlist = "";
|
||||
$('.foo').each(function () {
|
||||
if ($(this).is(":checked")) {
|
||||
|
||||
@@ -1598,14 +1610,20 @@ function downloadExcelAll() {
|
||||
}
|
||||
});
|
||||
|
||||
var filterArray = [];
|
||||
$("input[name='filter[]']:checked").each(function () {
|
||||
filterArray.push($(this).val());
|
||||
});
|
||||
|
||||
|
||||
if (idlist !== "") {
|
||||
//var url = CheckoutExcelAllUrl + "&idList=" + idlist;
|
||||
var url = CheckoutExcelAllUrl + "&idList=" + encodeURIComponent(idlist);
|
||||
|
||||
var url = CheckoutExcelAllUrl + "&idList=" + idlist;
|
||||
var yearFa = '&yearFa=' + year;
|
||||
var monthFa = '&monthFa=' + month;
|
||||
//console.log(url + '?checkoutId=' + idlist + yearFa + monthFa);
|
||||
filterArray.forEach(function (filter) {
|
||||
url += "&filter=" + encodeURIComponent(filter);
|
||||
});
|
||||
window.open(url, "_blank");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
// *************************** عملیت مربوط اسکرول کردن مربوط به سال و ماه در دسکتاپ ********************************
|
||||
$(document).ready(function () {
|
||||
let $checkAll = $("#checkAll2");
|
||||
let $checkboxes = $(".foo");
|
||||
|
||||
$checkAll.on("change", function () {
|
||||
$checkboxes.prop("checked", this.checked);
|
||||
});
|
||||
|
||||
$checkboxes.on("change", function () {
|
||||
let allChecked = $checkboxes.length === $checkboxes.filter(":checked").length;
|
||||
let someChecked = $checkboxes.filter(":checked").length > 0;
|
||||
$checkAll.prop("checked", allChecked);
|
||||
$checkAll.prop("indeterminate", !allChecked && someChecked);
|
||||
});
|
||||
});
|
||||
|
||||
// *************************** عملیت مربوط اسکرول کردن مربوط به سال و ماه در دسکتاپ ********************************
|
||||
var Scrollbar = window.Scrollbar;
|
||||
Scrollbar.init(document.querySelector('#my-scrollbar'), {
|
||||
alwaysShowTracks: true
|
||||
@@ -1366,6 +1382,12 @@ function loadMore() {
|
||||
<div class="Rtable-cell--heading">ساعات کارکرد</div>
|
||||
<div class="Rtable-cell--content ">${item.sumOfWorkingDays}</div>
|
||||
</div>
|
||||
<div class="Rtable-cell d-md-flex d-none width9">
|
||||
<div class="${item.totalPaymentD < 0 ? "bgColorMonthlySalaryMinus" : "bgColorMonthlySalaryPlus" }">
|
||||
<div class="Rtable-cell--heading">مبلغ قابل پرداخت</div>
|
||||
<div class="Rtable-cell--content ">${item.totalPayment} ریال</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="Rtable-contract w-100 d-flex d-md-none align-items-center justify-content-between printAllTd">
|
||||
<div class="d-flex justify-content-center align-items-center justify-content-between">
|
||||
@@ -1545,12 +1567,11 @@ function printAll() {
|
||||
window.location.href = url + '?idlist=' + idlist + yearFa + monthFa;
|
||||
}
|
||||
}
|
||||
function excelDownloadAll() {
|
||||
var idlist = "";
|
||||
|
||||
function showExcelAllModal() {
|
||||
var year = $('#Year').val();
|
||||
var month = $('#Month').val();
|
||||
|
||||
|
||||
if (year === '0' || month === '0') {
|
||||
$('#dropdown-year').addClass("errored");
|
||||
$('#dropdown-month').addClass("errored");
|
||||
@@ -1565,7 +1586,7 @@ function excelDownloadAll() {
|
||||
return
|
||||
}
|
||||
|
||||
if (!($('input:checkbox').is(":checked"))) {
|
||||
if (!($('.foo:checkbox').is(":checked"))) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('هیچ موردی انتخاب نشده است.');
|
||||
setTimeout(function () {
|
||||
@@ -1575,6 +1596,11 @@ function excelDownloadAll() {
|
||||
return
|
||||
}
|
||||
|
||||
window.location.href = showCheckoutExcelModalUrl;
|
||||
}
|
||||
|
||||
function downloadExcelAll() {
|
||||
var idlist = "";
|
||||
$('.foo').each(function () {
|
||||
if ($(this).is(":checked")) {
|
||||
|
||||
@@ -1585,19 +1611,23 @@ function excelDownloadAll() {
|
||||
}
|
||||
});
|
||||
|
||||
var filterArray = [];
|
||||
$("input[name='filter[]']:checked").each(function () {
|
||||
filterArray.push($(this).val());
|
||||
});
|
||||
|
||||
|
||||
if (idlist !== "") {
|
||||
//var url = CheckoutExcelAllUrl + "&idList=" + idlist;
|
||||
var url = CheckoutExcelAllUrl + "&idList=" + encodeURIComponent(idlist);
|
||||
|
||||
|
||||
var yearFa = '&yearFa=' + year;
|
||||
var monthFa = '&monthFa=' + month;
|
||||
var url = CheckoutExcelDownloadUrl + '&idlist=' + idlist;
|
||||
|
||||
|
||||
//console.log(url + '?checkoutId=' + idlist + yearFa + monthFa);
|
||||
filterArray.forEach(function (filter) {
|
||||
url += "&filter=" + encodeURIComponent(filter);
|
||||
});
|
||||
window.open(url, "_blank");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function printAllMobile() {
|
||||
var idlist = "";
|
||||
var year = $('#Year').val();
|
||||
|
||||
Reference in New Issue
Block a user