From ec97274d5ea6479ceeb510a5e7caf0acca144d6c Mon Sep 17 00:00:00 2001 From: Mahan Ch Date: Mon, 9 Jun 2025 15:07:06 +0330 Subject: [PATCH] add checkout rollcall domain to Checkout --- Company.Domain/CheckoutAgg/Checkout.cs | 146 +++++++++++++++++- .../CheckoutApplication.cs | 10 +- .../Repository/CheckoutRepository.cs | 1 + 3 files changed, 154 insertions(+), 3 deletions(-) diff --git a/Company.Domain/CheckoutAgg/Checkout.cs b/Company.Domain/CheckoutAgg/Checkout.cs index 760f8259..5e498fe1 100644 --- a/Company.Domain/CheckoutAgg/Checkout.cs +++ b/Company.Domain/CheckoutAgg/Checkout.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using _0_Framework.Application; using _0_Framework.Domain; +using _0_Framework.Domain.CustomizeCheckoutShared.Enums; using Company.Domain.CheckoutAgg.ValueObjects; using Company.Domain.CustomizeCheckoutAgg.ValueObjects; using Company.Domain.WorkshopAgg; @@ -29,7 +30,7 @@ public class Checkout : EntityBase string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue, string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute, ICollection loanInstallments, - ICollection salaryAids) + ICollection salaryAids,CheckoutRollCall checkoutRollCall) { EmployeeFullName = employeeFullName; FathersName = fathersName; @@ -88,6 +89,7 @@ public class Checkout : EntityBase TotalDayOfBunosesCompute = totalDayOfBunosesCompute; LoanInstallments = loanInstallments; SalaryAids = salaryAids; + CheckoutRollCall = checkoutRollCall; } public string EmployeeFullName { get; private set; } @@ -196,7 +198,8 @@ public class Checkout : EntityBase public ICollection LoanInstallments { get; set; } = []; public ICollection SalaryAids { get; set; } = []; - #endregion + public CheckoutRollCall CheckoutRollCall { get; private set; } + #endregion public Workshop Workshop { get; set; } @@ -308,4 +311,143 @@ public class Checkout : EntityBase LoanInstallments = lonaInstallments; InstallmentDeduction = installmentsAmount; } + + public void SetCheckoutRollCall(CheckoutRollCall checkoutRollCall) + { + CheckoutRollCall = checkoutRollCall; + } +} + +public class CheckoutRollCall +{ + public CheckoutRollCall(TimeSpan totalMandatoryTimeSpan, TimeSpan totalPresentTimeSpan, TimeSpan totalBreakTimeSpan, + TimeSpan totalWorkingTimeSpan, TimeSpan totalPaidLeaveTmeSpan, TimeSpan totalSickLeaveTimeSpan, + ICollection rollCallDaysCollection) + { + TotalMandatoryTimeSpan = totalMandatoryTimeSpan; + TotalPresentTimeSpan = totalPresentTimeSpan; + TotalBreakTimeSpan = totalBreakTimeSpan; + TotalWorkingTimeSpan = totalWorkingTimeSpan; + TotalPaidLeaveTmeSpan = totalPaidLeaveTmeSpan; + TotalSickLeaveTimeSpan = totalSickLeaveTimeSpan; + RollCallDaysCollection = rollCallDaysCollection; + } + /// + /// مجموع ساعت موظفی + /// + public TimeSpan TotalMandatoryTimeSpan { get; private set; } + + /// + /// مجموع ساعت حضور + /// + public TimeSpan TotalPresentTimeSpan { get; private set; } + + /// + /// مجموع ساعت استراحت + /// + public TimeSpan TotalBreakTimeSpan { get; private set; } + + /// + /// مجموع ساعت کارکرد + /// + public TimeSpan TotalWorkingTimeSpan { get; private set; } + + /// + /// مجموع ساعت مرخصی استحقاقی + /// + public TimeSpan TotalPaidLeaveTmeSpan { get; private set; } + + /// + /// مجموع ساعت مرخصی استعلاجی + /// + public TimeSpan TotalSickLeaveTimeSpan { get; private set; } + + /// + /// روز های حضور غیاب + /// + public ICollection RollCallDaysCollection { get; private set; } +} + +public class CheckoutRollCallDay +{ + public CheckoutRollCallDay(DateTime date, DateTime firstStartDate, DateTime firstEndDate, DateTime secondStartDate, DateTime secondEndStartDate, TimeSpan breakTimeSpan, bool isSliced, TimeSpan workingTimeSpan, bool isAbsent, bool isFriday, bool isHoliday, bool isBirthDay, string leaveType) + { + Date = date; + FirstStartDate = firstStartDate; + FirstEndDate = firstEndDate; + SecondStartDate = secondStartDate; + SecondEndStartDate = secondEndStartDate; + BreakTimeSpan = breakTimeSpan; + IsSliced = isSliced; + WorkingTimeSpan = workingTimeSpan; + IsAbsent = isAbsent; + IsFriday = isFriday; + IsHoliday = isHoliday; + IsBirthDay = isBirthDay; + LeaveType = leaveType; + } + /// + /// تاریخ + /// + public DateTime Date { get; private set; } + /// + /// ورود اول + /// + public DateTime FirstStartDate { get; private set; } + + /// + /// خروج اول + /// + public DateTime FirstEndDate { get; private set; } + + /// + /// ورود دوم + /// + public DateTime SecondStartDate { get; private set; } + + /// + /// خروج دوم + /// + public DateTime SecondEndStartDate { get; private set; } + + /// + /// ساعت استراحت + /// + public TimeSpan BreakTimeSpan { get; private set; } + + /// + /// مقدار زمان کارکرد + /// + public TimeSpan WorkingTimeSpan { get; private set; } + + /// + /// آیا منقطع است؟ + /// + public bool IsSliced { get; private set; } + + /// + /// آیا غیبت است + /// + public bool IsAbsent { get; private set; } + + /// + /// آیا جمعه است + /// + public bool IsFriday { get; private set; } + + /// + /// آیا تعطیل رسمی است + /// + public bool IsHoliday { get; private set; } + + /// + /// آیا روز تولد است + /// + public bool IsBirthDay { get; private set; } + + /// + /// نوع مرخصی - درصورت نداشتن مرخصی مقدارش null میباشد + /// + public string LeaveType { get; private set; } + } \ No newline at end of file diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 9d26aa35..4b1f2091 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -27,11 +27,12 @@ public class CheckoutApplication : ICheckoutApplication private readonly ILeaveApplication _leaveApplication; private readonly IMandatoryHoursApplication _mandatoryHoursApplication; private readonly IRollCallMandatoryRepository _rollCallMandatoryRepository; + private readonly IRollCallRepository _rollCallRepository; public CheckoutApplication(ICheckoutRepository checkoutRepository, IYearlySalaryRepository yearlySalaryRepository, ILeftWorkRepository leftWorkRepository, - IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository) + IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository) { _checkoutRepository = checkoutRepository; _yearlySalaryRepository = yearlySalaryRepository; @@ -41,6 +42,7 @@ public class CheckoutApplication : ICheckoutApplication _leaveApplication = leaveApplication; _mandatoryHoursApplication = mandatoryHoursApplication; _rollCallMandatoryRepository = rollCallMandatoryRepository; + _rollCallRepository = rollCallRepository; } [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 241")] @@ -189,6 +191,12 @@ public class CheckoutApplication : ICheckoutApplication command.InstallmentDeduction = loanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble()); + var rollCalls= _rollCallRepository.GetEmployeeRollCallsForMonth(command.EmployeeId, + command.WorkshopId, command.ContractStartGr, command.ContractEndGr).Select(x=>new CheckoutRollCallDay(x.DateTimeGr,x.StartDate1.tog)); + + + + var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay + command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay; var totalClaims = totalClaimsDouble.ToMoney(); diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 5065e283..bc1ca9b3 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -501,6 +501,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos entity.SetSalaryAid(command.SalaryAids, command.SalaryAidDeduction); entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction); + entity.SetCheckoutRollCall(command.CheckoutRollCall); await _context.SaveChangesAsync(); }