Employer Confirm Insurance
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.InsuranceList;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.LeftWorkInsurance;
|
||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||
|
||||
@@ -40,5 +41,16 @@ public interface ILeftWorkInsuranceRepository : IRepository<long, LeftWorkInsura
|
||||
/// <returns></returns>
|
||||
List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceLeftWorksAndInformation(long workshopId, DateTime startDate, DateTime endDate);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
/// <summary>
|
||||
/// پرسنل هایی که در قرارداد ترک کار دارند ولی در بیمه ترک کاری برایشان نخورده
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
List<LeftWorkViewModel> GetEmployeesWithContractExitOnly(long workshopId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InsuranceList;
|
||||
|
||||
@@ -14,4 +15,8 @@ public class EditInsuranceList:CreateInsuranceList
|
||||
public string Population { get; set; }
|
||||
public long? InsuranceJobId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// پرسنل هایی که قرارداد ترک کار کرده اند ولی ترک کار بیمه ندارند
|
||||
/// </summary>
|
||||
public List<LeftWorkViewModel> LeftWorkEmployees { get; set; }
|
||||
}
|
||||
@@ -292,12 +292,12 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var consumableItems = 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();
|
||||
yearlysalaryItem = _yearlySalaryItemApplication
|
||||
.GetItemsByYearlySalaryId(yearSalaryObj.Id).FirstOrDefault(x => x.ItemName == "مزد روزانه");
|
||||
housingAllowance = _yearlySalaryItemApplication
|
||||
.GetItemsByYearlySalaryId(yearSalaryObj.Id).FirstOrDefault(x => x.ItemName == "کمک هزینه مسکن");
|
||||
consumableItems = _yearlySalaryItemApplication
|
||||
.GetItemsByYearlySalaryId(yearSalaryObj.Id).FirstOrDefault(x => x.ItemName == "کمک هزینه اقلام");
|
||||
}
|
||||
|
||||
foreach (var item in insuranceListDetails.EmployeeDetailsForInsuranceList)
|
||||
@@ -341,6 +341,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
insuranceListDetails.AllInsuredShare = insuranceListDetails.InsuredShare +
|
||||
insuranceListDetails.EmployerShare +
|
||||
insuranceListDetails.UnEmploymentInsurance;
|
||||
|
||||
insuranceListDetails.LeftWorkEmployees =
|
||||
_leftWorkInsuranceRepository.GetEmployeesWithContractExitOnly(insuranceListDetails.WorkshopId);
|
||||
|
||||
return insuranceListDetails;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Company.Domain.InsuranceListAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
using Company.Domain.PersonnelCodeAgg;
|
||||
using CompanyManagment.App.Contracts.InsuranceList;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.LeftWorkInsurance;
|
||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -25,15 +26,15 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
public EditLeftWorkInsurance GetDetails(long id)
|
||||
{
|
||||
return _context.LeftWorkInsuranceList.Select(x => new EditLeftWorkInsurance()
|
||||
{
|
||||
Id = x.id,
|
||||
LeftWorkDate = x.LeftWorkDate != null ? x.LeftWorkDate.ToFarsi() : "",
|
||||
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
WorkshopName = x.WorkshopName,
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId
|
||||
})
|
||||
{
|
||||
Id = x.id,
|
||||
LeftWorkDate = x.LeftWorkDate != null ? x.LeftWorkDate.ToFarsi() : "",
|
||||
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
WorkshopName = x.WorkshopName,
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
EmployeeId = x.EmployeeId,
|
||||
JobId = x.JobId,
|
||||
|
||||
}).Where(x=>x.WorkshopId == workshopId);
|
||||
}).Where(x => x.WorkshopId == workshopId);
|
||||
return query.ToList();
|
||||
}
|
||||
|
||||
@@ -108,10 +109,10 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
foreach (var item in query)
|
||||
{
|
||||
var jobObj = _context.Jobs.Where(x => x.id == item.JobId).FirstOrDefault();
|
||||
var insuranceListIds = _context.EmployeeInsurancListDataSet.Where(x => x.EmployeeId == searchModel.EmployeeId && (x.StartWorkDate == item.StartWorkDate ||x.LeftWorkDate==item.LeftWorkDate))
|
||||
.Select(x=>x.InsuranceListId).ToList();
|
||||
var hasInsuranceList = _context.InsuranceListSet.Any(x => insuranceListIds.Contains(x.id) && x.WorkshopId==item.WorkshopId);
|
||||
|
||||
var insuranceListIds = _context.EmployeeInsurancListDataSet.Where(x => x.EmployeeId == searchModel.EmployeeId && (x.StartWorkDate == item.StartWorkDate || x.LeftWorkDate == item.LeftWorkDate))
|
||||
.Select(x => x.InsuranceListId).ToList();
|
||||
var hasInsuranceList = _context.InsuranceListSet.Any(x => insuranceListIds.Contains(x.id) && x.WorkshopId == item.WorkshopId);
|
||||
|
||||
list.Add(new LeftWorkInsuranceViewModel()
|
||||
{
|
||||
Id = item.id,
|
||||
@@ -125,7 +126,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
EmployeeId = item.EmployeeId,
|
||||
JobId = item.JobId,
|
||||
IncludeStatus = item.IncludeStatus,
|
||||
JobName = jobObj!=null?jobObj.JobName:string.Empty,
|
||||
JobName = jobObj != null ? jobObj.JobName : string.Empty,
|
||||
JobCode = jobObj != null ? jobObj.JobCode : string.Empty,
|
||||
HasInsuranceList = hasInsuranceList,
|
||||
});
|
||||
@@ -142,14 +143,14 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
var item = _context.LeftWorkInsuranceList.FirstOrDefault(x=>x.id==id);
|
||||
if(item !=null)
|
||||
var item = _context.LeftWorkInsuranceList.FirstOrDefault(x => x.id == id);
|
||||
if (item != null)
|
||||
_context.LeftWorkInsuranceList.Remove(item);
|
||||
|
||||
|
||||
_context.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
public OperationResult RemoveAllLeftWorkInsurance(long workshopId, long employeeId)
|
||||
public OperationResult RemoveAllLeftWorkInsurance(long workshopId, long employeeId)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
@@ -161,8 +162,8 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
var insuranceList = _context.InsuranceListSet.Where(x => x.WorkshopId == workshopId).ToList();
|
||||
foreach (var item in insuranceList)
|
||||
{
|
||||
hasInsurance =_context.EmployeeInsurancListDataSet.Any(x => x.EmployeeId == employeeId && x.InsuranceListId==item.id);
|
||||
if(hasInsurance)
|
||||
hasInsurance = _context.EmployeeInsurancListDataSet.Any(x => x.EmployeeId == employeeId && x.InsuranceListId == item.id);
|
||||
if (hasInsurance)
|
||||
break;
|
||||
}
|
||||
//tempChange
|
||||
@@ -174,7 +175,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
if (list != null && list.Count > 0)
|
||||
_context.LeftWorkInsuranceList.RemoveRange(list);
|
||||
|
||||
bool hasLeftWork = _context.LeftWorkList.Any(x => x.EmployeeId == employeeId && x.WorkshopId==workshopId);
|
||||
bool hasLeftWork = _context.LeftWorkList.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
|
||||
if (!hasLeftWork)
|
||||
{
|
||||
var personelCodeList = _context.PersonnelCodeSet.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).ToList();
|
||||
@@ -186,8 +187,8 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
string Message = "";
|
||||
|
||||
if (hasLeftWork)
|
||||
{
|
||||
op.Message="حذف با موفقیت انجام شد." + "<br/>" + "<span class='text-warning'>" +"کد پرسنلی این شخص در این کارگاه به دلیل استفاده در ترک کار قرارداد قابل حذف نمی باشد. " + "</span>";
|
||||
{
|
||||
op.Message = "حذف با موفقیت انجام شد." + "<br/>" + "<span class='text-warning'>" + "کد پرسنلی این شخص در این کارگاه به دلیل استفاده در ترک کار قرارداد قابل حذف نمی باشد. " + "</span>";
|
||||
op.IsSuccedded = true;
|
||||
}
|
||||
else
|
||||
@@ -231,7 +232,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
|
||||
public List<LeftWorkInsuranceViewModel> SearchForCreateInsuranceList(EmployeeForCreateInsuranceListSearchModel searchModel)
|
||||
{
|
||||
List <LeftWorkInsuranceViewModel> listLeftWorkInsurance = new List<LeftWorkInsuranceViewModel>();
|
||||
List<LeftWorkInsuranceViewModel> listLeftWorkInsurance = new List<LeftWorkInsuranceViewModel>();
|
||||
// IQueryable<LeftWorkInsuranceViewModel> query;
|
||||
|
||||
//if (searchModel.WorkshopIds != null && searchModel.WorkshopIds.Count > 0)
|
||||
@@ -286,7 +287,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
leftWorkInsurance.EmployeeId = item.EmployeeId;
|
||||
leftWorkInsurance.IncludeStatus = item.IncludeStatus;
|
||||
leftWorkInsurance.JobId = item.JobId;
|
||||
leftWorkInsurance.JobName = job!=null?job.JobName:string.Empty;
|
||||
leftWorkInsurance.JobName = job != null ? job.JobName : string.Empty;
|
||||
leftWorkInsurance.JobCode = job != null ? job.JobCode : string.Empty;
|
||||
listLeftWorkInsurance.Add(leftWorkInsurance);
|
||||
}
|
||||
@@ -319,7 +320,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
public LeftWorkInsuranceViewModel GetLeftPersonelByWorkshopIdAndEmployeeId(long workshopId, long employeeId)
|
||||
{
|
||||
var leftWorkInsurance = new LeftWorkInsuranceViewModel();
|
||||
var leftWorkInsuranceObj = _context.LeftWorkInsuranceList.Where(x=>x.EmployeeId==employeeId && x.WorkshopId==workshopId).OrderByDescending(x=>x.id).FirstOrDefault();
|
||||
var leftWorkInsuranceObj = _context.LeftWorkInsuranceList.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).OrderByDescending(x => x.id).FirstOrDefault();
|
||||
|
||||
if (leftWorkInsuranceObj != null)
|
||||
{
|
||||
@@ -327,7 +328,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
leftWorkInsurance.LeftWorkDateGr = leftWorkInsuranceObj.LeftWorkDate;
|
||||
leftWorkInsurance.StartWorkDateGr = leftWorkInsuranceObj.StartWorkDate;
|
||||
|
||||
if(leftWorkInsuranceObj.LeftWorkDate!=null)
|
||||
if (leftWorkInsuranceObj.LeftWorkDate != null)
|
||||
leftWorkInsurance.LeftWorkDate = leftWorkInsuranceObj.LeftWorkDate.ToFarsi();
|
||||
|
||||
leftWorkInsurance.StartWorkDate = leftWorkInsuranceObj.StartWorkDate.ToFarsi();
|
||||
@@ -361,7 +362,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
var personelcode = command.PersonnelCodeList.Where(x => x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId).FirstOrDefault();
|
||||
if (personelcode != null)
|
||||
{
|
||||
if(_context.PersonnelCodeSet.Any(x=> x.WorkshopId == command.WorkshopId && x.PersonnelCode == personelcode.PersonnelCode))
|
||||
if (_context.PersonnelCodeSet.Any(x => x.WorkshopId == command.WorkshopId && x.PersonnelCode == personelcode.PersonnelCode))
|
||||
{
|
||||
op.Failed(" کد پرسنلی در کارگاه " + command.WorkshopName + " تکراری می باشد. ");
|
||||
}
|
||||
@@ -370,7 +371,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
{
|
||||
return op.Failed(" کد پرسنلی در کارگاه " + command.WorkshopName + "نامعتبر است.");
|
||||
}
|
||||
_context.PersonnelCodeSet.Add(new PersonnelCodeDomain(command.WorkshopId, command.EmployeeId, personelcode.PersonnelCode));
|
||||
_context.PersonnelCodeSet.Add(new PersonnelCodeDomain(command.WorkshopId, command.EmployeeId, personelcode.PersonnelCode));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -453,11 +454,11 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
|
||||
foreach (var removeItem in leftworkInsuranceList)
|
||||
{
|
||||
if(!item.LeftworkInsuranceViewModels.Any(x=>x.Id==removeItem.id))
|
||||
if (!item.LeftworkInsuranceViewModels.Any(x => x.Id == removeItem.id))
|
||||
removeList.Add(removeItem);
|
||||
}
|
||||
foreach (var item2 in item.LeftworkInsuranceViewModels)
|
||||
{
|
||||
{
|
||||
DateTime? left = null;
|
||||
if (!string.IsNullOrWhiteSpace(item2.LeftWorkDate))
|
||||
left = item2.LeftWorkDate.ToGeorgianDateTime();
|
||||
@@ -469,7 +470,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
var check = _context.LeftWorkInsuranceList.Any(x =>
|
||||
x.EmployeeId == item2.EmployeeId && x.WorkshopId == item2.WorkshopId &&
|
||||
x.StartWorkDate == start);
|
||||
|
||||
|
||||
if (!check)
|
||||
{
|
||||
|
||||
@@ -477,11 +478,11 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
employeeFullName, item2.WorkshopName, item2.JobId, item2.IncludeStatus);
|
||||
Create(leftworkInsuranceObj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var leftworkInsurance = _context.LeftWorkInsuranceList.Where(x => x.id==item2.Id)?.FirstOrDefault();
|
||||
var leftworkInsurance = _context.LeftWorkInsuranceList.Where(x => x.id == item2.Id)?.FirstOrDefault();
|
||||
leftworkInsurance.Edit(left, start, item2.WorkshopId, item2.EmployeeId, item2.JobId, item2.IncludeStatus);
|
||||
}
|
||||
}
|
||||
@@ -508,13 +509,13 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
|
||||
public OperationResult CheckDeleteLeftWorkInsurance(long workshopId, long employeeId, DateTime date, int type)
|
||||
{
|
||||
|
||||
|
||||
var op = new OperationResult();
|
||||
bool hasInsurance = false;
|
||||
var insuranceList = _context.InsuranceListSet.Where(x => x.WorkshopId == workshopId).ToList();
|
||||
foreach (var item in insuranceList)
|
||||
{
|
||||
if(type == 1)
|
||||
if (type == 1)
|
||||
hasInsurance = _context.EmployeeInsurancListDataSet.Any(x => x.EmployeeId == employeeId && x.InsuranceListId == item.id && x.StartWorkDate.Date >= date.Date && item.ConfirmSentlist);
|
||||
else
|
||||
hasInsurance = _context.EmployeeInsurancListDataSet.Any(x => x.EmployeeId == employeeId && x.InsuranceListId == item.id && (x.LeftWorkDate != null && ((DateTime)x.LeftWorkDate).Date == date.Date));
|
||||
@@ -555,7 +556,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
|
||||
insuranceList = _context.InsuranceListSet.Where(x => x.Year == year && x.Month == month && x.WorkshopId == workshopId).ToList();
|
||||
if (insuranceList != null && insuranceList.Count > 0)
|
||||
{
|
||||
{
|
||||
foreach (var item in insuranceList)
|
||||
{
|
||||
if (type == 1)
|
||||
@@ -587,7 +588,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,7 +659,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
{
|
||||
string resulDate = month.ToFarsiMonthByNumber() + " " + year;
|
||||
//tempChange
|
||||
// return op.Failed("در صورت تمایل به ثبت تاریخ ترک کار به کار این پرسنل می بایست لیست تنظیمی بیمه "+ resulDate + " را حذف نمایید.");
|
||||
// return op.Failed("در صورت تمایل به ثبت تاریخ ترک کار به کار این پرسنل می بایست لیست تنظیمی بیمه "+ resulDate + " را حذف نمایید.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,7 +671,7 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
{
|
||||
var lefts = _context.LeftWorkInsuranceList
|
||||
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartWorkDate < startDate)
|
||||
.OrderBy(x=>x.StartWorkDate)
|
||||
.OrderBy(x => x.StartWorkDate)
|
||||
.ToList();
|
||||
if (lefts.Count > 0)
|
||||
{
|
||||
@@ -689,74 +690,110 @@ public class LeftWorkInsuranceRepository : RepositoryBase<long, LeftWorkInsuranc
|
||||
}
|
||||
}
|
||||
|
||||
var sum = totalDays.Sum(x=>x);
|
||||
var sum = totalDays.Sum(x => x);
|
||||
return (sum / 365);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region Insurance
|
||||
|
||||
public List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceLeftWorksAndInformation(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 })
|
||||
.GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(),
|
||||
result => result.left.EmployeeId,
|
||||
employeeInfo => employeeInfo.EmployeeId,
|
||||
(result, employeeInfo) => new
|
||||
{
|
||||
result.left,
|
||||
result.job,
|
||||
employeeInfo
|
||||
})
|
||||
.SelectMany(x => x.employeeInfo.DefaultIfEmpty(), (x, employeeInfo) => new { x, employeeInfo })
|
||||
.Select(result => new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
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,
|
||||
|
||||
//اطلاعات هویتی
|
||||
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();
|
||||
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 })
|
||||
.GroupJoin(_context.InsuranceEmployeeInformationSet.AsSplitQuery(),
|
||||
result => result.left.EmployeeId,
|
||||
employeeInfo => employeeInfo.EmployeeId,
|
||||
(result, employeeInfo) => new
|
||||
{
|
||||
result.left,
|
||||
result.job,
|
||||
employeeInfo
|
||||
})
|
||||
.SelectMany(x => x.employeeInfo.DefaultIfEmpty(), (x, employeeInfo) => new { x, employeeInfo })
|
||||
.Select(result => new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
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,
|
||||
|
||||
return query;
|
||||
//اطلاعات هویتی
|
||||
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();
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
public List<LeftWorkViewModel> GetEmployeesWithContractExitOnly(long workshopId)
|
||||
{
|
||||
var leftWorkedEmployees = _context.LeftWorkList
|
||||
.Where(x => x.WorkshopId == workshopId)
|
||||
.GroupBy(x => x.EmployeeId)
|
||||
.Select(x => new
|
||||
{
|
||||
EmployeeId = x.Key,
|
||||
x.OrderByDescending(s => s.StartWorkDate).FirstOrDefault().LeftWorkDate
|
||||
}).Where(x => x.LeftWorkDate != new DateTime(2121, 3, 21))
|
||||
.ToList();
|
||||
|
||||
var leftWorkEmployeeIds = leftWorkedEmployees.Select(x => x.EmployeeId);
|
||||
|
||||
var insuranceLeftWorkWithContractExitOnly = _context.LeftWorkInsuranceList.Where(x =>
|
||||
x.WorkshopId == workshopId && leftWorkEmployeeIds.Contains(x.EmployeeId) && x.LeftWorkDate == null).ToList()
|
||||
.Select(x =>
|
||||
{
|
||||
var employee = leftWorkedEmployees.First(l => l.EmployeeId == x.EmployeeId);
|
||||
return new LeftWorkViewModel()
|
||||
{
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId,
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
LeftWorkDate = employee.LeftWorkDate.ToFarsi(),
|
||||
LeftWorkDateGr = employee.LeftWorkDate
|
||||
};
|
||||
});
|
||||
|
||||
return insuranceLeftWorkWithContractExitOnly.ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user