maarge from InsuranceEmployeeSharecheckout

This commit is contained in:
SamSys
2025-10-27 17:20:38 +03:30
9 changed files with 11281 additions and 15 deletions

View File

@@ -12,10 +12,10 @@ namespace Company.Domain.CheckoutAgg;
public class Checkout : EntityBase public class Checkout : EntityBase
{ {
private Checkout() public Checkout()
{ {
}
}
public Checkout(string employeeFullName, string fathersName, string nationalCode, string dateOfBirth, public Checkout(string employeeFullName, string fathersName, string nationalCode, string dateOfBirth,
long employeeId, string workshopName, long workshopId, string contractNo, DateTime contractStart, long employeeId, string workshopName, long workshopId, string contractNo, DateTime contractStart,
DateTime contractEnd, string month, string year, long contractId, long workingHoursId, DateTime contractEnd, string month, string year, long contractId, long workingHoursId,
@@ -30,7 +30,7 @@ public class Checkout : EntityBase
string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue, string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue,
string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute, string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute,
ICollection<CheckoutLoanInstallment> loanInstallments, ICollection<CheckoutLoanInstallment> loanInstallments,
ICollection<CheckoutSalaryAid> salaryAids,CheckoutRollCall checkoutRollCall,TimeSpan employeeMandatoryHours) ICollection<CheckoutSalaryAid> salaryAids,CheckoutRollCall checkoutRollCall,TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList)
{ {
EmployeeFullName = employeeFullName; EmployeeFullName = employeeFullName;
FathersName = fathersName; FathersName = fathersName;
@@ -91,6 +91,7 @@ public class Checkout : EntityBase
SalaryAids = salaryAids; SalaryAids = salaryAids;
CheckoutRollCall = checkoutRollCall; CheckoutRollCall = checkoutRollCall;
EmployeeMandatoryHours = employeeMandatoryHours; EmployeeMandatoryHours = employeeMandatoryHours;
HasInsuranceShareTheSameAsList = hasInsuranceShareTheSameAsList;
} }
@@ -204,6 +205,11 @@ public class Checkout : EntityBase
/// ساعت موظفی پرسنل در ماه /// ساعت موظفی پرسنل در ماه
/// </summary> /// </summary>
public TimeSpan EmployeeMandatoryHours { get; set; } public TimeSpan EmployeeMandatoryHours { get; set; }
/// <summary>
/// آیا حق بیمه مشابه لیست بیمه حساب شده؟
/// </summary>
public bool HasInsuranceShareTheSameAsList { get; private set; }
#region valueObjects #region valueObjects
@@ -337,6 +343,11 @@ public class Checkout : EntityBase
{ {
EmployeeMandatoryHours = employeeMandatoryHours; EmployeeMandatoryHours = employeeMandatoryHours;
} }
public void SetInsuranceShare()
{
HasInsuranceShareTheSameAsList = true;
}
} }
public class CheckoutRollCall public class CheckoutRollCall

View File

@@ -31,6 +31,50 @@ public interface IInsuranceListApplication
double GetRoundValue(double value); double GetRoundValue(double value);
OperationResult ConfirmInsuranceList(long id); OperationResult ConfirmInsuranceList(long id);
#region New
/// <summary>
/// دستمزد روزانه مشاغل مقطوع بیمه
/// </summary>
/// <param name="year"></param>
/// <param name="workshopId"></param>
/// <param name="employeeId"></param>
/// <param name="startDateGr"></param>
/// <param name="endDateGr"></param>
/// <param name="jobId"></param>
/// <param name="population"></param>
/// <param name="insuranceJobId"></param>
/// <returns></returns>
double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr,
DateTime? endDateGr, long jobId, string population, long? insuranceJobId);
/// <summary>
/// محاسبه مزایای ماهانه
/// </summary>
/// <param name="endMonthCurrentDay"></param>
/// <param name="consumableItemsItemValue"></param>
/// <param name="housingAllowanceItemValue"></param>
/// <param name="maritalStatus"></param>
/// <param name="countWorkingDays"></param>
/// <param name="typeOfInsuranceSendWorkshop"></param>
/// <param name="jobId"></param>
/// <param name="employeeId"></param>
/// <param name="includeStatus"></param>
/// <returns></returns>
public double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue,
double housingAllowanceItemValue, double maritalStatus, int countWorkingDays,
string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus);
/// <summary>
///
/// </summary>
/// <param name="yearlysalaryItemValue"></param>
/// <param name="employeeId"></param>
/// <param name="workshopId"></param>
/// <param name="year"></param>
/// <returns></returns>
public double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year);
#endregion
List<InsuranceListViewModel> SearchForClient(InsuranceListSearchModel searchModel); List<InsuranceListViewModel> SearchForClient(InsuranceListSearchModel searchModel);
//farokhiChanges //farokhiChanges

View File

@@ -193,8 +193,19 @@ public class CheckoutApplication : ICheckoutApplication
//حق بیمه سهم کارگر //حق بیمه سهم کارگر
#region InsuranceDeduction #region InsuranceDeduction
var insuranceOverTime = command.HasInsuranceChekoutOverTime ? command.OvertimePay : 0; double insuranceDeduction = 0;
var insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100; bool hasInsuranceShareTheSameAsList = false;
if (command.InsuranceDeduction == 0)
{
var insuranceOverTime = command.HasInsuranceChekoutOverTime ? command.OvertimePay : 0;
insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
}
else
{
insuranceDeduction = command.InsuranceDeduction;
hasInsuranceShareTheSameAsList = true;
}
#endregion #endregion
@@ -375,7 +386,7 @@ public class CheckoutApplication : ICheckoutApplication
, command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays, , command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
, command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute, , command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours); loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList);
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult(); _checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
//_checkoutRepository.SaveChanges(); //_checkoutRepository.SaveChanges();

View File

@@ -1707,7 +1707,7 @@ public class InsuranceListApplication : IInsuranceListApplication
return result; return result;
} }
private double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId) public double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId)
{ {
double? result = 0; double? result = 0;
@@ -1858,7 +1858,7 @@ public class InsuranceListApplication : IInsuranceListApplication
/// <param name="jobId"></param> /// <param name="jobId"></param>
/// <param name="employeeId"></param> /// <param name="employeeId"></param>
/// <returns></returns> /// <returns></returns>
private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue, double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus) public double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue, double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus)
{ {
//ToDo //ToDo
//افزودن شرط مشمول مزایای //افزودن شرط مشمول مزایای
@@ -1898,7 +1898,7 @@ public class InsuranceListApplication : IInsuranceListApplication
private double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year) public double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
{ {
double dailyWage = yearlysalaryItemValue; double dailyWage = yearlysalaryItemValue;
InsuranceListSearchModel searchModel = new InsuranceListSearchModel(); InsuranceListSearchModel searchModel = new InsuranceListSearchModel();

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class hasInsuranceShareTheSameAsList_checkoutTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "HasInsuranceShareTheSameAsList",
table: "Checkouts",
type: "bit",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "HasInsuranceShareTheSameAsList",
table: "Checkouts");
}
}
}

View File

@@ -415,6 +415,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<bool>("HasAmountConflict") b.Property<bool>("HasAmountConflict")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<bool>("HasInsuranceShareTheSameAsList")
.HasColumnType("bit");
b.Property<bool>("HasRollCall") b.Property<bool>("HasRollCall")
.HasColumnType("bit"); .HasColumnType("bit");

View File

@@ -524,6 +524,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction); entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
entity.SetCheckoutRollCall(command.CheckoutRollCall); entity.SetCheckoutRollCall(command.CheckoutRollCall);
entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours); entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
if(command.HasInsuranceShareTheSameAsList)
entity.SetInsuranceShare();
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
} }

View File

@@ -32,6 +32,12 @@ using ServiceHost.Hubs;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using WorkFlow.Application.Contracts.WorkFlow; using WorkFlow.Application.Contracts.WorkFlow;
using System.Globalization; using System.Globalization;
using Company.Domain.LeftWorkInsuranceAgg;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
using Company.Domain.InsuranceListAgg;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.EFCore.Repository;
using System.Linq;
namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts; namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts;
@@ -59,6 +65,9 @@ public class IndexModel : PageModel
private readonly IYearlySalaryApplication _yearlySalaryApplication; private readonly IYearlySalaryApplication _yearlySalaryApplication;
private readonly IYearlySalaryRepository _yearlySalaryRepository; private readonly IYearlySalaryRepository _yearlySalaryRepository;
private readonly IWorkFlowApplication _workFlowApplication; private readonly IWorkFlowApplication _workFlowApplication;
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
private readonly IInsuranceListApplication _insuranceListApplication;
private readonly IInsuranceListRepository _insuranceListRepository;
public List<CheckoutViewModel> chekoutlist; public List<CheckoutViewModel> chekoutlist;
@@ -100,7 +109,7 @@ public class IndexModel : PageModel
ILeaveApplication leaveApplication, IHubContext<CheckoutHub> hubContext, ILeaveApplication leaveApplication, IHubContext<CheckoutHub> hubContext,
IEmployeeComputeOptionsApplication employeeComputeOptionsApplication, IEmployeeComputeOptionsApplication employeeComputeOptionsApplication,
IRollCallMandatoryApplication rollCallMandatoryApplication, IRollCallMandatoryApplication rollCallMandatoryApplication,
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApp, IWorkFlowApplication workFlowApplication) IRollCallEmployeeStatusApplication rollCallEmployeeStatusApp, IWorkFlowApplication workFlowApplication, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceListApplication insuranceListApplication, IInsuranceListRepository insuranceListRepository)
{ {
_contractApplication = contractApplication; _contractApplication = contractApplication;
_workshopApplication = workshopApplication; _workshopApplication = workshopApplication;
@@ -124,6 +133,9 @@ public class IndexModel : PageModel
_rollCallMandatoryApplication = rollCallMandatoryApplication; _rollCallMandatoryApplication = rollCallMandatoryApplication;
_rollCallEmployeeStatusApp = rollCallEmployeeStatusApp; _rollCallEmployeeStatusApp = rollCallEmployeeStatusApp;
_workFlowApplication = workFlowApplication; _workFlowApplication = workFlowApplication;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
_insuranceListApplication = insuranceListApplication;
_insuranceListRepository = insuranceListRepository;
} }
public string Message { get; set; } public string Message { get; set; }
@@ -165,7 +177,7 @@ public class IndexModel : PageModel
var searchResult = await _checkoutApplication.SearchCheckoutOptimized(searchModel); var searchResult = await _checkoutApplication.SearchCheckoutOptimized(searchModel);
var result = new MainViewModel(); var result = new CompanyManagment.App.Contracts.Checkout.MainViewModel();
result.IsSysManager = accountId is 2 or 3; result.IsSysManager = accountId is 2 or 3;
result.MainList = searchResult; result.MainList = searchResult;
if (searchModel.WorkshopId != 0 || searchModel.EmployeeId != 0) if (searchModel.WorkshopId != 0 || searchModel.EmployeeId != 0)
@@ -759,11 +771,33 @@ public class IndexModel : PageModel
var maxNumber = Convert.ToDouble(ContractsId.Count()); var maxNumber = Convert.ToDouble(ContractsId.Count());
if (ContractsId.Count > 0) if (ContractsId.Count > 0)
{ {
#region Insurance
var watch = new Stopwatch();
watch.Start();
var contractpData = _contractApplication.GetDetails(ContractsId[0]);
var startMonthFa = $"{ConvertYear}/{ConvertMonth.PadLeft(2, '0')}/01";
DateTime startDateGr = startMonthFa.ToGeorgianDateTime();
DateTime endDateGr = startMonthFa.FindeEndOfMonth().ToGeorgianDateTime();
int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2));
//مقادیر سالانه این تاریخ
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, ConvertYear);
var insuranceEmployeeData =
_leftWorkInsuranceRepository.GetEmployeeInsuranceLeftWorksAndInformation(contractpData.WorkshopIds, startDateGr,
endDateGr);
Console.WriteLine("checkout-test-timer" + watch.Elapsed);
watch.Stop();
#endregion
//int i = 0; //int i = 0;
foreach (var item in ContractsId) foreach (var item in ContractsId)
{ {
var contract = _contractApplication.GetDetails(item); var contract = _contractApplication.GetDetails(item);
//var workingHours = _workingHoursApplication.GetByContractId(contract.Id); //var workingHours = _workingHoursApplication.GetByContractId(contract.Id);
var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(contract.Id); var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(contract.Id);
var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth, var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth,
@@ -992,7 +1026,65 @@ public class IndexModel : PageModel
officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble, officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble,
familyAllowanceDouble, marriedAllowanceDouble, workshop.IsOldContract); familyAllowanceDouble, marriedAllowanceDouble, workshop.IsOldContract);
#region Insurance
double insuranceShare = 0;
var insuranceEmployeeDataItem =
insuranceEmployeeData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
if (insuranceEmployeeDataItem != null && insuranceEmployeeDataItem.StartWorkDateGr <= separation.ContractEndGr)
{
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(insuranceEmployeeDataItem.StartWorkDateGr, separation.LeftWorkDate, startDateGr, endDateGr, insuranceEmployeeDataItem.EmployeeId);
var leftWorkFa = workingDays.hasLeftWorkInMonth ? separation.LeftWorkDate.ToFarsi() : "";
//به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
double dailyWage = 0;
if (workshop.FixedSalary)
{
var res = _insuranceListApplication.GetDailyWageFixedSalary(ConvertYear, workshop.Id, insuranceEmployeeDataItem.EmployeeId, startDateGr,
endDateGr, insuranceEmployeeDataItem.JobId, workshop.Population, workshop.InsuranceJobId);
dailyWage = res ?? 0;
}
else
{
var res = _insuranceListApplication.ComputeDailyWage(yearlysaleries.DayliWage, insuranceEmployeeDataItem.EmployeeId, workshop.Id, ConvertYear);
dailyWage = res;
}
//بدست آوردن پایه سنوات
var baseYears = _insuranceListRepository.GetEmployeeInsuranceBaseYear(insuranceEmployeeDataItem.EmployeeId, workshop.Id,
workingDays.countWorkingDays, startDateGr, endDateGr, workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
//جمع مزد روزانه و پایه سنوات
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
//دستمزد ماهانه با محاسبه پایه سنوات
var monthlySalary = _insuranceListApplication.GetRoundValue(dailyWagePlusBaseYears * workingDays.countWorkingDays);
//حق تاهل
var marriedAllowance = employee.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0;
//محاسبه مزایای ماهانه
var monthlyBenefits = _insuranceListApplication.GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, workshop.TypeOfInsuranceSend, insuranceEmployeeDataItem.JobId, insuranceEmployeeDataItem.EmployeeId, insuranceEmployeeDataItem.IncludeStatus);
if (workshop.InsuranceCheckoutOvertime)
{
monthlyBenefits = _insuranceListApplication.GetRoundValue(monthlyBenefits += overTimeWorking);
}
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
//محاسبه حق بیمه سهم بیمه شده
insuranceShare = (benefitsIncludedContinuous * 7) / 100;
}
#endregion
var command = new CreateCheckout var command = new CreateCheckout
{ {
EmployeeFullName = employee.EmployeeFullName, EmployeeFullName = employee.EmployeeFullName,
@@ -1098,7 +1190,11 @@ public class IndexModel : PageModel
DailySalaryAffected = mandatoryCompute.DailySalaryAffected, DailySalaryAffected = mandatoryCompute.DailySalaryAffected,
#region InsuranceShare
InsuranceDeduction = _insuranceListApplication.GetRoundValue(insuranceShare),
#endregion