maarge from InsuranceEmployeeSharecheckout
This commit is contained in:
@@ -12,10 +12,10 @@ namespace Company.Domain.CheckoutAgg;
|
||||
|
||||
public class Checkout : EntityBase
|
||||
{
|
||||
private Checkout()
|
||||
public Checkout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Checkout(string employeeFullName, string fathersName, string nationalCode, string dateOfBirth,
|
||||
long employeeId, string workshopName, long workshopId, string contractNo, DateTime contractStart,
|
||||
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 totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute,
|
||||
ICollection<CheckoutLoanInstallment> loanInstallments,
|
||||
ICollection<CheckoutSalaryAid> salaryAids,CheckoutRollCall checkoutRollCall,TimeSpan employeeMandatoryHours)
|
||||
ICollection<CheckoutSalaryAid> salaryAids,CheckoutRollCall checkoutRollCall,TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList)
|
||||
{
|
||||
EmployeeFullName = employeeFullName;
|
||||
FathersName = fathersName;
|
||||
@@ -91,6 +91,7 @@ public class Checkout : EntityBase
|
||||
SalaryAids = salaryAids;
|
||||
CheckoutRollCall = checkoutRollCall;
|
||||
EmployeeMandatoryHours = employeeMandatoryHours;
|
||||
HasInsuranceShareTheSameAsList = hasInsuranceShareTheSameAsList;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +206,11 @@ public class Checkout : EntityBase
|
||||
/// </summary>
|
||||
public TimeSpan EmployeeMandatoryHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا حق بیمه مشابه لیست بیمه حساب شده؟
|
||||
/// </summary>
|
||||
public bool HasInsuranceShareTheSameAsList { get; private set; }
|
||||
|
||||
#region valueObjects
|
||||
|
||||
public ICollection<CheckoutLoanInstallment> LoanInstallments { get; set; } = [];
|
||||
@@ -337,6 +343,11 @@ public class Checkout : EntityBase
|
||||
{
|
||||
EmployeeMandatoryHours = employeeMandatoryHours;
|
||||
}
|
||||
|
||||
public void SetInsuranceShare()
|
||||
{
|
||||
HasInsuranceShareTheSameAsList = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CheckoutRollCall
|
||||
|
||||
@@ -31,6 +31,50 @@ public interface IInsuranceListApplication
|
||||
double GetRoundValue(double value);
|
||||
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);
|
||||
|
||||
//farokhiChanges
|
||||
|
||||
@@ -193,8 +193,19 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
//حق بیمه سهم کارگر
|
||||
#region InsuranceDeduction
|
||||
|
||||
double insuranceDeduction = 0;
|
||||
bool hasInsuranceShareTheSameAsList = false;
|
||||
if (command.InsuranceDeduction == 0)
|
||||
{
|
||||
var insuranceOverTime = command.HasInsuranceChekoutOverTime ? command.OvertimePay : 0;
|
||||
var insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
|
||||
insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
insuranceDeduction = command.InsuranceDeduction;
|
||||
hasInsuranceShareTheSameAsList = true;
|
||||
}
|
||||
|
||||
|
||||
#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.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,
|
||||
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours);
|
||||
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList);
|
||||
|
||||
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
|
||||
//_checkoutRepository.SaveChanges();
|
||||
|
||||
@@ -1707,7 +1707,7 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
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;
|
||||
@@ -1858,7 +1858,7 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
/// <param name="jobId"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <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
|
||||
//افزودن شرط مشمول مزایای
|
||||
@@ -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;
|
||||
InsuranceListSearchModel searchModel = new InsuranceListSearchModel();
|
||||
|
||||
11070
CompanyManagment.EFCore/Migrations/20251027125514_hasInsuranceShareTheSameAsList_checkoutTable.Designer.cs
generated
Normal file
11070
CompanyManagment.EFCore/Migrations/20251027125514_hasInsuranceShareTheSameAsList_checkoutTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,6 +415,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<bool>("HasAmountConflict")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("HasInsuranceShareTheSameAsList")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("HasRollCall")
|
||||
.HasColumnType("bit");
|
||||
|
||||
|
||||
@@ -524,6 +524,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
|
||||
entity.SetCheckoutRollCall(command.CheckoutRollCall);
|
||||
entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
|
||||
if(command.HasInsuranceShareTheSameAsList)
|
||||
entity.SetInsuranceShare();
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ using ServiceHost.Hubs;
|
||||
using System.Diagnostics.Contracts;
|
||||
using WorkFlow.Application.Contracts.WorkFlow;
|
||||
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;
|
||||
|
||||
@@ -59,6 +65,9 @@ public class IndexModel : PageModel
|
||||
private readonly IYearlySalaryApplication _yearlySalaryApplication;
|
||||
private readonly IYearlySalaryRepository _yearlySalaryRepository;
|
||||
private readonly IWorkFlowApplication _workFlowApplication;
|
||||
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
|
||||
private readonly IInsuranceListApplication _insuranceListApplication;
|
||||
private readonly IInsuranceListRepository _insuranceListRepository;
|
||||
|
||||
|
||||
public List<CheckoutViewModel> chekoutlist;
|
||||
@@ -100,7 +109,7 @@ public class IndexModel : PageModel
|
||||
ILeaveApplication leaveApplication, IHubContext<CheckoutHub> hubContext,
|
||||
IEmployeeComputeOptionsApplication employeeComputeOptionsApplication,
|
||||
IRollCallMandatoryApplication rollCallMandatoryApplication,
|
||||
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApp, IWorkFlowApplication workFlowApplication)
|
||||
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApp, IWorkFlowApplication workFlowApplication, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceListApplication insuranceListApplication, IInsuranceListRepository insuranceListRepository)
|
||||
{
|
||||
_contractApplication = contractApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
@@ -124,6 +133,9 @@ public class IndexModel : PageModel
|
||||
_rollCallMandatoryApplication = rollCallMandatoryApplication;
|
||||
_rollCallEmployeeStatusApp = rollCallEmployeeStatusApp;
|
||||
_workFlowApplication = workFlowApplication;
|
||||
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
|
||||
_insuranceListApplication = insuranceListApplication;
|
||||
_insuranceListRepository = insuranceListRepository;
|
||||
}
|
||||
|
||||
public string Message { get; set; }
|
||||
@@ -165,7 +177,7 @@ public class IndexModel : PageModel
|
||||
|
||||
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.MainList = searchResult;
|
||||
if (searchModel.WorkshopId != 0 || searchModel.EmployeeId != 0)
|
||||
@@ -759,6 +771,28 @@ public class IndexModel : PageModel
|
||||
var maxNumber = Convert.ToDouble(ContractsId.Count());
|
||||
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;
|
||||
foreach (var item in ContractsId)
|
||||
{
|
||||
@@ -993,6 +1027,64 @@ public class IndexModel : PageModel
|
||||
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
|
||||
{
|
||||
EmployeeFullName = employee.EmployeeFullName,
|
||||
@@ -1098,7 +1190,11 @@ public class IndexModel : PageModel
|
||||
|
||||
DailySalaryAffected = mandatoryCompute.DailySalaryAffected,
|
||||
|
||||
#region InsuranceShare
|
||||
|
||||
InsuranceDeduction = _insuranceListApplication.GetRoundValue(insuranceShare),
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user