This commit is contained in:
SamSys
2025-01-29 20:49:57 +03:30
parent bf0d6c6796
commit df6465c35d
9 changed files with 202 additions and 88 deletions

View File

@@ -33,11 +33,78 @@ public static class Tools
public static string[] DayNamesG = { "یکشنبه", "دو شنبه", "سه شنبه", "چهار شنبه", "پنج شنبه", "جمعه", "شنبه" };
/// <summary>
/// محاسبه سن
/// دریافت روزهای کارکرد پرسنل در لیست بیمه ماه مشخص شده
/// با کمک شروع بکار و ترک کار
/// </summary>
/// <param name="startWork"></param>
/// <param name="leftWork"></param>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <param name="employeeId"></param>
/// <returns></returns>
public static (int countWorkingDays,DateTime startWork,DateTime endWork,bool hasStartWorkInMonth,bool hasLeftWorkInMonth) GetEmployeeInsuranceWorkingDays(DateTime startWork,DateTime? leftWork,DateTime startDate,
DateTime endDate,long employeeId)
{
DateTime start = startDate;
DateTime end = endDate;
bool startWorkInMonth = false;
bool endWorkInMonth = false;
//اگر شروع بکار پرسنل در ماه مشخص شده لیست بیمه بود
if (startWork >= startDate)
{
start = startWork;
startWorkInMonth = true;
}
//اگر ترک کار پرسنل در ماه مشخص شده لیست بیمه بود
if (leftWork != null && leftWork.Value <= endDate)
{
end = leftWork.Value;
endWorkInMonth = true;
}
int countDays = (int)(end - start).TotalDays +1;
//روزهای کارکرد پرسنل با آی دی های زیر دستی تعریف شد
switch (employeeId)
{
//case 3812://ثابت- کسری حاجی پور
// countWorkingDays = 15;
// break;
case 40463://ثابت
countDays = 10;
break;
case 40469://ثابت
countDays = 7;
break;
case 9950://ثابت
countDays = 15;
break;
case 9640://ثابت
countDays = 15;
break;
case 40998://ثابت
countDays = 15;
break;
case 6219://ثابت
countDays = 15;
break;
//case 7897://ثابت
// countWorkingDays = 15;
}
return (countDays,start,end,startWorkInMonth,endWorkInMonth);
}
/// <summary>
/// محاسبه سن
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
public static (int yearCount, int monthCount, int dayCount) GetAge(DateTime startDate, DateTime endDate)
{

View File

@@ -35,6 +35,11 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
/// <returns></returns>
public List<InsuranceListViewModel> OptimizedSearch(InsuranceListSearchModel searchModel);
/// <summary>
/// محاسبه پایه سنوات بیمه برای پرسنل
/// </summary>
/// <returns></returns>
(int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay, DateTime listStartDate, DateTime endDate);
#endregion
#region client

View File

@@ -34,11 +34,11 @@ public interface ILeftWorkInsuranceRepository : IRepository<long, LeftWorkInsura
#region Insurance
/// <summary>
/// دریافت ترک کار بیمه با آی دی کارگاه
/// دریافت شروع و ترک کار بیمه پرسنل و اطلاعات هویتی آن
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate);
List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceLeftWorksAndInformation(long workshopId, DateTime startDate, DateTime endDate);
#endregion
}

View File

@@ -183,7 +183,11 @@ public class EmployeeDetailsForInsuranceListViewModel
public string JobCode { get; set; }
public double HousingAllowance { get; set; }
public double ConsumableItems { get; set; }
public double MaritalStatus { get; set; }
/// <summary>
/// وضعیت تاهل
/// </summary>
public string MaritalStatus { get; set; }
public bool IsMaritalStatusSet { get; set; }
public int EndMonthCurrentDay { get; set; }
public double SumOfDailyWage { get; set; }
@@ -195,6 +199,9 @@ public class EmployeeDetailsForInsuranceListViewModel
public bool HasLeftWorkInMonth { get; set; }
public bool HasStartWorkInMonth { get; set; }
public long EmployeeInsurancListDataId { get; set; }
/// <summary>
/// مشمول مزیا - عدم مشمول مزایا
/// </summary>
public bool IncludeStatus { get; set; }
/// <summary>
@@ -236,7 +243,7 @@ public class EmployeeDetailsForInsuranceListViewModel
/// حق تاهل
/// DSW_SPOUSE
/// </summary>
public string MarriedAllowance { get; set; }
public double MarriedAllowance { get; set; }
///// <summary>
///// مجموع پایه سنواتی کارکنان
///// DSK_INC

View File

@@ -32,13 +32,13 @@ public interface ILeftWorkInsuranceApplication
OperationResult CheckBeforeSaveLeftWorkInsurance(long workshopId, long employeeId, string date, int type);
#region Insurance
/// <summary>
/// دریافت ترک کار بیمه با آی دی کارگاه
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate);
#region Insurance
/// <summary>
/// دریافت شروع و ترک کار بیمه پرسنل و اطلاعات هویتی آن
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceLeftWorksAndInformation(long workshopId, DateTime startDate, DateTime endDate);
#endregion
}

View File

@@ -8,6 +8,7 @@ using Company.Domain.DateSalaryAgg;
using Company.Domain.DateSalaryItemAgg;
using Company.Domain.EmployeeAgg;
using Company.Domain.EmployeeChildrenAgg;
using Company.Domain.empolyerAgg;
using Company.Domain.InsuranceEmployeeInfoAgg;
using Company.Domain.InsuranceJobItemAgg;
using Company.Domain.InsuranceListAgg;
@@ -371,7 +372,7 @@ public class InsuranceListApplication: IInsuranceListApplication
public MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList( EmployeeForCreateInsuranceListSearchModel searchModel)
{
var watch = new Stopwatch();
watch.Start();
var result = new MainEmployeeDetailsViewModel();
var workshopId = searchModel.WorkshopIds.FirstOrDefault();
//var employerId = _workShopRepository.GetDetails(workshopId).EmployerIdList.FirstOrDefault();
@@ -379,19 +380,74 @@ public class InsuranceListApplication: IInsuranceListApplication
var isBolock = _contractingPartyApp.IsBlockCheckByWorkshopId(workshopId);
double monthlybaseYear = 0;
// اگر در این سال و ماه برای این کارگاه لیست بیمه ایجاد نشده بود
if (!_insuranceListRepositpry.Exists(x =>x.Year == searchModel.Year && x.Month == searchModel.Month && searchModel.WorkshopIds.Contains(x.WorkshopId)))
if (!_insuranceListRepositpry.Exists(x =>
x.Year == searchModel.Year && x.Month == searchModel.Month &&
searchModel.WorkshopIds.Contains(x.WorkshopId)))
{
DateTime startdateGr = (searchModel.Year + "/" + searchModel.Month + "/01").ToGeorgianDateTime();
DateTime endDateGr = (searchModel.Year + "/" + searchModel.Month + "/01").FindeEndOfMonth().ToGeorgianDateTime();
DateTime startDateGr = (searchModel.Year + "/" + searchModel.Month + "/01").ToGeorgianDateTime();
DateTime endDateGr = (searchModel.Year + "/" + searchModel.Month + "/01").FindeEndOfMonth()
.ToGeorgianDateTime();
List<EmployeeDetailsForInsuranceListViewModel> list = new List<EmployeeDetailsForInsuranceListViewModel>();
List<EmployeeDetailsForInsuranceListViewModel> list = new List<EmployeeDetailsForInsuranceListViewModel>();
//مقادیر سالانه این تاریخ
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, searchModel.Year);
// شروع بکار و ترک کار بیمه
var leftWorkInsuranceViewModel = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModel);
var leftWorkInsuranceViewModelList = _leftWorkInsuranceApplication.GetInsuranceleftWorks(workshopId, startdateGr, endDateGr);
// دریافت اطلاعات هویتی و شروع و ترک کار کارکنان
var employeesInfoAndLeftWorks =
_leftWorkInsuranceApplication.GetEmployeeInsuranceLeftWorksAndInformation(workshopId, startDateGr,
endDateGr);
watch.Start();
var computeResult = employeesInfoAndLeftWorks.Select(employee =>
{
var dateOfBirth = employee.DateOfBirthGr.ToFarsi();
var dateOfIssue = employee.DateOfIssueGr.ToFarsi();
var leftDate = employee.LeftWorkDateGr != null ? employee.LeftWorkDateGr.Value.AddDays(-1) : new DateTime();
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr,endDateGr, employee.EmployeeId);
//به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
var dailyWage = searchModel.FixedSalary ?
Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, workshopId, employee.EmployeeId, startDateGr, endDateGr, employee.JobId, searchModel.Population, searchModel.InsuranceJobId))
: ComputeDailyWage(yearlysaleries.DayliWage, employee.EmployeeId, workshopId, searchModel.Year);
return new EmployeeDetailsForInsuranceListViewModel
{
#region EmployeeInfo
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,
#endregion
#region Compute
IncludeStatus = employee.IncludeStatus,
DailyWage = GetRoundValue(dailyWage),
#endregion
};
});
Console.WriteLine("New Compute : " + watch.Elapsed);
watch.Stop();
watch.Start();
var leftWorkInsuranceViewModel = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModel);
//int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count();
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
string endMonthCurrent = startMonthCurrent.FindeEndOfMonth();
var model = new YearlySalarySearchModel();
@@ -402,11 +458,10 @@ public class InsuranceListApplication: IInsuranceListApplication
model.year = searchModel.Year;
//مقادیر سالانه این تاریخ
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDate, endDate, searchModel.Year);
foreach (var item in leftWorkInsuranceViewModelList)
foreach (var item in leftWorkInsuranceViewModel)
{
var employeeObject = _employeeRepository.GetDetailsByADDate(item.EmployeeId);
@@ -615,7 +670,7 @@ public class InsuranceListApplication: IInsuranceListApplication
employeeDetailsForInsuranceObj.MarriedAllowance = "0";
employeeDetailsForInsuranceObj.MarriedAllowance = 0;
if (item.IncludeStatus)
{
@@ -683,13 +738,14 @@ public class InsuranceListApplication: IInsuranceListApplication
result.IsExist = false;
result.IsBlock = isBolock;
result.MaritalStatus = yearlysaleries.MarriedAllowance;
}
Console.WriteLine("old heydari compute : " + watch.Elapsed);
}
else
{
result.IsExist = true;
result.IsBlock = isBolock;
}
Console.WriteLine("SearchEmployeeForCreateInsuranceList : " + watch.Elapsed);
return result;
}
@@ -1038,7 +1094,7 @@ public class InsuranceListApplication: IInsuranceListApplication
.Where(x => x.ItemName == "حق تاهل").FirstOrDefault();
item.HousingAllowance = housingAllowance.ItemValue;
item.ConsumableItems = consumableItems.ItemValue;
item.MaritalStatus = maritalStatus.ItemValue;
item.MarriedAllowance = maritalStatus.ItemValue;
item.YearlySalaryItem = yearlysalaryItem.ItemValue;
}

View File

@@ -609,9 +609,9 @@ public class LeftWorkInsuranceApplication : ILeftWorkInsuranceApplication
#region Insurance
public List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate)
public List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceLeftWorksAndInformation(long workshopId, DateTime startDate, DateTime endDate)
{
return _leftWorkInsuranceRepository.GetInsuranceleftWorks(workshopId, startDate, endDate);
return _leftWorkInsuranceRepository.GetEmployeeInsuranceLeftWorksAndInformation(workshopId, startDate, endDate);
}
#endregion

View File

@@ -1177,4 +1177,14 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
#endregion
public (int insuranceHistoryYearsCount, double baseYear) GetEmployeeInsuranceBaseYear(long employeeId, long workshopId, int countWorkingDay,DateTime listStartDate, DateTime endDate)
{
var lefts = _context.LeftWorkInsuranceList
.Where(x => x.EmployeeId == employeeId);
return (0, 0);
}
}

View File

@@ -695,7 +695,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
#region Insurance
public List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate)
public List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceLeftWorksAndInformation(long workshopId, DateTime startDate, DateTime endDate)
{
if (workshopId == 0)
return [];
@@ -713,7 +713,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
left => left.JobId,
job => job.id,
(left, job) => new { left, job })
.Join(_context.InsuranceEmployeeInformationSet,
.GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(),
result => result.left.EmployeeId,
employeeInfo => employeeInfo.EmployeeId,
(result, employeeInfo) => new
@@ -721,66 +721,35 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
result.left,
result.job,
employeeInfo
}
).Select(result => new EmployeeDetailsForInsuranceListViewModel
})
.SelectMany(x => x.employeeInfo.DefaultIfEmpty(), (x, employeeInfo) => new { x, employeeInfo })
.Select(result => new EmployeeDetailsForInsuranceListViewModel
{
StartWorkDateGr = result.left.StartWorkDate,
LeftWorkDateGr = result.left.LeftWorkDate,
StartWorkDateGr = result.x.left.StartWorkDate,
LeftWorkDateGr = result.x.left.LeftWorkDate,
IncludeStatus = result.x.left.IncludeStatus,
JobId = result.x.left.JobId,
JobName = result.x.job != null ? result.x.job.JobName : string.Empty,
JobCode = result.x.job != null ? result.x.job.JobCode : string.Empty,
InsuranceEmployeeInformationId = result.employeeInfo != null ? result.employeeInfo.id : 0,
EmployeeId = result.x.left.EmployeeId,
IncludeStatus = result.left.IncludeStatus,
JobId = result.left.JobId,
JobName = result.job != null ? result.job.JobName : string.Empty,
JobCode = result.job != null ? result.job.JobCode : string.Empty,
InsuranceEmployeeInformationId = result.employeeInfo.id,
EmployeeId = result.left.EmployeeId,
FName = result.employeeInfo != null ? result.employeeInfo.FName : result.left.Employee.FName,
LName = result.employeeInfo != null ? result.employeeInfo.LName : result.left.Employee.LName,
//اطلاعات هویتی
FName = result.employeeInfo != null ? result.employeeInfo.FName : result.x.left.Employee.FName,
LName = result.employeeInfo != null ? result.employeeInfo.LName : result.x.left.Employee.LName,
FatherName = result.employeeInfo != null ? result.employeeInfo.FatherName : result.x.left.Employee.FatherName,
DateOfBirthGr = result.employeeInfo != null ? result.employeeInfo.DateOfBirth : result.x.left.Employee.DateOfBirth,
DateOfIssueGr = result.employeeInfo != null ? result.employeeInfo.DateOfIssue : result.x.left.Employee.DateOfIssue,
PlaceOfIssue = result.employeeInfo != null ? result.employeeInfo.PlaceOfIssue : result.x.left.Employee.PlaceOfIssue,
IdNumber = result.employeeInfo != null ? result.employeeInfo.IdNumber : result.x.left.Employee.IdNumber,
Gender = result.employeeInfo != null ? result.employeeInfo.Gender : result.x.left.Employee.Gender,
NationalCode = result.x.left.Employee.NationalCode,
Nationality = result.x.left.Employee.Nationality,
InsuranceCode = result.x.left.Employee.InsuranceCode,
MaritalStatus = result.x.left.Employee.MaritalStatus,
IsMaritalStatusSet = !string.IsNullOrWhiteSpace(result.x.left.Employee.MaritalStatus)
}).ToList();
// FatherName = employeeInfoObject.FatherName
// DateOfBirth = employeeInfoObject.DateOfBirth
// DateOfIssue = employeeInfoObject.DateOfIssue
// DateOfBirthGr = employeeInfoObject.DateOfBirthGr
// DateOfIssueGr = employeeInfoObject.DateOfIssueGr
// PlaceOfIssue = employeeInfoObject.PlaceOfIssue
// IdNumber = employeeInfoObject.IdNumber
// Gender = employeeInfoObject.Gender
//LeftWorkInsuranceViewModel}
// {
// Id = left.id,
// //LeftWorkDate = left.LeftWorkDate != null ? left.LeftWorkDate.ToFarsi() : "",
// //StartWorkDate = left.StartWorkDate.ToFarsi(),
// StartWorkDateGr = left.StartWorkDate,
// LeftWorkDateGr = left.LeftWorkDate,
// EmployeeFullName = left.EmployeeFullName,
// WorkshopName = left.WorkshopName,
// WorkshopId = left.WorkshopId,
// EmployeeId = left.EmployeeId,
// IncludeStatus = left.IncludeStatus,
// JobId = left.JobId,
// JobName = job != null ? job.JobName : string.Empty,
// JobCode = job != null ? job.JobCode : string.Empty,
//});
return query;
}