|
|
|
|
@@ -2,10 +2,13 @@
|
|
|
|
|
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
|
|
|
|
using Company.Domain.CheckoutAgg;
|
|
|
|
|
using Company.Domain.CheckoutAgg.ValueObjects;
|
|
|
|
|
using Company.Domain.ContractAgg;
|
|
|
|
|
using Company.Domain.EmployeeAgg;
|
|
|
|
|
using Company.Domain.empolyerAgg;
|
|
|
|
|
using Company.Domain.InsuranceListAgg;
|
|
|
|
|
using Company.Domain.LeaveAgg;
|
|
|
|
|
using Company.Domain.LeftWorkAgg;
|
|
|
|
|
using Company.Domain.LeftWorkInsuranceAgg;
|
|
|
|
|
using Company.Domain.RollCallAgg;
|
|
|
|
|
using Company.Domain.RollCallEmployeeAgg;
|
|
|
|
|
using Company.Domain.WorkingHoursTempAgg;
|
|
|
|
|
@@ -16,12 +19,14 @@ using CompanyManagment.App.Contracts.Checkout.Dto;
|
|
|
|
|
using CompanyManagment.App.Contracts.Contract;
|
|
|
|
|
using CompanyManagment.App.Contracts.HolidayItem;
|
|
|
|
|
using CompanyManagment.App.Contracts.Hubs;
|
|
|
|
|
using CompanyManagment.App.Contracts.InsuranceList;
|
|
|
|
|
using CompanyManagment.App.Contracts.Leave;
|
|
|
|
|
using CompanyManagment.App.Contracts.MandantoryHours;
|
|
|
|
|
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
|
|
|
|
using CompanyManagment.App.Contracts.RollCall;
|
|
|
|
|
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
|
|
|
|
using CompanyManagment.App.Contracts.Workshop;
|
|
|
|
|
using CompanyManagment.App.Contracts.YearlySalary;
|
|
|
|
|
using CompanyManagment.EFCore.Migrations;
|
|
|
|
|
using CompanyManagment.EFCore.Repository;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
@@ -54,11 +59,16 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
private readonly IAuthHelper _authHelper;
|
|
|
|
|
private readonly IHubContext<CheckoutHub> _hubContext;
|
|
|
|
|
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
|
|
|
|
private readonly IContractRepository _contractRepository;
|
|
|
|
|
private readonly IInsuranceListRepository _insuranceListRepository;
|
|
|
|
|
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
|
|
|
|
|
private readonly IInsuranceListApplication _insuranceListApplication;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CheckoutApplication(ICheckoutRepository checkoutRepository, IYearlySalaryRepository yearlySalaryRepository,
|
|
|
|
|
ILeftWorkRepository leftWorkRepository,
|
|
|
|
|
IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper, IHubContext<CheckoutHub> hubContext, IRollCallEmployeeRepository rollCallEmployeeRepository)
|
|
|
|
|
IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper, IHubContext<CheckoutHub> hubContext, IRollCallEmployeeRepository rollCallEmployeeRepository, IContractRepository contractRepository, IInsuranceListRepository insuranceListRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceListApplication insuranceListApplication)
|
|
|
|
|
{
|
|
|
|
|
_checkoutRepository = checkoutRepository;
|
|
|
|
|
_yearlySalaryRepository = yearlySalaryRepository;
|
|
|
|
|
@@ -75,6 +85,10 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
_authHelper = authHelper;
|
|
|
|
|
_hubContext = hubContext;
|
|
|
|
|
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
|
|
|
|
_contractRepository = contractRepository;
|
|
|
|
|
_insuranceListRepository = insuranceListRepository;
|
|
|
|
|
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
|
|
|
|
|
_insuranceListApplication = insuranceListApplication;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 241")]
|
|
|
|
|
@@ -270,12 +284,12 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
|
|
|
|
|
rewardPay = rewards.Sum(x => x.AmountDouble);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var firstDayOfMonth = $"{command.ContractStart.Substring(0, 8)}01".ToGeorgianDateTime();
|
|
|
|
|
var firstDayOfCurrentMonth = new DateTime(syear, smonth, 1, new PersianCalendar());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var firstDayOfMonth = $"{command.ContractStart.Substring(0, 8)}01".ToGeorgianDateTime();
|
|
|
|
|
var firstDayOfCurrentMonth = new DateTime(syear, smonth, 1, new PersianCalendar());
|
|
|
|
|
|
|
|
|
|
LeaveSearchModel sickLeaveSearch = new LeaveSearchModel()
|
|
|
|
|
{
|
|
|
|
|
@@ -391,12 +405,12 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
|
|
|
|
|
command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay + rewardPay;
|
|
|
|
|
var totalClaims = totalClaimsDouble.ToMoney();
|
|
|
|
|
var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
|
|
|
|
|
var totalDeductions = totalDeductionDouble.ToMoney();
|
|
|
|
|
var totalPayment = totalClaimsDouble - totalDeductionDouble;
|
|
|
|
|
var totalClaimsDouble = monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + command.OvertimePay +
|
|
|
|
|
command.NightworkPay + familyAllowance + bunos + years + command.LeavePay + command.FridayPay + command.ShiftPay + rewardPay;
|
|
|
|
|
var totalClaims = totalClaimsDouble.ToMoney();
|
|
|
|
|
var totalDeductionDouble = insuranceDeduction + command.AbsenceDeduction + command.InstallmentDeduction + command.SalaryAidDeduction;
|
|
|
|
|
var totalDeductions = totalDeductionDouble.ToMoney();
|
|
|
|
|
var totalPayment = totalClaimsDouble - totalDeductionDouble;
|
|
|
|
|
|
|
|
|
|
if (_checkoutRepository.Exists(x =>
|
|
|
|
|
x.Month == command.Month && x.Year == command.Year && x.ContractNo == command.ContractNo))
|
|
|
|
|
@@ -411,13 +425,13 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var checkout = new Checkout(command.EmployeeFullName, command.FathersName, command.NationalCode
|
|
|
|
|
, command.DateOfBirth, command.EmployeeId, command.WorkshopName, command.WorkshopId, command.ContractNo, command.ContractStartGr, command.ContractEndGr, month, year,
|
|
|
|
|
command.ContractId, command.WorkingHoursId, monthlyWage, bacicYears, consumableItem, housingAllowance
|
|
|
|
|
, 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, hasInsuranceShareTheSameAsList, rewards, rewardPay);
|
|
|
|
|
var checkout = new Checkout(command.EmployeeFullName, command.FathersName, command.NationalCode
|
|
|
|
|
, command.DateOfBirth, command.EmployeeId, command.WorkshopName, command.WorkshopId, command.ContractNo, command.ContractStartGr, command.ContractEndGr, month, year,
|
|
|
|
|
command.ContractId, command.WorkingHoursId, monthlyWage, bacicYears, consumableItem, housingAllowance
|
|
|
|
|
, 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, hasInsuranceShareTheSameAsList, rewards, rewardPay);
|
|
|
|
|
|
|
|
|
|
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
|
|
|
|
|
//_checkoutRepository.SaveChanges();
|
|
|
|
|
@@ -781,11 +795,11 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
year = "0";
|
|
|
|
|
month = "0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = await GetContractResultToCreateCheckout(workshopId, employeeId, year, month, null,
|
|
|
|
|
null);
|
|
|
|
|
if(result.CreateCheckoutList.Count == 0)
|
|
|
|
|
if (result.CreateCheckoutList.Count == 0)
|
|
|
|
|
return op.Failed("موردی یافت نشد");
|
|
|
|
|
var finalResult = result.CreateCheckoutList.Select(x => new ContractsListToCreateCheckoutDto
|
|
|
|
|
{
|
|
|
|
|
@@ -808,7 +822,7 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
|
|
|
|
|
public async Task<OperationResult> CreateCheckoutApi(List<long> ids, string year, string month, long workshopId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var op = new OperationResult();
|
|
|
|
|
|
|
|
|
|
//آی دی کاربر لاگین شده برای استفاده در signalR
|
|
|
|
|
@@ -817,21 +831,43 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getContractsData = await
|
|
|
|
|
_checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, year, month, workshopId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region GetInsuranceData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var startMonthFa = $"{year}/{month.PadLeft(2, '0')}/01";
|
|
|
|
|
DateTime startDateGr = startMonthFa.ToGeorgianDateTime();
|
|
|
|
|
DateTime endDateGr = startMonthFa.FindeEndOfMonth().ToGeorgianDateTime();
|
|
|
|
|
int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var insuranceListData =
|
|
|
|
|
_insuranceListRepository.EmployeeInsuranceDataBy(startDateGr, getContractsData.Data.WorkshopId);
|
|
|
|
|
var yearlysaleries = _yearlySalaryRepository.GetInsuranceItems(startDateGr, endDateGr, year);
|
|
|
|
|
|
|
|
|
|
var insuranceEmployeeData =
|
|
|
|
|
_leftWorkInsuranceRepository.GetEmployeeInsuranceLeftWorksAndInformation(getContractsData.Data.WorkshopId, startDateGr,
|
|
|
|
|
endDateGr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var getContractsData = await
|
|
|
|
|
_checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, year, month, workshopId);
|
|
|
|
|
|
|
|
|
|
if (!getContractsData.IsSuccedded)
|
|
|
|
|
{
|
|
|
|
|
await _hubContext.Clients.Group(CheckoutHub.GetGroupName(currntAcc))
|
|
|
|
|
.SendAsync("StartProcessingFailed", getContractsData.Message);
|
|
|
|
|
return op.Failed(getContractsData.Message);
|
|
|
|
|
await _hubContext.Clients.Group(CheckoutHub.GetGroupName(currntAcc))
|
|
|
|
|
.SendAsync("StartProcessingFailed", getContractsData.Message);
|
|
|
|
|
return op.Failed(getContractsData.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var timer = new Stopwatch();
|
|
|
|
|
timer.Start();
|
|
|
|
|
int i = 0;
|
|
|
|
|
@@ -882,18 +918,18 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//دستمزد روزانه بدون تاثیر ساعت کار
|
|
|
|
|
var dailyWageUnAffected =await _yearlySalaryRepository.GetCheckoutDailyWage(contract,
|
|
|
|
|
var dailyWageUnAffected = await _yearlySalaryRepository.GetCheckoutDailyWage(contract,
|
|
|
|
|
item.Separation.ContractStartGr, item.Separation.ContractEndGr);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var hasRollCall =await _rollCallEmployeeRepository.HasRollCallRecord(item.EmployeeId, workshopId, item.Separation.ContractStartGr, item.Separation.ContractEndGr);
|
|
|
|
|
|
|
|
|
|
var hasRollCall = await _rollCallEmployeeRepository.HasRollCallRecord(item.EmployeeId, workshopId, item.Separation.ContractStartGr, item.Separation.ContractEndGr);
|
|
|
|
|
if (getContractsData.Data.IsStaticCheckout)
|
|
|
|
|
hasRollCall = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//محاسبه موظفی
|
|
|
|
|
#region MandatoryCompute
|
|
|
|
|
var mandatoryCompute = new ComputingViewModel();
|
|
|
|
|
@@ -906,21 +942,287 @@ public class CheckoutApplication : ICheckoutApplication
|
|
|
|
|
item.WorkingHours.GetWorkDateHide = contract.GetWorkDate;
|
|
|
|
|
item.WorkingHours.WorkshopId = workshopId;
|
|
|
|
|
item.WorkingHours.EmployeeId = item.EmployeeId;
|
|
|
|
|
|
|
|
|
|
mandatoryCompute =await _rollCallMandatoryRepository.MandatoryCompute(item.EmployeeId, workshopId,
|
|
|
|
|
|
|
|
|
|
mandatoryCompute = await _rollCallMandatoryRepository.MandatoryCompute(item.EmployeeId, workshopId,
|
|
|
|
|
item.Separation.ContractStartGr, item.Separation.ContractEndGr, item.WorkingHours, getContractsData.Data.WorkshopHolidayWorking,
|
|
|
|
|
hasRollCall, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contract.EmployeeId == 9659)
|
|
|
|
|
mandatoryCompute.SumTime44 = "48 - 24";
|
|
|
|
|
|
|
|
|
|
var officialHoliday = mandatoryCompute.OfficialHoliday;
|
|
|
|
|
var Friday = int.Parse(mandatoryCompute.NumberOfFriday);
|
|
|
|
|
var fridayStartToEnd = mandatoryCompute.FridayStartToEnd;
|
|
|
|
|
|
|
|
|
|
var totalHoursH = mandatoryCompute.TotalHoursesH;
|
|
|
|
|
var totalHoursM = mandatoryCompute.TotalHoursesM;
|
|
|
|
|
var dayliWage = mandatoryCompute.SalaryCompute.MoneyToDouble();
|
|
|
|
|
var consumableItemDouble = mandatoryCompute.ConsumableItems.MoneyToDouble();
|
|
|
|
|
var housingAllowanceDouble = mandatoryCompute.HousingAllowance.MoneyToDouble();
|
|
|
|
|
var familyAllowanceDouble = mandatoryCompute.FamilyAllowance.MoneyToDouble();
|
|
|
|
|
var marriedAllowanceDouble = mandatoryCompute.MarriedAllowance.MoneyToDouble();
|
|
|
|
|
|
|
|
|
|
//اضافه کاری
|
|
|
|
|
var overTimeWorking = _yearlySalaryRepository.GetOverTimeWorking(dayliWage,
|
|
|
|
|
mandatoryCompute.OverTimeWorkH, mandatoryCompute.OverTimeWorkM);
|
|
|
|
|
//شبکاری
|
|
|
|
|
var overNightWorking = _yearlySalaryRepository.GetOverNightWorking(dayliWage,
|
|
|
|
|
mandatoryCompute.OverNightWorkH, mandatoryCompute.OverNightWorkM, mandatoryCompute.SumTime44,
|
|
|
|
|
officialHoliday, Friday, item.Separation.ContractStartGr, item.Separation.ContractEndGr, totalHoursH,
|
|
|
|
|
totalHoursM);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//سنوات
|
|
|
|
|
var yearsPay = _yearlySalaryRepository.Years(item.Separation.ContractStartGr, item.Separation.LeftWorkDate,
|
|
|
|
|
item.Separation.ContractEndGr,
|
|
|
|
|
dayliWage, item.YearsOption, item.Separation.HasLeft, item.Separation.StartWorkDate, contract.ContractStartGr,
|
|
|
|
|
contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, getContractsData.Data.IsOldContract);
|
|
|
|
|
//عیدی
|
|
|
|
|
#region BonusesPay
|
|
|
|
|
var bunosesPay = _yearlySalaryRepository.Bunoses(item.Separation.ContarctStart, item.Separation.LeftWorkDate,
|
|
|
|
|
item.Separation.ContractStartGr, item.Separation.ContractEndGr,
|
|
|
|
|
dayliWage, item.BonusesOption, item.Separation.HasLeft, item.Separation.StartWorkDate,
|
|
|
|
|
contract.ContractStartGr,
|
|
|
|
|
contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, getContractsData.Data.IsOldContract);
|
|
|
|
|
//اگر تصفیه حساب پاک شده برای عیدی یا سنوات وجود داشت
|
|
|
|
|
if (bunosesPay.NotCompleted || yearsPay.NotCompleted)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
List<BunosesAndYearsPayStatus> lostCheckoutsDates = new List<BunosesAndYearsPayStatus>();
|
|
|
|
|
if ((bunosesPay.NotCompleted && yearsPay.NotCompleted) || (bunosesPay.NotCompleted && !yearsPay.NotCompleted))
|
|
|
|
|
lostCheckoutsDates = bunosesPay.BunosesStatusList;
|
|
|
|
|
if (!bunosesPay.NotCompleted && yearsPay.NotCompleted)
|
|
|
|
|
lostCheckoutsDates = yearsPay.BunosesStatusList;
|
|
|
|
|
|
|
|
|
|
foreach (var found in lostCheckoutsDates)
|
|
|
|
|
{
|
|
|
|
|
ComputingViewModel foundMandatoryCompute = new ComputingViewModel();
|
|
|
|
|
var foundContract = _contractRepository.GetContractByStartEnd(found.ContractStart,
|
|
|
|
|
found.ContractEnd, contract.WorkshopIds, contract.EmployeeId);
|
|
|
|
|
|
|
|
|
|
if (foundContract.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
var foundWorkingHours = _workingHoursTempRepository.GetByContractIdConvertToShiftwork4(foundContract.Id);
|
|
|
|
|
foundWorkingHours.ContractStartGr = found.ContractStart;
|
|
|
|
|
foundWorkingHours.ContractEndGr = found.ContractEnd;
|
|
|
|
|
foundWorkingHours.ContarctStart = found.ContractStart.ToFarsi();
|
|
|
|
|
foundWorkingHours.ContractEnd = found.ContractEnd.ToFarsi();
|
|
|
|
|
foundWorkingHours.GetWorkDate = foundContract.GetWorkDate;
|
|
|
|
|
foundWorkingHours.GetWorkDateHide = foundContract.GetWorkDate;
|
|
|
|
|
foundWorkingHours.WorkshopId = contract.WorkshopIds;
|
|
|
|
|
foundWorkingHours.EmployeeId = contract.EmployeeId;
|
|
|
|
|
bool foundHasRollCall = await _rollCallEmployeeRepository.HasRollCallRecord(item.EmployeeId, workshopId, found.ContractStart, found.ContractEnd);
|
|
|
|
|
|
|
|
|
|
if (getContractsData.Data.IsStaticCheckout)
|
|
|
|
|
foundHasRollCall = false;
|
|
|
|
|
|
|
|
|
|
foundMandatoryCompute = await _rollCallMandatoryRepository.MandatoryCompute(contract.EmployeeId,
|
|
|
|
|
contract.WorkshopIds,
|
|
|
|
|
found.ContractStart, found.ContractEnd, foundWorkingHours, getContractsData.Data.WorkshopHolidayWorking, foundHasRollCall, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var MontlyYearsBunos =
|
|
|
|
|
_yearlySalaryRepository.GetMontlyBunosYears(foundMandatoryCompute.weeklyTime, found.ContractStart, found.ContractEnd,
|
|
|
|
|
foundMandatoryCompute.SalaryCompute.MoneyToDouble(), foundMandatoryCompute.SumTime44, foundMandatoryCompute.OfficialHoliday,
|
|
|
|
|
int.Parse(foundMandatoryCompute.NumberOfFriday), foundMandatoryCompute.TotalHolidayAndNotH, foundMandatoryCompute.TotalHolidayAndNotM,
|
|
|
|
|
foundMandatoryCompute.Basic, foundMandatoryCompute.FridayStartToEnd, foundMandatoryCompute.DayliFeeComplete, hasRollCall, getContractsData.Data.WorkshopHolidayWorking, item.WorkingHours.ShiftWork);
|
|
|
|
|
double foundMontlySalary = MontlyYearsBunos.MontlyWage + MontlyYearsBunos.BasicYears;
|
|
|
|
|
int foundTotaldays = Convert.ToInt32(MontlyYearsBunos.SumOfWorkingDay);
|
|
|
|
|
double foundDayliWage = foundMontlySalary / foundTotaldays;
|
|
|
|
|
if (bunosesPay.NotCompleted)
|
|
|
|
|
{
|
|
|
|
|
double foundBonuses = ((foundDayliWage * 60) / 365) * foundTotaldays;
|
|
|
|
|
bunosesPay.Bunoses += foundBonuses;
|
|
|
|
|
bunosesPay.TotalDayCompute += foundTotaldays;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (yearsPay.NotCompleted)
|
|
|
|
|
{
|
|
|
|
|
double foundBonuses = ((foundDayliWage * 30) / 365) * foundTotaldays;
|
|
|
|
|
yearsPay.YearsPay += foundBonuses;
|
|
|
|
|
yearsPay.TotalDayCompute += foundTotaldays;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//مزد مرخصی جدید
|
|
|
|
|
var leavePayNew = _yearlySalaryRepository.LeavePay(item.Separation.ContarctStart,
|
|
|
|
|
item.Separation.LeftWorkDate, item.Separation.ContractStartGr, item.Separation.ContractEndGr,
|
|
|
|
|
dayliWage, item.ComputeOption, item.Separation.HasLeft, item.Separation.StartWorkDate,
|
|
|
|
|
contract.ContractStartGr,
|
|
|
|
|
contract.ContractEndGr, contract.WorkshopIds, contract.EmployeeId, fridayStartToEnd,
|
|
|
|
|
officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble,
|
|
|
|
|
familyAllowanceDouble, marriedAllowanceDouble, getContractsData.Data.IsOldContract);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Insurance
|
|
|
|
|
|
|
|
|
|
double insuranceShare = 0;
|
|
|
|
|
//اگر پرسنل داری شروع بکار بیمه بود
|
|
|
|
|
var insuranceEmployeeDataItem =
|
|
|
|
|
insuranceEmployeeData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
|
|
|
|
|
|
|
|
|
|
//اگر لیست بیمه برای پرسنل ساخته شده بود
|
|
|
|
|
var insuranceListDataWithDetails =
|
|
|
|
|
insuranceListData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
|
|
|
|
|
if (insuranceListDataWithDetails != null)
|
|
|
|
|
{
|
|
|
|
|
insuranceShare = insuranceListDataWithDetails.InsuranceShare;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (insuranceEmployeeDataItem != null && insuranceEmployeeDataItem.StartWorkDateGr <= item.Separation.ContractEndGr)
|
|
|
|
|
{
|
|
|
|
|
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(insuranceEmployeeDataItem.StartWorkDateGr, item.Separation.LeftWorkDate, startDateGr, endDateGr, insuranceEmployeeDataItem.EmployeeId);
|
|
|
|
|
var leftWorkFa = workingDays.hasLeftWorkInMonth ? item.Separation.LeftWorkDate.ToFarsi() : "";
|
|
|
|
|
|
|
|
|
|
//به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
|
|
|
|
|
|
|
|
|
|
double dailyWage = 0;
|
|
|
|
|
if (getContractsData.Data.FixedSalary)
|
|
|
|
|
{
|
|
|
|
|
var res = _insuranceListApplication.GetDailyWageFixedSalary(year, getContractsData.Data.WorkshopId, insuranceEmployeeDataItem.EmployeeId, startDateGr,
|
|
|
|
|
endDateGr, insuranceEmployeeDataItem.JobId, getContractsData.Data.Population, getContractsData.Data.InsuranceJobId);
|
|
|
|
|
dailyWage = res ?? 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var res = _insuranceListApplication.ComputeDailyWage(yearlysaleries.DayliWage, insuranceEmployeeDataItem.EmployeeId, getContractsData.Data.WorkshopId, year);
|
|
|
|
|
dailyWage = res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//بدست آوردن پایه سنوات
|
|
|
|
|
var baseYears = _insuranceListRepository.GetEmployeeInsuranceBaseYear(insuranceEmployeeDataItem.EmployeeId, getContractsData.Data.WorkshopId,
|
|
|
|
|
workingDays.countWorkingDays, startDateGr, endDateGr, workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
|
|
|
|
|
|
|
|
|
|
//جمع مزد روزانه و پایه سنوات
|
|
|
|
|
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//دستمزد ماهانه با محاسبه پایه سنوات
|
|
|
|
|
var monthlySalary = Tools.GetRoundDoubleValue(dailyWagePlusBaseYears * workingDays.countWorkingDays);
|
|
|
|
|
|
|
|
|
|
//حق تاهل
|
|
|
|
|
var marriedAllowanceForInsurance = item.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0;
|
|
|
|
|
|
|
|
|
|
//محاسبه مزایای ماهانه
|
|
|
|
|
var monthlyBenefits = _insuranceListApplication.GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowanceForInsurance, workingDays.countWorkingDays, getContractsData.Data.TypeOfInsuranceSend, insuranceEmployeeDataItem.JobId, insuranceEmployeeDataItem.EmployeeId, insuranceEmployeeDataItem.IncludeStatus);
|
|
|
|
|
if (getContractsData.Data.HasInsuranceCheckoutOverTime)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
monthlyBenefits = Tools.GetRoundDoubleValue(monthlyBenefits += overTimeWorking);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
|
|
|
|
|
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
|
|
|
|
|
|
|
|
|
|
//محاسبه حق بیمه سهم بیمه شده
|
|
|
|
|
insuranceShare = (benefitsIncludedContinuous * 7) / 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
#region ResultToSave
|
|
|
|
|
|
|
|
|
|
var syear = Convert.ToInt32(item.ContractStart.Substring(0, 4));
|
|
|
|
|
|
|
|
|
|
string monthfarsiName = (item.ContractStart.Substring(5, 2)).ToFarsiMonthByNumber();
|
|
|
|
|
|
|
|
|
|
var yearShamsi = item.ContractStart.Substring(0, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dayliWageDouble = mandatoryCompute.SalaryCompute.MoneyToDouble();
|
|
|
|
|
// کمک هزینه اقلام
|
|
|
|
|
var consumableItem = mandatoryCompute.ConsumableItems.MoneyToDouble();
|
|
|
|
|
//حق اولاد
|
|
|
|
|
var familyAllowance = mandatoryCompute.FamilyAllowance.MoneyToDouble();
|
|
|
|
|
//کمک هزینه مسکن
|
|
|
|
|
var housingAllowance = mandatoryCompute.HousingAllowance.MoneyToDouble();
|
|
|
|
|
//حق تاهل
|
|
|
|
|
var marriedAllowance = mandatoryCompute.MarriedAllowance.MoneyToDouble();
|
|
|
|
|
|
|
|
|
|
#region Salary
|
|
|
|
|
|
|
|
|
|
var totalDays = (item.Separation.ContractEndGr - item.Separation.ContractStartGr).TotalDays + 1;
|
|
|
|
|
|
|
|
|
|
//حقوق ماهانه
|
|
|
|
|
var monthlyWage = mandatoryCompute.DailySalaryAffected * totalDays;
|
|
|
|
|
//پایه سنوات
|
|
|
|
|
var bacicYears = mandatoryCompute.BaseYearAffected * totalDays;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//سنوات
|
|
|
|
|
var years = yearsPay.YearsPay;
|
|
|
|
|
//عیدی و پاداش
|
|
|
|
|
var bunos = bunosesPay.Bunoses;
|
|
|
|
|
|
|
|
|
|
//فاطمه احمدژاد === موقت عیدی و پاداش و سنوات حساب نشه
|
|
|
|
|
if (item.EmployeeId == 45104 && getContractsData.Data.WorkshopId == 315)
|
|
|
|
|
{
|
|
|
|
|
years = 0;
|
|
|
|
|
|
|
|
|
|
bunos = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//تعداد زروز های فیش
|
|
|
|
|
var sumOfWorkingDays = $"{totalDays}";
|
|
|
|
|
|
|
|
|
|
//مبلغ جمعه کاری
|
|
|
|
|
double fridayPay = 0;
|
|
|
|
|
if (Friday > 0)
|
|
|
|
|
{
|
|
|
|
|
var fridayPercent = dayliWageDouble * 40 / 100;
|
|
|
|
|
//فوق العاده جمعه کاری
|
|
|
|
|
fridayPay = fridayPercent * Friday;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//حق بیمه سهم کارگر
|
|
|
|
|
#region InsuranceDeduction
|
|
|
|
|
|
|
|
|
|
double insuranceDeduction = 0;
|
|
|
|
|
bool hasInsuranceShareTheSameAsList = false;
|
|
|
|
|
var inshuranceShareRound = Tools.GetRoundDoubleValue(insuranceShare);
|
|
|
|
|
if (inshuranceShareRound == 0)
|
|
|
|
|
{
|
|
|
|
|
var insuranceOverTime = getContractsData.Data.HasInsuranceCheckoutOverTime ? overTimeWorking : 0;
|
|
|
|
|
insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insuranceDeduction = inshuranceShareRound;
|
|
|
|
|
hasInsuranceShareTheSameAsList = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
|
|
|
|
Console.WriteLine("================================================================== ");
|
|
|
|
|
Console.WriteLine("========================================Counter ================== " + (i+1));
|
|
|
|
|
Console.WriteLine("========================================Counter ================== " + (i + 1));
|
|
|
|
|
Console.WriteLine("================================================================== ");
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
i += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
|
|
|
Console.WriteLine("after GetData To mandatoryCompute" + timer.Elapsed);
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|