start new insurancelist operations
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using AccountManagement.Domain.MediaAgg;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.DateSalaryAgg;
|
||||
using Company.Domain.DateSalaryItemAgg;
|
||||
@@ -15,6 +18,7 @@ using Company.Domain.empolyerAgg;
|
||||
using Company.Domain.InsuranceEmployeeInfoAgg;
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
using Company.Domain.InsuranceListAgg;
|
||||
using Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
using Company.Domain.InsurancWorkshopInfoAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
@@ -32,10 +36,12 @@ using CompanyManagment.App.Contracts.YearlySalary;
|
||||
using CompanyManagment.App.Contracts.YearlySalaryItems;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using MD.PersianDateTime.Standard;
|
||||
using Microsoft.AspNetCore.Authorization.Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class InsuranceListApplication: IInsuranceListApplication
|
||||
public class InsuranceListApplication : IInsuranceListApplication
|
||||
{
|
||||
|
||||
//private readonly ITransactionManager _transactionManager;
|
||||
@@ -57,11 +63,11 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
|
||||
private readonly IInsuranceYearlySalaryApplication _insuranceYearlySalaryApplication;
|
||||
private readonly ICheckoutRepository _checkoutRepository;
|
||||
|
||||
public InsuranceListApplication( IInsuranceListRepository insuranceListRepositpry, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceEmployeeInfoRepository insuranceEmployeeInfoRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workShopRepository, ILeftWorkInsuranceApplication leftWorkInsuranceApplication, IInsuranceEmployeeInfoApplication insuranceEmployeeInfoApplication, IEmployeeInsurancListDataApplication employeeInsurancListDataApplication, IYearlySalaryApplication yearlySalaryApplication,IYearlySalaryItemApplication yearlySalaryItemApplication ,IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository,IInsuranceJobItemRepositpry insuranceJobItemRepository, IDateSalaryRepository dateSalaryRepository, IDateSalaryItemRepository dateSalaryItemRepository, IPersonalContractingPartyApp contractingPartyApp, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceYearlySalaryApplication insuranceYearlySalaryApplication, ICheckoutRepository checkoutRepository)
|
||||
private readonly IMediaRepository _mediaRepository;
|
||||
public InsuranceListApplication(IInsuranceListRepository insuranceListRepositpry, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceEmployeeInfoRepository insuranceEmployeeInfoRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workShopRepository, ILeftWorkInsuranceApplication leftWorkInsuranceApplication, IInsuranceEmployeeInfoApplication insuranceEmployeeInfoApplication, IEmployeeInsurancListDataApplication employeeInsurancListDataApplication, IYearlySalaryApplication yearlySalaryApplication, IYearlySalaryItemApplication yearlySalaryItemApplication, IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository, IInsuranceJobItemRepositpry insuranceJobItemRepository, IDateSalaryRepository dateSalaryRepository, IDateSalaryItemRepository dateSalaryItemRepository, IPersonalContractingPartyApp contractingPartyApp, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceYearlySalaryApplication insuranceYearlySalaryApplication, ICheckoutRepository checkoutRepository, IMediaRepository mediaRepository)
|
||||
{
|
||||
// _transactionManager = transactionManager;
|
||||
|
||||
|
||||
_insuranceListRepositpry = insuranceListRepositpry;
|
||||
_employeeInsurancListDataRepository = employeeInsurancListDataRepository;
|
||||
_insuranceEmployeeInfoRepository = insuranceEmployeeInfoRepository;
|
||||
@@ -80,21 +86,22 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
|
||||
_insuranceYearlySalaryApplication = insuranceYearlySalaryApplication;
|
||||
_checkoutRepository = checkoutRepository;
|
||||
_mediaRepository = mediaRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateInsuranceList command)
|
||||
{
|
||||
|
||||
|
||||
var operation = new OperationResult();
|
||||
if (command.WorkshopId==0 )
|
||||
if (command.WorkshopId == 0)
|
||||
{
|
||||
return operation.Failed(" انتخاب کارگاه اجباری می باشد ");
|
||||
}
|
||||
if ( command.Month == "0" )
|
||||
if (command.Month == "0")
|
||||
{
|
||||
return operation.Failed(" انتخاب ماه اجباری می باشد ");
|
||||
}
|
||||
if ( command.Year == "0")
|
||||
if (command.Year == "0")
|
||||
{
|
||||
return operation.Failed("انتخاب سال اجباری می باشد ");
|
||||
}
|
||||
@@ -171,7 +178,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
public OperationResult Edit(EditInsuranceList command)
|
||||
{
|
||||
|
||||
|
||||
var operation = new OperationResult();
|
||||
if (command.WorkshopId == 0)
|
||||
{
|
||||
@@ -185,7 +192,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
{
|
||||
return operation.Failed("انتخاب سال اجباری می باشد ");
|
||||
}
|
||||
else if (_insuranceListRepositpry.Exists(x =>x.id!=command.Id && x.WorkshopId == command.WorkshopId && x.Month == command.Month && x.Year == command.Year))
|
||||
else if (_insuranceListRepositpry.Exists(x => x.id != command.Id && x.WorkshopId == command.WorkshopId && x.Month == command.Month && x.Year == command.Year))
|
||||
{
|
||||
return operation.Failed(" لیست بیمه برای کارگاه، سال و ماه انتخاب شده قبلا ایجاد شده است ");
|
||||
}
|
||||
@@ -211,7 +218,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
createInsuranceEmployeeInfo.Gender = item.Gender;
|
||||
createInsuranceEmployeeInfo.InsuranceCode = item.InsuranceCode;
|
||||
createInsuranceEmployeeInfo.DateOfBirthGr = item.DateOfBirth.ToGeorgianDateTime();
|
||||
createInsuranceEmployeeInfo.DateOfIssueGr =!string.IsNullOrEmpty(item.DateOfIssue)? item.DateOfIssue.ToGeorgianDateTime(): "1300/10/11".ToGeorgianDateTime();
|
||||
createInsuranceEmployeeInfo.DateOfIssueGr = !string.IsNullOrEmpty(item.DateOfIssue) ? item.DateOfIssue.ToGeorgianDateTime() : "1300/10/11".ToGeorgianDateTime();
|
||||
_insuranceEmployeeInfoApplication.Create(createInsuranceEmployeeInfo);
|
||||
}
|
||||
else
|
||||
@@ -266,8 +273,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EditInsuranceList GetDetails(long id)
|
||||
{
|
||||
@@ -302,8 +309,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
foreach (var item in insuranceListDetails.EmployeeDetailsForInsuranceList)
|
||||
{
|
||||
|
||||
item.IncludeStatus = _leftWorkInsuranceApplication.GetLeftPersonelByWorkshopIdAndEmployeeId(insuranceListDetails.WorkshopId,item.EmployeeId).IncludeStatus;
|
||||
|
||||
item.IncludeStatus = _leftWorkInsuranceApplication.GetLeftPersonelByWorkshopIdAndEmployeeId(insuranceListDetails.WorkshopId, item.EmployeeId).IncludeStatus;
|
||||
if (!string.IsNullOrEmpty(item.LeftWorkDate))
|
||||
{
|
||||
var yearEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(0, 4));
|
||||
@@ -348,7 +355,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
return insuranceListDetails;
|
||||
}
|
||||
|
||||
public List<InsuranceListViewModel> Search(InsuranceListSearchModel searchModel)
|
||||
public List<InsuranceListViewModel> Search(InsuranceListSearchModel searchModel)
|
||||
{
|
||||
return _insuranceListRepositpry.OptimizedSearch(searchModel);
|
||||
//var result = _insuranceListRepositpry.Search(searchModel);
|
||||
@@ -380,10 +387,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
public MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList( EmployeeForCreateInsuranceListSearchModel searchModel)
|
||||
public MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList(EmployeeForCreateInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var watch = new Stopwatch();
|
||||
|
||||
var watch = new Stopwatch();
|
||||
|
||||
var result = new MainEmployeeDetailsViewModel();
|
||||
var workshopId = searchModel.WorkshopIds.FirstOrDefault();
|
||||
var workshop = _workShopRepository.GetDetails(workshopId);
|
||||
@@ -392,30 +399,30 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
double monthlybaseYear = 0;
|
||||
// اگر در این سال و ماه برای این کارگاه لیست بیمه ایجاد نشده بود
|
||||
if (!_insuranceListRepositpry.Exists(x =>
|
||||
x.Year == searchModel.Year && x.Month == searchModel.Month &&
|
||||
searchModel.WorkshopIds.Contains(x.WorkshopId)))
|
||||
x.Year == searchModel.Year && x.Month == searchModel.Month &&
|
||||
searchModel.WorkshopIds.Contains(x.WorkshopId)))
|
||||
{
|
||||
|
||||
var startMonthFa = $"{searchModel.Year}/{searchModel.Month.PadLeft(2, '0')}/01";
|
||||
DateTime startDateGr = startMonthFa.ToGeorgianDateTime();
|
||||
DateTime endDateGr = startMonthFa.FindeEndOfMonth()
|
||||
.ToGeorgianDateTime();
|
||||
DateTime endDateGr = startMonthFa.FindeEndOfMonth()
|
||||
.ToGeorgianDateTime();
|
||||
int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2));
|
||||
|
||||
|
||||
//مقادیر سالانه این تاریخ
|
||||
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, searchModel.Year);
|
||||
|
||||
//مقادیر سالانه این تاریخ
|
||||
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, searchModel.Year);
|
||||
|
||||
|
||||
// دریافت اطلاعات هویتی و شروع و ترک کار کارکنان
|
||||
var employeesInfoAndLeftWorks =
|
||||
_leftWorkInsuranceApplication.GetEmployeeInsuranceLeftWorksAndInformation(workshopId, startDateGr,
|
||||
endDateGr);
|
||||
// دریافت اطلاعات هویتی و شروع و ترک کار کارکنان
|
||||
var employeesInfoAndLeftWorks =
|
||||
_leftWorkInsuranceApplication.GetEmployeeInsuranceLeftWorksAndInformation(workshopId, startDateGr,
|
||||
endDateGr);
|
||||
|
||||
var employeeInsurancDataPreviusList =
|
||||
_insuranceListRepositpry.GetEmployeeInsuranceDataAmonthAgo(startDateGr, workshopId);
|
||||
watch.Start();
|
||||
var computeResult = employeesInfoAndLeftWorks.Select(employee =>
|
||||
watch.Start();
|
||||
var computeResult = employeesInfoAndLeftWorks.Select(employee =>
|
||||
{
|
||||
var dateOfBirth = employee.DateOfBirthGr.ToFarsi();
|
||||
var dateOfIssue = employee.DateOfIssueGr.ToFarsi();
|
||||
@@ -426,7 +433,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//آیا در کارگاه تیک محاسبه اضافه کار یا حق اولاد زده شده است؟
|
||||
bool hasWorkshopOverTimeOrFamilyAllowance =
|
||||
workshop.InsuranceCheckoutFamilyAllowance || workshop.InsuranceCheckoutOvertime;
|
||||
|
||||
|
||||
//آیا پرسنل فیش حقوق دارد
|
||||
//این مورد زمانی چک می شود که تیک محاسبه در کارگاه زده شده باشد
|
||||
// در غیر اینصورت بصورت پیشفرض دارای فیش حقوق در نظر گرفته می شود
|
||||
@@ -439,10 +446,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
searchModel.Year, searchModel.Month);
|
||||
if (checkout.hasChekout)
|
||||
{
|
||||
|
||||
|
||||
familyAllowance = checkout.FamilyAlloance;
|
||||
overTimePay = checkout.OverTimePay;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -451,9 +458,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr,endDateGr, employee.EmployeeId);
|
||||
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employee.LeftWorkDateGr.ToFarsi(): "";
|
||||
|
||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr, endDateGr, employee.EmployeeId);
|
||||
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employee.LeftWorkDateGr.ToFarsi() : "";
|
||||
var startWorkFa = employee.StartWorkDateGr.ToFarsi();
|
||||
//به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
|
||||
|
||||
@@ -463,34 +470,34 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var res = GetDailyWageFixedSalary(searchModel.Year, workshopId, employee.EmployeeId, startDateGr,
|
||||
endDateGr, employee.JobId, searchModel.Population, searchModel.InsuranceJobId);
|
||||
dailyWage = res ?? 0;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var res = ComputeDailyWage(yearlysaleries.DayliWage, employee.EmployeeId, workshopId, searchModel.Year);
|
||||
dailyWage = res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//بدست آوردن پایه سنوات
|
||||
var baseYears = _insuranceListRepositpry.GetEmployeeInsuranceBaseYear(employee.EmployeeId, workshopId,
|
||||
workingDays.countWorkingDays, startDateGr, endDateGr,workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
|
||||
workingDays.countWorkingDays, startDateGr, endDateGr, workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
|
||||
//آیا کارفرما یا مدیر عامل است؟
|
||||
|
||||
baseYears.baseYear = isManager ? 0 : baseYears.baseYear;
|
||||
Console.WriteLine(employee.JobId + " - "+ baseYears.baseYear);
|
||||
//جمع مزد روزانه و پایه سنوات
|
||||
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
|
||||
|
||||
|
||||
//دستمزد ماهانه با محاسبه پایه سنوات
|
||||
baseYears.baseYear = isManager ? 0 : baseYears.baseYear;
|
||||
Console.WriteLine(employee.JobId + " - " + baseYears.baseYear);
|
||||
//جمع مزد روزانه و پایه سنوات
|
||||
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
|
||||
|
||||
|
||||
//دستمزد ماهانه با محاسبه پایه سنوات
|
||||
var monthlySalary = GetRoundValue(dailyWagePlusBaseYears * workingDays.countWorkingDays);
|
||||
|
||||
//حق تاهل
|
||||
var marriedAllowance = employee.MaritalStatus == "متاهل" && !isManager ? yearlysaleries.MarriedAllowance : 0;
|
||||
|
||||
//محاسبه مزایای ماهانه
|
||||
var monthlyBenefits = GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, employee.JobId, employee.EmployeeId,employee.IncludeStatus);
|
||||
var monthlyBenefits = GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, employee.JobId, employee.EmployeeId, employee.IncludeStatus);
|
||||
|
||||
//if (employee.EmployeeId is 7999)// سید عباس خوشکلام سلیمان
|
||||
// monthlyBenefits = 80869389;
|
||||
@@ -501,7 +508,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
monthlyBenefits = GetRoundValue(monthlyBenefits += overTimePay);
|
||||
}
|
||||
|
||||
|
||||
//سرای ملک
|
||||
// نوشین خالی
|
||||
// 39692467
|
||||
@@ -509,13 +516,13 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
// monthlyBenefits += 39692467;
|
||||
|
||||
var marriedAllowanceCompute = MarriedAllowance(employee.MaritalStatus, employee.JobId, employee.IncludeStatus,
|
||||
workingDays.countWorkingDays, yearlysaleries.MarriedAllowance, endOfMonth);
|
||||
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
|
||||
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
|
||||
workingDays.countWorkingDays, yearlysaleries.MarriedAllowance, endOfMonth);
|
||||
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
|
||||
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
|
||||
|
||||
//benefitsIncludedContinuous = employee.JobId != 16 ? benefitsIncludedContinuous : 0;
|
||||
//محاسبه حق بیمه سهم بیمه شده
|
||||
var insuranceShare = (benefitsIncludedContinuous * 7) / 100;
|
||||
//benefitsIncludedContinuous = employee.JobId != 16 ? benefitsIncludedContinuous : 0;
|
||||
//محاسبه حق بیمه سهم بیمه شده
|
||||
var insuranceShare = (benefitsIncludedContinuous * 7) / 100;
|
||||
|
||||
//محاسبه حق بیمه سهم کارفرما
|
||||
var employerShare = (benefitsIncludedContinuous * 20) / 100;
|
||||
@@ -535,30 +542,30 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
benefitsIncludedNonContinuous = GetRoundValue(benefitsIncludedNonContinuous + familyAllowance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var includedAndNotIncluded = benefitsIncludedContinuous + benefitsIncludedNonContinuous;
|
||||
|
||||
|
||||
return new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
#region EmployeeInfo
|
||||
{
|
||||
#region EmployeeInfo
|
||||
EmployeeHasCheckout = employeeHasCheckout,
|
||||
InsuranceEmployeeInformationId = employee.InsuranceEmployeeInformationId,
|
||||
EmployeeId = employee.EmployeeId,
|
||||
FName = employee.FName,
|
||||
LName = employee.LName,
|
||||
FatherName = employee.FatherName,
|
||||
DateOfBirth = dateOfBirth == "1300/10/11" ? "" : dateOfBirth,
|
||||
DateOfIssue = dateOfIssue,
|
||||
DateOfBirthGr = employee.DateOfBirthGr,
|
||||
DateOfIssueGr = employee.DateOfIssueGr,
|
||||
PlaceOfIssue = employee.PlaceOfIssue,
|
||||
IdNumber = employee.IdNumber,
|
||||
Gender = employee.Gender,
|
||||
NationalCode = employee.NationalCode,
|
||||
Nationality = employee.Nationality,
|
||||
InsuranceCode = employee.InsuranceCode,
|
||||
EmployeeId = employee.EmployeeId,
|
||||
FName = employee.FName,
|
||||
LName = employee.LName,
|
||||
FatherName = employee.FatherName,
|
||||
DateOfBirth = dateOfBirth == "1300/10/11" ? "" : dateOfBirth,
|
||||
DateOfIssue = dateOfIssue,
|
||||
DateOfBirthGr = employee.DateOfBirthGr,
|
||||
DateOfIssueGr = employee.DateOfIssueGr,
|
||||
PlaceOfIssue = employee.PlaceOfIssue,
|
||||
IdNumber = employee.IdNumber,
|
||||
Gender = employee.Gender,
|
||||
NationalCode = employee.NationalCode,
|
||||
Nationality = employee.Nationality,
|
||||
InsuranceCode = employee.InsuranceCode,
|
||||
// آیا وضعیت تاهل پرسنل ست شده است
|
||||
IsMaritalStatusSet = !string.IsNullOrWhiteSpace(employee.MaritalStatus),
|
||||
MaritalStatus = employee.MaritalStatus,
|
||||
@@ -582,7 +589,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
IncludeStatus = employee.IncludeStatus,
|
||||
|
||||
//دستمزد روزانه
|
||||
DailyWage = GetRoundValue(dailyWage),
|
||||
DailyWage = GetRoundValue(dailyWage),
|
||||
DailyWageStr = dailyWage.ToMoney(),
|
||||
|
||||
HasConfilictJobs = dailyWage == 0,
|
||||
@@ -598,13 +605,13 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
//دستمزد ماهانه
|
||||
MonthlySalary = monthlySalary,
|
||||
|
||||
|
||||
|
||||
|
||||
//مزایای ماهانه
|
||||
MonthlyBenefits = monthlyBenefits,
|
||||
|
||||
//جمع مزایای مشمول و دستمزد ماهانه
|
||||
BenefitsIncludedContinuous = benefitsIncludedContinuous,
|
||||
//جمع مزایای مشمول و دستمزد ماهانه
|
||||
BenefitsIncludedContinuous = benefitsIncludedContinuous,
|
||||
|
||||
//مزایای غیر مشمول *
|
||||
BenefitsIncludedNonContinuous = benefitsIncludedNonContinuous,
|
||||
@@ -636,9 +643,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
|
||||
};
|
||||
}).ToList();
|
||||
}).ToList();
|
||||
Console.WriteLine("New Compute : " + watch.Elapsed);
|
||||
watch.Stop();
|
||||
watch.Stop();
|
||||
|
||||
watch.Start();
|
||||
|
||||
@@ -951,28 +958,28 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
result.IsExist = true;
|
||||
result.IsBlock = isBolock;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public double MarriedAllowance(string maritalStatus,long jobId, bool includedStatus,
|
||||
int countWorkingDays, double marriedAlowance,int endMonthCurrentDay)
|
||||
public double MarriedAllowance(string maritalStatus, long jobId, bool includedStatus,
|
||||
int countWorkingDays, double marriedAlowance, int endMonthCurrentDay)
|
||||
{
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager)//اگر مدیر عامل بود
|
||||
return 0;
|
||||
if (maritalStatus != "متاهل")//اگر مجرد بود
|
||||
return 0;
|
||||
|
||||
if(countWorkingDays == endMonthCurrentDay)
|
||||
return (marriedAlowance);
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager)//اگر مدیر عامل بود
|
||||
return 0;
|
||||
if (maritalStatus != "متاهل")//اگر مجرد بود
|
||||
return 0;
|
||||
|
||||
if (countWorkingDays == endMonthCurrentDay)
|
||||
return (marriedAlowance);
|
||||
|
||||
return endMonthCurrentDay switch
|
||||
{
|
||||
29 => GetRoundValue((marriedAlowance / 29) * countWorkingDays),
|
||||
30 => GetRoundValue((marriedAlowance / 30) * countWorkingDays),
|
||||
31 => GetRoundValue((marriedAlowance / 31) * countWorkingDays),
|
||||
_ => marriedAlowance
|
||||
29 => GetRoundValue((marriedAlowance / 29) * countWorkingDays),
|
||||
30 => GetRoundValue((marriedAlowance / 30) * countWorkingDays),
|
||||
31 => GetRoundValue((marriedAlowance / 31) * countWorkingDays),
|
||||
_ => marriedAlowance
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1147,9 +1154,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
string strValue = value.ToString();
|
||||
if (strValue.IndexOf('.') > -1)
|
||||
{
|
||||
|
||||
|
||||
string a = strValue.Substring(strValue.IndexOf('.')+1, 1);
|
||||
|
||||
string a = strValue.Substring(strValue.IndexOf('.') + 1, 1);
|
||||
if (int.Parse(a) > 5)
|
||||
{
|
||||
return (Math.Round(value, MidpointRounding.ToPositiveInfinity));
|
||||
@@ -1166,13 +1173,13 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//محاسبه پرسنل در جدول - DSKWOR EDIT
|
||||
public MainEmployeeDetailsViewModel SearchEmployeeListForEditByInsuranceListId(EmployeeForEditInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var mainEmployeeDetailsViewModel= new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModel2= new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModelForNewPersonel= new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModel = new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModel2 = new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModelForNewPersonel = new MainEmployeeDetailsViewModel();
|
||||
|
||||
List<long> ids = searchModel.WorkshopIds.Where(x=>x!=searchModel.WorkshopId).ToList();
|
||||
List<long> ids = searchModel.WorkshopIds.Where(x => x != searchModel.WorkshopId).ToList();
|
||||
searchModel.Month = searchModel.Month.PadLeft(2, '0');
|
||||
if (!_insuranceListRepositpry.Exists(x => x.Year == searchModel.Year && x.Month == searchModel.Month && (ids!=null && ids.Count > 0 && ids.Contains(x.WorkshopId))))
|
||||
if (!_insuranceListRepositpry.Exists(x => x.Year == searchModel.Year && x.Month == searchModel.Month && (ids != null && ids.Count > 0 && ids.Contains(x.WorkshopId))))
|
||||
{
|
||||
|
||||
mainEmployeeDetailsViewModel = _insuranceListRepositpry.SearchEmployeeListForEditByInsuranceListId(searchModel);
|
||||
@@ -1194,11 +1201,11 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var searchModelForCreate = new EmployeeForCreateInsuranceListSearchModel();
|
||||
searchModelForCreate.Month = searchModel.Month;
|
||||
searchModelForCreate.Year = searchModel.Year;
|
||||
searchModelForCreate.WorkshopIds=new List<long>(){ searchModel.WorkshopId };
|
||||
searchModelForCreate.WorkshopIds = new List<long>() { searchModel.WorkshopId };
|
||||
var leftWorkInsuranceViewModelList = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModelForCreate);
|
||||
var newEmployeeId = leftWorkInsuranceViewModelList.Select(x => x.EmployeeId).ToList();
|
||||
var oldEmployeeId = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.Select(x => x.EmployeeId).ToList();
|
||||
if(!newEmployeeId.SequenceEqual(oldEmployeeId))
|
||||
if (!newEmployeeId.SequenceEqual(oldEmployeeId))
|
||||
{
|
||||
var employeeAddIds = new List<long>();
|
||||
var employeeRemoveIds = new List<long>();
|
||||
@@ -1223,14 +1230,14 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
if (employeeAddIds != null && employeeAddIds.Count > 0)
|
||||
{
|
||||
leftWorkInsuranceViewModelList = leftWorkInsuranceViewModelList.Where(x => employeeAddIds.Contains(x.EmployeeId)).ToList();
|
||||
mainEmployeeDetailsViewModelForNewPersonel = GetEmployeeForInsuranceList(leftWorkInsuranceViewModelList,searchModel);
|
||||
mainEmployeeDetailsViewModelForNewPersonel = GetEmployeeForInsuranceList(leftWorkInsuranceViewModelList, searchModel);
|
||||
if (mainEmployeeDetailsViewModelForNewPersonel.EmployeeDetailsForInsuranceList != null &&
|
||||
mainEmployeeDetailsViewModelForNewPersonel.EmployeeDetailsForInsuranceList.Count > 0)
|
||||
{
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.Union(mainEmployeeDetailsViewModelForNewPersonel.EmployeeDetailsForInsuranceList).ToList();
|
||||
}
|
||||
}
|
||||
if (employeeRemoveIds != null && employeeRemoveIds.Count>0)
|
||||
if (employeeRemoveIds != null && employeeRemoveIds.Count > 0)
|
||||
{
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel
|
||||
.EmployeeDetailsForInsuranceList.Where(x => !employeeRemoveIds.Contains(x.EmployeeId))
|
||||
@@ -1251,12 +1258,12 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var day = 1;
|
||||
var persianCurrentStartDate = new PersianDateTime(year, month, day);
|
||||
var persianCurrentEndDate = new PersianDateTime(year, month, dayMonthCurrent);
|
||||
|
||||
|
||||
var model = new YearlySalarySearchModel();
|
||||
model.StartDateGr = startMonthCurrent.ToGeorgianDateTime();
|
||||
model.EndDateGr = endMonthCurrent.ToGeorgianDateTime();
|
||||
model.year = searchModel.Year;
|
||||
|
||||
|
||||
var yearlysalaryItem = new YearlysalaryItemViewModel();
|
||||
var housingAllowance = new YearlysalaryItemViewModel();
|
||||
var consumableItems = new YearlysalaryItemViewModel();
|
||||
@@ -1270,7 +1277,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
int endWork = 0;
|
||||
item.IsMaritalStatusSet = // آیا وضعیت تاهل پرسنل ست شده است
|
||||
!string.IsNullOrWhiteSpace(employeeObject.MaritalStatus);
|
||||
|
||||
|
||||
#region HasConfilictLeftWork
|
||||
|
||||
bool hasConfilict = false;
|
||||
@@ -1325,7 +1332,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
}
|
||||
|
||||
//ترک کارش در ماه و سال جاری بود نمایش داده شود
|
||||
if (!string.IsNullOrEmpty(item.LeftWorkDate) && !item.LeftWorkDate.Contains(searchModel.Year+"/"+searchModel.Month ) )
|
||||
if (!string.IsNullOrEmpty(item.LeftWorkDate) && !item.LeftWorkDate.Contains(searchModel.Year + "/" + searchModel.Month))
|
||||
{
|
||||
item.LeftWorkDate = string.Empty;
|
||||
item.LeftWorkDateGr = null;
|
||||
@@ -1366,8 +1373,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var monthStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(5, 2));
|
||||
var dayStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(8, 2));
|
||||
var persianStartDateUser = new PersianDateTime(yearStartDateUser, monthStartDateUser, dayStartDateUser);
|
||||
|
||||
if(persianStartDateUser <= persianCurrentStartDate)
|
||||
|
||||
if (persianStartDateUser <= persianCurrentStartDate)
|
||||
{
|
||||
startWork = 1;
|
||||
}
|
||||
@@ -1376,18 +1383,18 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
startWork = dayStartDateUser;
|
||||
}
|
||||
|
||||
if(persianStartDateUser < persianCurrentStartDate)
|
||||
if (persianStartDateUser < persianCurrentStartDate)
|
||||
item.HasStartWorkInMonth = false;
|
||||
else
|
||||
item.HasStartWorkInMonth = true;
|
||||
|
||||
|
||||
|
||||
if (hasConfilict) //اگر ترک کار شخص تغییر کرده بود، دوباره محاسبه شود
|
||||
{
|
||||
item.StartMonthCurrent = startMonthCurrent;
|
||||
item.HousingAllowance = housingAllowance.ItemValue;
|
||||
item.ConsumableItems = consumableItems.ItemValue;
|
||||
item.DailyWage= ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId, searchModel.WorkshopId, searchModel.Year);
|
||||
item.DailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId, searchModel.WorkshopId, searchModel.Year);
|
||||
item.DailyWageStr = item.DailyWage.ToMoney();
|
||||
}
|
||||
else
|
||||
@@ -1447,15 +1454,15 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
item.UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance);
|
||||
|
||||
// item.BenefitsIncludedNonContinuous = item.BenefitsIncludedContinuous;
|
||||
item.IncludedAndNotIncluded = item.BenefitsIncludedContinuous + item.BenefitsIncludedNonContinuous;
|
||||
item.IncludedAndNotIncluded = item.BenefitsIncludedContinuous + item.BenefitsIncludedNonContinuous;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList!=null && mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList.Count>0)
|
||||
if (mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList != null && mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList.Count > 0)
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.Union(mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList).OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth).ThenBy(x => x.LName).ToList();
|
||||
else
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth).ThenBy(x => x.LName).ToList();
|
||||
|
||||
|
||||
mainEmployeeDetailsViewModel.IsExist = false;
|
||||
mainEmployeeDetailsViewModel.MaritalStatus = maritalStatus.ItemValue;
|
||||
}
|
||||
@@ -1486,7 +1493,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
// endDateGr);
|
||||
|
||||
var employeeInsurancDataPreviusList =
|
||||
_insuranceListRepositpry.GetEmployeeInsuranceDataForEdit(searchModel.InsuranceId,startDateGr,endDateGr);
|
||||
_insuranceListRepositpry.GetEmployeeInsuranceDataForEdit(searchModel.InsuranceId, startDateGr, endDateGr);
|
||||
|
||||
var computeResult = employeeInsurancDataPreviusList.Select(employeeData =>
|
||||
{
|
||||
@@ -1550,12 +1557,12 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
overTimePayIsSet = false;
|
||||
}
|
||||
return new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
{
|
||||
#region EmployeeInfo
|
||||
EmployeeHasCheckout = employeeHasCheckout,
|
||||
EmployeeInsurancListDataId = employeeData.EmployeeInsurancListDataId,
|
||||
|
||||
InsuranceEmployeeInformationId = employeeData.InsuranceEmployeeInformationId,
|
||||
InsuranceEmployeeInformationId = employeeData.InsuranceEmployeeInformationId,
|
||||
EmployeeId = employeeData.EmployeeId,
|
||||
FName = employeeData.FName,
|
||||
LName = employeeData.LName,
|
||||
@@ -1676,9 +1683,9 @@ 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)
|
||||
private double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId)
|
||||
{
|
||||
|
||||
|
||||
double? result = 0;
|
||||
string month = $"{startDateGr.ToFarsi()}".Substring(5, 2);
|
||||
//اگر مشاغل مقطوع بود و شغلش کارفرما بود
|
||||
@@ -1727,7 +1734,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
{
|
||||
var inJob = _insuranceJobItemRepository
|
||||
.GetInsuranceJobItemByInsuranceJobId((long)workshop.InsuranceJobId,year, month);
|
||||
.GetInsuranceJobItemByInsuranceJobId((long)workshop.InsuranceJobId, year, month);
|
||||
if (workshop.Population == "MoreThan500")
|
||||
{
|
||||
var max = inJob.MaxBy(x => x.PercentageMoreThan);
|
||||
@@ -1776,9 +1783,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
else
|
||||
{
|
||||
|
||||
var searchModel = new InsuranceJobItemSearchModel();
|
||||
searchModel.InsuranceJobId = (long)insuranceJobId;
|
||||
var JobItem = _insuranceJobItemRepository.GetInsuranceJobItemByInsuranceJobIdForFixedSalary((long)insuranceJobId, jobId, year, month);
|
||||
var searchModel = new InsuranceJobItemSearchModel();
|
||||
searchModel.InsuranceJobId = (long)insuranceJobId;
|
||||
var JobItem = _insuranceJobItemRepository.GetInsuranceJobItemByInsuranceJobIdForFixedSalary((long)insuranceJobId, jobId, year, month);
|
||||
|
||||
if (JobItem != null && JobItem.Id != 0)
|
||||
{
|
||||
@@ -1804,7 +1811,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -1827,28 +1834,28 @@ 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)
|
||||
private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue, double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus)
|
||||
{
|
||||
//ToDo
|
||||
//افزودن شرط مشمول مزایای
|
||||
//ToDo
|
||||
//افزودن شرط مشمول مزایای
|
||||
|
||||
//اگر پرسنل کارفرما بود و نوع لیست کارگاه کمک دولت بود مزایا محاسبه نشود
|
||||
//اگر تیک مشمول مزایا در ترک کار خاموش بود مزایا نگیرد
|
||||
//اگر پرسنل کارفرما بود و نوع لیست کارگاه کمک دولت بود مزایا محاسبه نشود
|
||||
//اگر تیک مشمول مزایا در ترک کار خاموش بود مزایا نگیرد
|
||||
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager && !includeStatus)
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager && !includeStatus)
|
||||
return 0;
|
||||
//پرسنل استثناء
|
||||
if (employeeId == 42783)
|
||||
return 53082855;
|
||||
|
||||
|
||||
//if(employeeId == 8859)
|
||||
// return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / 31) * countWorkingDays);
|
||||
|
||||
//مزایای ماهانه با توجه به پایان ماه که 30 یا 31 روزه است، متفاوت می باشد
|
||||
//برای ماه 29 روزه هم تقسیم بر 30 می شود.
|
||||
if (countWorkingDays == endMonthCurrentDay)
|
||||
//if(employeeId == 8859)
|
||||
// return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / 31) * countWorkingDays);
|
||||
|
||||
//مزایای ماهانه با توجه به پایان ماه که 30 یا 31 روزه است، متفاوت می باشد
|
||||
//برای ماه 29 روزه هم تقسیم بر 30 می شود.
|
||||
if (countWorkingDays == endMonthCurrentDay)
|
||||
return (consumableItemsItemValue + housingAllowanceItemValue + maritalStatus);
|
||||
else if (endMonthCurrentDay == 29)//farokhiChanges در خط پایین عدد 30 رو به 29 تغییر دادم
|
||||
return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / 29) * countWorkingDays);
|
||||
@@ -1860,31 +1867,31 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / endMonthCurrentDay) * countWorkingDays);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
|
||||
|
||||
private double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
|
||||
{
|
||||
double dailyWage = yearlysalaryItemValue;
|
||||
InsuranceListSearchModel searchModel = new InsuranceListSearchModel();
|
||||
InsuranceListSearchModel searchModel = new InsuranceListSearchModel();
|
||||
var insuransList = _insuranceListRepositpry.GetInsuranceListByWorkshopIdAndYear(workshopId, year);
|
||||
if (insuransList != null)
|
||||
{
|
||||
var employeeInsurancListData = _employeeInsurancListDataRepository.GetEmployeeInsurancListDataByEmployeeIdAndInsuranceListId( employeeId, insuransList.Id);
|
||||
if (employeeInsurancListData != null && employeeInsurancListData.DailyWage> dailyWage)
|
||||
var employeeInsurancListData = _employeeInsurancListDataRepository.GetEmployeeInsurancListDataByEmployeeIdAndInsuranceListId(employeeId, insuransList.Id);
|
||||
if (employeeInsurancListData != null && employeeInsurancListData.DailyWage > dailyWage)
|
||||
{
|
||||
dailyWage=employeeInsurancListData.DailyWage;
|
||||
dailyWage = employeeInsurancListData.DailyWage;
|
||||
}
|
||||
}
|
||||
|
||||
dailyWage = employeeId == 6536 ? 9399512 : dailyWage;
|
||||
return dailyWage;
|
||||
}
|
||||
public MainEmployeeDetailsViewModel GetEmployeeForInsuranceList(List<LeftWorkInsuranceViewModel> leftWorkInsuranceViewModelList, EmployeeForEditInsuranceListSearchModel searchModel)
|
||||
public MainEmployeeDetailsViewModel GetEmployeeForInsuranceList(List<LeftWorkInsuranceViewModel> leftWorkInsuranceViewModelList, EmployeeForEditInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var result = new MainEmployeeDetailsViewModel();
|
||||
|
||||
List<EmployeeDetailsForInsuranceListViewModel> list = new List<EmployeeDetailsForInsuranceListViewModel>();
|
||||
int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count();
|
||||
int leftWorkInsuranceCount = leftWorkInsuranceViewModelList.Count();
|
||||
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
|
||||
string endMonthCurrent = startMonthCurrent.FindeEndOfMonth();
|
||||
|
||||
@@ -1893,7 +1900,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
model.EndDateGr = endMonthCurrent.ToGeorgianDateTime();
|
||||
model.year = searchModel.Year;
|
||||
|
||||
|
||||
|
||||
|
||||
var yearSalaryObj = _yearlySalaryApplication.GetDetailsBySearchModel(model);
|
||||
|
||||
@@ -1953,7 +1960,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
employeeDetailsForInsuranceObj.FName = employeeObject.FName;
|
||||
employeeDetailsForInsuranceObj.LName = employeeObject.LName;
|
||||
employeeDetailsForInsuranceObj.FatherName = employeeObject.FatherName;
|
||||
employeeDetailsForInsuranceObj.DateOfBirth = employeeObject.DateOfBirth=="1300/10/11"?"": employeeObject.DateOfBirth;
|
||||
employeeDetailsForInsuranceObj.DateOfBirth = employeeObject.DateOfBirth == "1300/10/11" ? "" : employeeObject.DateOfBirth;
|
||||
employeeDetailsForInsuranceObj.DateOfIssue = employeeObject.DateOfIssue;
|
||||
employeeDetailsForInsuranceObj.PlaceOfIssue = employeeObject.PlaceOfIssue;
|
||||
employeeDetailsForInsuranceObj.NationalCode = employeeObject.NationalCode;
|
||||
@@ -2059,8 +2066,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
case 40469://ثابت
|
||||
countWorkingDays = 7;
|
||||
break;
|
||||
//case 9950://ثابت
|
||||
// countWorkingDays = 15;
|
||||
//case 9950://ثابت
|
||||
// countWorkingDays = 15;
|
||||
break;
|
||||
case 9640://ثابت
|
||||
countWorkingDays = 15;
|
||||
@@ -2071,9 +2078,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
case 6219://ثابت
|
||||
countWorkingDays = 15;
|
||||
break;
|
||||
//case 7897://ثابت
|
||||
// countWorkingDays = 15;
|
||||
// break;
|
||||
//case 7897://ثابت
|
||||
// countWorkingDays = 15;
|
||||
// break;
|
||||
}
|
||||
;
|
||||
#endregion
|
||||
@@ -2085,17 +2092,17 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
double dailyWage = employeeDetailsForInsuranceObj.DailyWage;
|
||||
if (searchModel.FixedSalary)
|
||||
{
|
||||
dailyWage = Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, item.WorkshopId,item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId));
|
||||
dailyWage = Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, item.WorkshopId, item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId));
|
||||
employeeDetailsForInsuranceObj.HasConfilictJobs = (dailyWage == 0 ? true : false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (yearlysalaryItem != null)
|
||||
{
|
||||
if(!searchModel.FixedSalary )
|
||||
if (!searchModel.FixedSalary)
|
||||
{
|
||||
//dailyWage= yearlysalaryItem.ItemValue;
|
||||
dailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId,item.WorkshopId, searchModel.Year) ;
|
||||
dailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId, item.WorkshopId, searchModel.Year);
|
||||
}
|
||||
employeeDetailsForInsuranceObj.DailyWage = GetRoundValue(dailyWage);
|
||||
employeeDetailsForInsuranceObj.DailyWageStr = employeeDetailsForInsuranceObj.DailyWage.ToMoney();
|
||||
@@ -2119,8 +2126,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
employeeDetailsForInsuranceObj.MonthlyBenefits = 0;
|
||||
}
|
||||
|
||||
employeeDetailsForInsuranceObj.BenefitsIncludedContinuous =employeeDetailsForInsuranceObj.MonthlyBenefits + employeeDetailsForInsuranceObj.MonthlySalary;
|
||||
|
||||
employeeDetailsForInsuranceObj.BenefitsIncludedContinuous = employeeDetailsForInsuranceObj.MonthlyBenefits + employeeDetailsForInsuranceObj.MonthlySalary;
|
||||
|
||||
//if ((!item.IncludeStatus &&(item.JobId == 10 || item.JobId == 17 || item.JobId == 18 || item.JobId == 16)) ||(item.IncludeStatus && item.JobId == 10)) // 10 --> karfarma
|
||||
//{
|
||||
// var insuranceShare2 =(employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 27) / 100;
|
||||
@@ -2133,14 +2140,14 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//}
|
||||
|
||||
var employerShare = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 20) / 100;
|
||||
employeeDetailsForInsuranceObj.EmployerShare = GetRoundValue(employerShare); //Math.Round(employerShare, MidpointRounding.ToPositiveInfinity);
|
||||
employeeDetailsForInsuranceObj.EmployerShare = GetRoundValue(employerShare); //Math.Round(employerShare, MidpointRounding.ToPositiveInfinity);
|
||||
|
||||
|
||||
//if (searchModel.TypeOfInsuranceSendWorkshop == "Govermentlist" && item.JobId==10)//کمک دولت
|
||||
//{employeeDetailsForInsuranceObj.InsuranceShare = 0;}
|
||||
|
||||
|
||||
var unEmploymentInsurance =(employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 3) / 100;
|
||||
var unEmploymentInsurance = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 3) / 100;
|
||||
employeeDetailsForInsuranceObj.UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance);
|
||||
|
||||
employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous = employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous;
|
||||
@@ -2195,7 +2202,119 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
public double GetMonthlyBaseYear(double dayliBase, int countWorkingDays)
|
||||
{
|
||||
double res =GetRoundValue(dayliBase * countWorkingDays);
|
||||
double res = GetRoundValue(dayliBase * countWorkingDays);
|
||||
return res;
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
|
||||
|
||||
|
||||
public async Task<OperationResult> ConfirmInsuranceOperation(InsuranceListConfirmOperation command)
|
||||
{
|
||||
// Improved version of the ConfirmInsuranceOperation method's main logic
|
||||
async Task<long> CreateMediaAsync(InsuranceList insuranceList, string insuranceType, IFormFile file)
|
||||
{
|
||||
var path = Path.Combine(_mediaRepository.BasePath, "InsuranceList", $"{insuranceList.Year}_{insuranceList.Month}", insuranceList.id.ToString());
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
string uniqueFileName = $"{insuranceType}_{Path.GetFileNameWithoutExtension(file.FileName)}_{DateTime.Now.Ticks}{Path.GetExtension(file.FileName)}";
|
||||
string filePath = Path.Combine(path, uniqueFileName);
|
||||
|
||||
await using (var stream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
await file.CopyToAsync(stream);
|
||||
}
|
||||
var type = Path.GetExtension(filePath);
|
||||
var media = new Media(filePath, type, "فایل", "InsuranceList");
|
||||
await _mediaRepository.CreateAsync(media);
|
||||
await _mediaRepository.SaveChangesAsync();
|
||||
return media.id;
|
||||
}
|
||||
|
||||
var op = new OperationResult();
|
||||
var insuranceList = _insuranceListRepositpry.Get(command.InsuranceListId);
|
||||
if (insuranceList == null)
|
||||
return op.Failed("لیست بیمه پیدا نشد");
|
||||
|
||||
bool completeDebt = false, completeInspection = false, completeApproval = false;
|
||||
|
||||
// Debt Section
|
||||
if (command.Debt.Type != InsuranceListDebtType.None)
|
||||
{
|
||||
var debt = command.Debt;
|
||||
if (string.IsNullOrWhiteSpace(debt.DebtDate))
|
||||
return op.Failed("لطفا تاریخ بدهی را وارد کنید");
|
||||
if (!debt.DebtDate.TryToGeorgianDateTime(out var debtDateGr))
|
||||
return op.Failed("تاریخ بدهی نامعتبر است");
|
||||
|
||||
if (debt.DebtFile is not { Length: > 0 })
|
||||
return op.Failed("لطفا فایل بدهی را وارد کنید");
|
||||
|
||||
if (debt.DebtFile.Length > 20_000_000)
|
||||
return op.Failed("حجم فایل نمیتواند از 20 مگابایت بیشتر باشد");
|
||||
|
||||
var debtAmount = debt.Amount.MoneyToDouble();
|
||||
if (debtAmount <= 0)
|
||||
return op.Failed("مبلغ بدهی نامعتبر است");
|
||||
|
||||
var mediaId = await CreateMediaAsync(insuranceList, "debt", debt.DebtFile);
|
||||
var debtEntity = new InsuranceListDebt(debt.Type, debtDateGr, debtAmount, mediaId);
|
||||
insuranceList.SetDebt(debtEntity);
|
||||
completeDebt = true;
|
||||
}
|
||||
|
||||
// Inspection Section
|
||||
if (command.Inspection.Type != InsuraceListInspectionType.None)
|
||||
{
|
||||
var inspection = command.Inspection;
|
||||
if (string.IsNullOrWhiteSpace(inspection.LastInspectionDate))
|
||||
return op.Failed("لطفا تاریخ بازرسی را وارد کنید");
|
||||
|
||||
if (!inspection.LastInspectionDate.TryToGeorgianDateTime(out var inspectionDateGr))
|
||||
return op.Failed("تاریخ بازرسی نامعتبر است");
|
||||
|
||||
if (inspection.InspectionFile is not { Length: > 0 })
|
||||
return op.Failed("لطفا فایل بازرسی را وارد کنید");
|
||||
|
||||
if (inspection.InspectionFile.Length > 20_000_000)
|
||||
return op.Failed("حجم فایل نمیتواند از 20 مگابایت بیشتر باشد");
|
||||
|
||||
var mediaId = await CreateMediaAsync(insuranceList, "inspection", inspection.InspectionFile);
|
||||
var inspectionEntity = new InsuranceListInspection(inspection.Type, inspectionDateGr, mediaId);
|
||||
insuranceList.SetInspection(inspectionEntity);
|
||||
completeInspection = true;
|
||||
}
|
||||
|
||||
// Approval Section
|
||||
if (command.Approval.ApprovalStatus != InsuranceListEmployerApprovalStatus.None)
|
||||
{
|
||||
var approval = command.Approval;
|
||||
if (approval.ApprovalStatus == InsuranceListEmployerApprovalStatus.VerbalApproval)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(approval.Description))
|
||||
return op.Failed("لطفا توضیحات را وارد کنید");
|
||||
|
||||
if (approval.Description.Length < 15)
|
||||
return op.Failed("توضیحات باید حداقل 15 کاراکتر باشد");
|
||||
}
|
||||
var approvalEntity = new InsuranceListEmployerApproval(approval.ApprovalStatus, approval.Description);
|
||||
insuranceList.SetEmployerApproval(approvalEntity);
|
||||
completeApproval = true;
|
||||
}
|
||||
|
||||
// Final Confirmation
|
||||
if (command.ConfirmSentList)
|
||||
{
|
||||
if (!(completeApproval && completeDebt && completeInspection))
|
||||
return op.Failed("تا زمانی که تمامی بخش ها پر نشده باشد نمیتوانید لیست را ارسال کنید");
|
||||
|
||||
insuranceList.SetConfirmSentlist(true);
|
||||
}
|
||||
|
||||
await _insuranceListRepositpry.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user