feat: add dynamic deduction items for late entry and insurance fines to checkout calculations

This commit is contained in:
2025-11-20 12:58:25 +03:30
parent 2035b6fff8
commit 3937cd8a9f
9 changed files with 166 additions and 101 deletions

View File

@@ -0,0 +1,9 @@
namespace _0_Framework.Application.Enums
{
public class CheckoutDynamicDeductionItem
{
public string Name { get; set; }
public int Count { get; set; }
public string Amount { get; set; }
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Domain;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
@@ -33,7 +34,8 @@ public class CustomizeCheckout : EntityBase
ICollection<CustomizeCheckoutSalaryAid> customizeCheckoutSalaryAids,
ICollection<CustomizeCheckoutReward> customizeCheckoutRewards, TimeSpan lateToWorkValue, double settingSalary,
double dailyWage, WorkshopShiftStatus shiftStatus, IrregularShift irregularShift,
ICollection<CustomizeRotatingShift> customizeRotatingShifts, ICollection<CustomizeCheckoutRegularShift> employeeSettingsShifts)
ICollection<CustomizeRotatingShift> customizeRotatingShifts, ICollection<CustomizeCheckoutRegularShift> employeeSettingsShifts,
ICollection<CheckoutDynamicDeductionItem> checkoutDynamicDeductions)
{
YearInt = Convert.ToInt32(contractStart.ToFarsi().Substring(0, 4));
MonthInt = Convert.ToInt32(contractStart.ToFarsi().Substring(5, 2));
@@ -83,6 +85,7 @@ public class CustomizeCheckout : EntityBase
IrregularShift = irregularShift;
CustomizeRotatingShifts = customizeRotatingShifts;
RegularShifts = employeeSettingsShifts;
CheckoutDynamicDeductions = checkoutDynamicDeductions;
}
@@ -286,6 +289,7 @@ public class CustomizeCheckout : EntityBase
public ICollection<CustomizeCheckoutLoanInstallments> CustomizeCheckoutLoanInstallments { get; set; }
public ICollection<CustomizeCheckoutSalaryAid> CustomizeCheckoutSalaryAids { get; set; }
public ICollection<CustomizeCheckoutReward> CustomizeCheckoutRewards { get; set; }
public ICollection<CheckoutDynamicDeductionItem> CheckoutDynamicDeductions { get; private set; }
public IrregularShift IrregularShift { get; set; }
public ICollection<CustomizeRotatingShift> CustomizeRotatingShifts { get; set; }

View File

@@ -9,6 +9,7 @@ using Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
using System.Linq;
using _0_Framework.Application.Enums;
namespace Company.Domain.CustomizeCheckoutTempAgg;
@@ -21,7 +22,8 @@ public class CustomizeCheckoutTemp : EntityBase
{
LateToWorkValue = lateToWorkValue;
}
public CustomizeCheckoutTemp(DateTime contractStart, DateTime contractEnd, long employeeId, string employeeFName,
public CustomizeCheckoutTemp(
DateTime contractStart, DateTime contractEnd, long employeeId, string employeeFName,
string employeeLName, DateTime employeeDateOfBirth,
string employeeNationalCode, string workshopFullName, long workshopId, long? contractId,
double monthlySalary, double fridayPay, double overTimePay, double baseYearsPay, double bonusesPay,
@@ -37,7 +39,8 @@ public class CustomizeCheckoutTemp : EntityBase
ICollection<CustomizeCheckoutTempSalaryAid> customizeCheckoutSalaryAids,
ICollection<CustomizeCheckoutTempReward> customizeCheckoutRewards,
TimeSpan lateToWorkValue, double settingSalary, double dailyWage, WorkshopShiftStatus shiftStatus, IrregularShift irregularShift,
ICollection<CustomizeRotatingShift> customizeRotatingShifts, ICollection<CustomizeCheckoutRegularShift> employeeSettingsShifts)
ICollection<CustomizeRotatingShift> customizeRotatingShifts, ICollection<CustomizeCheckoutRegularShift> employeeSettingsShifts,
ICollection<CheckoutDynamicDeductionItem> checkoutDynamicDeductions)
{
YearInt = Convert.ToInt32(contractStart.ToFarsi().Substring(0, 4));
MonthInt = Convert.ToInt32(contractStart.ToFarsi().Substring(5, 2));
@@ -87,6 +90,7 @@ public class CustomizeCheckoutTemp : EntityBase
IrregularShift = irregularShift;
CustomizeRotatingShifts = customizeRotatingShifts;
RegularShifts = employeeSettingsShifts;
CheckoutDynamicDeductions = checkoutDynamicDeductions;
}
#region Getters
@@ -123,6 +127,7 @@ public class CustomizeCheckoutTemp : EntityBase
public IrregularShift IrregularShift { get; set; }
public ICollection<CustomizeRotatingShift> CustomizeRotatingShifts { get; set; }
public ICollection<CustomizeCheckoutRegularShift> RegularShifts { get; set; }
public ICollection<CheckoutDynamicDeductionItem> CheckoutDynamicDeductions { get; private set; }
#endregion

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Security.AccessControl;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
@@ -18,8 +19,6 @@ namespace CompanyManagment.App.Contracts.CustomizeCheckout;
public class CustomizeCheckoutMandatoryViewModel
{
/// <summary>
/// حقوق ماهانه
/// </summary>
@@ -207,6 +206,8 @@ public class CustomizeCheckoutMandatoryViewModel
public ICollection<CustomizeRotatingShift> CustomizeRotatingShifts { get; set; } = [];
public ICollection<CustomizeSifts> EmployeeSettingsShifts { get; set; } = [];
public List<CheckoutDynamicDeductionItem> DynamicDeductions { get; set; } = new();
}

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Runtime;
using System.Security.AccessControl;
using _0_Framework.Application.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
@@ -12,10 +13,10 @@ using CompanyManagment.App.Contracts.Loan;
using CompanyManagment.App.Contracts.Reward;
using CompanyManagment.App.Contracts.SalaryAid;
namespace CompanyManagment.App.Contracts.CustomizeCheckout
namespace CompanyManagment.App.Contracts.CustomizeCheckout;
public class CustomizeCheckoutViewModel
{
public class CustomizeCheckoutViewModel
{
public long Id { get; set; }
public DateTime CreationDate { get; set; }
public string Month { get; set; }
@@ -111,8 +112,8 @@ namespace CompanyManagment.App.Contracts.CustomizeCheckout
public bool HasAmountConflict { get; set; }
// New: up to three dynamic deduction items (title -> amount string)
public IDictionary<string, string> DynamicDeductions { get; set; } = new Dictionary<string, string>();
// New: up to three dynamic deduction items (name, count, amount)
public List<CheckoutDynamicDeductionItem> CheckoutDynamicDeductions { get; set; } = new List<CheckoutDynamicDeductionItem>();
//public bool HasLeft { get; set; }
//public string IsBlockCantracingParty { get; set; }
@@ -123,5 +124,4 @@ namespace CompanyManagment.App.Contracts.CustomizeCheckout
//public string HousingAllowance { get; set; }
//public string YearsPay { get; set; }
}
}

View File

@@ -123,7 +123,7 @@ namespace CompanyManagment.Application
result.LateToWorkDeduction, result.EarlyExitDeduction, result.RewardPay, result.SalaryAidDeduction, result.InstallmentDeduction, result.FineDeduction,
result.TaxDeduction, result.SumOfWorkingDays, result.TotalClaimsStr, result.TotalDeductionsStr, result.TotalPayment, contract?.ContractNo ?? "-",
fines, loanInstallments, salaryAids, rewards, result.LateToWorkValue, result.SettingSalary, result.DailyWage, result.ShiftStatus, result.IrregularShift, result.CustomizeRotatingShifts,
regularShift);
regularShift,result.DynamicDeductions);
_customizeCheckoutRepository.Create(entity);
@@ -187,7 +187,7 @@ namespace CompanyManagment.Application
computations.LateToWorkDeduction, computations.EarlyExitDeduction, computations.RewardPay, computations.SalaryAidDeduction, computations.InstallmentDeduction, computations.FineDeduction,
computations.TaxDeduction, computations.SumOfWorkingDays, computations.TotalClaimsStr, computations.TotalDeductionsStr, computations.TotalPayment, contract?.ContractNo ?? "-",
fines, loanInstallments, salaryAids, rewards, computations.LateToWorkValue, computations.SettingSalary, computations.DailyWage, computations.ShiftStatus, computations.IrregularShift,
computations.CustomizeRotatingShifts, regularShift);
computations.CustomizeRotatingShifts, regularShift,computations.DynamicDeductions);
_customizeCheckoutRepository.Create(entity);
_customizeCheckoutRepository.RemoveEmployeeCustomizeCheckoutInDates(command.WorkshopId, employeeId, command.ContractStart, command.ContractEnd);

View File

@@ -98,7 +98,7 @@ namespace CompanyManagment.Application
result.LateToWorkDeduction, result.EarlyExitDeduction, result.RewardPay, result.SalaryAidDeduction, result.InstallmentDeduction, result.FineDeduction,
result.TaxDeduction, result.SumOfWorkingDays, result.TotalClaimsStr, result.TotalDeductionsStr, result.TotalPayment, contract?.ContractNo ?? "-",
fines, loanInstallments, salaryAids, rewards, result.LateToWorkValue, result.SettingSalary, result.DailyWage, result.ShiftStatus, result.IrregularShift, result.CustomizeRotatingShifts,
regularShift);
regularShift,result.DynamicDeductions);
_customizeCheckoutTempRepository.Create(entity);
@@ -147,6 +147,7 @@ namespace CompanyManagment.Application
var regularShift = computations.EmployeeSettingsShifts.Select(x =>
new CustomizeCheckoutRegularShift(x.StartTime, x.EndTime, x.Placement)).ToList();
var entity = new CustomizeCheckoutTemp(command.ContractStart, command.ContractEnd, employeeId, employee.FName, employee.LName, employee.DateOfBirth, employee.NationalCode,
workshop.WorkshopFullName, command.WorkshopId, contract?.Id,
computations.MonthlySalary, computations.FridayPay, computations.OverTimePay, computations.BaseYearsPay,
@@ -155,7 +156,7 @@ namespace CompanyManagment.Application
computations.LateToWorkDeduction, computations.EarlyExitDeduction, computations.RewardPay, computations.SalaryAidDeduction, computations.InstallmentDeduction, computations.FineDeduction,
computations.TaxDeduction, computations.SumOfWorkingDays, computations.TotalClaimsStr, computations.TotalDeductionsStr, computations.TotalPayment, contract?.ContractNo ?? "-",
fines, loanInstallments, salaryAids, rewards, computations.LateToWorkValue, computations.SettingSalary, computations.DailyWage, computations.ShiftStatus, computations.IrregularShift,
computations.CustomizeRotatingShifts, regularShift);
computations.CustomizeRotatingShifts, regularShift,computations.DynamicDeductions);
_customizeCheckoutTempRepository.Create(entity);
_customizeCheckoutTempRepository.RemoveEmployeeTemporaryCheckoutInDates(command.WorkshopId, employeeId, command.ContractStart, command.ContractEnd);
}

View File

@@ -20,6 +20,7 @@ using CompanyManagment.App.Contracts.Fine;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using _0_Framework.Application.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
@@ -4304,19 +4305,25 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
long workshopId,
DateTime contractStart, DateTime contractEnd)
{
var dynamicdeductions = new List<CheckoutDynamicDeductionItem>();
//مقدار جریمه تاخیر ورود
double lateEntryFine = 0;
//مرز جریمه جداگانه تاخیر ورود
int minuteThresholdForLateEntryFine = 16;
//تعداد دفعاتی که پرسنل بیش از مرز تاخیر ورود داشته است
int lateEntryFineTimes = 0;
//مرز محاسبه تعجیل خروج
int minuteThresholdForEarlyExitCalculation = 30;
//مبلغ جریمه تاخیر ورود
int lateEntryFineAmount = 40_000;
int lateEntryFineAmount = 400_000;
//مقدار جریمه افرادی که دارای بیمه هستند ولی غیبت کرده اند
int absenceForInsuranceEmployeesAmount = 150_000;
int absenceForInsuranceEmployeesAmount = 1500_000;
//جریمه غیبت برای پرسنل بیمه شده
double absenceForInsuranceFine = 0;
//تعداد روز غیبت پرسنل بیمه شده
int absenceForInsuranceDays = 0;
var checkoutEnd = contractEnd;
@@ -4726,12 +4733,14 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
leavePermittedDays -= absenceDays;
leavePayAmount = leavePermittedDays * dailyWage;
absentsDeductionAmount = 0;
absenceDays = 0;
}
else
{
absenceDays -= leavePermittedDays;
absentsDeductionAmount = absenceDays * dailyWage;
leavePayAmount = 0;
leavePermittedDays = 0;
}
#endregion
@@ -5046,6 +5055,7 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
{
lateEntryFineTimes = (int)minutes / minuteThresholdForLateEntryFine;
lateEntryFine = lateEntryFineTimes * lateEntryFineAmount;
}
lateToWorkDeduction += dayMinuteWage * minutes;
@@ -5060,6 +5070,14 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
}
}
dynamicdeductions.Add(new()
{
Amount = lateEntryFine.ToMoney(),
Name = "جریمه 40 تومانی",
Count = lateEntryFineTimes
});
// if (mandatoryDays == 31)
// {
@@ -5068,6 +5086,28 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
#endregion
# region جریمه افراد غایبی که بیمه هستند
var leftWorkInsurance = _context.LeftWorkInsuranceList.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId
&&( x.StartWorkDate <= contractEnd &&
x.LeftWorkDate >= contractStart)
|| (x.LeftWorkDate == null && x.StartWorkDate <= contractEnd));
if (leftWorkInsurance != null && absenceDays >0)
{
absenceForInsuranceFine = absenceDays * absenceForInsuranceEmployeesAmount;
absenceForInsuranceDays = absenceDays;
dynamicdeductions.Add(new CheckoutDynamicDeductionItem
{
Amount = absenceForInsuranceFine.ToMoney(),
Name = "جریمه بیمه",
Count = absenceForInsuranceDays
});
}
#endregion
return new CustomizeCheckoutMandatoryViewModel
{
InsuranceDeduction = Math.Truncate(insuranceDeductionAmount),
@@ -5110,6 +5150,7 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
CustomizeRotatingShifts = customizeWorkshopEmployeeSettings.CustomizeRotatingShifts,
EmployeeSettingsShifts = customizeWorkshopEmployeeSettings.CustomizeWorkshopEmployeeSettingsShifts
.Select(x => (CustomizeSifts)x).ToList(),
DynamicDeductions = dynamicdeductions,
};
}

View File

@@ -13,4 +13,8 @@
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
</ItemGroup>
<ItemGroup>
<Folder Include="Domain\CustomizeCheckoutShared\ValueObjects\" />
</ItemGroup>
</Project>