chnage GetInsuranceLeft
This commit is contained in:
@@ -31,4 +31,14 @@ public interface ILeftWorkInsuranceRepository : IRepository<long, LeftWorkInsura
|
||||
OperationResult CheckEditLeftWorkInsurance(long workshopId, long employeeId, DateTime date, int type);
|
||||
OperationResult CheckBeforeSaveLeftWorkInsurance(long workshopId, long employeeId, DateTime toGeorgianDateTime, int type);
|
||||
int TotalWorkingYears(long employeeId, long workshopId, DateTime startDate);
|
||||
|
||||
#region Insurance
|
||||
/// <summary>
|
||||
/// دریافت ترک کار بیمه با آی دی کارگاه
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -51,7 +51,14 @@ public interface IYearlySalaryRepository : IRepository<long, YearlySalary>
|
||||
Task<HolidayApiVewModel> HolidayGregorian(DateTime gregorianDate);
|
||||
Task<HolidayApiVewModel> HolidayShamsi(string shamsiDate);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region Insurance
|
||||
|
||||
InsuranceYearlySalaryModel GetInsuranceItems(DateTime startDate, DateTime endDate, string year);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -31,4 +31,14 @@ public interface ILeftWorkInsuranceApplication
|
||||
OperationResult CheckEditLeftWorkInsurance(long workshopId, long employeeId, string date, int type);
|
||||
|
||||
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);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -19,4 +19,10 @@ public interface IYearlySalaryApplication
|
||||
|
||||
Task<HolidayApiVewModel> HolidayGregorian(DateTime gregorianDate);
|
||||
Task<HolidayApiVewModel> HolidayShamsi(string shamsiDate);
|
||||
|
||||
#region Insurance
|
||||
|
||||
InsuranceYearlySalaryModel GetInsuranceItems(DateTime startDate, DateTime endDate, string year);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.YearlySalary;
|
||||
|
||||
public class InsuranceYearlySalaryModel
|
||||
{
|
||||
public double DayliWage { get; set; }
|
||||
public double HousingAllowance { get; set; }
|
||||
public double ConsumableItems { get; set; }
|
||||
public double MarriedAllowance { get; set; }
|
||||
|
||||
}
|
||||
@@ -381,42 +381,30 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
// اگر در این سال و ماه برای این کارگاه لیست بیمه ایجاد نشده بود
|
||||
if (!_insuranceListRepositpry.Exists(x =>x.Year == searchModel.Year && x.Month == searchModel.Month && searchModel.WorkshopIds.Contains(x.WorkshopId)))
|
||||
{
|
||||
List<EmployeeDetailsForInsuranceListViewModel> list = new List<EmployeeDetailsForInsuranceListViewModel>();
|
||||
|
||||
// شروع بکار و ترک کار بیمه
|
||||
var leftWorkInsuranceViewModelList =_leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModel);
|
||||
DateTime startdateGr = (searchModel.Year + "/" + searchModel.Month + "/01").ToGeorgianDateTime();
|
||||
DateTime endDateGr = (searchModel.Year + "/" + searchModel.Month + "/01").FindeEndOfMonth().ToGeorgianDateTime();
|
||||
|
||||
int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count();
|
||||
List<EmployeeDetailsForInsuranceListViewModel> list = new List<EmployeeDetailsForInsuranceListViewModel>();
|
||||
|
||||
// شروع بکار و ترک کار بیمه
|
||||
var leftWorkInsuranceViewModel = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModel);
|
||||
var leftWorkInsuranceViewModelList = _leftWorkInsuranceApplication.GetInsuranceleftWorks(workshopId, startdateGr, endDateGr);
|
||||
//int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count();
|
||||
|
||||
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
|
||||
string endMonthCurrent = startMonthCurrent.FindeEndOfMonth();
|
||||
|
||||
var model = new YearlySalarySearchModel();
|
||||
var startDate = startMonthCurrent.ToGeorgianDateTime();
|
||||
var endDate = endMonthCurrent.ToGeorgianDateTime();
|
||||
model.StartDateGr = startDate;
|
||||
model.EndDateGr = endMonthCurrent.ToGeorgianDateTime();
|
||||
model.year = searchModel.Year;
|
||||
|
||||
|
||||
//مقادیر سالانه این تاریخ
|
||||
var yearSalaryObj = _yearlySalaryApplication.GetDetailsBySearchModel(model);
|
||||
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDate, endDate, searchModel.Year);
|
||||
|
||||
var yearlysalaryItem = new YearlysalaryItemViewModel();
|
||||
var housingAllowance = new YearlysalaryItemViewModel();
|
||||
var consumableItems = new YearlysalaryItemViewModel();
|
||||
var maritalStatus = new YearlysalaryItemViewModel();
|
||||
if (yearSalaryObj != null)
|
||||
{
|
||||
yearlysalaryItem = _yearlySalaryItemApplication.GetItemsByYearlySalaryId(yearSalaryObj.Id)
|
||||
.Where(x => x.ItemName == "مزد روزانه").FirstOrDefault();
|
||||
housingAllowance = _yearlySalaryItemApplication.GetItemsByYearlySalaryId(yearSalaryObj.Id)
|
||||
.Where(x => x.ItemName == "کمک هزینه مسکن").FirstOrDefault();
|
||||
consumableItems = _yearlySalaryItemApplication.GetItemsByYearlySalaryId(yearSalaryObj.Id)
|
||||
.Where(x => x.ItemName == "کمک هزینه اقلام").FirstOrDefault();
|
||||
maritalStatus = _yearlySalaryItemApplication.GetItemsByYearlySalaryId(yearSalaryObj.Id)
|
||||
.Where(x => x.ItemName == "حق تاهل").FirstOrDefault();
|
||||
|
||||
}
|
||||
|
||||
foreach (var item in leftWorkInsuranceViewModelList)
|
||||
{
|
||||
@@ -425,7 +413,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var employeeDetailsForInsuranceObj = new EmployeeDetailsForInsuranceListViewModel();
|
||||
employeeDetailsForInsuranceObj.HasConfilictJobs = false;
|
||||
|
||||
employeeDetailsForInsuranceObj.IsMaritalStatusSet = // آیا وضعیت تاهل پرسنل ست شده است
|
||||
// آیا وضعیت تاهل پرسنل ست شده است
|
||||
employeeDetailsForInsuranceObj.IsMaritalStatusSet =
|
||||
!string.IsNullOrWhiteSpace(employeeObject.MaritalStatus);
|
||||
//دزیافت اطلاعات هویتی پرسنل
|
||||
//در صورت نداشن دیتا از جدول پرسنل پر می شود
|
||||
@@ -593,17 +582,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, workshopId,item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId));
|
||||
employeeDetailsForInsuranceObj.HasConfilictJobs = (dailyWage == 0 ? true : false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (yearlysalaryItem != null)
|
||||
if (yearlysaleries != null)
|
||||
{
|
||||
if(!searchModel.FixedSalary )
|
||||
{
|
||||
//dailyWage= yearlysalaryItem.ItemValue;
|
||||
dailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId,item.WorkshopId, searchModel.Year) ;
|
||||
dailyWage = ComputeDailyWage(yearlysaleries.DayliWage, item.EmployeeId,workshopId, searchModel.Year) ;
|
||||
//(double basic, int totalYears) basicResult = BasicYear(item.EmployeeId, workshopId, startDate);
|
||||
//var basic = basicResult.basic;
|
||||
|
||||
@@ -618,10 +607,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
employeeDetailsForInsuranceObj.DailyWageStr = employeeDetailsForInsuranceObj.DailyWage.ToMoney();
|
||||
employeeDetailsForInsuranceObj.DailyWagePlusBaseYears = "0";
|
||||
employeeDetailsForInsuranceObj.MonthlySalary = GetRoundValue(dailyWage * countWorkingDays);
|
||||
employeeDetailsForInsuranceObj.HousingAllowance = housingAllowance.ItemValue;
|
||||
employeeDetailsForInsuranceObj.ConsumableItems = consumableItems.ItemValue;
|
||||
employeeDetailsForInsuranceObj.HousingAllowance = yearlysaleries.HousingAllowance;
|
||||
employeeDetailsForInsuranceObj.ConsumableItems = yearlysaleries.ConsumableItems;
|
||||
employeeDetailsForInsuranceObj.EndMonthCurrentDay = endMonthCurrentDay;
|
||||
employeeDetailsForInsuranceObj.YearlySalaryItem = yearlysalaryItem.ItemValue;
|
||||
employeeDetailsForInsuranceObj.YearlySalaryItem = yearlysaleries.DayliWage;
|
||||
employeeDetailsForInsuranceObj.MonthlyBaseYearsStr = monthlybaseYear.ToMoney();
|
||||
|
||||
|
||||
@@ -630,8 +619,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
if (item.IncludeStatus)
|
||||
{
|
||||
var marital = employeeObject.MaritalStatus == "متاهل" ? maritalStatus.ItemValue : 0;
|
||||
employeeDetailsForInsuranceObj.MonthlyBenefits = GetMonthlyBenefits(endMonthCurrentDay, consumableItems.ItemValue, housingAllowance.ItemValue, marital, countWorkingDays);
|
||||
var marital = employeeObject.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0;
|
||||
employeeDetailsForInsuranceObj.MonthlyBenefits = GetMonthlyBenefits(endMonthCurrentDay, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marital, countWorkingDays);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -693,7 +682,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
result.EmployeeDetailsForInsuranceList = list;
|
||||
result.IsExist = false;
|
||||
result.IsBlock = isBolock;
|
||||
result.MaritalStatus = maritalStatus.ItemValue;
|
||||
result.MaritalStatus = yearlysaleries.MarriedAllowance;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -447,30 +447,17 @@ public class LeftWorkInsuranceApplication : ILeftWorkInsuranceApplication
|
||||
public List<LeftWorkInsuranceViewModel> SearchForCreateInsuranceList(
|
||||
EmployeeForCreateInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var resultList = new List<LeftWorkInsuranceViewModel>();
|
||||
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
|
||||
var resultList = new List<LeftWorkInsuranceViewModel>();
|
||||
var leftWorkInsuranceList = _leftWorkInsuranceRepository.SearchForCreateInsuranceList(searchModel);
|
||||
|
||||
//foreach (var item in leftWorkInsuranceList)
|
||||
//{
|
||||
// item.StartWorkDate = item.StartWorkDateGr.ToFarsi();
|
||||
// if (item.LeftWorkDateGr != null)
|
||||
// {
|
||||
// item.LeftWorkDate = item.LeftWorkDateGr.ToFarsi();
|
||||
// item.EndWorkDate = GetBeforeDate(item.LeftWorkDate);
|
||||
// item.IsActiveWorkshop = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.IsActiveWorkshop = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
//انتخاب ماه و سال برای ثبت بیمه اجباری است
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month))
|
||||
{
|
||||
string yearAndMonth = searchModel.Year + "/" + searchModel.Month;
|
||||
|
||||
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
|
||||
|
||||
// string endMonthCurrent = searchModel.Year + "/" + searchModel.Month + startMonthCurrent.FindeEndOfMonth();
|
||||
|
||||
var year = Convert.ToInt32(searchModel.Year);
|
||||
@@ -619,4 +606,15 @@ public class LeftWorkInsuranceApplication : ILeftWorkInsuranceApplication
|
||||
return _leftWorkInsuranceRepository.CheckBeforeSaveLeftWorkInsurance(workshopId, employeeId, date.ToGeorgianDateTime(), type);
|
||||
|
||||
}
|
||||
|
||||
#region Insurance
|
||||
|
||||
public List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
return _leftWorkInsuranceRepository.GetInsuranceleftWorks(workshopId, startDate, endDate);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
@@ -148,4 +148,19 @@ public class YearlySalaryApplication : IYearlySalaryApplication
|
||||
{
|
||||
return _yearlySalaryRepository.HolidayShamsi(shamsiDate);
|
||||
}
|
||||
|
||||
#region Insurance
|
||||
/// <summary>
|
||||
/// دریافت مقادیر برای استفاده در بیمه
|
||||
/// </summary>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <returns></returns>
|
||||
public InsuranceYearlySalaryModel GetInsuranceItems(DateTime startDate, DateTime endDate, string year)
|
||||
{
|
||||
return _yearlySalaryRepository.GetInsuranceItems(startDate, endDate, year);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using Company.Domain.PersonnelCodeAgg;
|
||||
using CompanyManagment.App.Contracts.InsuranceList;
|
||||
using CompanyManagment.App.Contracts.LeftWorkInsurance;
|
||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -691,4 +692,98 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region Insurance
|
||||
|
||||
public List<EmployeeDetailsForInsuranceListViewModel> GetInsuranceleftWorks(long workshopId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (workshopId == 0)
|
||||
return [];
|
||||
var query = _context.LeftWorkInsuranceList.Include(x => x.Employee)
|
||||
.Where(x => x.WorkshopId == workshopId)
|
||||
.Where(x =>
|
||||
((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) &&
|
||||
((DateTime)x.LeftWorkDate >= startDate &&
|
||||
(DateTime)x.LeftWorkDate <= endDate)) ||
|
||||
((x.LeftWorkDate != null && x.LeftWorkDate != DateTime.MinValue) &&
|
||||
(DateTime)x.LeftWorkDate >= endDate) ||
|
||||
(x.LeftWorkDate == null || x.LeftWorkDate == DateTime.MinValue))
|
||||
.Where(x => x.StartWorkDate <= endDate)
|
||||
.Join(_context.Jobs,
|
||||
left => left.JobId,
|
||||
job => job.id,
|
||||
(left, job) => new { left, job })
|
||||
.Join(_context.InsuranceEmployeeInformationSet,
|
||||
result => result.left.EmployeeId,
|
||||
employeeInfo => employeeInfo.EmployeeId,
|
||||
(result, employeeInfo) => new
|
||||
{
|
||||
result.left,
|
||||
result.job,
|
||||
employeeInfo
|
||||
|
||||
}
|
||||
|
||||
).Select(result => new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
StartWorkDateGr = result.left.StartWorkDate,
|
||||
LeftWorkDateGr = result.left.LeftWorkDate,
|
||||
|
||||
|
||||
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,
|
||||
|
||||
|
||||
|
||||
|
||||
}).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;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -3472,5 +3472,27 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Insurance
|
||||
|
||||
public InsuranceYearlySalaryModel GetInsuranceItems(DateTime startDate, DateTime endDate, string year)
|
||||
{
|
||||
var query = _context.YearlySalaries
|
||||
.Where(x => x.StartDate <= startDate && x.EndDate >= endDate && x.Year == year)
|
||||
.Include(x => x.YearlySalaryItemsList)
|
||||
.Select(x=> new InsuranceYearlySalaryModel
|
||||
{
|
||||
DayliWage = x.YearlySalaryItemsList.FirstOrDefault(item=>item.ItemName == "مزد روزانه").ItemValue,
|
||||
ConsumableItems = x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "کمک هزینه اقلام").ItemValue,
|
||||
HousingAllowance = x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "کمک هزینه مسکن").ItemValue,
|
||||
MarriedAllowance = x.YearlySalaryItemsList.Any(item => item.ItemName == "حق تاهل")? x.YearlySalaryItemsList.FirstOrDefault(item => item.ItemName == "حق تاهل").ItemValue : 0,
|
||||
|
||||
}).FirstOrDefault();
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user