diff --git a/0_Framework/Domain/CustomizeCheckoutShared/Base/BaseCustomizeEntity.cs b/0_Framework/Domain/CustomizeCheckoutShared/Base/BaseCustomizeEntity.cs
index f1490e86..2b563221 100644
--- a/0_Framework/Domain/CustomizeCheckoutShared/Base/BaseCustomizeEntity.cs
+++ b/0_Framework/Domain/CustomizeCheckoutShared/Base/BaseCustomizeEntity.cs
@@ -13,7 +13,7 @@ public class BaseCustomizeEntity : EntityBase
public BaseCustomizeEntity(FridayPay fridayPay, OverTimePay overTimePay,
BaseYearsPay baseYearsPay, BonusesPay bonusesPay, NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction, FineAbsenceDeduction fineAbsenceDeduction, LateToWork lateToWork, EarlyExit earlyExit,
- FridayWork fridayWork, HolidayWork holidayWork, BreakTime breakTime)
+ FridayWork fridayWork, HolidayWork holidayWork, BreakTime breakTime,int leavePermittedDays)
{
FridayPay = fridayPay;
@@ -32,6 +32,7 @@ public class BaseCustomizeEntity : EntityBase
FridayWork = fridayWork;
HolidayWork = holidayWork;
BreakTime = breakTime;
+ LeavePermittedDays = leavePermittedDays;
}
///
@@ -109,6 +110,11 @@ public class BaseCustomizeEntity : EntityBase
///
public HolidayWork HolidayWork { get; protected set; }
+ ///
+ /// تعداد روز های مجاز برای مرخصی
+ ///
+ public int LeavePermittedDays { get; protected set; }
- public BreakTime BreakTime { get; protected set; }
+
+ public BreakTime BreakTime { get; protected set; }
}
\ No newline at end of file
diff --git a/0_Framework/Domain/CustomizeCheckoutShared/Enums/EarlyExitType.cs b/0_Framework/Domain/CustomizeCheckoutShared/Enums/EarlyExitType.cs
index 3393e4db..2f6dbf25 100644
--- a/0_Framework/Domain/CustomizeCheckoutShared/Enums/EarlyExitType.cs
+++ b/0_Framework/Domain/CustomizeCheckoutShared/Enums/EarlyExitType.cs
@@ -2,18 +2,18 @@
public enum EarlyExitType
{
- ///
- /// محاسبه نمیشود
- ///
- None,
+ ///
+ /// محاسبه نمیشود
+ ///
+ None,
- ///
- /// به ازای هر دقیقه تعجیل به نسبت حقوق دریافتی از حقوق پرسنل کسر میگردد
- ///
- Default,
+ ///
+ /// به ازای هر دقیقه تعجیل به نسبت حقوق دریافتی از حقوق پرسنل کسر میگردد
+ ///
+ Default,
- ///
- /// در صورت تعجیل به ازای هر دقیقه مبلغی از مزد روزانه کسر میشود
- ///
- MoneyPerMinute
+ ///
+ /// در صورت تعجیل به ازای هر دقیقه مبلغی از مزد روزانه کسر میشود
+ ///
+ MoneyPerMinute
}
\ No newline at end of file
diff --git a/0_Framework/Domain/CustomizeCheckoutShared/Enums/FridayPayType.cs b/0_Framework/Domain/CustomizeCheckoutShared/Enums/FridayPayType.cs
index 6fc52193..35d64b2e 100644
--- a/0_Framework/Domain/CustomizeCheckoutShared/Enums/FridayPayType.cs
+++ b/0_Framework/Domain/CustomizeCheckoutShared/Enums/FridayPayType.cs
@@ -6,10 +6,10 @@ public enum FridayPayType
///محاسبه نمیشود
///
None,
- ///
- /// اضافه کار محاسبه میشود
- ///
- ExtraWorking,
+ /////
+ ///// اضافه کار محاسبه میشود
+ /////
+ //ExtraWorking,
///
/// به صورت درصدی از مزد روزانه به ازای هر ساعت کار در جمعه
///
diff --git a/0_Framework/Domain/CustomizeCheckoutShared/Enums/LateToWorkType.cs b/0_Framework/Domain/CustomizeCheckoutShared/Enums/LateToWorkType.cs
index 15073df7..37f1f026 100644
--- a/0_Framework/Domain/CustomizeCheckoutShared/Enums/LateToWorkType.cs
+++ b/0_Framework/Domain/CustomizeCheckoutShared/Enums/LateToWorkType.cs
@@ -2,18 +2,18 @@
public enum LateToWorkType
{
- ///
- /// محاسبه نمیشود
- ///
- None,
+ ///
+ /// محاسبه نمیشود
+ ///
+ None,
- ///
- /// به ازای هر دقیقه تاخیر به نسبت حقوق دریافتی از حقوق پرسنل کسر میگردد
- ///
- Default,
+ ///
+ /// به ازای هر دقیقه تاخیر به نسبت حقوق دریافتی از حقوق پرسنل کسر میگردد
+ ///
+ Default,
- ///
- /// در صورت تاخیر به ازای هر دقیقه مبلغی از مزد روزانه کسر میشود
- ///
- MoneyPerMinute
+ ///
+ /// در صورت تاخیر به ازای هر دقیقه مبلغی از مزد روزانه کسر میشود
+ ///
+ MoneyPerMinute
}
\ No newline at end of file
diff --git a/0_Framework/Domain/CustomizeCheckoutShared/Enums/WorkshopShiftStatus.cs b/0_Framework/Domain/CustomizeCheckoutShared/Enums/WorkshopShiftStatus.cs
index a281acc9..6d4e988a 100644
--- a/0_Framework/Domain/CustomizeCheckoutShared/Enums/WorkshopShiftStatus.cs
+++ b/0_Framework/Domain/CustomizeCheckoutShared/Enums/WorkshopShiftStatus.cs
@@ -10,5 +10,10 @@ public enum WorkshopShiftStatus
///
/// نامنظم
///
- Irregular
+ Irregular,
+
+ ///
+ /// چرخشی
+ ///
+ Rotating
}
\ No newline at end of file
diff --git a/0_Framework/Domain/CustomizeCheckoutShared/ValueObjects/CustomizeRotatingShift.cs b/0_Framework/Domain/CustomizeCheckoutShared/ValueObjects/CustomizeRotatingShift.cs
new file mode 100644
index 00000000..f6e7ee6e
--- /dev/null
+++ b/0_Framework/Domain/CustomizeCheckoutShared/ValueObjects/CustomizeRotatingShift.cs
@@ -0,0 +1,24 @@
+using System;
+using Microsoft.AspNetCore.Authentication;
+
+namespace _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
+
+public record CustomizeRotatingShift
+{
+ public CustomizeRotatingShift(TimeOnly startTime,TimeOnly endTime)
+ {
+ StartTime = startTime;
+ EndTime = endTime;
+ }
+ public TimeOnly StartTime { get; set; }
+ public TimeOnly EndTime { get; set; }
+
+ public virtual bool Equals(CustomizeRotatingShift other)
+ {
+ if (StartTime==other.StartTime && EndTime == other.EndTime)
+ {
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettings.cs b/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettings.cs
index df00c49b..26f5063e 100644
--- a/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettings.cs
+++ b/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettings.cs
@@ -10,203 +10,214 @@ using Company.Domain.CustomizeWorkshopGroupSettingsAgg.Entities;
using Company.Domain.EmployeeAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings.ValueObjectsViewModel;
+using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Mvc;
namespace Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
public class CustomizeWorkshopEmployeeSettings : BaseCustomizeEntity
{
- private CustomizeWorkshopEmployeeSettings()
- {
+ private CustomizeWorkshopEmployeeSettings()
+ {
- }
- public CustomizeWorkshopEmployeeSettings(FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay,
- BonusesPay bonusesPay, NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
- FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
- FineAbsenceDeduction fineAbsenceDeduction, LateToWork lateToWork, EarlyExit earlyExit, long employeeId,
- long workshopId, double salary, long customizeWorkshopGroupSettingId,
- ICollection customizeWorkshopEmployeeSettingsShifts,
- FridayWork fridayWork,
- HolidayWork holidayWork, IrregularShift irregularShift, WorkshopShiftStatus workshopShiftStatus, BreakTime breakTime) : base(fridayPay, overTimePay,
- baseYearsPay, bonusesPay, nightWorkPay,
- marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction, lateToWork,
- earlyExit, fridayWork, holidayWork, breakTime)
- {
- CustomizeWorkshopEmployeeSettingsShifts = EmployeeSettingsShiftsConvertor(customizeWorkshopEmployeeSettingsShifts);
+ }
+ public CustomizeWorkshopEmployeeSettings(FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay,
+ BonusesPay bonusesPay, NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
+ FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
+ FineAbsenceDeduction fineAbsenceDeduction, LateToWork lateToWork, EarlyExit earlyExit, long employeeId,
+ long workshopId, double salary, long customizeWorkshopGroupSettingId,
+ ICollection customizeWorkshopEmployeeSettingsShifts,
+ FridayWork fridayWork,
+ HolidayWork holidayWork, IrregularShift irregularShift, WorkshopShiftStatus workshopShiftStatus, BreakTime breakTime, int leavePermittedDays, ICollection rotatingShifts) :
+ base(fridayPay, overTimePay,
+ baseYearsPay, bonusesPay, nightWorkPay,
+ marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction, lateToWork,
+ earlyExit, fridayWork, holidayWork, breakTime, leavePermittedDays)
+ {
+ CustomizeWorkshopGroupSettingId = customizeWorkshopGroupSettingId;
+ IsSettingChanged = false;
+ IsShiftChanged = false;
+ EmployeeId = employeeId;
+ WorkshopId = workshopId;
+ Salary = salary;
+ WorkshopShiftStatus = workshopShiftStatus;
- CustomizeWorkshopGroupSettingId = customizeWorkshopGroupSettingId;
+ CustomizeWorkshopEmployeeSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? EmployeeSettingsShiftsConvertor(customizeWorkshopEmployeeSettingsShifts) : [];
- IsSettingChanged = false;
- IsShiftChanged = false;
- EmployeeId = employeeId;
- WorkshopId = workshopId;
- Salary = salary;
- WorkshopShiftStatus = workshopShiftStatus;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- }
+ CustomizeRotatingShifts = workshopShiftStatus == WorkshopShiftStatus.Rotating ? rotatingShifts : [];
- public IrregularShift IrregularShift { get; set; }
- public WorkshopShiftStatus WorkshopShiftStatus { get; private set; }
- public long EmployeeId { get; private set; }
- public long WorkshopId { get; private set; }
- public double Salary { get; private set; }
- public bool IsShiftChanged { get; private set; }
- public bool IsSettingChanged { get; private set; }
- public long CustomizeWorkshopGroupSettingId { get; set; }
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+ }
- public ICollection CustomizeWorkshopEmployeeSettingsShifts { get; set; }
- public CustomizeWorkshopGroupSettings CustomizeWorkshopGroupSettings { get; set; }
+ public IrregularShift IrregularShift { get; set; }
+ public WorkshopShiftStatus WorkshopShiftStatus { get; private set; }
+ public long EmployeeId { get; private set; }
+ public long WorkshopId { get; private set; }
+ public double Salary { get; private set; }
+ public bool IsShiftChanged { get; private set; }
+ public bool IsSettingChanged { get; private set; }
+ public long CustomizeWorkshopGroupSettingId { get; set; }
+ public ICollection CustomizeRotatingShifts { get; set; }
+ public ICollection CustomizeWorkshopEmployeeSettingsShifts { get; set; }
+ public CustomizeWorkshopGroupSettings CustomizeWorkshopGroupSettings { get; set; }
- ///
- /// تغییر مقادیر تنظیمات پرسنل
- ///
- /// شیفت های کاری پرسنل
- /// حقوق ماهیانه اختصاص داده شده
- /// جمعه کاری
- /// اضافه کاری
- /// سنوات
- /// عیدی
- /// شب کاری
- /// حق تاهل
- /// نوبت کاری
- /// حق اولاد
- /// مزد مرخصی
- /// حق بیمه
- /// جریمه غیبت
- /// تاخیر در ورود
- /// تعجیل درخروج
- /// آیا در روز های جمعه موظف به کار است
- /// آیا در تعطیلات رسمی موظف به کار است
- /// نوع شیفت کاری
- /// آیا شیفت منظم است یا نا منظم
- ///
- public void EditEmployees(double salary, FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay, BonusesPay bonusesPay,
- NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
- FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
- FineAbsenceDeduction fineAbsenceDeduction, LateToWork lateToWork, EarlyExit earlyExit,
- FridayWork fridayWork, HolidayWork holidayWork, IrregularShift irregularShift,
- WorkshopShiftStatus workshopShiftStatus, bool isSettingChange)
- {
- SetValueObjects(fridayPay, overTimePay, baseYearsPay, bonusesPay
- , nightWorkPay, marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction,
- lateToWork, earlyExit);
+ ///
+ /// تغییر مقادیر تنظیمات پرسنل
+ ///
+ /// شیفت های کاری پرسنل
+ /// حقوق ماهیانه اختصاص داده شده
+ /// جمعه کاری
+ /// اضافه کاری
+ /// سنوات
+ /// عیدی
+ /// شب کاری
+ /// حق تاهل
+ /// نوبت کاری
+ /// حق اولاد
+ /// مزد مرخصی
+ /// حق بیمه
+ /// جریمه غیبت
+ /// تاخیر در ورود
+ /// تعجیل درخروج
+ /// آیا در روز های جمعه موظف به کار است
+ /// آیا در تعطیلات رسمی موظف به کار است
+ /// نوع شیفت کاری
+ /// آیا شیفت منظم است یا نا منظم
+ ///
+ public void EditEmployees(double salary, FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay, BonusesPay bonusesPay,
+ NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
+ FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
+ FineAbsenceDeduction fineAbsenceDeduction, LateToWork lateToWork, EarlyExit earlyExit,
+ FridayWork fridayWork, HolidayWork holidayWork, IrregularShift irregularShift,
+ WorkshopShiftStatus workshopShiftStatus, bool isSettingChange, int leavePermittedDays)
+ {
+ SetValueObjects(fridayPay, overTimePay, baseYearsPay, bonusesPay
+ , nightWorkPay, marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction,
+ lateToWork, earlyExit);
- Salary = salary;
- IsSettingChanged = isSettingChange;
- FridayWork = fridayWork;
- HolidayWork = holidayWork;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- WorkshopShiftStatus = workshopShiftStatus;
- }
+ Salary = salary;
+ IsSettingChanged = isSettingChange;
+ FridayWork = fridayWork;
+ HolidayWork = holidayWork;
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+ WorkshopShiftStatus = workshopShiftStatus;
+ LeavePermittedDays = leavePermittedDays;
+ }
- public void SimpleEdit(
- ICollection employeeSettingsShift,
- IrregularShift irregularShift,
- WorkshopShiftStatus workshopShiftStatus, BreakTime breakTime, bool isShiftChange,HolidayWork holidayWork,FridayWork fridayWork)
- {
- CustomizeWorkshopEmployeeSettingsShifts = EmployeeSettingsShiftsConvertor(employeeSettingsShift);
- BreakTime = new BreakTime(breakTime.HasBreakTimeValue, breakTime.BreakTimeValue);
- IsShiftChanged = isShiftChange;
- WorkshopShiftStatus = workshopShiftStatus;
- HolidayWork = holidayWork;
- FridayWork = fridayWork;
+ public void SimpleEdit(
+ ICollection employeeSettingsShift,
+ IrregularShift irregularShift,
+ WorkshopShiftStatus workshopShiftStatus, BreakTime breakTime, bool isShiftChange, FridayWork fridayWork, HolidayWork holidayWork,
+ ICollection rotatingShifts)
+ {
+ BreakTime = new BreakTime(breakTime.HasBreakTimeValue, breakTime.BreakTimeValue);
+ IsShiftChanged = isShiftChange;
+ WorkshopShiftStatus = workshopShiftStatus;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- }
+ CustomizeWorkshopEmployeeSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? EmployeeSettingsShiftsConvertor(employeeSettingsShift) : [];
+
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+
+ CustomizeRotatingShifts = workshopShiftStatus == WorkshopShiftStatus.Rotating ? rotatingShifts : [];
+
+ FridayWork = fridayWork;
+ HolidayWork = holidayWork;
+ }
- private List EmployeeSettingsShiftsConvertor(
- ICollection employeeSettingsShift)
- {
- var customizeWorkshopSettingShiftsList =
- employeeSettingsShift.ToList(); // Handle the special case where there's only one shift
- if (customizeWorkshopSettingShiftsList.Count == 1)
- {
- var singleShift = customizeWorkshopSettingShiftsList.First();
- return new List
- {
- new CustomizeWorkshopEmployeeSettingsShift(singleShift.StartTime, singleShift.EndTime,
- singleShift.Placement, TimeOnly.MaxValue)
- };
- }
+ private List EmployeeSettingsShiftsConvertor(
+ ICollection employeeSettingsShift)
+ {
+ var customizeWorkshopSettingShiftsList =
+ employeeSettingsShift.ToList();
+ // Handle the special case where there's only one shift
+ if (customizeWorkshopSettingShiftsList.Count == 1)
+ {
+ var singleShift = customizeWorkshopSettingShiftsList.First();
+ return new List
+ {
+ new CustomizeWorkshopEmployeeSettingsShift(singleShift.StartTime, singleShift.EndTime,
+ singleShift.Placement, TimeOnly.MaxValue)
+ };
+ }
- return customizeWorkshopSettingShiftsList.Select((x, index) =>
- {
+ return customizeWorkshopSettingShiftsList.Select((x, index) =>
+ {
- if (index == 0)
- {
- return new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement);
+ if (index == 0)
+ {
+ return new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement);
- }
+ }
- // Ensure no more than three shifts
- if (index >= 3)
- {
- throw new InvalidDataException("شیفت های پرسنل نمیتواند بیشتر از سه تا باشد");
- }
+ // Ensure no more than three shifts
+ if (index >= 3)
+ {
+ throw new InvalidDataException("شیفت های پرسنل نمیتواند بیشتر از سه تا باشد");
+ }
- var previousShift = customizeWorkshopSettingShiftsList[index - 1];
- var nextStart = new DateTime(DateOnly.MinValue, x.StartTime);
- var previousEnd = new DateTime(DateOnly.MinValue, previousShift.EndTime);
- if (nextStart < previousEnd)
- {
- nextStart = nextStart.AddDays(1);
- }
+ var previousShift = customizeWorkshopSettingShiftsList[index - 1];
+ var nextStart = new DateTime(DateOnly.MinValue, x.StartTime);
+ var previousEnd = new DateTime(DateOnly.MinValue, previousShift.EndTime);
+ if (nextStart < previousEnd)
+ {
+ nextStart = nextStart.AddDays(1);
+ }
- var differenceTimeSpan = nextStart - previousEnd;
- var oneThirdOfDifference = (differenceTimeSpan / 3) * 2;
- var previousTimeThreshold = TimeOnly.FromDateTime(previousEnd.AddTicks(oneThirdOfDifference.Ticks));
- return new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement,
- previousTimeThreshold);
- }).ToList();
+ var differenceTimeSpan = nextStart - previousEnd;
+ var oneThirdOfDifference = (differenceTimeSpan / 3) * 2;
+ var previousTimeThreshold = TimeOnly.FromDateTime(previousEnd.AddTicks(oneThirdOfDifference.Ticks));
+ return new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement,
+ previousTimeThreshold);
+ }).ToList();
- }
+ }
- private void SetValueObjects(FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay,
- BonusesPay bonusesPay
- , NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
- FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
- FineAbsenceDeduction fineAbsenceDeduction,
- LateToWork lateToWork, EarlyExit earlyExit)
- {
- FridayPay = new(fridayPay.FridayPayType, fridayPay.Value);
- OverTimePay = new(overTimePay.OverTimePayType, overTimePay.Value);
- BaseYearsPay = new(baseYearsPay.BaseYearsPayType, baseYearsPay.Value, baseYearsPay.PaymentType);
- BonusesPay = new(bonusesPay.BonusesPayType, bonusesPay.Value, bonusesPay.PaymentType);
- NightWorkPay = new(nightWorkPay.NightWorkingType, nightWorkPay.Value);
- MarriedAllowance = new(marriedAllowance.MarriedAllowanceType, marriedAllowance.Value);
- ShiftPay = new(shiftPay.ShiftType, shiftPay.ShiftPayType, shiftPay.Value);
- FamilyAllowance = new(familyAllowance.FamilyAllowanceType, familyAllowance.Value);
- LeavePay = new(leavePay.LeavePayType, leavePay.Value);
- InsuranceDeduction = new(insuranceDeduction.InsuranceDeductionType, insuranceDeduction.Value);
- FineAbsenceDeduction = new(
- fineAbsenceDeduction.FineAbsenceDeductionType, fineAbsenceDeduction.Value,
- fineAbsenceDeduction.FineAbsenceDayOfWeekCollection
- .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
- );
- LateToWork = new(
- lateToWork.LateToWorkType,
- lateToWork.LateToWorkTimeFines.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
- .ToList(), lateToWork.Value
- );
- EarlyExit = new(earlyExit.EarlyExitType,
- earlyExit.EarlyExitTimeFines.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
- .ToList(), earlyExit.Value);
- }
+ private void SetValueObjects(FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay,
+ BonusesPay bonusesPay
+ , NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
+ FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
+ FineAbsenceDeduction fineAbsenceDeduction,
+ LateToWork lateToWork, EarlyExit earlyExit)
+ {
+ FridayPay = new(fridayPay.FridayPayType, fridayPay.Value);
+ OverTimePay = new(overTimePay.OverTimePayType, overTimePay.Value);
+ BaseYearsPay = new(baseYearsPay.BaseYearsPayType, baseYearsPay.Value, baseYearsPay.PaymentType);
+ BonusesPay = new(bonusesPay.BonusesPayType, bonusesPay.Value, bonusesPay.PaymentType);
+ NightWorkPay = new(nightWorkPay.NightWorkingType, nightWorkPay.Value);
+ MarriedAllowance = new(marriedAllowance.MarriedAllowanceType, marriedAllowance.Value);
+ ShiftPay = new(shiftPay.ShiftType, shiftPay.ShiftPayType, shiftPay.Value);
+ FamilyAllowance = new(familyAllowance.FamilyAllowanceType, familyAllowance.Value);
+ LeavePay = new(leavePay.LeavePayType, leavePay.Value);
+ InsuranceDeduction = new(insuranceDeduction.InsuranceDeductionType, insuranceDeduction.Value);
+ FineAbsenceDeduction = new(
+ fineAbsenceDeduction.FineAbsenceDeductionType, fineAbsenceDeduction.Value,
+ fineAbsenceDeduction.FineAbsenceDayOfWeekCollection
+ .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
+ );
+ LateToWork = new(
+ lateToWork.LateToWorkType,
+ lateToWork.LateToWorkTimeFines.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
+ .ToList(), lateToWork.Value
+ );
+ EarlyExit = new(earlyExit.EarlyExitType,
+ earlyExit.EarlyExitTimeFines.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
+ .ToList(), earlyExit.Value);
+ }
}
\ No newline at end of file
diff --git a/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettingsShift.cs b/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettingsShift.cs
index 00e1fda6..bf3bf7fe 100644
--- a/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettingsShift.cs
+++ b/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/Entities/CustomizeWorkshopEmployeeSettingsShift.cs
@@ -1,4 +1,4 @@
-
+using _0_Framework.Domain;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
using System;
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
diff --git a/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/ICustomizeWorkshopEmployeeSettingsRepository.cs b/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/ICustomizeWorkshopEmployeeSettingsRepository.cs
index 624a931f..230c4b1f 100644
--- a/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/ICustomizeWorkshopEmployeeSettingsRepository.cs
+++ b/Company.Domain/CustomizeWorkshopEmployeeSettingsAgg/ICustomizeWorkshopEmployeeSettingsRepository.cs
@@ -9,9 +9,9 @@ public interface ICustomizeWorkshopEmployeeSettingsRepository : IRepository GetBy(long groupId);
List GetEmployeeSettingsByWorkshopId(long workshopId);
List GetEmployeeSettingNotInMainGroup(long entityWorkshopId);
+
}
\ No newline at end of file
diff --git a/Company.Domain/CustomizeWorkshopGroupSettingsAgg/Entities/CustomizeWorkshopGroupSettings.cs b/Company.Domain/CustomizeWorkshopGroupSettingsAgg/Entities/CustomizeWorkshopGroupSettings.cs
index 2e66359e..bd48840c 100644
--- a/Company.Domain/CustomizeWorkshopGroupSettingsAgg/Entities/CustomizeWorkshopGroupSettings.cs
+++ b/Company.Domain/CustomizeWorkshopGroupSettingsAgg/Entities/CustomizeWorkshopGroupSettings.cs
@@ -9,6 +9,7 @@ using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
using Company.Domain.CustomizeWorkshopSettingsAgg.Entities;
using Company.Domain.WorkshopAgg;
+using CompanyManagment.App.Contracts.Leave;
using Newtonsoft.Json.Serialization;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
@@ -27,20 +28,25 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
BonusesPay bonusesPay, NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
FineAbsenceDeduction fineAbsenceDeduction, LateToWork lateToWork, EarlyExit earlyExit, FridayWork fridayWork,
- HolidayWork holidayWork, BreakTime breakTime, WorkshopShiftStatus workshopShiftStatus, IrregularShift irregularShift) : base(fridayPay, overTimePay, baseYearsPay, bonusesPay, nightWorkPay,
+ HolidayWork holidayWork, BreakTime breakTime, WorkshopShiftStatus workshopShiftStatus, IrregularShift irregularShift, int leavePermittedDays, ICollection rotatingShifts) :
+ base(fridayPay, overTimePay, baseYearsPay, bonusesPay, nightWorkPay,
marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction, lateToWork,
- earlyExit, fridayWork, holidayWork, breakTime)
+ earlyExit, fridayWork, holidayWork, breakTime, leavePermittedDays)
{
GroupName = groupName;
Salary = salary;
CustomizeWorkshopSettingId = customizeWorkshopSettingId;
GuardGroupShifts(customizeWorkshopGroupSettingsShifts);
- CustomizeWorkshopGroupSettingsShifts = customizeWorkshopGroupSettingsShifts;
WorkshopShiftStatus = workshopShiftStatus;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- }
+
+ CustomizeRotatingShifts = workshopShiftStatus == WorkshopShiftStatus.Rotating ? rotatingShifts : [];
+
+ CustomizeWorkshopGroupSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? customizeWorkshopGroupSettingsShifts : [];
+
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+ }
private void GuardGroupShifts(ICollection customizeWorkshopGroupSettingsShifts)
{
@@ -60,6 +66,7 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
public IrregularShift IrregularShift { get; set; }
public ICollection CustomizeWorkshopGroupSettingsShifts { get; set; }
public ICollection CustomizeWorkshopEmployeeSettingsCollection { get; set; }
+ public ICollection CustomizeRotatingShifts { get; set; }
public CustomizeWorkshopSettings CustomizeWorkshopSettings { get; set; }
@@ -70,8 +77,8 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
LeavePay leavePay, InsuranceDeduction insuranceDeduction, FineAbsenceDeduction fineAbsenceDeduction,
LateToWork lateToWork, EarlyExit earlyExit,
ICollection customizeWorkshopGroupSettingsShifts, FridayWork fridayWork,
- HolidayWork holidayWork, IrregularShift irregularShift,
- WorkshopShiftStatus workshopShiftStatus, long customizeWorkshopSettingId,BreakTime breakTime)
+ HolidayWork holidayWork, IrregularShift irregularShift, ICollection rotatingShifts,
+ WorkshopShiftStatus workshopShiftStatus, long customizeWorkshopSettingId, BreakTime breakTime, int leavePermittedDays)
{
GuardGroupShifts(customizeWorkshopGroupSettingsShifts);
GroupName = "اصلی";
@@ -91,11 +98,15 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
EarlyExit = earlyExit;
FridayWork = fridayWork;
HolidayWork = holidayWork;
- CustomizeWorkshopGroupSettingsShifts = customizeWorkshopGroupSettingsShifts;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- WorkshopShiftStatus = workshopShiftStatus;
+ LeavePermittedDays = leavePermittedDays;
+ CustomizeWorkshopGroupSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? customizeWorkshopGroupSettingsShifts : [];
+
+ CustomizeRotatingShifts = workshopShiftStatus == WorkshopShiftStatus.Rotating ? rotatingShifts : [];
+
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+ WorkshopShiftStatus = workshopShiftStatus;
CustomizeWorkshopSettingId = customizeWorkshopSettingId;
MainGroup = true;
BreakTime = breakTime;
@@ -112,7 +123,7 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
OverTimePay overTimePay, BaseYearsPay baseYearsPay, BonusesPay bonusesPay, ShiftPay shiftPay,
NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, FamilyAllowance familyAllowance,
LeavePay leavePay, InsuranceDeduction insuranceDeduction, FineAbsenceDeduction fineAbsenceDeduction,
- LateToWork lateToWork, EarlyExit earlyExit, FridayWork fridayWork, HolidayWork holidayWork, bool isSettingChange)
+ LateToWork lateToWork, EarlyExit earlyExit, FridayWork fridayWork, HolidayWork holidayWork, bool isSettingChange, int leavePermittedDays)
{
GroupName = groupName;
Salary = salary;
@@ -132,6 +143,8 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
FridayWork = fridayWork;
HolidayWork = holidayWork;
IsSettingChange = isSettingChange;
+ LeavePermittedDays = leavePermittedDays;
+
var employeeSettingsShift = CustomizeWorkshopGroupSettingsShifts
.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
@@ -141,7 +154,7 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
{
item.EditEmployees(Salary, FridayPay, OverTimePay, BaseYearsPay, BonusesPay
, NightWorkPay, MarriedAllowance, ShiftPay, FamilyAllowance, LeavePay, InsuranceDeduction, FineAbsenceDeduction,
- LateToWork, EarlyExit, FridayWork, HolidayWork, IrregularShift, WorkshopShiftStatus, false);
+ LateToWork, EarlyExit, FridayWork, HolidayWork, IrregularShift, WorkshopShiftStatus, false, leavePermittedDays);
}
}
public void EditAndOverwriteOnAllEmployees(string groupName, double salary,
@@ -149,26 +162,18 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
OverTimePay overTimePay, BaseYearsPay baseYearsPay, BonusesPay bonusesPay, ShiftPay shiftPay,
NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, FamilyAllowance familyAllowance,
LeavePay leavePay, InsuranceDeduction insuranceDeduction, FineAbsenceDeduction fineAbsenceDeduction,
- LateToWork lateToWork, EarlyExit earlyExit, FridayWork fridayWork, HolidayWork holidayWork, bool isSettingChange)
+ LateToWork lateToWork, EarlyExit earlyExit, FridayWork fridayWork, HolidayWork holidayWork, bool isSettingChange, int leavePermittedDays)
{
+ SetValueObjects(fridayPay, overTimePay, baseYearsPay, bonusesPay
+ , nightWorkPay, marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction,
+ lateToWork, earlyExit);
GroupName = groupName;
Salary = salary;
- FridayPay = fridayPay;
- OverTimePay = overTimePay;
- BaseYearsPay = baseYearsPay;
- BonusesPay = bonusesPay;
- NightWorkPay = nightWorkPay;
- MarriedAllowance = marriedAllowance;
- ShiftPay = shiftPay;
- FamilyAllowance = familyAllowance;
- LeavePay = leavePay;
- InsuranceDeduction = insuranceDeduction;
- FineAbsenceDeduction = fineAbsenceDeduction;
- LateToWork = lateToWork;
- EarlyExit = earlyExit;
FridayWork = fridayWork;
HolidayWork = holidayWork;
IsSettingChange = isSettingChange;
+ LeavePermittedDays = leavePermittedDays;
+
var employeeSettingsShift = CustomizeWorkshopGroupSettingsShifts
.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
@@ -177,7 +182,7 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
{
item.EditEmployees(Salary, FridayPay, OverTimePay, BaseYearsPay, BonusesPay
, NightWorkPay, MarriedAllowance, ShiftPay, FamilyAllowance, LeavePay, InsuranceDeduction, FineAbsenceDeduction,
- LateToWork, EarlyExit, FridayWork, HolidayWork, IrregularShift, WorkshopShiftStatus, false);
+ LateToWork, EarlyExit, FridayWork, HolidayWork, IrregularShift, WorkshopShiftStatus, false, leavePermittedDays);
}
}
@@ -190,18 +195,23 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
public void EditSimpleAndOverwriteOnEmployee(string groupName, IEnumerable employeeIds,
ICollection customizeWorkshopGroupSettingsShifts, WorkshopShiftStatus workshopShiftStatus,
- IrregularShift irregularShift, BreakTime breakTime, bool isShiftChange,HolidayWork holidayWork , FridayWork fridayWork)
+ IrregularShift irregularShift, BreakTime breakTime, bool isShiftChange, FridayWork fridayWork, HolidayWork holidayWork, ICollection rotatingShifts)
{
GroupName = groupName;
- CustomizeWorkshopGroupSettingsShifts = customizeWorkshopGroupSettingsShifts;
+ CustomizeWorkshopGroupSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? customizeWorkshopGroupSettingsShifts : [];
WorkshopShiftStatus = workshopShiftStatus;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- BreakTime = new BreakTime(breakTime.HasBreakTimeValue, breakTime.BreakTimeValue);
+
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+ CustomizeRotatingShifts = workshopShiftStatus == WorkshopShiftStatus.Rotating ? rotatingShifts : [];
+
+
+ BreakTime = new BreakTime(breakTime.HasBreakTimeValue, breakTime.BreakTimeValue);
IsShiftChange = isShiftChange;
FridayWork = fridayWork;
HolidayWork = holidayWork;
+
//var employeeSettingsShift = customizeWorkshopGroupSettingsShifts
// .Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
if (isShiftChange)
@@ -210,35 +220,49 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
}
var permittedToOverWrite = CustomizeWorkshopEmployeeSettingsCollection.Where(x => employeeIds.Contains(x.id));
+
foreach (var item in permittedToOverWrite)
{
+ var newRotatingShifts = CustomizeRotatingShifts.Select(x => new CustomizeRotatingShift(x.StartTime, x.EndTime))
+ .ToList();
item.SimpleEdit(customizeWorkshopGroupSettingsShifts
.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList(),
- IrregularShift, WorkshopShiftStatus, BreakTime, false,holidayWork, fridayWork);
+ IrregularShift, WorkshopShiftStatus, BreakTime, false, FridayWork, HolidayWork, newRotatingShifts);
}
}
public void EditSimpleAndOverwriteOnAllEmployees(string groupName,
- ICollection customizeWorkshopGroupSettingsShifts, WorkshopShiftStatus workshopShiftStatus, IrregularShift irregularShift, BreakTime breakTime, bool isShiftChange)
+ ICollection customizeWorkshopGroupSettingsShifts,
+ WorkshopShiftStatus workshopShiftStatus, IrregularShift irregularShift, BreakTime breakTime, bool isShiftChange,
+ FridayWork fridayWork, HolidayWork holidayWork, ICollection rotatingShifts)
{
GroupName = groupName;
- CustomizeWorkshopGroupSettingsShifts = customizeWorkshopGroupSettingsShifts;
+ CustomizeWorkshopGroupSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? customizeWorkshopGroupSettingsShifts : [];
WorkshopShiftStatus = workshopShiftStatus;
- IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
- new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
- : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
- BreakTime = new BreakTime(breakTime.HasBreakTimeValue, breakTime.BreakTimeValue);
+
+ IrregularShift = workshopShiftStatus == WorkshopShiftStatus.Regular ?
+ new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None)
+ : new IrregularShift(irregularShift.StartTime, irregularShift.EndTime, irregularShift.WorkshopIrregularShifts);
+
+ CustomizeRotatingShifts = workshopShiftStatus == WorkshopShiftStatus.Rotating ? rotatingShifts : [];
+
+
+ BreakTime = new BreakTime(breakTime.HasBreakTimeValue, breakTime.BreakTimeValue);
IsShiftChange = isShiftChange;
+ HolidayWork = holidayWork;
+ FridayWork = fridayWork;
//var employeeSettingsShift = customizeWorkshopGroupSettingsShifts
// .Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
foreach (var item in CustomizeWorkshopEmployeeSettingsCollection)
{
+ var newRotatingShifts = CustomizeRotatingShifts.Select(x => new CustomizeRotatingShift(x.StartTime, x.EndTime))
+ .ToList();
item.SimpleEdit(customizeWorkshopGroupSettingsShifts
.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList(),
- irregularShift, workshopShiftStatus, breakTime, false,HolidayWork,FridayWork);
+ irregularShift, workshopShiftStatus, breakTime, false, FridayWork, HolidayWork, newRotatingShifts);
}
}
@@ -275,16 +299,48 @@ public class CustomizeWorkshopGroupSettings : BaseCustomizeEntity
IrregularShift.WorkshopIrregularShifts);
BreakTime breakTime = new(BreakTime.HasBreakTimeValue, BreakTime.BreakTimeValue);
+ var rotatingShift = CustomizeRotatingShifts.Select(x => new CustomizeRotatingShift(x.StartTime, x.EndTime)).ToList();
+
var customizeWorkshopEmployeeSettings = new CustomizeWorkshopEmployeeSettings(fridayPay, overTimePay, baseYearsPay, bonusesPay, nightWorkPay,
marriedAllowance, shiftPay, familyAllowance, leavePay, insuranceDeduction, fineAbsenceDeduction, lateToWork,
earlyExit, employeeId, workshopId, Salary, id, shifts, FridayWork, HolidayWork, irregularShift,
- WorkshopShiftStatus, breakTime);
+ WorkshopShiftStatus, breakTime, LeavePermittedDays, rotatingShift);
CustomizeWorkshopEmployeeSettingsCollection.Add(customizeWorkshopEmployeeSettings);
}
-
+ private void SetValueObjects(FridayPay fridayPay, OverTimePay overTimePay, BaseYearsPay baseYearsPay,
+ BonusesPay bonusesPay
+ , NightWorkPay nightWorkPay, MarriedAllowance marriedAllowance, ShiftPay shiftPay,
+ FamilyAllowance familyAllowance, LeavePay leavePay, InsuranceDeduction insuranceDeduction,
+ FineAbsenceDeduction fineAbsenceDeduction,
+ LateToWork lateToWork, EarlyExit earlyExit)
+ {
+ FridayPay = new(fridayPay.FridayPayType, fridayPay.Value);
+ OverTimePay = new(overTimePay.OverTimePayType, overTimePay.Value);
+ BaseYearsPay = new(baseYearsPay.BaseYearsPayType, baseYearsPay.Value, baseYearsPay.PaymentType);
+ BonusesPay = new(bonusesPay.BonusesPayType, bonusesPay.Value, bonusesPay.PaymentType);
+ NightWorkPay = new(nightWorkPay.NightWorkingType, nightWorkPay.Value);
+ MarriedAllowance = new(marriedAllowance.MarriedAllowanceType, marriedAllowance.Value);
+ ShiftPay = new(shiftPay.ShiftType, shiftPay.ShiftPayType, shiftPay.Value);
+ FamilyAllowance = new(familyAllowance.FamilyAllowanceType, familyAllowance.Value);
+ LeavePay = new(leavePay.LeavePayType, leavePay.Value);
+ InsuranceDeduction = new(insuranceDeduction.InsuranceDeductionType, insuranceDeduction.Value);
+ FineAbsenceDeduction = new(
+ fineAbsenceDeduction.FineAbsenceDeductionType, fineAbsenceDeduction.Value,
+ fineAbsenceDeduction.FineAbsenceDayOfWeekCollection
+ .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
+ );
+ LateToWork = new(
+ lateToWork.LateToWorkType,
+ lateToWork.LateToWorkTimeFines.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
+ .ToList(), lateToWork.Value
+ );
+ EarlyExit = new(earlyExit.EarlyExitType,
+ earlyExit.EarlyExitTimeFines.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
+ .ToList(), earlyExit.Value);
+ }
//public void OverWriteEmployeesShiftAndSalary(IEnumerable ids,ICollection employeeSettingsShifts,double salary)
diff --git a/Company.Domain/CustomizeWorkshopGroupSettingsAgg/ICustomizeWorkshopGroupSettingsRepository.cs b/Company.Domain/CustomizeWorkshopGroupSettingsAgg/ICustomizeWorkshopGroupSettingsRepository.cs
index 29f39d5a..3fd22355 100644
--- a/Company.Domain/CustomizeWorkshopGroupSettingsAgg/ICustomizeWorkshopGroupSettingsRepository.cs
+++ b/Company.Domain/CustomizeWorkshopGroupSettingsAgg/ICustomizeWorkshopGroupSettingsRepository.cs
@@ -10,7 +10,7 @@ public interface ICustomizeWorkshopGroupSettingsRepository : IRepository GetEmployeesWithoutGroup(long workshopId);
+ List GetEmployeesWithoutGroup(long workshopSettingsId);
List GetEmployeesWithoutGroupByWorkshopId(long workshopId);
CustomizeWorkshopGroupSettings GetWithEmployees(long groupId);
List GetShiftChangedEmployeeSettingsByGroupSettingsId(long groupSettingsId);
diff --git a/Company.Domain/CustomizeWorkshopSettingsAgg/Entities/CustomizeWorkshopSettings.cs b/Company.Domain/CustomizeWorkshopSettingsAgg/Entities/CustomizeWorkshopSettings.cs
index 0a3e2537..ca3470ee 100644
--- a/Company.Domain/CustomizeWorkshopSettingsAgg/Entities/CustomizeWorkshopSettings.cs
+++ b/Company.Domain/CustomizeWorkshopSettingsAgg/Entities/CustomizeWorkshopSettings.cs
@@ -17,7 +17,7 @@ public class CustomizeWorkshopSettings : BaseCustomizeEntity
public CustomizeWorkshopSettings(long workshopId,
ICollection customizeWorkshopSettingsShifts, int leavePermittedDays,
- WorkshopShiftStatus workshopShiftStatus)
+ WorkshopShiftStatus workshopShiftStatus,FridayWork fridayWork,HolidayWork holidayWork)
{
FridayPay = new FridayPay(FridayPayType.None, 0);
OverTimePay = new OverTimePay(OverTimePayType.None, 0);
@@ -38,8 +38,8 @@ public class CustomizeWorkshopSettings : BaseCustomizeEntity
OverTimeThresholdMinute = 0;
Currency = Currency.Rial;
MaxMonthDays = MaxMonthDays.Default;
- FridayWork = FridayWork.Default;
- HolidayWork = HolidayWork.Default;
+ FridayWork = fridayWork;
+ HolidayWork = holidayWork;
BonusesPaysInEndOfMonth = BonusesPaysInEndOfYear.EndOfYear;
WorkshopShiftStatus = workshopShiftStatus;
@@ -69,10 +69,7 @@ public class CustomizeWorkshopSettings : BaseCustomizeEntity
public MaxMonthDays MaxMonthDays { get; private set; }
- ///
- /// تعداد روز های مجاز برای مرخصی
- ///
- public int LeavePermittedDays { get; private set; }
+
///
/// آیا عیدی همیشه آخر سال تعلق میگیره یا در زمان ترک کار هم تعلق میگیره
@@ -129,26 +126,26 @@ public class CustomizeWorkshopSettings : BaseCustomizeEntity
Currency = currency;
}
- public void ChangeWorkshopShifts(ICollection customizeWorkshopSettingsShifts,
- WorkshopShiftStatus workshopShiftStatus, FridayWork fridayWork, HolidayWork holidayWork)
- {
- WorkshopShiftStatus = workshopShiftStatus;
+ public void ChangeWorkshopShifts(ICollection customizeWorkshopSettingsShifts,
+ WorkshopShiftStatus workshopShiftStatus,FridayWork fridayWork,HolidayWork holidayWork)
+ {
+ WorkshopShiftStatus = workshopShiftStatus;
HolidayWork = holidayWork;
FridayWork = fridayWork;
- CustomizeWorkshopSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? customizeWorkshopSettingsShifts : new List();
- if (workshopShiftStatus == WorkshopShiftStatus.Regular)
- {
- var date = new DateOnly();
- var firstStartShift = new DateTime(date, CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime);
- var lastEndShift = new DateTime(date, CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime);
-
-
+ CustomizeWorkshopSettingsShifts = workshopShiftStatus == WorkshopShiftStatus.Regular ? customizeWorkshopSettingsShifts : new List();
+ if (workshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
+ var date = new DateOnly();
+ var firstStartShift = new DateTime(date, CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime);
+ var lastEndShift = new DateTime(date, CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime);
+
+
if (lastEndShift > firstStartShift)
firstStartShift = firstStartShift.AddDays(1);
var offSet = (firstStartShift - lastEndShift).Divide(2);
EndTimeOffSet = TimeOnly.FromDateTime(lastEndShift.Add(offSet));
}
- }
+ }
}
\ No newline at end of file
diff --git a/Company.Domain/CustomizeWorkshopSettingsAgg/ICustomizeWorkshopSettingsRepository.cs b/Company.Domain/CustomizeWorkshopSettingsAgg/ICustomizeWorkshopSettingsRepository.cs
index 4f912233..20a046dc 100644
--- a/Company.Domain/CustomizeWorkshopSettingsAgg/ICustomizeWorkshopSettingsRepository.cs
+++ b/Company.Domain/CustomizeWorkshopSettingsAgg/ICustomizeWorkshopSettingsRepository.cs
@@ -1,25 +1,25 @@
-using System.Collections.Generic;
-using _0_Framework.Application;
+using _0_Framework.Application;
using _0_Framework.Domain;
using Company.Domain.CustomizeWorkshopSettingsAgg.Entities;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
+using System.Collections.Generic;
namespace Company.Domain.CustomizeWorkshopSettingsAgg;
public interface ICustomizeWorkshopSettingsRepository : IRepository
{
- // It will Get the Workshop Settings with its groups and the employees of groups.
- CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth);
+ // It will Get the Workshop Settings with its groups and the employees of groups.
+ CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth);
+ CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId);
-
- CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByWorkshopIdGroupSettingsId(long workshopId,
- long employeeId);
- CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId);
-
- EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId);
+ EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId);
EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId);
List GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId);
CustomizeWorkshopSettingsViewModel GetWorkshopIncludeGroupsByWorkshopId(long workshopId);
+ #region Pooya
+ List GetEmployeeSettingsWithMonthlySalary(long workshopId);
+ List GetEmployeeSettingsByWorkshopId(long workshopId);
+ #endregion
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeEmployeeSettings.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeEmployeeSettings.cs
index 87fbc6a9..c780fa38 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeEmployeeSettings.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeEmployeeSettings.cs
@@ -1,6 +1,7 @@
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings.ValueObjectsViewModel;
using System.Collections.Generic;
+using System.Security.AccessControl;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
@@ -15,4 +16,5 @@ public class CreateCustomizeEmployeeSettings
public WorkshopShiftStatus WorkshopShiftStatus { get; set; }
public IrregularShift IrregularShift { get; set; }
+ public int LeavePermittedDays { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopGroupSettings.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopGroupSettings.cs
index 4354f2f4..b80062f9 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopGroupSettings.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopGroupSettings.cs
@@ -7,6 +7,7 @@ namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
public class CreateCustomizeWorkshopGroupSettings
{
+
public string Name { get; set; }
public string Salary { get; set; }
public long CustomizeWorkshopSettingId { get; set; }
@@ -17,4 +18,6 @@ public class CreateCustomizeWorkshopGroupSettings
public int LeavePermittedDays { get; set; }
public FridayWork FridayWork { get; set; }
public HolidayWork HolidayWork { get; set; }
+ public ICollection CustomizeRotatingShiftsViewModels { get; set; }
+
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopSettings.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopSettings.cs
index 0115e0c7..e40246d5 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopSettings.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CreateCustomizeWorkshopSettings.cs
@@ -20,6 +20,17 @@ public class CreateCustomizeWorkshopSettings
public BreakTime BreakTime { get; set; }
+ ///
+ /// آیا جمعه کار میکند یا نه
+ ///
+ public FridayWork FridayWork { get; set; }
+
+ ///
+ /// آیا در روز های تعطیل کار میکند
+ ///
+ public HolidayWork HolidayWork { get; set; }
+
+
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeRotatingShiftsViewModel.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeRotatingShiftsViewModel.cs
new file mode 100644
index 00000000..ec67d9f4
--- /dev/null
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeRotatingShiftsViewModel.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
+
+public class CustomizeRotatingShiftsViewModel
+{
+ public string StartTime{ get; set; }
+ public string EndTime{ get; set; }
+};
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopEmployeeSettingsViewModel.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopEmployeeSettingsViewModel.cs
index 015d5438..5c130801 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopEmployeeSettingsViewModel.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopEmployeeSettingsViewModel.cs
@@ -1,8 +1,6 @@
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
-using System;
-using System.Collections.Generic;
-using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
+using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
@@ -24,4 +22,5 @@ public class CustomizeWorkshopEmployeeSettingsViewModel
public HolidayWork HolidayWork { get; set; }
public FridayWork FridayWork { get; set; }
public int LeavePermittedDays { get; set; }
+ public ICollection CustomizeRotatingShiftsViewModels { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopGroupSettingsViewModel.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopGroupSettingsViewModel.cs
index cc11e91e..a19afa21 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopGroupSettingsViewModel.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopGroupSettingsViewModel.cs
@@ -12,6 +12,10 @@ public class CustomizeWorkshopGroupSettingsViewModel
public bool MainGroup { get; set; }
public List RollCallWorkshopShifts { get; set; }
public List RollCallWorkshopEmployeesSettings { get; set; }
+ public List CustomizeRotatingShiftsViewModels { get; set; }
public WorkshopShiftStatus WorkshopShiftStatus { get; set; }
public IrregularShift IrregularShift { get; set; }
+ public BreakTime BreakTime { get; set; }
+ public FridayWork FridayWork { get; set; }
+ public HolidayWork HolidayWork { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs
index 7b34dd6c..7079d21c 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/CustomizeWorkshopSettingsViewModel.cs
@@ -1,5 +1,5 @@
-using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
-using System.Collections.Generic;
+using System.Collections.Generic;
+using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
@@ -7,6 +7,6 @@ public class CustomizeWorkshopSettingsViewModel
{
public long Id { get; set; }
public string Name { get; set; }
- public List GroupSettings { get; set; }
public WorkshopShiftStatus WorkshopShiftStatus { get; set; }
+ public List GroupSettings { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeEmployeeSettings.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeEmployeeSettings.cs
index fa50f043..a29d491e 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeEmployeeSettings.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeEmployeeSettings.cs
@@ -89,5 +89,6 @@ public class EditCustomizeEmployeeSettings:CreateCustomizeEmployeeSettings
public bool IsShiftChanged { get; set; }
public bool IsSettingChanged { get; set; }
public IEnumerable ShiftViewModel { get; set; }
+ public ICollection CustomizeRotatingShifts{ get; set; }
public BreakTime BreakTime { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopGroupSettings.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopGroupSettings.cs
index 37652094..acb4683e 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopGroupSettings.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopGroupSettings.cs
@@ -1,90 +1,90 @@
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings.ValueObjectsViewModel;
using System.Collections.Generic;
-using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
public class EditCustomizeWorkshopGroupSettings : CreateCustomizeWorkshopGroupSettings
{
- public long Id { get; set; }
- public List EmployeeIds { get; set; }
+ public long Id { get; set; }
+ public List EmployeeIds { get; set; }
- ///
- /// جمعه کاری
- ///
- public FridayPayViewModel FridayPay { get; set; }
+ ///
+ /// جمعه کاری
+ ///
+ public FridayPayViewModel FridayPay { get; set; }
- ///
- /// اضافه کاری
- ///
- public OverTimePayViewModel OverTimePay { get; set; }
- ///
- /// سنوات
- ///
- public BaseYearsPayViewModel BaseYearsPay { get; set; }
+ ///
+ /// اضافه کاری
+ ///
+ public OverTimePayViewModel OverTimePay { get; set; }
- ///
- /// عیدی
- ///
- public BonusesPayViewModel BonusesPay { get; set; }
+ ///
+ /// سنوات
+ ///
+ public BaseYearsPayViewModel BaseYearsPay { get; set; }
- ///
- /// شب کاری
- ///
- public NightWorkPayViewModel NightWorkPay { get; set; }
+ ///
+ /// عیدی
+ ///
+ public BonusesPayViewModel BonusesPay { get; set; }
- ///
- /// حق تاهل
- ///
- public MarriedAllowanceViewModel MarriedAllowance { get; set; }
+ ///
+ /// شب کاری
+ ///
+ public NightWorkPayViewModel NightWorkPay { get; set; }
- ///
- /// نوبت کاری
- ///
- public ShiftPayViewModel ShiftPay { get; set; }
+ ///
+ /// حق تاهل
+ ///
+ public MarriedAllowanceViewModel MarriedAllowance { get; set; }
- ///
- /// حق اولاد(حق فرزند)ء
- ///
- public FamilyAllowanceViewModel FamilyAllowance { get; set; }
+ ///
+ /// نوبت کاری
+ ///
+ public ShiftPayViewModel ShiftPay { get; set; }
- ///
- /// مزد مرخصی
- ///
- public LeavePayViewModel LeavePay { get; set; }
+ ///
+ /// حق اولاد(حق فرزند)ء
+ ///
+ public FamilyAllowanceViewModel FamilyAllowance { get; set; }
- ///
- /// حق بیمه
- ///
- public InsuranceDeductionViewModel InsuranceDeduction { get; set; }
+ ///
+ /// مزد مرخصی
+ ///
+ public LeavePayViewModel LeavePay { get; set; }
- ///
- /// جریمه غیبت
- ///
- public FineAbsenceDeductionViewModel FineAbsenceDeduction { get; set; }
+ ///
+ /// حق بیمه
+ ///
+ public InsuranceDeductionViewModel InsuranceDeduction { get; set; }
- ///
- /// تاخیر در ورود
- ///
- public LateToWorkViewModel LateToWork { get; set; }
+ ///
+ /// جریمه غیبت
+ ///
+ public FineAbsenceDeductionViewModel FineAbsenceDeduction { get; set; }
- ///
- /// نعجیل در خروج
- ///
- public EarlyExitViewModel EarlyExit { get; set; }
+ ///
+ /// تاخیر در ورود
+ ///
+ public LateToWorkViewModel LateToWork { get; set; }
- ///
- /// آیا جمعه کار میکند یا نه
- ///
- public FridayWork FridayWork { get; set; }
+ ///
+ /// نعجیل در خروج
+ ///
+ public EarlyExitViewModel EarlyExit { get; set; }
- ///
- /// آیا در روز های تعطیل کار میکند
- ///
- public HolidayWork HolidayWork { get; set; }
+ ///
+ /// آیا جمعه کار میکند یا نه
+ ///
+ public FridayWork FridayWork { get; set; }
- public bool IsShiftChanged { get; set; }
- public bool IsSettingChanged { get; set; }
+ ///
+ /// آیا در روز های تعطیل کار میکند
+ ///
+ public HolidayWork HolidayWork { get; set; }
+
+ public bool IsShiftChanged { get; set; }
+ public bool IsSettingChanged { get; set; }
}
\ No newline at end of file
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopSettings.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopSettings.cs
index 1b917a24..ba2c96d3 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopSettings.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/EditCustomizeWorkshopSettings.cs
@@ -81,15 +81,6 @@ public class EditCustomizeWorkshopSettings : CreateCustomizeWorkshopSettings
public EarlyExitViewModel EarlyExit { get; set; }
- ///
- /// آیا جمعه کار میکند یا نه
- ///
- public FridayWork FridayWork { get; set; }
-
- ///
- /// آیا در روز های تعطیل کار میکند
- ///
- public HolidayWork HolidayWork { get; set; }
///
/// آیا عیدی همیشه آخر سال تعلق میگیره یا در زمان ترک کار هم تعلق میگیره
diff --git a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/ICustomizeWorkshopSettingsApplication.cs b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/ICustomizeWorkshopSettingsApplication.cs
index cb6aef7b..8e051851 100644
--- a/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/ICustomizeWorkshopSettingsApplication.cs
+++ b/CompanyManagment.App.Contracts/CustomizeWorkshopSettings/ICustomizeWorkshopSettingsApplication.cs
@@ -41,6 +41,8 @@ public interface ICustomizeWorkshopSettingsApplication
OperationResult AddEmployeeToMainGroupSettings(long workshopId, long employeeId);
+ OperationResult CreateEmployeesSettingsAndSetChanges(EditCustomizeEmployeeSettings command);
+
///
/// این متد تاریخ شیفت تنظیمات کارگاه را تغییر میدهد
///
@@ -50,13 +52,11 @@ public interface ICustomizeWorkshopSettingsApplication
///
///
OperationResult EditWorkshopSettingShifts(List shiftViewModels,
- long customizeWorkshopSettingsId, WorkshopShiftStatus workshopShiftStatus, FridayWork fridayWork, HolidayWork holidayWork);
+ long customizeWorkshopSettingsId,WorkshopShiftStatus workshopShiftStatus,FridayWork fridayWork,HolidayWork holidayWork);
- // It will Get the Workshop Settings with its groups and the employees of groups.
- CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth);
+ // It will Get the Workshop Settings with its groups and the employees of groups.
+ CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth);
- public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByEmployeeIdWorkshopId(long workshopId,
- long employeeId);
List GetChangedEmployeeSettingsByGroupSettingsId(long groupSettingsId);
@@ -65,8 +65,6 @@ public interface ICustomizeWorkshopSettingsApplication
CustomizeWorkshopEmployeeSettingsViewModel GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(long workshopId, long employeeId);
- CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByEmployeeIdGroupSettingsId(long workshopId, long employeeId);
-
List GetEmployeeSettingsByGroupSettingsId(long groupSettingsId);
EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId);
@@ -78,7 +76,9 @@ public interface ICustomizeWorkshopSettingsApplication
///
EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId);
- EditCustomizeWorkshopGroupSettings GetCustomizeWorkshopGroupSettingsDetails(long groupId);
+ CustomizeWorkshopSettingsViewModel GetWorkshopIncludeGroupsByWorkshopId(long workshopId);
+
+ EditCustomizeWorkshopGroupSettings GetCustomizeWorkshopGroupSettingsDetails(long groupId);
EditCustomizeEmployeeSettings GetCustomizeEmployeeSettingsDetails(long customizeEmployeeId);
diff --git a/CompanyManagment.Application/CustomizeWorkshopSettingsApplication.cs b/CompanyManagment.Application/CustomizeWorkshopSettingsApplication.cs
index 5360e4f2..aef84929 100644
--- a/CompanyManagment.Application/CustomizeWorkshopSettingsApplication.cs
+++ b/CompanyManagment.Application/CustomizeWorkshopSettingsApplication.cs
@@ -1,8 +1,6 @@
using _0_Framework.Application;
-using _0_Framework.Domain.CustomizeCheckoutShared.Base;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
-using AccountManagement.Application.Contracts.Account;
using AccountManagement.Application.Contracts.CameraAccount;
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
@@ -14,189 +12,340 @@ using Company.Domain.EmployeeAgg;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.RollCallEmployee;
-using CompanyManagment.App.Contracts.Workshop;
-using CompanyManagment.EFCore.Migrations;
using Microsoft.EntityFrameworkCore;
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Runtime.ExceptionServices;
using System.Transactions;
namespace CompanyManagment.Application;
public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository,
- IAuthHelper authHelper, IPasswordHasher passwordHasher, ICameraAccountApplication cameraAccountApplication,
- ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, IEmployeeRepository employeeRepository,
- ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository,
- IRollCallEmployeeApplication rollCallEmployeeApplication)
- : ICustomizeWorkshopSettingsApplication
+ IAuthHelper authHelper, IPasswordHasher passwordHasher, ICameraAccountApplication cameraAccountApplication,
+ ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, IEmployeeRepository employeeRepository,
+ ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository,
+ IRollCallEmployeeApplication rollCallEmployeeApplication)
+ : ICustomizeWorkshopSettingsApplication
{
- private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
- private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
- private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
- private readonly IAuthHelper _authHelper = authHelper;
- private readonly IEmployeeRepository _employeeRepository = employeeRepository;
- private readonly IPasswordHasher _passwordHasher = passwordHasher;
- private readonly ICameraAccountApplication _cameraAccountApplication = cameraAccountApplication;
- private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication = rollCallEmployeeApplication;
+ private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
+ private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
+ private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
+ private readonly IAuthHelper _authHelper = authHelper;
+ private readonly IEmployeeRepository _employeeRepository = employeeRepository;
+ private readonly IPasswordHasher _passwordHasher = passwordHasher;
+ private readonly ICameraAccountApplication _cameraAccountApplication = cameraAccountApplication;
+ private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication = rollCallEmployeeApplication;
- #region RollCallShifts
+ #region RollCallShifts
- //Create workshop settings
- public OperationResult CreateWorkshopSettings(CreateCustomizeWorkshopSettings command)
- {
- OperationResult op = new();
- var workshopId = _passwordHasher.SlugDecrypt(_authHelper.GetWorkshopSlug());
- //تبدیل شیفت های ویو مدل به انتیتی
- List shiftCollection = new List();
- if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
- {
- #region Validation
- if (command.ShiftsList.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
- return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
- try
- {
- shiftCollection =
- command.ShiftsList.Select(x =>
- {
- var placement = x.Placement switch
- {
- ShiftPlacement.First => "اول",
- ShiftPlacement.Second => "دوم",
- ShiftPlacement.Third => "سوم"
- };
- if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
- throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
- if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
- throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
+ //Create workshop settings
+ public OperationResult CreateWorkshopSettings(CreateCustomizeWorkshopSettings command)
+ {
+ OperationResult op = new();
+ var workshopId = _passwordHasher.SlugDecrypt(_authHelper.GetWorkshopSlug());
+ //تبدیل شیفت های ویو مدل به انتیتی
+ List shiftCollection = new List();
+ if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
+ #region Validation
+ if (command.ShiftsList.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
+ return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
+ try
+ {
+ shiftCollection =
+ command.ShiftsList.Select(x =>
+ {
+ var placement = x.Placement switch
+ {
+ ShiftPlacement.First => "اول",
+ ShiftPlacement.Second => "دوم",
+ ShiftPlacement.Third => "سوم"
+ };
+ if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
+ throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
+ if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
+ throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
- return new CustomizeWorkshopSettingsShift(start, end, x.Placement);
+ return new CustomizeWorkshopSettingsShift(start, end, x.Placement);
- }).ToList();
- }
- catch (InvalidDataException e)
- {
+ }).ToList();
+ }
+ catch (InvalidDataException e)
+ {
- return op.Failed(e.Message);
- }
- if (workshopId < 1)
- {
- return op.Failed("خطای سیستمی");
- }
- DateTime day = DateTime.Now;
- DateTime previousEnd = new DateTime();
- var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
+ return op.Failed(e.Message);
+ }
+ if (workshopId < 1)
+ {
+ return op.Failed("خطای سیستمی");
+ }
+ DateTime day = DateTime.Now;
+ DateTime previousEnd = new DateTime();
+ var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
- shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
+ shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
- foreach (var shift in shiftCollection)
- {
- (DateTime start, DateTime end, ShiftPlacement placement) newShift =
- new()
- {
- placement = shift.Placement,
- start = new DateTime(DateOnly.FromDateTime(day), shift.StartTime),
- end = new DateTime(DateOnly.FromDateTime(day), shift.EndTime)
+ foreach (var shift in shiftCollection)
+ {
+ (DateTime start, DateTime end, ShiftPlacement placement) newShift =
+ new()
+ {
+ placement = shift.Placement,
+ start = new DateTime(DateOnly.FromDateTime(day), shift.StartTime),
+ end = new DateTime(DateOnly.FromDateTime(day), shift.EndTime)
- };
+ };
- if (previousEnd != new DateTime())
- {
- if (newShift.start <= previousEnd)
- {
- newShift.start = newShift.start.AddDays(1);
- }
- }
- while (newShift.start >= newShift.end)
- {
- newShift.end = newShift.end.AddDays(1);
- }
- finalShiftList.Add(newShift);
- previousEnd = newShift.end;
- }
+ if (previousEnd != new DateTime())
+ {
+ if (newShift.start <= previousEnd)
+ {
+ newShift.start = newShift.start.AddDays(1);
+ }
+ }
+ while (newShift.start >= newShift.end)
+ {
+ newShift.end = newShift.end.AddDays(1);
+ }
+ finalShiftList.Add(newShift);
+ previousEnd = newShift.end;
+ }
- var firstShiftStart = finalShiftList.FirstOrDefault(x => x.placement == ShiftPlacement.First).start;
- var lastShiftEnd = finalShiftList.OrderByDescending(x => x.placement).FirstOrDefault().end;
- if (firstShiftStart.AddDays(1) < lastShiftEnd)
- return op.Failed("بازه زمانی کارگاه نامعتبر است");
- var total = finalShiftList.Sum(x => (x.end - x.start).TotalHours);
- if (total >= 24)
- {
- return op.Failed("بازه زمانی کارگاه نمیتواند بیشتر از 24 ساعت باشد");
- }
- #endregion
- }
- else
- {
- command.ShiftsList = [];
- shiftCollection = [];
+ var firstShiftStart = finalShiftList.FirstOrDefault(x => x.placement == ShiftPlacement.First).start;
+ var lastShiftEnd = finalShiftList.OrderByDescending(x => x.placement).FirstOrDefault().end;
+ if (firstShiftStart.AddDays(1) < lastShiftEnd)
+ return op.Failed("بازه زمانی کارگاه نامعتبر است");
+ var total = finalShiftList.Sum(x => (x.end - x.start).TotalHours);
+ if (total >= 24)
+ {
+ return op.Failed("بازه زمانی کارگاه نمیتواند بیشتر از 24 ساعت باشد");
+ }
+ #endregion
+ }
+ else
+ {
+ command.ShiftsList = [];
+ shiftCollection = [];
- }
+ }
- var record = new CustomizeWorkshopSettings(workshopId, shiftCollection, command.LeavePermittedDays,
- command.WorkshopShiftStatus);
- using (var transaction = new TransactionScope())
- {
+ var record = new CustomizeWorkshopSettings(workshopId, shiftCollection, command.LeavePermittedDays,
+ command.WorkshopShiftStatus, command.FridayWork, command.HolidayWork);
+ using (var transaction = new TransactionScope())
+ {
- try
- {
- _customizeWorkshopSettingsRepository.Create(record);
- _customizeWorkshopSettingsRepository.SaveChanges();
+ try
+ {
+ _customizeWorkshopSettingsRepository.Create(record);
+ _customizeWorkshopSettingsRepository.SaveChanges();
- OperationResult result = new OperationResult();
+ OperationResult result = new OperationResult();
- result = command.WorkshopShiftStatus == WorkshopShiftStatus.Regular ? CreateGeneralGroup(record) : result.Succcedded();
+ result = command.WorkshopShiftStatus == WorkshopShiftStatus.Regular ? CreateGeneralGroup(record) : result.Succcedded();
- if (result.IsSuccedded)
- {
- transaction.Complete();
- }
- else
- {
- op = result;
- transaction.Dispose();
- }
- }
- catch
- {
- transaction.Dispose();
- // ignored
- }
- }
+ if (result.IsSuccedded)
+ {
+ transaction.Complete();
+ }
+ else
+ {
+ op = result;
+ transaction.Dispose();
+ }
+ }
+ catch
+ {
+ transaction.Dispose();
+ // ignored
+ }
+ }
- return string.IsNullOrWhiteSpace(op.Message) ? op.Succcedded() : op;
+ return string.IsNullOrWhiteSpace(op.Message) ? op.Succcedded() : op;
- }
+ }
- //create group settings with workshopSettingsId.
- public OperationResult CreateGroupSettingsByRollCallWorkshopSettingId(CreateCustomizeWorkshopGroupSettings command)
- {
- OperationResult op = new();
- CustomizeWorkshopSettings workshopSettings =
- _customizeWorkshopSettingsRepository.Get(command.CustomizeWorkshopSettingId);
- List shiftCollection = new List();
+ //create group settings with workshopSettingsId.
+ public OperationResult CreateGroupSettingsByRollCallWorkshopSettingId(CreateCustomizeWorkshopGroupSettings command)
+ {
+ OperationResult op = new();
+ CustomizeWorkshopSettings workshopSettings =
+ _customizeWorkshopSettingsRepository.Get(command.CustomizeWorkshopSettingId);
+ List shiftCollection = new List();
+
+ ICollection customizeRotatingShifts = [];
#region validation
if (workshopSettings == null)
- return op.Failed("خطای سیستمی");
+ return op.Failed("خطای سیستمی");
- if (string.IsNullOrWhiteSpace(command.Name))
- return op.Failed("لطفا نام گروه را وارد کنید");
+ if (string.IsNullOrWhiteSpace(command.Name))
+ return op.Failed("لطفا نام گروه را وارد کنید");
- if (string.IsNullOrWhiteSpace(command.Salary))
- return op.Failed("لطفا حقوق مورد نظر خود را وارد کنید");
+ if (string.IsNullOrWhiteSpace(command.Salary))
+ return op.Failed("لطفا حقوق مورد نظر خود را وارد کنید");
- if (!_customizeWorkshopSettingsRepository.Exists(x => x.id == command.CustomizeWorkshopSettingId))
- return op.Failed("چنین ساعت کاری برای کارگاهی وجود ندارد");
+ if (!_customizeWorkshopSettingsRepository.Exists(x => x.id == command.CustomizeWorkshopSettingId))
+ return op.Failed("چنین ساعت کاری برای کارگاهی وجود ندارد");
+
+ if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
+ if (command.ShiftViewModel.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
+ return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
+ try
+ {
+ shiftCollection =
+ command.ShiftViewModel.Select(x =>
+ {
+ var placement = x.Placement switch
+ {
+ ShiftPlacement.First => "اول",
+ ShiftPlacement.Second => "دوم",
+ ShiftPlacement.Third => "سوم"
+ };
+ if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
+ throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
+ if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
+ throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
+
+
+ return new CustomizeWorkshopGroupSettingsShift(start, end, x.Placement);
+
+ }).ToList();
+ }
+ catch (InvalidDataException e)
+ {
+
+ return op.Failed(e.Message);
+ }
+ DateTime previousEnd = new DateTime();
+ var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
+
+ shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
+
+ foreach (var shift in shiftCollection)
+ {
+ (DateTime start, DateTime end, ShiftPlacement placement) newShift =
+ new()
+ {
+ placement = shift.Placement,
+ start = new DateTime(DateOnly.MinValue, shift.StartTime),
+ end = new DateTime(DateOnly.MinValue, shift.EndTime)
+
+
+ };
+
+ if (previousEnd != new DateTime())
+ {
+ if (newShift.start <= previousEnd)
+ {
+ newShift.start = newShift.start.AddDays(1);
+ }
+ }
+ while (newShift.start >= newShift.end)
+ {
+ newShift.end = newShift.end.AddDays(1);
+ }
+ finalShiftList.Add(newShift);
+ previousEnd = newShift.end;
+ }
+ //var firstWorkshopTimeShift = workshopSettings.CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime;
+ //var lastWorkshopTimeShift = workshopSettings.CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime;
+
+ //var startDateTime = new DateTime(DateOnly.MinValue, firstWorkshopTimeShift);
+ //var lastDateTime = new DateTime(DateOnly.MinValue, lastWorkshopTimeShift);
+ //if (lastDateTime < startDateTime)
+ //{
+ // lastDateTime = lastDateTime.AddDays(1);
+ //}
+
+ //var lastGroupShift = finalShiftList.MaxBy(x => x.placement).end;
+ //var firstGroupShift = finalShiftList.MinBy(x => x.placement).start;
+ //if (lastDateTime < lastGroupShift || firstGroupShift < startDateTime)
+ //{
+ // return op.Failed("ساعت کاری گروه باید بین ساعت کاری کارگاه باشد");
+ //}
+ }
+ else if (command.WorkshopShiftStatus == WorkshopShiftStatus.Irregular)
+ {
+ var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
+
+ var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
+
+ if (irregularShiftEndTime < irregularShiftStartTime)
+ {
+ irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
+ }
+
+ switch (command.IrregularShift.WorkshopIrregularShifts)
+ {
+ case WorkshopIrregularShifts.TwelveThirtySix:
+
+ if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
+ {
+ return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
+ }
+ break;
+ case WorkshopIrregularShifts.TwelveTwentyFour:
+ if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
+ {
+ return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
+ }
+ break;
+ }
+ }
+ else
+ {
+
+ customizeRotatingShifts = command.CustomizeRotatingShiftsViewModels.Select(x=> new CustomizeRotatingShift(TimeOnly.Parse( x.StartTime), TimeOnly.Parse(x.EndTime))).ToList();
+ }
+
+ #endregion
+
+ var breakTime = new BreakTime(command.BreakTime.HasBreakTimeValue, command.BreakTime.BreakTimeValue);
+
+ double salary = command.Salary.MoneyToDouble();
+
+
+ var entity = new CustomizeWorkshopGroupSettings(command.Name, salary, command.CustomizeWorkshopSettingId, shiftCollection, workshopSettings.FridayPay, workshopSettings.OverTimePay,
+ workshopSettings.BaseYearsPay, workshopSettings.BonusesPay, workshopSettings.NightWorkPay, workshopSettings.MarriedAllowance,
+ workshopSettings.ShiftPay, workshopSettings.FamilyAllowance, workshopSettings.LeavePay, workshopSettings.InsuranceDeduction, workshopSettings.FineAbsenceDeduction,
+ workshopSettings.LateToWork, workshopSettings.EarlyExit, command.FridayWork,
+ command.HolidayWork, breakTime, command.WorkshopShiftStatus, command.IrregularShift, command.LeavePermittedDays,customizeRotatingShifts);
+
+ _customizeWorkshopGroupSettingsRepository.Create(entity);
+
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+ return op.Succcedded();
+ }
+
+ //Create Employee Settings with Group data. It will Replace the Group data (such as salary, shifts and ...) on Employee settings On creation.
+ public OperationResult CreateEmployeesSettingsAndSetChanges(EditCustomizeEmployeeSettings command)
+ {
+ var op = new OperationResult();
+ var customizeWorkshopGroupSettings = _customizeWorkshopGroupSettingsRepository.Get(command.GroupId);
+ if (customizeWorkshopGroupSettings ==null)
+ {
+ return op.Failed("گروه انتخاب شده نا معتبر است");
+ }
+
+ if (customizeWorkshopGroupSettings.MainGroup)
+ {
+ var createDefaultEmployee = CreateEmployeeSettings(command);
+ return createDefaultEmployee;
+ }
+
+
+ List shiftCollection = new List();
+
+ var isChanged = false;
+ #region validation
+
if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
{
@@ -219,7 +368,7 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
- return new CustomizeWorkshopGroupSettingsShift(start, end, x.Placement);
+ return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
}).ToList();
}
@@ -275,6 +424,19 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
//{
// return op.Failed("ساعت کاری گروه باید بین ساعت کاری کارگاه باشد");
//}
+
+
+ if (shiftCollection.All(x => customizeWorkshopGroupSettings.CustomizeWorkshopGroupSettingsShifts.Any(y => x.Equals(y)))
+ && command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus && command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
+ command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork && command.BreakTime == customizeWorkshopGroupSettings.BreakTime)
+ {
+ isChanged = false;
+ }
+
+ else
+ {
+ isChanged = true;
+ }
}
else
{
@@ -303,6 +465,16 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
}
break;
}
+ if (command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus && command.BreakTime == customizeWorkshopGroupSettings.BreakTime &&
+ command.IrregularShift == customizeWorkshopGroupSettings.IrregularShift && command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
+ command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork)
+ {
+ isChanged = false;
+ }
+ else
+ {
+ isChanged = true;
+ }
}
#endregion
@@ -313,204 +485,227 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
- var entity = new CustomizeWorkshopGroupSettings(command.Name, salary, command.CustomizeWorkshopSettingId, shiftCollection, workshopSettings.FridayPay, workshopSettings.OverTimePay,
- workshopSettings.BaseYearsPay, workshopSettings.BonusesPay, workshopSettings.NightWorkPay, workshopSettings.MarriedAllowance,
- workshopSettings.ShiftPay, workshopSettings.FamilyAllowance, workshopSettings.LeavePay, workshopSettings.InsuranceDeduction, workshopSettings.FineAbsenceDeduction,
- workshopSettings.LateToWork, workshopSettings.EarlyExit, workshopSettings.FridayWork,
- workshopSettings.HolidayWork, breakTime, command.WorkshopShiftStatus, command.IrregularShift);
+ //var entity = new CustomizeWorkshopEmployeeSettings(customizeWorkshopGroupSettings.FridayPay, customizeWorkshopGroupSettings.OverTimePay,
+ // customizeWorkshopGroupSettings.BaseYearsPay, customizeWorkshopGroupSettings.BonusesPay, customizeWorkshopGroupSettings.NightWorkPay, customizeWorkshopGroupSettings.MarriedAllowance,
+ // customizeWorkshopGroupSettings.ShiftPay, customizeWorkshopGroupSettings.FamilyAllowance, customizeWorkshopGroupSettings.LeavePay, customizeWorkshopGroupSettings.InsuranceDeduction, customizeWorkshopGroupSettings.FineAbsenceDeduction,
+ // customizeWorkshopGroupSettings.LateToWork, customizeWorkshopGroupSettings.EarlyExit, command.EmployeeIds.First(),command.WorkshopId, salary, command.GroupId,
+ // shiftCollection, command.FridayWork, command.HolidayWork, command.IrregularShift, command.WorkshopShiftStatus, breakTime, command.LeavePermittedDays);
- _customizeWorkshopGroupSettingsRepository.Create(entity);
+ //_customizeWorkshopEmployeeSettingsRepository.Create(entity);
+
+ //entity.SimpleEdit(shiftCollection,command.IrregularShift,command.WorkshopShiftStatus,command.BreakTime,isChanged,command.FridayWork,command.HolidayWork);
_customizeWorkshopGroupSettingsRepository.SaveChanges();
return op.Succcedded();
+
+
+
}
- //Create Employee Settings with Group data. It will Replace the Group data (such as salary, shifts and ...) on Employee settings On creation.
public OperationResult EditWorkshopSettingShifts(List shiftViewModels, long customizeWorkshopSettingsId,
- WorkshopShiftStatus workshopShiftStatus, FridayWork fridayWork, HolidayWork holidayWork)
- {
- OperationResult op = new OperationResult();
- var entity = _customizeWorkshopSettingsRepository.Get(customizeWorkshopSettingsId);
- if (entity == null)
- return op.Failed("چنین آیتمی وجود ندارد");
+ WorkshopShiftStatus workshopShiftStatus, FridayWork fridayWork, HolidayWork holidayWork)
+ {
+ OperationResult op = new OperationResult();
+ var entity = _customizeWorkshopSettingsRepository.Get(customizeWorkshopSettingsId);
+ if (entity == null)
+ return op.Failed("چنین آیتمی وجود ندارد");
- //تبدیل شیفت های ویو مدل به انتیتی
- List shiftCollection = [];
+ //تبدیل شیفت های ویو مدل به انتیتی
+ List shiftCollection = [];
- #region Validation
- if (workshopShiftStatus == WorkshopShiftStatus.Regular)
- {
- try
- {
- shiftCollection =
- shiftViewModels.Select(x =>
- {
- var placement = x.Placement switch
- {
- ShiftPlacement.First => "اول",
- ShiftPlacement.Second => "دوم",
- ShiftPlacement.Third => "سوم",
- _ => throw new ArgumentOutOfRangeException()
- };
- if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
- throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
- if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
- throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
+ #region Validation
+ if (workshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
+ try
+ {
+ shiftCollection =
+ shiftViewModels.Select(x =>
+ {
+ var placement = x.Placement switch
+ {
+ ShiftPlacement.First => "اول",
+ ShiftPlacement.Second => "دوم",
+ ShiftPlacement.Third => "سوم",
+ _ => throw new ArgumentOutOfRangeException()
+ };
+ if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
+ throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
+ if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
+ throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
- return new CustomizeWorkshopSettingsShift(start, end, x.Placement);
+ return new CustomizeWorkshopSettingsShift(start, end, x.Placement);
- }).ToList();
- }
- catch (InvalidDataException e)
- {
+ }).ToList();
+ }
+ catch (InvalidDataException e)
+ {
- return op.Failed(e.Message);
- }
+ return op.Failed(e.Message);
+ }
- DateTime day = DateTime.Now;
- DateTime previousEnd = new DateTime();
- var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
+ DateTime day = DateTime.Now;
+ DateTime previousEnd = new DateTime();
+ var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
- shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
+ shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
- foreach (var shift in shiftCollection)
- {
- (DateTime start, DateTime end, ShiftPlacement placement) newShift =
- new()
- {
- placement = shift.Placement,
- start = new DateTime(DateOnly.FromDateTime(day), shift.StartTime),
- end = new DateTime(DateOnly.FromDateTime(day), shift.EndTime)
+ foreach (var shift in shiftCollection)
+ {
+ (DateTime start, DateTime end, ShiftPlacement placement) newShift =
+ new()
+ {
+ placement = shift.Placement,
+ start = new DateTime(DateOnly.FromDateTime(day), shift.StartTime),
+ end = new DateTime(DateOnly.FromDateTime(day), shift.EndTime)
- };
+ };
- if (previousEnd != new DateTime())
- {
- if (newShift.start <= previousEnd)
- {
- newShift.start = newShift.start.AddDays(1);
- }
- }
- while (newShift.start >= newShift.end)
- {
- newShift.end = newShift.end.AddDays(1);
- }
- finalShiftList.Add(newShift);
- previousEnd = newShift.end;
- }
+ if (previousEnd != new DateTime())
+ {
+ if (newShift.start <= previousEnd)
+ {
+ newShift.start = newShift.start.AddDays(1);
+ }
+ }
+ while (newShift.start >= newShift.end)
+ {
+ newShift.end = newShift.end.AddDays(1);
+ }
+ finalShiftList.Add(newShift);
+ previousEnd = newShift.end;
+ }
- var firstShiftStart = finalShiftList.FirstOrDefault(x => x.placement == ShiftPlacement.First).start;
- var lastShiftEnd = finalShiftList.OrderByDescending(x => x.placement).FirstOrDefault().end;
- if (firstShiftStart.AddDays(1) < lastShiftEnd)
- return op.Failed("بازه زمانی کارگاه نامعتبر است");
- var total = finalShiftList.Sum(x => (x.end - x.start).TotalHours);
- if (total >= 24)
- {
- return op.Failed("بازه زمانی کارگاه نمیتواند بیشتر از 24 ساعت باشد");
- }
- }
+ var firstShiftStart = finalShiftList.FirstOrDefault(x => x.placement == ShiftPlacement.First).start;
+ var lastShiftEnd = finalShiftList.OrderByDescending(x => x.placement).FirstOrDefault().end;
+ if (firstShiftStart.AddDays(1) < lastShiftEnd)
+ return op.Failed("بازه زمانی کارگاه نامعتبر است");
+ var total = finalShiftList.Sum(x => (x.end - x.start).TotalHours);
+ if (total >= 24)
+ {
+ return op.Failed("بازه زمانی کارگاه نمیتواند بیشتر از 24 ساعت باشد");
+ }
+ }
- #endregion
+ #endregion
- using var transActionScope = new TransactionScope();
- entity.ChangeWorkshopShifts(shiftCollection, workshopShiftStatus, fridayWork, holidayWork);
+ using var transActionScope = new TransactionScope();
+ entity.ChangeWorkshopShifts(shiftCollection, workshopShiftStatus, fridayWork, holidayWork);
- //op = ChangeAllGroupsShiftsWithEmployees(entity, replaceChangedGroups);
- //if (!op.IsSuccedded)
- //{
- // return op;
- //}
- _customizeWorkshopSettingsRepository.SaveChanges();
+ //op = ChangeAllGroupsShiftsWithEmployees(entity, replaceChangedGroups);
+ //if (!op.IsSuccedded)
+ //{
+ // return op;
+ //}
+ _customizeWorkshopSettingsRepository.SaveChanges();
- if (!(_customizeWorkshopGroupSettingsRepository.Exists(x => x.CustomizeWorkshopSettingId == entity.id && x.MainGroup)) && entity.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
- {
- var operationResult = CreateGeneralGroup(entity);
- if (!operationResult.IsSuccedded)
- return operationResult;
- }
- transActionScope.Complete();
- return op.Succcedded();
- }
- public OperationResult EditSimpleRollCallGroupSetting(EditCustomizeWorkshopGroupSettings command)
- {
- OperationResult op = new();
+ if (!(_customizeWorkshopGroupSettingsRepository.Exists(x => x.CustomizeWorkshopSettingId == entity.id && x.MainGroup)) && entity.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
+ var operationResult = CreateGeneralGroup(entity);
+ if (!operationResult.IsSuccedded)
+ return operationResult;
+ }
+ transActionScope.Complete();
+ return op.Succcedded();
+ }
+ public OperationResult EditSimpleRollCallGroupSetting(EditCustomizeWorkshopGroupSettings command)
+ {
+ OperationResult op = new();
- #region Validation
+ #region Validation
- if (string.IsNullOrWhiteSpace(command.Name))
- return op.Failed("لطفا نام گروه را وارد کنید");
+ if (string.IsNullOrWhiteSpace(command.Name))
+ return op.Failed("لطفا نام گروه را وارد کنید");
- if (!_customizeWorkshopGroupSettingsRepository.Exists(x => x.id == command.Id))
- return op.Failed("چنین ساعت کاری برای گروه وجود ندارد");
+ if (!_customizeWorkshopGroupSettingsRepository.Exists(x => x.id == command.Id))
+ return op.Failed("چنین ساعت کاری برای گروه وجود ندارد");
- #endregion
+ #endregion
- var entity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(command.Id);
+ var entity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(command.Id);
- var workshopSettings = _customizeWorkshopSettingsRepository.Get(entity.CustomizeWorkshopSettingId);
+ var workshopSettings = _customizeWorkshopSettingsRepository.Get(entity.CustomizeWorkshopSettingId);
- var employeeIds = command.IsShiftChanged ? entity.CustomizeWorkshopEmployeeSettingsCollection
- .Select(x => x.id).ToList() : entity.CustomizeWorkshopEmployeeSettingsCollection.Where(x => !x.IsShiftChanged)
- .Select(x => x.id).ToList();
- var groupSettingsShifts = new List();
- bool isChanged;
- if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
- {
+ var employeeIds = command.IsShiftChanged ? entity.CustomizeWorkshopEmployeeSettingsCollection
+ .Select(x => x.id).ToList() : entity.CustomizeWorkshopEmployeeSettingsCollection.Where(x => !x.IsShiftChanged)
+ .Select(x => x.id).ToList();
+ var groupSettingsShifts = new List();
+ ICollection rotatingShift = [];
+ bool isChanged;
+ if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
- groupSettingsShifts = command.ShiftViewModel.Select(x =>
- {
- if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
- throw new InvalidDataException();
- if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
- throw new InvalidDataException();
+ groupSettingsShifts = command.ShiftViewModel.Select(x =>
+ {
+ if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
+ throw new InvalidDataException();
+ if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
+ throw new InvalidDataException();
- return new CustomizeWorkshopGroupSettingsShift(start, end, x.Placement);
+ return new CustomizeWorkshopGroupSettingsShift(start, end, x.Placement);
- }).ToList();
- ;
- if (groupSettingsShifts.All(x => workshopSettings.CustomizeWorkshopSettingsShifts.Any(y => x.Equals(y)))
- && command.WorkshopShiftStatus == workshopSettings.WorkshopShiftStatus &&
- command.BreakTime == workshopSettings.BreakTime)
- {
- isChanged = false;
- }
- else
- {
- isChanged = true;
- }
- }
+ }).ToList();
+ ;
+ if (groupSettingsShifts.All(x => workshopSettings.CustomizeWorkshopSettingsShifts.Any(y => x.Equals(y)))
+ && command.WorkshopShiftStatus == workshopSettings.WorkshopShiftStatus && command.FridayWork == workshopSettings.FridayWork &&
+ command.HolidayWork == workshopSettings.HolidayWork&&
+ command.BreakTime == workshopSettings.BreakTime)
+ {
+ isChanged = false;
+ }
+ else
+ {
+ isChanged = true;
+ }
+ }
+ else if (command.WorkshopShiftStatus == WorkshopShiftStatus.Irregular)
+ {
+ var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
+
+ var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
+
+ if (irregularShiftEndTime < irregularShiftStartTime)
+ {
+ irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
+ }
+
+ switch (command.IrregularShift.WorkshopIrregularShifts)
+ {
+ case WorkshopIrregularShifts.TwelveThirtySix:
+
+ if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
+ {
+ return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
+ }
+ break;
+ case WorkshopIrregularShifts.TwelveTwentyFour:
+ if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
+ {
+ return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
+ }
+ break;
+ }
+ if (command.WorkshopShiftStatus == workshopSettings.WorkshopShiftStatus && command.BreakTime == workshopSettings.BreakTime
+ && command.FridayWork == workshopSettings.FridayWork &&
+ command.HolidayWork == workshopSettings.HolidayWork)
+ {
+ isChanged = false;
+ }
+ else
+ {
+ isChanged = true;
+ }
+ }
else
{
- var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
-
- var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
-
- if (irregularShiftEndTime < irregularShiftStartTime)
- {
- irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
- }
-
- switch (command.IrregularShift.WorkshopIrregularShifts)
- {
- case WorkshopIrregularShifts.TwelveThirtySix:
-
- if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
- {
- return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
- }
- break;
- case WorkshopIrregularShifts.TwelveTwentyFour:
- if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
- {
- return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
- }
- break;
- }
- if (command.WorkshopShiftStatus == workshopSettings.WorkshopShiftStatus && command.BreakTime == workshopSettings.BreakTime)
+ rotatingShift = command.CustomizeRotatingShiftsViewModels
+ .Select(x => new CustomizeRotatingShift(TimeOnly.Parse(x.StartTime), TimeOnly.Parse(x.EndTime))).ToList();
+ if (command.WorkshopShiftStatus == workshopSettings.WorkshopShiftStatus && command.BreakTime == workshopSettings.BreakTime
+ && command.FridayWork == workshopSettings.FridayWork &&
+ command.HolidayWork == workshopSettings.HolidayWork)
{
isChanged = false;
}
@@ -520,119 +715,118 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
}
}
- var breakTime = new BreakTime(command.BreakTime.HasBreakTimeValue, command.BreakTime.BreakTimeValue);
+ var breakTime = new BreakTime(command.BreakTime.HasBreakTimeValue, command.BreakTime.BreakTimeValue);
- entity.EditSimpleAndOverwriteOnEmployee(command.Name, employeeIds, groupSettingsShifts, command.WorkshopShiftStatus,
- command.IrregularShift, breakTime, isChanged,command.HolidayWork,command.FridayWork);
+ entity.EditSimpleAndOverwriteOnEmployee(command.Name, employeeIds, groupSettingsShifts, command.WorkshopShiftStatus,
+ command.IrregularShift, breakTime, isChanged, command.FridayWork, command.HolidayWork,rotatingShift);
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
- return op.Succcedded();
- }
- public OperationResult EditSimpleRollCallEmployeeSetting(EditCustomizeEmployeeSettings command)
- {
- OperationResult op = new();
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+ return op.Succcedded();
+ }
+ public OperationResult EditSimpleRollCallEmployeeSetting(EditCustomizeEmployeeSettings command)
+ {
+ OperationResult op = new();
- var entity = _customizeWorkshopEmployeeSettingsRepository.Get(command.Id);
+ var entity = _customizeWorkshopEmployeeSettingsRepository.Get(command.Id);
- #region Validation
+ #region Validation
- if (entity == null)
- return op.Failed("چنین پرسنلی وجود ندارد");
+ if (entity == null)
+ return op.Failed("چنین پرسنلی وجود ندارد");
#endregion
var groupSettings =
_customizeWorkshopGroupSettingsRepository.GetIncludeWorkshopSettings(
entity.CustomizeWorkshopGroupSettingId);
-
- List employeesShifts = new();
+ List employeesShifts = [];
+ ICollection rotatingShift = [];
bool isChanged = false;
-
-
if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
- {
+ {
- #region Validation
- if (command.ShiftViewModel.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
- return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
- try
- {
- employeesShifts =
- command.ShiftViewModel.Select(x =>
- {
- var placement = x.Placement switch
- {
- ShiftPlacement.First => "اول",
- ShiftPlacement.Second => "دوم",
- ShiftPlacement.Third => "سوم"
- };
- if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
- throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
- if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
- throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
+ #region Validation
+ if (command.ShiftViewModel.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
+ return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
+ try
+ {
+ employeesShifts =
+ command.ShiftViewModel.Select(x =>
+ {
+ var placement = x.Placement switch
+ {
+ ShiftPlacement.First => "اول",
+ ShiftPlacement.Second => "دوم",
+ ShiftPlacement.Third => "سوم"
+ };
+ if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
+ throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
+ if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
+ throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
- return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
+ return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
- }).ToList();
- }
- catch (InvalidDataException e)
- {
+ }).ToList();
+ }
+ catch (InvalidDataException e)
+ {
- return op.Failed(e.Message);
- }
- if (command.WorkshopId < 1)
- {
- return op.Failed("خطای سیستمی");
- }
- DateTime day = DateTime.Now;
- DateTime previousEnd = new DateTime();
- var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
+ return op.Failed(e.Message);
+ }
+ if (command.WorkshopId < 1)
+ {
+ return op.Failed("خطای سیستمی");
+ }
+ DateTime day = DateTime.Now;
+ DateTime previousEnd = new DateTime();
+ var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
- employeesShifts = employeesShifts.OrderBy(x => x.Placement).ToList();
+ employeesShifts = employeesShifts.OrderBy(x => x.Placement).ToList();
- foreach (var shift in employeesShifts)
- {
- (DateTime start, DateTime end, ShiftPlacement placement) newShift =
- new()
- {
- placement = shift.Placement,
- start = new DateTime(DateOnly.FromDateTime(day), shift.StartTime),
- end = new DateTime(DateOnly.FromDateTime(day), shift.EndTime)
+ foreach (var shift in employeesShifts)
+ {
+ (DateTime start, DateTime end, ShiftPlacement placement) newShift =
+ new()
+ {
+ placement = shift.Placement,
+ start = new DateTime(DateOnly.FromDateTime(day), shift.StartTime),
+ end = new DateTime(DateOnly.FromDateTime(day), shift.EndTime)
- };
+ };
- if (previousEnd != new DateTime())
- {
- if (newShift.start <= previousEnd)
- {
- newShift.start = newShift.start.AddDays(1);
- }
- }
- while (newShift.start >= newShift.end)
- {
- newShift.end = newShift.end.AddDays(1);
- }
- finalShiftList.Add(newShift);
- previousEnd = newShift.end;
- }
+ if (previousEnd != new DateTime())
+ {
+ if (newShift.start <= previousEnd)
+ {
+ newShift.start = newShift.start.AddDays(1);
+ }
+ }
+ while (newShift.start >= newShift.end)
+ {
+ newShift.end = newShift.end.AddDays(1);
+ }
+ finalShiftList.Add(newShift);
+ previousEnd = newShift.end;
+ }
- var firstShiftStart = finalShiftList.FirstOrDefault(x => x.placement == ShiftPlacement.First).start;
- var lastShiftEnd = finalShiftList.OrderByDescending(x => x.placement).FirstOrDefault().end;
- if (firstShiftStart.AddDays(1) < lastShiftEnd)
- return op.Failed("بازه زمانی کارگاه نامعتبر است");
- var total = finalShiftList.Sum(x => (x.end - x.start).TotalHours);
- if (total >= 24)
- {
- return op.Failed("بازه زمانی کارگاه نمیتواند بیشتر از 24 ساعت باشد");
- }
+ var firstShiftStart = finalShiftList.FirstOrDefault(x => x.placement == ShiftPlacement.First).start;
+ var lastShiftEnd = finalShiftList.OrderByDescending(x => x.placement).FirstOrDefault().end;
+ if (firstShiftStart.AddDays(1) < lastShiftEnd)
+ return op.Failed("بازه زمانی کارگاه نامعتبر است");
+ var total = finalShiftList.Sum(x => (x.end - x.start).TotalHours);
+ if (total >= 24)
+ {
+ return op.Failed("بازه زمانی کارگاه نمیتواند بیشتر از 24 ساعت باشد");
+ }
#endregion
+
if (employeesShifts.All(x => groupSettings.CustomizeWorkshopGroupSettingsShifts.Any(y => x.Equals(y)))
- && command.WorkshopShiftStatus == groupSettings.WorkshopShiftStatus && command.FridayWork == groupSettings.FridayWork &&
- command.HolidayWork == groupSettings.HolidayWork && command.BreakTime == groupSettings.BreakTime)
- {
+ && command.WorkshopShiftStatus == groupSettings.WorkshopShiftStatus && command.FridayWork == groupSettings.FridayWork &&
+ command.HolidayWork == groupSettings.HolidayWork &&command.BreakTime == groupSettings.BreakTime)
+ {
isChanged = false;
}
@@ -641,122 +835,142 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
isChanged = true;
}
}
+ else if (command.WorkshopShiftStatus == WorkshopShiftStatus.Irregular)
+ {
+ var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
+
+ var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
+
+ if (irregularShiftEndTime < irregularShiftStartTime)
+ {
+ irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
+ }
+
+ switch (command.IrregularShift.WorkshopIrregularShifts)
+ {
+ case WorkshopIrregularShifts.TwelveThirtySix:
+
+ if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
+ {
+ return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
+ }
+ break;
+ case WorkshopIrregularShifts.TwelveTwentyFour:
+ if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
+ {
+ return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
+ }
+ break;
+ }
+
+ if (command.WorkshopShiftStatus == groupSettings.WorkshopShiftStatus && command.BreakTime == groupSettings.BreakTime &&
+ command.IrregularShift == groupSettings.IrregularShift && command.FridayWork == groupSettings.FridayWork &&
+ command.HolidayWork == groupSettings.HolidayWork)
+ {
+ isChanged = false;
+ }
+ else
+ {
+ isChanged = true;
+ }
+ }
else
{
- var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
+ rotatingShift = command.CustomizeRotatingShifts
+ .Select(x => new CustomizeRotatingShift(TimeOnly.Parse( x.StartTime), TimeOnly.Parse(x.EndTime))).ToList();
- var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
-
- if (irregularShiftEndTime < irregularShiftStartTime)
- {
- irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
- }
-
- switch (command.IrregularShift.WorkshopIrregularShifts)
- {
- case WorkshopIrregularShifts.TwelveThirtySix:
-
- if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
- {
- return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
- }
- break;
- case WorkshopIrregularShifts.TwelveTwentyFour:
- if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
- {
- return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
- }
- break;
- }
-
- if (command.WorkshopShiftStatus == groupSettings.WorkshopShiftStatus && command.BreakTime == groupSettings.BreakTime &&
- command.IrregularShift == groupSettings.IrregularShift && command.FridayWork == groupSettings.FridayWork &&
- command.HolidayWork == groupSettings.HolidayWork)
+ if (rotatingShift.All(x => groupSettings.CustomizeRotatingShifts.Any(y => x.Equals(y)))
+ && command.WorkshopShiftStatus == groupSettings.WorkshopShiftStatus && command.FridayWork == groupSettings.FridayWork &&
+ command.HolidayWork == groupSettings.HolidayWork && command.BreakTime == groupSettings.BreakTime)
{
isChanged = false;
}
+
else
{
isChanged = true;
}
+
}
- entity.SimpleEdit(employeesShifts, command.IrregularShift, command.WorkshopShiftStatus, command.BreakTime, isChanged,command.HolidayWork,command.FridayWork);
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
- return op.Succcedded();
- }
+ entity.SimpleEdit(employeesShifts, command.IrregularShift, command.WorkshopShiftStatus, command.BreakTime,
+ isChanged, command.FridayWork, command.HolidayWork,rotatingShift);
- //Remove the Employee From the Group Settings
- public OperationResult RemoveEmployeeFromRollCallWorkshopGroup(long employeeId, long groupId, long workshopId)
- {
- OperationResult op = new();
- var groupEntity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(groupId);
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+ return op.Succcedded();
+ }
- #region Validation
+ //Remove the Employee From the Group Settings
+ public OperationResult RemoveEmployeeFromRollCallWorkshopGroup(long employeeId, long groupId, long workshopId)
+ {
+ OperationResult op = new();
+ var groupEntity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(groupId);
- if (groupEntity == null)
- {
- return op.Failed("چنین گروهی وجود ندارد");
- }
+ #region Validation
- #endregion
+ if (groupEntity == null)
+ {
+ return op.Failed("چنین گروهی وجود ندارد");
+ }
- using var transaction = new TransactionScope();
- groupEntity.RemoveEmployeeFromGroup(employeeId);
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
- var res = AddEmployeeToMainGroupSettings(workshopId, employeeId);
- if (res.IsSuccedded)
- {
- transaction.Complete();
- return op.Succcedded();
+ #endregion
- }
+ using var transaction = new TransactionScope();
+ groupEntity.RemoveEmployeeFromGroup(employeeId);
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+ var res = AddEmployeeToMainGroupSettings(workshopId, employeeId);
+ if (res.IsSuccedded)
+ {
+ transaction.Complete();
+ return op.Succcedded();
- return res;
+ }
- }
+ return res;
- public OperationResult AddEmployeeToMainGroupSettings(long workshopId, long employeeId)
- {
- var op = new OperationResult();
+ }
- var mainGroup = _customizeWorkshopGroupSettingsRepository.GetWorkshopMainGroup(workshopId);
- if(mainGroup == null)
- return op.Succcedded();
+ public OperationResult AddEmployeeToMainGroupSettings(long workshopId, long employeeId)
+ {
+ var op = new OperationResult();
- mainGroup.AddEmployeeSettingToGroupWithGroupData(employeeId, workshopId);
+ var mainGroup = _customizeWorkshopGroupSettingsRepository.GetWorkshopMainGroup(workshopId);
+ if (mainGroup == null)
+ return op.Succcedded();
+ mainGroup.AddEmployeeSettingToGroupWithGroupData(employeeId, workshopId);
- _customizeWorkshopEmployeeSettingsRepository.SaveChanges();
+ _customizeWorkshopEmployeeSettingsRepository.SaveChanges();
- return op.Succcedded();
- }
+ return op.Succcedded();
+ }
- #endregion
+ #endregion
- #region CustomizeCheckoutSettings
- public OperationResult CreateEmployeeSettings(CreateCustomizeEmployeeSettings command)
- {
- OperationResult op = new();
- CustomizeWorkshopGroupSettings mainGroup = new CustomizeWorkshopGroupSettings();
+ #region CustomizeCheckoutSettings
+ public OperationResult CreateEmployeeSettings(CreateCustomizeEmployeeSettings command)
+ {
+ OperationResult op = new();
+ CustomizeWorkshopGroupSettings mainGroup = new CustomizeWorkshopGroupSettings();
- #region Validation
+ #region Validation
- //if (!_customizeWorkshopGroupSettingsRepository.Exists(x => x.id == command.GroupId))
- // return op.Failed("چنین گروهی وجود ندارد");
+ //if (!_customizeWorkshopGroupSettingsRepository.Exists(x => x.id == command.GroupId))
+ // return op.Failed("چنین گروهی وجود ندارد");
- if (!_employeeRepository.Exists(x => command.EmployeeIds.Any(y => x.id == y)))
- return op.Failed("چنین پرسنلی وجود ندارد");
+ if (!_employeeRepository.Exists(x => command.EmployeeIds.Any(y => x.id == y)))
+ return op.Failed("چنین پرسنلی وجود ندارد");
- #endregion
- var groupData = _customizeWorkshopGroupSettingsRepository.GetIncludeWorkshopSettings(command.GroupId);
- if (groupData == null)
- return op.Failed("خطای سیستمی");
- var workshopSettings = _customizeWorkshopSettingsRepository.Get(groupData.CustomizeWorkshopSettingId);
- var employeesInMainGroup = new List();
+ #endregion
- mainGroup = _customizeWorkshopGroupSettingsRepository.GetWorkshopMainGroup(command.WorkshopId);
+ var groupData = _customizeWorkshopGroupSettingsRepository.GetIncludeWorkshopSettings(command.GroupId);
+ if (groupData == null)
+ return op.Failed("خطای سیستمی");
+ var workshopSettings = _customizeWorkshopSettingsRepository.Get(groupData.CustomizeWorkshopSettingId);
+ var employeesInMainGroup = new List();
+
+ mainGroup = _customizeWorkshopGroupSettingsRepository.GetWorkshopMainGroup(command.WorkshopId);
if (workshopSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
{
@@ -765,7 +979,7 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
employeesInMainGroup = _customizeWorkshopEmployeeSettingsRepository.GetBy(mainGroup.id);
if (_customizeWorkshopEmployeeSettingsRepository.Exists(x => x.WorkshopId == command.WorkshopId
- && command.EmployeeIds.Contains(x.EmployeeId) && x.CustomizeWorkshopGroupSettingId != mainGroup.id))
+ && command.EmployeeIds.Contains(x.EmployeeId) && x.CustomizeWorkshopGroupSettingId != mainGroup.id))
{
return op.Failed("این پرسنل در گروه دیگری وجود دارد");
}
@@ -773,35 +987,35 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
else
{
if (_customizeWorkshopEmployeeSettingsRepository.Exists(x => x.WorkshopId == command.WorkshopId
- && command.EmployeeIds.Contains(x.EmployeeId)))
+ && command.EmployeeIds.Contains(x.EmployeeId)))
{
return op.Failed("این پرسنل در گروه دیگری وجود دارد");
}
}
}
else
- {
- if (mainGroup != null)
- {
- employeesInMainGroup = _customizeWorkshopEmployeeSettingsRepository.GetBy(mainGroup.id);
+ {
+ if (mainGroup != null)
+ {
+ employeesInMainGroup = _customizeWorkshopEmployeeSettingsRepository.GetBy(mainGroup.id);
if (_customizeWorkshopEmployeeSettingsRepository.Exists(x => x.WorkshopId == command.WorkshopId
- && command.EmployeeIds.Contains(
- x.EmployeeId) &&
- x.CustomizeWorkshopGroupSettingId !=
- mainGroup.id))
- {
- return op.Failed("این پرسنل در گروه دیگری وجود دارد");
- }
- }
- else
- {
- if (_customizeWorkshopEmployeeSettingsRepository.Exists(x => x.WorkshopId == command.WorkshopId
- && command.EmployeeIds.Contains(x.EmployeeId)))
+ && command.EmployeeIds.Contains(
+ x.EmployeeId) &&
+ x.CustomizeWorkshopGroupSettingId !=
+ mainGroup.id))
{
return op.Failed("این پرسنل در گروه دیگری وجود دارد");
}
}
- }
+ else
+ {
+ if (_customizeWorkshopEmployeeSettingsRepository.Exists(x => x.WorkshopId == command.WorkshopId
+ && command.EmployeeIds.Contains(x.EmployeeId)))
+ {
+ return op.Failed("این پرسنل در گروه دیگری وجود دارد");
+ }
+ }
+ }
@@ -809,564 +1023,546 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
- foreach (var id in command.EmployeeIds)
- {
- var employeeSettings = employeesInMainGroup.FirstOrDefault(x => x.EmployeeId == id);
- if (employeeSettings != null)
- {
- _customizeWorkshopEmployeeSettingsRepository.Remove(employeeSettings.id);
- }
- var entity = new CustomizeWorkshopEmployeeSettings(
- new(groupData.FridayPay.FridayPayType, groupData.FridayPay.Value),
- new(groupData.OverTimePay.OverTimePayType, groupData.OverTimePay.Value),
- new(groupData.BaseYearsPay.BaseYearsPayType, groupData.BaseYearsPay.Value, groupData.BaseYearsPay.PaymentType),
- new(groupData.BonusesPay.BonusesPayType, groupData.BonusesPay.Value, groupData.BonusesPay.PaymentType),
- new(groupData.NightWorkPay.NightWorkingType, groupData.NightWorkPay.Value),
- new(groupData.MarriedAllowance.MarriedAllowanceType, groupData.MarriedAllowance.Value),
- new(groupData.ShiftPay.ShiftType, groupData.ShiftPay.ShiftPayType, groupData.ShiftPay.Value),
- new(groupData.FamilyAllowance.FamilyAllowanceType, groupData.FamilyAllowance.Value),
- new(groupData.LeavePay.LeavePayType, groupData.LeavePay.Value),
- new(groupData.InsuranceDeduction.InsuranceDeductionType, groupData.InsuranceDeduction.Value),
- new(groupData.FineAbsenceDeduction.FineAbsenceDeductionType, groupData.FineAbsenceDeduction.Value,
- groupData.FineAbsenceDeduction.FineAbsenceDayOfWeekCollection
- .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()),
- new(groupData.LateToWork.LateToWorkType,
- groupData.LateToWork.LateToWorkTimeFines.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
- .ToList(), groupData.LateToWork.Value),
- new(groupData.EarlyExit.EarlyExitType,
- groupData.EarlyExit.EarlyExitTimeFines.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
- .ToList(), groupData.EarlyExit.Value),
- id,
- groupData.CustomizeWorkshopSettings.WorkshopId,
- groupData.Salary,
- groupData.id,
- shifts.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement))
- .ToList(),
- groupData.FridayWork,
- groupData.HolidayWork,
- groupData.IrregularShift,
- groupData.WorkshopShiftStatus,
- new(groupData.BreakTime.HasBreakTimeValue, groupData.BreakTime.BreakTimeValue)
+ foreach (var id in command.EmployeeIds)
+ {
+ var employeeSettings = employeesInMainGroup.FirstOrDefault(x => x.EmployeeId == id);
+ if (employeeSettings != null)
+ {
+ _customizeWorkshopEmployeeSettingsRepository.Remove(employeeSettings.id);
+ }
+ var entity = new CustomizeWorkshopEmployeeSettings(
+ new(groupData.FridayPay.FridayPayType, groupData.FridayPay.Value),
+ new(groupData.OverTimePay.OverTimePayType, groupData.OverTimePay.Value),
+ new(groupData.BaseYearsPay.BaseYearsPayType, groupData.BaseYearsPay.Value, groupData.BaseYearsPay.PaymentType),
+ new(groupData.BonusesPay.BonusesPayType, groupData.BonusesPay.Value, groupData.BonusesPay.PaymentType),
+ new(groupData.NightWorkPay.NightWorkingType, groupData.NightWorkPay.Value),
+ new(groupData.MarriedAllowance.MarriedAllowanceType, groupData.MarriedAllowance.Value),
+ new(groupData.ShiftPay.ShiftType, groupData.ShiftPay.ShiftPayType, groupData.ShiftPay.Value),
+ new(groupData.FamilyAllowance.FamilyAllowanceType, groupData.FamilyAllowance.Value),
+ new(groupData.LeavePay.LeavePayType, groupData.LeavePay.Value),
+ new(groupData.InsuranceDeduction.InsuranceDeductionType, groupData.InsuranceDeduction.Value),
+ new(groupData.FineAbsenceDeduction.FineAbsenceDeductionType, groupData.FineAbsenceDeduction.Value,
+ groupData.FineAbsenceDeduction.FineAbsenceDayOfWeekCollection
+ .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()),
+ new(groupData.LateToWork.LateToWorkType,
+ groupData.LateToWork.LateToWorkTimeFines.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
+ .ToList(), groupData.LateToWork.Value),
+ new(groupData.EarlyExit.EarlyExitType,
+ groupData.EarlyExit.EarlyExitTimeFines.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
+ .ToList(), groupData.EarlyExit.Value),
+ id,
+ groupData.CustomizeWorkshopSettings.WorkshopId,
+ groupData.Salary,
+ groupData.id,
+ shifts.Select(x => new CustomizeWorkshopEmployeeSettingsShift(x.StartTime, x.EndTime, x.Placement))
+ .ToList(),
+ groupData.FridayWork,
+ groupData.HolidayWork,
+ groupData.IrregularShift,
+ groupData.WorkshopShiftStatus,
+ new(groupData.BreakTime.HasBreakTimeValue, groupData.BreakTime.BreakTimeValue),
+ command.LeavePermittedDays,
+ groupData.CustomizeRotatingShifts.Select(x=> new CustomizeRotatingShift(x.StartTime,x.EndTime)).ToList()
);
- _customizeWorkshopEmployeeSettingsRepository.Create(entity);
-
- }
- _customizeWorkshopEmployeeSettingsRepository.SaveChanges();
-
-
- return op.Succcedded();
- }
+ _customizeWorkshopEmployeeSettingsRepository.Create(entity);
+
+ }
+ _customizeWorkshopEmployeeSettingsRepository.SaveChanges();
+
+
+ return op.Succcedded();
+ }
- //Edit the Workshop Settings Data
- public OperationResult EditWorkshopSetting(EditCustomizeWorkshopSettings command, bool replaceInAllGroups)
- {
- OperationResult op = new();
+ //Edit the Workshop Settings Data
+ public OperationResult EditWorkshopSetting(EditCustomizeWorkshopSettings command, bool replaceInAllGroups)
+ {
+ OperationResult op = new();
- #region Validation
+ #region Validation
- if (!_customizeWorkshopSettingsRepository.Exists(x => x.id == command.Id))
- return op.Failed("خطای سیستمی");
+ if (!_customizeWorkshopSettingsRepository.Exists(x => x.id == command.Id))
+ return op.Failed("خطای سیستمی");
- #endregion
+ #endregion
- var entity = _customizeWorkshopSettingsRepository.Get(command.Id);
- if (entity == null)
- return op.Failed("چنین آیتمی وجود ندارد");
+ var entity = _customizeWorkshopSettingsRepository.Get(command.Id);
+ if (entity == null)
+ return op.Failed("چنین آیتمی وجود ندارد");
- FridayPay fridayPay = new(command.FridayPay.FridayPayType, command.FridayPay.Value);
- OverTimePay overTimePay = new(command.OverTimePay.OverTimePayType, command.OverTimePay.Value);
- BaseYearsPay baseYearsPay = new(command.BaseYearsPay.BaseYearsPayType, command.BaseYearsPay.Value, command.BaseYearsPay.PaymentType);
- BonusesPay bonusesPay = new(command.BonusesPay.BonusesPayType, command.BonusesPay.Value, command.BonusesPay.PaymentType);
- NightWorkPay nightWorkPay = new(command.NightWorkPay.NightWorkingType, command.NightWorkPay.Value);
- MarriedAllowance marriedAllowance = new(command.MarriedAllowance.MarriedAllowanceType, command.MarriedAllowance.Value);
- ShiftPay shiftPay = new(ShiftType.None, ShiftPayType.None, 0);
- FamilyAllowance familyAllowance = new(command.FamilyAllowance.FamilyAllowanceType, command.FamilyAllowance.Value);
- LeavePay leavePay = new(command.LeavePay.LeavePayType, command.LeavePay.Value);
- InsuranceDeduction insuranceDeduction = new(command.InsuranceDeduction.InsuranceDeductionType, command.InsuranceDeduction.Value);
- FineAbsenceDeduction fineAbsenceDeduction = new(
- command.FineAbsenceDeduction.FineAbsenceDeductionType,
- command.FineAbsenceDeduction.Value,
- command.FineAbsenceDeduction.FineAbsenceDayOfWeekViewModels?.Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList() ?? new List()
- );
- LateToWork lateToWork = new(
- command.LateToWork.LateToWorkType,
- command.LateToWork.LateToWorkTimeFinesVewModels?.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
- .ToList() ?? new List()
- , command.LateToWork.Value
- );
-
- EarlyExit earlyExit = new(command.EarlyExit.EarlyExitType,
- command.EarlyExit.EarlyExitTimeFinesViewModels?.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney)).ToList() ?? new List()
- , command.EarlyExit.Value);
-
-
- var groups = _customizeWorkshopGroupSettingsRepository.GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(entity.id);
-
- using (var transaction = new TransactionScope())
- {
-
- try
- {
- entity.Edit(fridayPay, overTimePay, baseYearsPay, bonusesPay, nightWorkPay, marriedAllowance, shiftPay,
- familyAllowance, leavePay, insuranceDeduction,
- fineAbsenceDeduction, lateToWork, earlyExit, command.FridayWork, command.HolidayWork,
- command.BonusesPaysInEndOfMonth, command.LeavePermittedDays, command.BaseYearsPayInEndOfYear,
- command.OverTimeThresholdMinute);
-
- _customizeWorkshopSettingsRepository.SaveChanges();
- var editViewModel = new EditCustomizeWorkshopGroupSettings()
- {
-
- };
- OperationResult result = new OperationResult();
- if (entity.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
- {
- //foreach (var group in groups)
- //{
- // var employeeIds = group.CustomizeWorkshopEmployeeSettingsCollection.Select(x => x.EmployeeId)
- // .ToList();
- // group.EditAndOverwriteOnEmployees(group.GroupName,group.Salary,employeeIds,group.FridayPay,group.OverTimePay,group.BaseYearsPay,group.BonusesPay,
- // group.ShiftPay,group.NightWorkPay,group.MarriedAllowance,group.FamilyAllowance,group.LeavePay,group.InsuranceDeduction,
- // group.FineAbsenceDeduction,);
- //}
- }
- else
- {
- result = result.Succcedded();
- }
-
- ChangeAllSettingsGroups(entity, replaceInAllGroups);
-
- result.Succcedded();
-
-
- transaction.Complete();
-
- }
- catch
- {
- // ignored
- }
- }
-
- return string.IsNullOrWhiteSpace(op.Message) ? op.Succcedded() : op;
- }
-
-
-
- //Edit the Group Settings Data
- public OperationResult EditRollCallGroupSetting(EditCustomizeWorkshopGroupSettings command)
- {
- OperationResult op = new();
-
- #region Validation
-
- if (string.IsNullOrWhiteSpace(command.Name))
- return op.Failed("لطفا نام گروه را وارد کنید");
-
- if (string.IsNullOrWhiteSpace(command.Salary))
- return op.Failed("لطفا حقوق مورد نظر خود را وارد کنید");
-
- if (!_customizeWorkshopGroupSettingsRepository.Exists(x => x.id == command.Id))
- return op.Failed("چنین ساعت کاری برای گروه وجود ندارد");
-
- #endregion
-
-
- var entity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(command.Id);
-
- FridayPay fridayPay = new(command.FridayPay.FridayPayType, command.FridayPay.Value);
- OverTimePay overTimePay = new(command.OverTimePay.OverTimePayType, command.OverTimePay.Value);
- BaseYearsPay baseYearsPay = new(command.BaseYearsPay.BaseYearsPayType, command.BaseYearsPay.Value, command.BaseYearsPay.PaymentType);
- BonusesPay bonusesPay = new(command.BonusesPay.BonusesPayType, command.BonusesPay.Value, command.BonusesPay.PaymentType);
- NightWorkPay nightWorkPay = new(command.NightWorkPay.NightWorkingType, command.NightWorkPay.Value);
- MarriedAllowance marriedAllowance = new(command.MarriedAllowance.MarriedAllowanceType, command.MarriedAllowance.Value);
- //ShiftPay shiftPay = new(command.ShiftPay.ShiftType, command.ShiftPay.ShiftPayType, command.ShiftPay.Value);
- ShiftPay shiftPay = new(ShiftType.None, ShiftPayType.None, 0);
- FamilyAllowance familyAllowance = new(command.FamilyAllowance.FamilyAllowanceType, command.FamilyAllowance.Value);
- LeavePay leavePay = new(command.LeavePay.LeavePayType, command.LeavePay.Value);
- InsuranceDeduction insuranceDeduction = new(command.InsuranceDeduction.InsuranceDeductionType, command.InsuranceDeduction.Value);
- FineAbsenceDeduction fineAbsenceDeduction = new(
- command.FineAbsenceDeduction.FineAbsenceDeductionType, command.FineAbsenceDeduction.Value,
- command.FineAbsenceDeduction.FineAbsenceDayOfWeekViewModels
- .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
- );
- LateToWork lateToWork = new(
- command.LateToWork.LateToWorkType,
- command.LateToWork.LateToWorkTimeFinesVewModels.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
- .ToList(), command.LateToWork.Value
- );
- EarlyExit earlyExit = new(command.EarlyExit.EarlyExitType,
- command.EarlyExit.EarlyExitTimeFinesViewModels.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
- .ToList(), command.EarlyExit.Value);
-
- double salary = command.Salary.MoneyToDouble();
-
-
- bool isChanged;
- if (fridayPay == entity.FridayPay && overTimePay == entity.OverTimePay && baseYearsPay == entity.BaseYearsPay && bonusesPay == entity.BonusesPay
- && shiftPay == entity.ShiftPay && nightWorkPay == entity.NightWorkPay && marriedAllowance == entity.MarriedAllowance
- && familyAllowance == entity.FamilyAllowance && leavePay == entity.LeavePay && insuranceDeduction == entity.InsuranceDeduction
- && fineAbsenceDeduction == entity.FineAbsenceDeduction && lateToWork == entity.LateToWork && earlyExit == entity.EarlyExit && command.FridayWork == entity.FridayWork
- && command.HolidayWork == entity.HolidayWork && command.IrregularShift == entity.IrregularShift && command.WorkshopShiftStatus == entity.WorkshopShiftStatus)
- {
- isChanged = false;
- }
- else
- {
- isChanged = true;
- }
- entity.EditAndOverwriteOnEmployees(command.Name, salary, command.EmployeeIds, fridayPay, overTimePay,
- baseYearsPay, bonusesPay, shiftPay, nightWorkPay, marriedAllowance, familyAllowance,
- leavePay, insuranceDeduction, fineAbsenceDeduction, lateToWork, earlyExit,
- command.FridayWork, command.HolidayWork, isChanged);
-
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
-
- return op.Succcedded();
- }
-
- //Edit the Employee settings and change the 'IsChanged' bool to true.
- public OperationResult EditRollCallEmployeeSettings(EditCustomizeEmployeeSettings command)
- {
- OperationResult op = new();
- var entity = _customizeWorkshopEmployeeSettingsRepository.Get(command.Id);
-
- #region Validation
-
- if (entity == null)
- return op.Failed("چنین پرسنلی وجود ندارد");
-
- #endregion
-
- FridayPay fridayPay = new(command.FridayPay.FridayPayType, command.FridayPay.Value);
- OverTimePay overTimePay = new(command.OverTimePay.OverTimePayType, command.OverTimePay.Value);
- BaseYearsPay baseYearsPay = new(command.BaseYearsPay.BaseYearsPayType, command.BaseYearsPay.Value, command.BaseYearsPay.PaymentType);
- BonusesPay bonusesPay = new(command.BonusesPay.BonusesPayType, command.BonusesPay.Value, command.BonusesPay.PaymentType);
- NightWorkPay nightWorkPay = new(command.NightWorkPay.NightWorkingType, command.NightWorkPay.Value);
- MarriedAllowance marriedAllowance = new(command.MarriedAllowance.MarriedAllowanceType, command.MarriedAllowance.Value);
- // ShiftPay shiftPay = new(command.ShiftPay.ShiftType, command.ShiftPay.ShiftPayType, command.ShiftPay.Value);
- ShiftPay shiftPay = new(ShiftType.None, ShiftPayType.None, 0);
- FamilyAllowance familyAllowance = new(command.FamilyAllowance.FamilyAllowanceType, command.FamilyAllowance.Value);
- LeavePay leavePay = new(command.LeavePay.LeavePayType, command.LeavePay.Value);
- InsuranceDeduction insuranceDeduction = new(command.InsuranceDeduction.InsuranceDeductionType, command.InsuranceDeduction.Value);
- FineAbsenceDeduction fineAbsenceDeduction = new(
- command.FineAbsenceDeduction.FineAbsenceDeductionType, command.FineAbsenceDeduction.Value,
- command.FineAbsenceDeduction.FineAbsenceDayOfWeekViewModels
- .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
- );
- LateToWork lateToWork = new(
- command.LateToWork.LateToWorkType,
- command.LateToWork.LateToWorkTimeFinesVewModels.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
- .ToList(), command.LateToWork.Value
- );
- EarlyExit earlyExit = new(command.EarlyExit.EarlyExitType,
- command.EarlyExit.EarlyExitTimeFinesViewModels.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
- .ToList(), command.EarlyExit.Value);
-
-
- double salary = command.Salary.MoneyToDouble();
-
- var employeesShifts =
- command.ShiftViewModel.Select(x =>
- {
- if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
- throw new InvalidDataException();
- if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
- throw new InvalidDataException();
-
- return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
-
- }).ToList();
-
- bool isChanged;
- if (fridayPay == entity.FridayPay && overTimePay == entity.OverTimePay && baseYearsPay == entity.BaseYearsPay && bonusesPay == entity.BonusesPay
- && shiftPay == entity.ShiftPay && nightWorkPay == entity.NightWorkPay && marriedAllowance == entity.MarriedAllowance
- && familyAllowance == entity.FamilyAllowance && leavePay == entity.LeavePay && insuranceDeduction == entity.InsuranceDeduction
- && fineAbsenceDeduction == entity.FineAbsenceDeduction && lateToWork == entity.LateToWork && earlyExit == entity.EarlyExit && command.FridayWork == entity.FridayWork
- && command.HolidayWork == entity.HolidayWork && command.IrregularShift == entity.IrregularShift && command.WorkshopShiftStatus == entity.WorkshopShiftStatus)
- {
- isChanged = false;
- }
- else
- {
- isChanged = true;
- }
-
- //change employee data manually. It changes the 'IsChanged' property to true.
- entity.EditEmployees(salary, fridayPay, overTimePay, baseYearsPay,
- bonusesPay, nightWorkPay, marriedAllowance, shiftPay, familyAllowance, leavePay,
- insuranceDeduction, fineAbsenceDeduction, lateToWork, earlyExit, command.FridayWork, command.HolidayWork, command.IrregularShift,
- command.WorkshopShiftStatus, isChanged);
-
-
- _customizeWorkshopEmployeeSettingsRepository.SaveChanges();
- return op.Succcedded();
- }
-
- public OperationResult RemoveGroupSettings(long groupSettingsId)
- {
- OperationResult op = new OperationResult();
- var entity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(groupSettingsId);
- if (entity.CustomizeWorkshopEmployeeSettingsCollection.Any())
- return op.Failed("نمیتونید گروهی که پرسنل در آن وجود دارد را حذف کنید");
-
- _customizeWorkshopGroupSettingsRepository.Remove(entity.id);
- return op.Succcedded();
- }
- #endregion
-
- #region Queries
-
- public List GetChangedEmployeeSettingsByGroupSettingsId(long groupSettingsId)
- {
- return _customizeWorkshopGroupSettingsRepository.GetShiftChangedEmployeeSettingsByGroupSettingsId(
- groupSettingsId);
- }
-
-
- // It will Get the Workshop Settings with its groups and the employees of groups.
- public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth)
- {
-
-
- #region Validation
-
- if (workshopId is < 1)
- return new();
-
- #endregion
-
- var record = _customizeWorkshopSettingsRepository.GetWorkshopSettingsByWorkshopId(workshopId, auth);
-
- return record;
- }
-
- public CustomizeWorkshopEmployeeSettingsViewModel GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(long workshopId,
- long employeeId)
- {
- var entity =
- _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId, employeeId);
- if (entity == null)
- return new();
-
- string employeeFullName = _employeeRepository.Get(entity.EmployeeId).FullName;
- return new CustomizeWorkshopEmployeeSettingsViewModel()
- {
- EmployeeId = entity.EmployeeId,
- Id = entity.id,
- IsSettingChanged = entity.IsSettingChanged,
- IsShiftChanged = entity.IsShiftChanged,
- Name = entity.CustomizeWorkshopGroupSettings.GroupName,
- EmployeeFullName = employeeFullName,
- Salary = entity.Salary,
- BreakTime = entity.BreakTime,
- WorkshopShiftStatus = entity.WorkshopShiftStatus,
- IrregularShift = entity.IrregularShift,
- RollCallWorkshopShifts = entity.CustomizeWorkshopEmployeeSettingsShifts.Select(x =>
- new CustomizeWorkshopShiftViewModel()
- {
- EndTime = x.EndTime.ToString("HH:mm"),
- Placement = x.Placement,
- StartTime = x.StartTime.ToString("HH:mm")
- }).ToList(),
- FridayWork = entity.FridayWork,
- HolidayWork = entity.HolidayWork
- };
- }
-
- public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByEmployeeIdGroupSettingsId(long workshopId, long employeeId)
- {
- var entity =
- _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdGroupSettingsId(workshopId, employeeId);
- if (entity == null)
- return new();
-
- string employeeFullName = _employeeRepository.Get(entity.EmployeeId).FullName;
- return new CustomizeWorkshopEmployeeSettingsViewModel()
- {
- EmployeeId = entity.EmployeeId,
- Id = entity.id,
- IsSettingChanged = entity.IsSettingChanged,
- IsShiftChanged = entity.IsShiftChanged,
- Name = entity.CustomizeWorkshopGroupSettings.GroupName,
- EmployeeFullName = employeeFullName,
- Salary = entity.Salary,
- BreakTime = entity.BreakTime,
- WorkshopShiftStatus = entity.WorkshopShiftStatus,
- IrregularShift = entity.IrregularShift,
- RollCallWorkshopShifts = entity.CustomizeWorkshopEmployeeSettingsShifts.Select(x =>
- new CustomizeWorkshopShiftViewModel()
- {
- EndTime = x.EndTime.ToString("HH:mm"),
- Placement = x.Placement,
- StartTime = x.StartTime.ToString("HH:mm")
- }).ToList()
- };
- }
-
- public List GetEmployeeSettingsByGroupSettingsId(long groupSettingsId)
- {
-
- List result = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(groupSettingsId);
-
- if (result == null)
- return new();
-
- return result;
-
- }
-
-
-
- public List GetEmployeesWithoutGroup(long rollCallWorkshopSettingId)
- {
- return _customizeWorkshopGroupSettingsRepository.GetEmployeesWithoutGroup(rollCallWorkshopSettingId);
- }
-
- public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByEmployeeIdWorkshopId(long workshopId, long employeeId)
- {
- return _customizeWorkshopSettingsRepository.GetEmployeeSettingsByWorkshopIdGroupSettingsId(workshopId, employeeId);
- }
-
- public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId)
- {
- return _customizeWorkshopSettingsRepository.GetWorkshopSettingsByWorkshopIdForAdmin(workshopId);
-
- }
- public EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId)
- {
- return _customizeWorkshopSettingsRepository.GetWorkshopSettingsDetails(workshopId);
- }
-
- public EditCustomizeWorkshopGroupSettings GetCustomizeWorkshopGroupSettingsDetails(long groupId)
- {
- return _customizeWorkshopGroupSettingsRepository.GetCustomizeWorkshopGroupSettingsDetails(groupId);
- }
-
- public EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId)
- {
- return _customizeWorkshopSettingsRepository.GetSimpleWorkshopSettings(workshopId);
- }
-
- public EditCustomizeEmployeeSettings GetCustomizeEmployeeSettingsDetails(long customizeEmployeeId)
- {
- return _customizeWorkshopEmployeeSettingsRepository.GetCustomizeEmployeeSettingsDetails(customizeEmployeeId);
- }
-
- public List GetEmployeesWithoutGroupByWorkshopId(long workshopId)
- {
- return _customizeWorkshopGroupSettingsRepository.GetEmployeesWithoutGroupByWorkshopId(workshopId);
- }
-
- public List GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId)
- {
- return _customizeWorkshopSettingsRepository.GetShiftChangesGroupAndEmployees(customizeWorkshopSettingsId);
- }
-
- public List GetEmployeeSettingsByWorkshopId(long workshopId)
- {
- return _customizeWorkshopEmployeeSettingsRepository.GetEmployeeSettingsByWorkshopId(workshopId);
- }
-
- private OperationResult CreateGeneralGroup(CustomizeWorkshopSettings entity)
- {
- var op = new OperationResult();
-
- if (_customizeWorkshopGroupSettingsRepository.Exists(x => x.CustomizeWorkshopSettingId == entity.id && x.MainGroup))
- {
- return op.Succcedded();
- }
-
- try
- {
- var shifts =
- entity.CustomizeWorkshopSettingsShifts.Select(x =>
- new CustomizeWorkshopGroupSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
- var irregularShift = new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None);
-
- var customizeWorkshopGroupSettings = new CustomizeWorkshopGroupSettings().CreateMainGroup(entity.FridayPay, entity.OverTimePay,
- entity.BaseYearsPay, entity.BonusesPay, entity.ShiftPay, entity.NightWorkPay, entity.MarriedAllowance,
- entity.FamilyAllowance, entity.LeavePay, entity.InsuranceDeduction, entity.FineAbsenceDeduction,
- entity.LateToWork, entity.EarlyExit, shifts, entity.FridayWork, entity.HolidayWork,
- irregularShift, entity.WorkshopShiftStatus, entity.id,new BreakTime(false,new TimeOnly()));
-
- _customizeWorkshopGroupSettingsRepository.Create(customizeWorkshopGroupSettings);
-
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
-
- var employeesHasSettings = _customizeWorkshopEmployeeSettingsRepository
- .GetEmployeeSettingNotInMainGroup(entity.WorkshopId).Select(x => x.EmployeeId);
-
- var rollCallEmployeeViewModels = _rollCallEmployeeApplication.GetByWorkshopId(entity.WorkshopId).Where(x => !employeesHasSettings.Contains(x.EmployeeId));
-
- foreach (var rollCallEmployeeViewModel in rollCallEmployeeViewModels)
- {
- customizeWorkshopGroupSettings.AddEmployeeSettingToGroupWithGroupData(
- rollCallEmployeeViewModel.EmployeeId, entity.WorkshopId);
- }
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
- return op.Succcedded();
- }
- catch (Exception e)
- {
- return op.Failed(e.Message);
- }
-
-
- }
-
- private OperationResult ChangeAllGroupsShiftsWithEmployees(CustomizeWorkshopSettings entity, bool replaceChangedGroups)
- {
- var op = new OperationResult();
- var groupSettings = _customizeWorkshopGroupSettingsRepository.GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(entity.id);
-
- if (!replaceChangedGroups)
- {
- groupSettings = groupSettings.Where(x => !x.IsShiftChange).ToList();
- }
-
- var groupShifts = entity.CustomizeWorkshopSettingsShifts
- .Select(x => new CustomizeWorkshopGroupSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
-
- var irregularShift = new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None);
- foreach (var customizeWorkshopGroupSettings in groupSettings)
- {
- customizeWorkshopGroupSettings.EditSimpleAndOverwriteOnAllEmployees(customizeWorkshopGroupSettings.GroupName,
- groupShifts, WorkshopShiftStatus.Regular, irregularShift, new BreakTime(false, new TimeOnly()), false);
- }
- _customizeWorkshopGroupSettingsRepository.SaveChanges();
- return op.Succcedded();
- }
- private void ChangeAllSettingsGroups(CustomizeWorkshopSettings customizeWorkshopSettings, bool replaceInAllGroups)
- {
- var op = new OperationResult();
- var groupSettings = _customizeWorkshopGroupSettingsRepository.GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(customizeWorkshopSettings.id);
-
- if (!replaceInAllGroups)
- {
- groupSettings = groupSettings.Where(x => !x.IsSettingChange).ToList();
- }
-
-
-
- foreach (var groupSetting in groupSettings)
- {
- groupSetting.EditAndOverwriteOnAllEmployees(groupSetting.GroupName, groupSetting.Salary,
- customizeWorkshopSettings.FridayPay,
- customizeWorkshopSettings.OverTimePay, customizeWorkshopSettings.BaseYearsPay,
- customizeWorkshopSettings.BonusesPay, customizeWorkshopSettings.ShiftPay,
- customizeWorkshopSettings.NightWorkPay, customizeWorkshopSettings.MarriedAllowance,
- customizeWorkshopSettings.FamilyAllowance, customizeWorkshopSettings.LeavePay,
- customizeWorkshopSettings.InsuranceDeduction, customizeWorkshopSettings.FineAbsenceDeduction,
- customizeWorkshopSettings.LateToWork, customizeWorkshopSettings.EarlyExit,
- customizeWorkshopSettings.FridayWork, customizeWorkshopSettings.HolidayWork, replaceInAllGroups);
- }
- _customizeWorkshopSettingsRepository.SaveChanges();
- }
-
- #endregion
+ FridayPay fridayPay = new(command.FridayPay.FridayPayType, command.FridayPay.Value);
+ OverTimePay overTimePay = new(command.OverTimePay.OverTimePayType, command.OverTimePay.Value);
+ BaseYearsPay baseYearsPay = new(command.BaseYearsPay.BaseYearsPayType, command.BaseYearsPay.Value, command.BaseYearsPay.PaymentType);
+ BonusesPay bonusesPay = new(command.BonusesPay.BonusesPayType, command.BonusesPay.Value, command.BonusesPay.PaymentType);
+ NightWorkPay nightWorkPay = new(command.NightWorkPay.NightWorkingType, command.NightWorkPay.Value);
+ MarriedAllowance marriedAllowance = new(command.MarriedAllowance.MarriedAllowanceType, command.MarriedAllowance.Value);
+ ShiftPay shiftPay = new(ShiftType.None, ShiftPayType.None, 0);
+ FamilyAllowance familyAllowance = new(command.FamilyAllowance.FamilyAllowanceType, command.FamilyAllowance.Value);
+ LeavePay leavePay = new(command.LeavePay.LeavePayType, command.LeavePay.Value);
+ InsuranceDeduction insuranceDeduction = new(command.InsuranceDeduction.InsuranceDeductionType, command.InsuranceDeduction.Value);
+ FineAbsenceDeduction fineAbsenceDeduction = new(
+ command.FineAbsenceDeduction.FineAbsenceDeductionType,
+ command.FineAbsenceDeduction.Value,
+ command.FineAbsenceDeduction.FineAbsenceDayOfWeekViewModels?.Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList() ?? new List()
+ );
+ LateToWork lateToWork = new(
+ command.LateToWork.LateToWorkType,
+ command.LateToWork.LateToWorkTimeFinesVewModels?.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
+ .ToList() ?? new List()
+ , command.LateToWork.Value
+ );
+
+ EarlyExit earlyExit = new(command.EarlyExit.EarlyExitType,
+ command.EarlyExit.EarlyExitTimeFinesViewModels?.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney)).ToList() ?? new List()
+ , command.EarlyExit.Value);
+
+
+ var groups = _customizeWorkshopGroupSettingsRepository.GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(entity.id);
+
+ using (var transaction = new TransactionScope())
+ {
+
+ try
+ {
+ entity.Edit(fridayPay, overTimePay, baseYearsPay, bonusesPay, nightWorkPay, marriedAllowance, shiftPay,
+ familyAllowance, leavePay, insuranceDeduction,
+ fineAbsenceDeduction, lateToWork, earlyExit, command.FridayWork, command.HolidayWork,
+ command.BonusesPaysInEndOfMonth, command.LeavePermittedDays, command.BaseYearsPayInEndOfYear,
+ command.OverTimeThresholdMinute);
+
+ _customizeWorkshopSettingsRepository.SaveChanges();
+ var editViewModel = new EditCustomizeWorkshopGroupSettings()
+ {
+
+ };
+ OperationResult result = new OperationResult();
+ if (entity.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
+ {
+ //foreach (var group in groups)
+ //{
+ // var employeeIds = group.CustomizeWorkshopEmployeeSettingsCollection.Select(x => x.EmployeeId)
+ // .ToList();
+ // group.EditAndOverwriteOnEmployees(group.GroupName,group.Salary,employeeIds,group.FridayPay,group.OverTimePay,group.BaseYearsPay,group.BonusesPay,
+ // group.ShiftPay,group.NightWorkPay,group.MarriedAllowance,group.FamilyAllowance,group.LeavePay,group.InsuranceDeduction,
+ // group.FineAbsenceDeduction,);
+ //}
+ }
+ else
+ {
+ result = result.Succcedded();
+ }
+
+ ChangeAllSettingsGroups(entity, replaceInAllGroups);
+
+ result.Succcedded();
+
+
+ transaction.Complete();
+
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ return string.IsNullOrWhiteSpace(op.Message) ? op.Succcedded() : op;
+ }
+
+
+
+ //Edit the Group Settings Data
+ public OperationResult EditRollCallGroupSetting(EditCustomizeWorkshopGroupSettings command)
+ {
+ OperationResult op = new();
+
+ #region Validation
+
+ if (string.IsNullOrWhiteSpace(command.Name))
+ return op.Failed("لطفا نام گروه را وارد کنید");
+
+ if (string.IsNullOrWhiteSpace(command.Salary))
+ return op.Failed("لطفا حقوق مورد نظر خود را وارد کنید");
+
+ if (!_customizeWorkshopGroupSettingsRepository.Exists(x => x.id == command.Id))
+ return op.Failed("چنین ساعت کاری برای گروه وجود ندارد");
+
+ #endregion
+
+
+ var entity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(command.Id);
+
+ FridayPay fridayPay = new(command.FridayPay.FridayPayType, command.FridayPay.Value);
+ OverTimePay overTimePay = new(command.OverTimePay.OverTimePayType, command.OverTimePay.Value);
+ BaseYearsPay baseYearsPay = new(command.BaseYearsPay.BaseYearsPayType, command.BaseYearsPay.Value, command.BaseYearsPay.PaymentType);
+ BonusesPay bonusesPay = new(command.BonusesPay.BonusesPayType, command.BonusesPay.Value, command.BonusesPay.PaymentType);
+ NightWorkPay nightWorkPay = new(command.NightWorkPay.NightWorkingType, command.NightWorkPay.Value);
+ MarriedAllowance marriedAllowance = new(command.MarriedAllowance.MarriedAllowanceType, command.MarriedAllowance.Value);
+ //ShiftPay shiftPay = new(command.ShiftPay.ShiftType, command.ShiftPay.ShiftPayType, command.ShiftPay.Value);
+ ShiftPay shiftPay = new(ShiftType.None, ShiftPayType.None, 0);
+ FamilyAllowance familyAllowance = new(command.FamilyAllowance.FamilyAllowanceType, command.FamilyAllowance.Value);
+ LeavePay leavePay = new(command.LeavePay.LeavePayType, command.LeavePay.Value);
+ InsuranceDeduction insuranceDeduction = new(command.InsuranceDeduction.InsuranceDeductionType, command.InsuranceDeduction.Value);
+ FineAbsenceDeduction fineAbsenceDeduction = new(
+ command.FineAbsenceDeduction.FineAbsenceDeductionType, command.FineAbsenceDeduction.Value,
+ command.FineAbsenceDeduction.FineAbsenceDayOfWeekViewModels
+ .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
+ );
+ LateToWork lateToWork = new(
+ command.LateToWork.LateToWorkType,
+ command.LateToWork.LateToWorkTimeFinesVewModels.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
+ .ToList(), command.LateToWork.Value
+ );
+ EarlyExit earlyExit = new(command.EarlyExit.EarlyExitType,
+ command.EarlyExit.EarlyExitTimeFinesViewModels.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
+ .ToList(), command.EarlyExit.Value);
+
+ double salary = command.Salary.MoneyToDouble();
+
+
+ bool isChanged;
+ if (fridayPay == entity.FridayPay && overTimePay == entity.OverTimePay && baseYearsPay == entity.BaseYearsPay && bonusesPay == entity.BonusesPay
+ && shiftPay == entity.ShiftPay && nightWorkPay == entity.NightWorkPay && marriedAllowance == entity.MarriedAllowance
+ && familyAllowance == entity.FamilyAllowance && leavePay == entity.LeavePay && insuranceDeduction == entity.InsuranceDeduction
+ && fineAbsenceDeduction == entity.FineAbsenceDeduction && lateToWork == entity.LateToWork && earlyExit == entity.EarlyExit && command.FridayWork == entity.FridayWork
+ && command.HolidayWork == entity.HolidayWork && command.IrregularShift == entity.IrregularShift && command.WorkshopShiftStatus == entity.WorkshopShiftStatus)
+ {
+ isChanged = false;
+ }
+ else
+ {
+ isChanged = true;
+ }
+ entity.EditAndOverwriteOnEmployees(command.Name, salary, command.EmployeeIds, fridayPay, overTimePay,
+ baseYearsPay, bonusesPay, shiftPay, nightWorkPay, marriedAllowance, familyAllowance,
+ leavePay, insuranceDeduction, fineAbsenceDeduction, lateToWork, earlyExit,
+ command.FridayWork, command.HolidayWork, isChanged, command.LeavePermittedDays);
+
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+
+ return op.Succcedded();
+ }
+
+ //Edit the Employee settings and change the 'IsChanged' bool to true.
+ public OperationResult EditRollCallEmployeeSettings(EditCustomizeEmployeeSettings command)
+ {
+ OperationResult op = new();
+ var entity = _customizeWorkshopEmployeeSettingsRepository.Get(command.Id);
+
+ #region Validation
+
+ if (entity == null)
+ return op.Failed("چنین پرسنلی وجود ندارد");
+
+ #endregion
+
+ FridayPay fridayPay = new(command.FridayPay.FridayPayType, command.FridayPay.Value);
+ OverTimePay overTimePay = new(command.OverTimePay.OverTimePayType, command.OverTimePay.Value);
+ BaseYearsPay baseYearsPay = new(command.BaseYearsPay.BaseYearsPayType, command.BaseYearsPay.Value, command.BaseYearsPay.PaymentType);
+ BonusesPay bonusesPay = new(command.BonusesPay.BonusesPayType, command.BonusesPay.Value, command.BonusesPay.PaymentType);
+ NightWorkPay nightWorkPay = new(command.NightWorkPay.NightWorkingType, command.NightWorkPay.Value);
+ MarriedAllowance marriedAllowance = new(command.MarriedAllowance.MarriedAllowanceType, command.MarriedAllowance.Value);
+ // ShiftPay shiftPay = new(command.ShiftPay.ShiftType, command.ShiftPay.ShiftPayType, command.ShiftPay.Value);
+ ShiftPay shiftPay = new(ShiftType.None, ShiftPayType.None, 0);
+ FamilyAllowance familyAllowance = new(command.FamilyAllowance.FamilyAllowanceType, command.FamilyAllowance.Value);
+ LeavePay leavePay = new(command.LeavePay.LeavePayType, command.LeavePay.Value);
+ InsuranceDeduction insuranceDeduction = new(command.InsuranceDeduction.InsuranceDeductionType, command.InsuranceDeduction.Value);
+ FineAbsenceDeduction fineAbsenceDeduction = new(
+ command.FineAbsenceDeduction.FineAbsenceDeductionType, command.FineAbsenceDeduction.Value,
+ command.FineAbsenceDeduction.FineAbsenceDayOfWeekViewModels
+ .Select(x => new FineAbsenceDayOfWeek(x.DayOfWeek)).ToList()
+ );
+ LateToWork lateToWork = new(
+ command.LateToWork.LateToWorkType,
+ command.LateToWork.LateToWorkTimeFinesVewModels.Select(x => new LateToWorkTimeFine(x.Minute, x.FineMoney))
+ .ToList(), command.LateToWork.Value
+ );
+ EarlyExit earlyExit = new(command.EarlyExit.EarlyExitType,
+ command.EarlyExit.EarlyExitTimeFinesViewModels.Select(x => new EarlyExitTimeFine(x.Minute, x.FineMoney))
+ .ToList(), command.EarlyExit.Value);
+
+
+ double salary = command.Salary.MoneyToDouble();
+
+ var employeesShifts =
+ command.ShiftViewModel.Select(x =>
+ {
+ if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
+ throw new InvalidDataException();
+ if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
+ throw new InvalidDataException();
+
+ return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
+
+ }).ToList();
+
+ bool isChanged;
+ if (fridayPay == entity.FridayPay && overTimePay == entity.OverTimePay && baseYearsPay == entity.BaseYearsPay && bonusesPay == entity.BonusesPay
+ && shiftPay == entity.ShiftPay && nightWorkPay == entity.NightWorkPay && marriedAllowance == entity.MarriedAllowance
+ && familyAllowance == entity.FamilyAllowance && leavePay == entity.LeavePay && insuranceDeduction == entity.InsuranceDeduction
+ && fineAbsenceDeduction == entity.FineAbsenceDeduction && lateToWork == entity.LateToWork && earlyExit == entity.EarlyExit && command.FridayWork == entity.FridayWork
+ && command.HolidayWork == entity.HolidayWork && command.IrregularShift == entity.IrregularShift && command.WorkshopShiftStatus == entity.WorkshopShiftStatus)
+ {
+ isChanged = false;
+ }
+ else
+ {
+ isChanged = true;
+ }
+
+ //change employee data manually. It changes the 'IsChanged' property to true.
+ entity.EditEmployees(salary, fridayPay, overTimePay, baseYearsPay,
+ bonusesPay, nightWorkPay, marriedAllowance, shiftPay, familyAllowance, leavePay,
+ insuranceDeduction, fineAbsenceDeduction, lateToWork, earlyExit, command.FridayWork, command.HolidayWork, command.IrregularShift,
+ command.WorkshopShiftStatus, isChanged, command.LeavePermittedDays);
+
+
+ _customizeWorkshopEmployeeSettingsRepository.SaveChanges();
+ return op.Succcedded();
+ }
+
+ public OperationResult RemoveGroupSettings(long groupSettingsId)
+ {
+ OperationResult op = new OperationResult();
+ var entity = _customizeWorkshopGroupSettingsRepository.GetWithEmployees(groupSettingsId);
+ if (entity.CustomizeWorkshopEmployeeSettingsCollection.Any())
+ return op.Failed("نمیتوانید گروهی که پرسنل در آن وجود دارد را حذف کنید");
+
+ _customizeWorkshopGroupSettingsRepository.Remove(entity.id);
+ return op.Succcedded();
+ }
+ #endregion
+
+ #region Queries
+
+
+ public List GetChangedEmployeeSettingsByGroupSettingsId(long groupSettingsId)
+ {
+ return _customizeWorkshopGroupSettingsRepository.GetShiftChangedEmployeeSettingsByGroupSettingsId(
+ groupSettingsId);
+ }
+
+
+ // It will Get the Workshop Settings with its groups and the employees of groups.
+ public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopId(long workshopId, AuthViewModel auth)
+ {
+
+
+ #region Validation
+
+ if (workshopId is < 1)
+ return new();
+
+ #endregion
+
+ var record = _customizeWorkshopSettingsRepository.GetWorkshopSettingsByWorkshopId(workshopId, auth);
+
+ return record;
+ }
+
+ public CustomizeWorkshopEmployeeSettingsViewModel GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(long workshopId, long employeeId)
+ {
+ var entity =
+ _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId, employeeId);
+ if (entity == null)
+ return new();
+
+ string employeeFullName = _employeeRepository.Get(entity.EmployeeId).FullName;
+ return new CustomizeWorkshopEmployeeSettingsViewModel()
+ {
+ EmployeeId = entity.EmployeeId,
+ Id = entity.id,
+ IsSettingChanged = entity.IsSettingChanged,
+ IsShiftChanged = entity.IsShiftChanged,
+ Name = entity.CustomizeWorkshopGroupSettings.GroupName,
+ EmployeeFullName = employeeFullName,
+ Salary = entity.Salary,
+ BreakTime = entity.BreakTime,
+ WorkshopShiftStatus = entity.WorkshopShiftStatus,
+ IrregularShift = entity.IrregularShift,
+ RollCallWorkshopShifts = entity.CustomizeWorkshopEmployeeSettingsShifts.Select(x =>
+ new CustomizeWorkshopShiftViewModel()
+ {
+ EndTime = x.EndTime.ToString("HH:mm"),
+ Placement = x.Placement,
+ StartTime = x.StartTime.ToString("HH:mm")
+ }).ToList(),
+ FridayWork = entity.FridayWork,
+ HolidayWork = entity.HolidayWork,
+ CustomizeRotatingShiftsViewModels = entity.CustomizeRotatingShifts.Select(x=>new CustomizeRotatingShiftsViewModel()
+ {
+ StartTime = x.StartTime.ToString("HH:mm"),
+ EndTime = x.EndTime.ToString("HH:mm")
+ }).ToList()
+
+ };
+ }
+
+ public List GetEmployeeSettingsByGroupSettingsId(long groupSettingsId)
+ {
+
+ List result = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(groupSettingsId);
+
+ if (result == null)
+ return new();
+
+ return result;
+
+ }
+
+ public CustomizeWorkshopSettingsViewModel GetWorkshopIncludeGroupsByWorkshopId(long workshopId)
+ {
+ return _customizeWorkshopSettingsRepository.GetWorkshopIncludeGroupsByWorkshopId(workshopId);
+ }
+
+
+ public List GetEmployeesWithoutGroup(long rollCallWorkshopSettingId)
+ {
+ return _customizeWorkshopGroupSettingsRepository.GetEmployeesWithoutGroup(rollCallWorkshopSettingId);
+ }
+ public List GetEmployeesWithoutGroupByWorkshopId(long workshopId)
+ {
+ return _customizeWorkshopGroupSettingsRepository.GetEmployeesWithoutGroupByWorkshopId(workshopId);
+ }
+
+
+
+ public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId)
+ {
+ return _customizeWorkshopSettingsRepository.GetWorkshopSettingsByWorkshopIdForAdmin(workshopId);
+
+ }
+ public EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId)
+ {
+ return _customizeWorkshopSettingsRepository.GetWorkshopSettingsDetails(workshopId);
+ }
+
+ public EditCustomizeWorkshopGroupSettings GetCustomizeWorkshopGroupSettingsDetails(long groupId)
+ {
+ return _customizeWorkshopGroupSettingsRepository.GetCustomizeWorkshopGroupSettingsDetails(groupId);
+ }
+
+ public EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId)
+ {
+ return _customizeWorkshopSettingsRepository.GetSimpleWorkshopSettings(workshopId);
+ }
+
+ public EditCustomizeEmployeeSettings GetCustomizeEmployeeSettingsDetails(long customizeEmployeeId)
+ {
+ return _customizeWorkshopEmployeeSettingsRepository.GetCustomizeEmployeeSettingsDetails(customizeEmployeeId);
+ }
+
+ public List GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId)
+ {
+ return _customizeWorkshopSettingsRepository.GetShiftChangesGroupAndEmployees(customizeWorkshopSettingsId);
+ }
+
+ public List GetEmployeeSettingsByWorkshopId(long workshopId)
+ {
+ return _customizeWorkshopEmployeeSettingsRepository.GetEmployeeSettingsByWorkshopId(workshopId);
+ }
+
+ private OperationResult CreateGeneralGroup(CustomizeWorkshopSettings entity)
+ {
+ var op = new OperationResult();
+
+ if (_customizeWorkshopGroupSettingsRepository.Exists(x => x.CustomizeWorkshopSettingId == entity.id && x.MainGroup))
+ {
+ return op.Succcedded();
+ }
+
+ try
+ {
+ var shifts =
+ entity.CustomizeWorkshopSettingsShifts.Select(x =>
+ new CustomizeWorkshopGroupSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
+ var irregularShift = new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None);
+
+ var customizeWorkshopGroupSettings = new CustomizeWorkshopGroupSettings().CreateMainGroup(entity.FridayPay, entity.OverTimePay,
+ entity.BaseYearsPay, entity.BonusesPay, entity.ShiftPay, entity.NightWorkPay, entity.MarriedAllowance,
+ entity.FamilyAllowance, entity.LeavePay, entity.InsuranceDeduction, entity.FineAbsenceDeduction,
+ entity.LateToWork, entity.EarlyExit, shifts, entity.FridayWork, entity.HolidayWork,
+ irregularShift, [] , entity.WorkshopShiftStatus, entity.id, new BreakTime(false, new TimeOnly()), entity.LeavePermittedDays);
+
+ _customizeWorkshopGroupSettingsRepository.Create(customizeWorkshopGroupSettings);
+
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+
+ var employeesHasSettings = _customizeWorkshopEmployeeSettingsRepository
+ .GetEmployeeSettingNotInMainGroup(entity.WorkshopId).Select(x => x.EmployeeId);
+
+ var rollCallEmployeeViewModels = _rollCallEmployeeApplication.GetByWorkshopId(entity.WorkshopId).Where(x => !employeesHasSettings.Contains(x.EmployeeId));
+
+ foreach (var rollCallEmployeeViewModel in rollCallEmployeeViewModels)
+ {
+ customizeWorkshopGroupSettings.AddEmployeeSettingToGroupWithGroupData(
+ rollCallEmployeeViewModel.EmployeeId, entity.WorkshopId);
+ }
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+ return op.Succcedded();
+ }
+ catch (Exception e)
+ {
+ return op.Failed(e.Message);
+ }
+
+
+ }
+
+ private OperationResult ChangeAllGroupsShiftsWithEmployees(CustomizeWorkshopSettings entity, bool replaceChangedGroups)
+ {
+ var op = new OperationResult();
+ var groupSettings = _customizeWorkshopGroupSettingsRepository.GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(entity.id);
+
+ if (!replaceChangedGroups)
+ {
+ groupSettings = groupSettings.Where(x => !x.IsShiftChange).ToList();
+ }
+
+ var groupShifts = entity.CustomizeWorkshopSettingsShifts
+ .Select(x => new CustomizeWorkshopGroupSettingsShift(x.StartTime, x.EndTime, x.Placement)).ToList();
+
+
+
+ var irregularShift = new IrregularShift(new TimeOnly(), new TimeOnly(), WorkshopIrregularShifts.None);
+ foreach (var customizeWorkshopGroupSettings in groupSettings)
+ {
+ customizeWorkshopGroupSettings.EditSimpleAndOverwriteOnAllEmployees(customizeWorkshopGroupSettings.GroupName,
+ groupShifts, entity.WorkshopShiftStatus, irregularShift, new BreakTime(false, new TimeOnly()),
+ false, entity.FridayWork, entity.HolidayWork, []);
+ }
+ _customizeWorkshopGroupSettingsRepository.SaveChanges();
+ return op.Succcedded();
+ }
+ private void ChangeAllSettingsGroups(CustomizeWorkshopSettings customizeWorkshopSettings, bool replaceInAllGroups)
+ {
+ var op = new OperationResult();
+ var groupSettings = _customizeWorkshopGroupSettingsRepository.GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(customizeWorkshopSettings.id);
+
+ if (!replaceInAllGroups)
+ {
+ groupSettings = groupSettings.Where(x => !x.IsSettingChange).ToList();
+ }
+
+
+
+ foreach (var groupSetting in groupSettings)
+ {
+ groupSetting.EditAndOverwriteOnAllEmployees(groupSetting.GroupName, groupSetting.Salary,
+ customizeWorkshopSettings.FridayPay,
+ customizeWorkshopSettings.OverTimePay, customizeWorkshopSettings.BaseYearsPay,
+ customizeWorkshopSettings.BonusesPay, customizeWorkshopSettings.ShiftPay,
+ customizeWorkshopSettings.NightWorkPay, customizeWorkshopSettings.MarriedAllowance,
+ customizeWorkshopSettings.FamilyAllowance, customizeWorkshopSettings.LeavePay,
+ customizeWorkshopSettings.InsuranceDeduction, customizeWorkshopSettings.FineAbsenceDeduction,
+ customizeWorkshopSettings.LateToWork, customizeWorkshopSettings.EarlyExit,
+ customizeWorkshopSettings.FridayWork, customizeWorkshopSettings.HolidayWork, replaceInAllGroups,
+ customizeWorkshopSettings.LeavePermittedDays);
+ }
+ _customizeWorkshopSettingsRepository.SaveChanges();
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/CompanyManagment.EFCore/Mapping/CustomizeWorkshopEmployeeSettingsMapping.cs b/CompanyManagment.EFCore/Mapping/CustomizeWorkshopEmployeeSettingsMapping.cs
index d55aa642..f296640c 100644
--- a/CompanyManagment.EFCore/Mapping/CustomizeWorkshopEmployeeSettingsMapping.cs
+++ b/CompanyManagment.EFCore/Mapping/CustomizeWorkshopEmployeeSettingsMapping.cs
@@ -228,5 +228,7 @@ public class CustomizeWorkshopEmployeeSettingsMapping : IEntityTypeConfiguration
});
+ builder.OwnsMany(x => x.CustomizeRotatingShifts);
+
}
}
\ No newline at end of file
diff --git a/CompanyManagment.EFCore/Mapping/CustomizeWorkshopGroupSettingsMapping.cs b/CompanyManagment.EFCore/Mapping/CustomizeWorkshopGroupSettingsMapping.cs
index d16c54e3..830224f7 100644
--- a/CompanyManagment.EFCore/Mapping/CustomizeWorkshopGroupSettingsMapping.cs
+++ b/CompanyManagment.EFCore/Mapping/CustomizeWorkshopGroupSettingsMapping.cs
@@ -227,6 +227,9 @@ public class CustomizeWorkshopGroupSettingsMapping : IEntityTypeConfiguration x.CustomizeRotatingShifts);
+
+
builder.HasOne(x => x.CustomizeWorkshopSettings).WithMany(x => x.CustomizeWorkshopGroupSettingsCollection)
.HasForeignKey(x => x.CustomizeWorkshopSettingId);
diff --git a/CompanyManagment.EFCore/Migrations/20250104151137_CWS_Daltons.Designer.cs b/CompanyManagment.EFCore/Migrations/20250104151137_CWS_Daltons.Designer.cs
new file mode 100644
index 00000000..f6f5a15b
--- /dev/null
+++ b/CompanyManagment.EFCore/Migrations/20250104151137_CWS_Daltons.Designer.cs
@@ -0,0 +1,7901 @@
+//
+using System;
+using CompanyManagment.EFCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CompanyManagment.EFCore.Migrations
+{
+ [DbContext(typeof(CompanyContext))]
+ [Migration("20250104151137_CWS_Daltons")]
+ partial class CWS_Daltons
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("Company.Domain.AndroidApkVersionAgg.AndroidApkVersion", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("IsActive")
+ .IsRequired()
+ .HasMaxLength(1)
+ .HasColumnType("nvarchar(1)");
+
+ b.Property("Path")
+ .HasMaxLength(255)
+ .HasColumnType("nvarchar(255)");
+
+ b.Property("Title")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("VersionCode")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("VersionName")
+ .HasMaxLength(35)
+ .HasColumnType("nvarchar(35)");
+
+ b.HasKey("id");
+
+ b.ToTable("AndroidApkVersions", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.BillAgg.EntityBill", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("Appointed")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Contact")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IsActiveString")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProcessingStage")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SubjectBill")
+ .IsRequired()
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.HasKey("id");
+
+ b.ToTable("TextManager_Bill", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.Board.Board", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("BoardChairman")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("BoardType_Id")
+ .HasColumnType("int");
+
+ b.Property("Branch")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("DisputeResolutionPetitionDate")
+ .HasColumnType("datetime2");
+
+ b.Property("ExpertReport")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("File_Id")
+ .HasColumnType("bigint");
+
+ b.HasKey("id");
+
+ b.HasIndex("BoardType_Id");
+
+ b.HasIndex("File_Id");
+
+ b.ToTable("Boards", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.BoardType.BoardType", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Title")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("BoardTypes", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.ChapterAgg.EntityChapter", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("Chapter")
+ .IsRequired()
+ .HasMaxLength(60)
+ .HasColumnType("nvarchar(60)");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("IsActiveString")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Subtitle_Id")
+ .HasColumnType("bigint");
+
+ b.HasKey("id");
+
+ b.HasIndex("Subtitle_Id");
+
+ b.ToTable("TextManager_Chapter", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.CheckoutAgg.Checkout", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("AbsenceDeduction")
+ .HasColumnType("float");
+
+ b.Property("AbsencePeriod")
+ .HasColumnType("float");
+
+ b.Property("AbsenceValue")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("ArchiveCode")
+ .HasMaxLength(15)
+ .HasColumnType("nvarchar(15)");
+
+ b.Property("AverageHoursPerDay")
+ .HasColumnType("float");
+
+ b.Property("BaseYearsPay")
+ .HasColumnType("float");
+
+ b.Property("BonusesPay")
+ .HasColumnType("float");
+
+ b.Property("ConsumableItems")
+ .HasColumnType("float");
+
+ b.Property("ContractEnd")
+ .HasColumnType("datetime2");
+
+ b.Property("ContractId")
+ .HasColumnType("bigint");
+
+ b.Property("ContractNo")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("ContractStart")
+ .HasColumnType("datetime2");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("CreditLeaves")
+ .HasColumnType("float");
+
+ b.Property("DateOfBirth")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("EmployeeFullName")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("EmployeeId")
+ .HasColumnType("bigint");
+
+ b.Property("FamilyAllowance")
+ .HasColumnType("float");
+
+ b.Property("FathersName")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("FridayPay")
+ .HasColumnType("float");
+
+ b.Property("FridayWorkValue")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("HasRollCall")
+ .HasColumnType("bit");
+
+ b.Property("HousingAllowance")
+ .HasColumnType("float");
+
+ b.Property("InstallmentDeduction")
+ .HasColumnType("float");
+
+ b.Property("InsuranceDeduction")
+ .HasColumnType("float");
+
+ b.Property("IsActiveString")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("LeaveCheckout")
+ .HasColumnType("bit");
+
+ b.Property("LeavePay")
+ .HasColumnType("float");
+
+ b.Property("MarriedAllowance")
+ .HasColumnType("float");
+
+ b.Property("MissionPay")
+ .HasColumnType("float");
+
+ b.Property("Month")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("MonthlySalary")
+ .HasColumnType("float");
+
+ b.Property("NationalCode")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("NightworkPay")
+ .HasColumnType("float");
+
+ b.Property("OverNightWorkValue")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("OverTimeWorkValue")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("OvertimePay")
+ .HasColumnType("float");
+
+ b.Property("PersonnelCode")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("RewardPay")
+ .HasColumnType("float");
+
+ b.Property("RotatingShiftValue")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("SalaryAidDeduction")
+ .HasColumnType("float");
+
+ b.Property("ShiftPay")
+ .HasColumnType("float");
+
+ b.Property("Signature")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("SumOfWorkingDays")
+ .HasMaxLength(6)
+ .HasColumnType("nvarchar(6)");
+
+ b.Property("TaxDeducation")
+ .HasColumnType("float");
+
+ b.Property("TotalClaims")
+ .HasMaxLength(25)
+ .HasColumnType("nvarchar(25)");
+
+ b.Property("TotalDayOfBunosesCompute")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("TotalDayOfLeaveCompute")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("TotalDayOfYearsCompute")
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("TotalDeductions")
+ .HasMaxLength(25)
+ .HasColumnType("nvarchar(25)");
+
+ b.Property("TotalPayment")
+ .HasColumnType("float");
+
+ b.Property("WorkingHoursId")
+ .HasColumnType("bigint");
+
+ b.Property("WorkshopId")
+ .HasColumnType("bigint");
+
+ b.Property("WorkshopName")
+ .HasMaxLength(70)
+ .HasColumnType("nvarchar(70)");
+
+ b.Property("Year")
+ .HasMaxLength(4)
+ .HasColumnType("nvarchar(4)");
+
+ b.Property("YearsPay")
+ .HasColumnType("float");
+
+ b.HasKey("id");
+
+ b.HasIndex("WorkshopId");
+
+ b.ToTable("Checkouts", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.ClassifiedSalaryAgg.ClassifiedSalary", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("EndDate")
+ .HasColumnType("datetime2");
+
+ b.Property("Group1")
+ .HasColumnType("float");
+
+ b.Property("Group10")
+ .HasColumnType("float");
+
+ b.Property("Group11")
+ .HasColumnType("float");
+
+ b.Property("Group12")
+ .HasColumnType("float");
+
+ b.Property("Group13")
+ .HasColumnType("float");
+
+ b.Property("Group14")
+ .HasColumnType("float");
+
+ b.Property("Group15")
+ .HasColumnType("float");
+
+ b.Property("Group16")
+ .HasColumnType("float");
+
+ b.Property("Group17")
+ .HasColumnType("float");
+
+ b.Property("Group18")
+ .HasColumnType("float");
+
+ b.Property("Group19")
+ .HasColumnType("float");
+
+ b.Property("Group2")
+ .HasColumnType("float");
+
+ b.Property("Group20")
+ .HasColumnType("float");
+
+ b.Property("Group3")
+ .HasColumnType("float");
+
+ b.Property("Group4")
+ .HasColumnType("float");
+
+ b.Property("Group5")
+ .HasColumnType("float");
+
+ b.Property("Group6")
+ .HasColumnType("float");
+
+ b.Property("Group7")
+ .HasColumnType("float");
+
+ b.Property("Group8")
+ .HasColumnType("float");
+
+ b.Property("Group9")
+ .HasColumnType("float");
+
+ b.Property("StartDate")
+ .HasColumnType("datetime2");
+
+ b.Property("Year")
+ .HasColumnType("int");
+
+ b.HasKey("id");
+
+ b.ToTable("ClassifiedSalaries", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.ClientEmployeeWorkshopAgg.ClientEmployeeWorkshop", b =>
+ {
+ b.Property("WorkshopId")
+ .HasColumnType("bigint");
+
+ b.Property("EmployeeId")
+ .HasColumnType("bigint");
+
+ b.HasKey("WorkshopId", "EmployeeId");
+
+ b.HasIndex("EmployeeId");
+
+ b.ToTable("ClientWorkshopEmployee", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.Contact2Agg.EntityContact", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("IsActiveString")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("NameContact")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Signature")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("id");
+
+ b.ToTable("TextManager_Contact", (string)null);
+ });
+
+ modelBuilder.Entity("Company.Domain.ContarctingPartyAgg.PersonalContractingParty", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("bigint");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id"));
+
+ b.Property("Address")
+ .HasMaxLength(500)
+ .HasColumnType("nvarchar(500)");
+
+ b.Property("AgentPhone")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("ArchiveCode")
+ .HasColumnType("int");
+
+ b.Property("BlockTimes")
+ .HasColumnType("int");
+
+ b.Property("City")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("FName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("IdNumber")
+ .HasMaxLength(20)
+ .HasColumnType("nvarchar(20)");
+
+ b.Property("IsActiveString")
+ .HasMaxLength(5)
+ .HasColumnType("nvarchar(5)");
+
+ b.Property("IsBlock")
+ .HasMaxLength(5)
+ .HasColumnType("nvarchar(5)");
+
+ b.Property("IsLegal")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("LName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("NationalId")
+ .IsRequired()
+ .HasMaxLength(15)
+ .HasColumnType("nvarchar(15)");
+
+ b.Property("Nationalcode")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
+ b.Property("Phone")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("RegisterId")
+ .IsRequired()
+ .HasMaxLength(15)
+ .HasColumnType("nvarchar(15)");
+
+ b.Property("RepresentativeFullName")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("RepresentativeId")
+ .HasColumnType("bigint");
+
+ b.Property("State")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("SureName")
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property