Files
Backend-Api/CompanyManagment.EFCore/Mapping/CustomizeCheckoutTempMapping.cs
2025-04-27 19:37:50 +03:30

132 lines
5.3 KiB
C#

using _0_Framework.Application;
using System;
using _0_Framework.InfraStructure;
using Company.Domain.CustomizeCheckoutAgg;
using Company.Domain.CustomizeCheckoutTempAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class CustomizeCheckoutTempMapping : IEntityTypeConfiguration<CustomizeCheckoutTemp>
{
public void Configure(EntityTypeBuilder<CustomizeCheckoutTemp> builder)
{
builder.ToTable("CustomizeCheckoutTemps");
builder.HasKey(x => x.id);
#region relationProperties
builder.Property(x => x.EmployeeId);
builder.Property(x => x.WorkshopId);
builder.Property(x => x.ContractId).IsRequired(false);
#endregion
builder.Property(x => x.ContractNo).HasMaxLength(20);
builder.Property(x => x.YearInt);
builder.Property(x => x.MonthInt);
builder.Property(x => x.MonthlySalary);
builder.Property(x => x.ContractStart);
builder.Property(x => x.ContractEnd);
builder.Property(x => x.FridayPay);
builder.Property(x => x.OverTimePay);
builder.Property(x => x.BaseYearsPay);
builder.Property(x => x.BonusesPay);
builder.Property(x => x.NightWorkPay);
builder.Property(x => x.MarriedAllowance);
builder.Property(x => x.ShiftPay);
builder.Property(x => x.FamilyAllowance);
builder.Property(x => x.LeavePay);
builder.Property(x => x.InsuranceDeduction);
builder.Property(x => x.FineAbsenceDeduction);
builder.Property(x => x.LateToWorkDeduction);
builder.Property(x => x.EarlyExitDeduction);
builder.Property(x => x.RewardPay);
builder.Property(x => x.SalaryAidDeduction);
builder.Property(x => x.InstallmentDeduction);
builder.Property(x => x.FineDeduction);
builder.Property(x => x.TaxDeduction);
builder.Property(x => x.SumOfWorkingDays);
builder.Property(x => x.TotalClaims);
builder.Property(x => x.TotalDeductions);
builder.Property(x => x.TotalPayment);
builder.Property(x => x.EmployeeFName).HasMaxLength(100);
builder.Property(x => x.EmployeeLName).HasMaxLength(100);
builder.Property(x => x.NationalCode).HasMaxLength(10);
builder.Property(x => x.WorkshopFullName).HasMaxLength(255);
builder.Property(x => x.LateToWorkValue).HasTimeSpanConversion();
builder.OwnsMany(x => x.CheckoutFines, checkoutFine =>
{
checkoutFine.Property(x => x.IsActive).HasConversion(
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
checkoutFine.Property(x => x.Title).HasMaxLength(255);
checkoutFine.Property(x => x.FineDateFa).HasMaxLength(12);
checkoutFine.Property(x => x.Amount).HasMaxLength(20);
});
builder.OwnsMany(x => x.CustomizeCheckoutLoanInstallments, installments =>
{
installments.Property(x => x.AmountForMonth).HasMaxLength(25);
installments.Property(x => x.IsActive).HasConversion(
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
installments.Property(x => x.Year).HasMaxLength(4);
installments.Property(x => x.Month).HasMaxLength(2);
installments.Property(x => x.LoanRemaining).HasMaxLength(25);
installments.Property(x => x.LoanAmount).HasMaxLength(30);
});
builder.OwnsMany(x => x.CustomizeCheckoutSalaryAids, salaryAid =>
{
salaryAid.Property(x => x.SalaryAidDateTimeFa).HasMaxLength(15);
salaryAid.Property(x => x.Amount).HasMaxLength(25);
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
});
builder.OwnsMany(x => x.CustomizeCheckoutRewards, rewards =>
{
rewards.Property(x => x.GrantDateFa).HasMaxLength(15);
rewards.Property(x => x.Title).HasMaxLength(255);
rewards.Property(x => x.IsActive).HasConversion(
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
rewards.Property(x => x.Amount).HasMaxLength(25);
rewards.Property(x => x.Description).HasColumnType("ntext");
});
builder.OwnsOne(x => x.IrregularShift, irregularShift =>
{
irregularShift.Property(x => x.WorkshopIrregularShifts).HasConversion<string>().HasMaxLength(30);
irregularShift.Property(x => x.StartTime).IsRequired();
irregularShift.Property(x => x.EndTime).IsRequired();
});
builder.OwnsMany(x => x.RegularShifts, shift =>
{
//shift.ToTable("RegularShifts");
shift.HasKey(x => x.id);
shift.Property(x => x.Placement).HasConversion<string>().HasMaxLength(20);
});
builder.OwnsMany(x => x.CustomizeRotatingShifts);
builder.Property(x => x.ShiftStatus).HasConversion<string>().HasMaxLength(10);
#region Relastions
//builder.HasOne(x => x.Workshop)
// .WithMany(x => x.CustomizeCheckouts)
// .HasForeignKey(x => x.WorkshopId);
//builder.HasOne(x => x.Employee)
// .WithMany(x => x.CustomizeCheckouts)
// .HasForeignKey(x => x.EmployeeId);
#endregion
}
}