|
|
|
@@ -7,6 +7,7 @@ using System.Linq;
|
|
|
|
using System.Reflection.Metadata.Ecma335;
|
|
|
|
using System.Reflection.Metadata.Ecma335;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using _0_Framework.Application;
|
|
|
|
using _0_Framework.Application;
|
|
|
|
|
|
|
|
using _0_Framework.Exceptions;
|
|
|
|
using _0_Framework.InfraStructure;
|
|
|
|
using _0_Framework.InfraStructure;
|
|
|
|
using Company.Domain.CheckoutAgg;
|
|
|
|
using Company.Domain.CheckoutAgg;
|
|
|
|
using Company.Domain.LeftWorkAgg;
|
|
|
|
using Company.Domain.LeftWorkAgg;
|
|
|
|
@@ -50,9 +51,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
private readonly IRollCallMandatoryRepository _rollCallMandatoryRepository;
|
|
|
|
private readonly IRollCallMandatoryRepository _rollCallMandatoryRepository;
|
|
|
|
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
|
|
|
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
|
|
|
|
|
|
|
|
|
|
|
public CheckoutRepository(IAuthHelper authHelper, CompanyContext context, IConfiguration configuration, ILeftWorkRepository leftWorkRepository, IWorkingHoursTempApplication workingHoursTempApplication, IRollCallRepository rollCallRepository, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallEmployeeRepository rollCallEmployeeRepository) : base(context)
|
|
|
|
public CheckoutRepository(IAuthHelper authHelper, CompanyContext context, IConfiguration configuration,
|
|
|
|
|
|
|
|
ILeftWorkRepository leftWorkRepository, IWorkingHoursTempApplication workingHoursTempApplication,
|
|
|
|
|
|
|
|
IRollCallRepository rollCallRepository, IRollCallMandatoryRepository rollCallMandatoryRepository,
|
|
|
|
|
|
|
|
IRollCallEmployeeRepository rollCallEmployeeRepository) : base(context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_authHelper = authHelper;
|
|
|
|
_authHelper = authHelper;
|
|
|
|
_context = context;
|
|
|
|
_context = context;
|
|
|
|
_configuration = configuration;
|
|
|
|
_configuration = configuration;
|
|
|
|
@@ -71,7 +74,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
/// <param name="سال به صورت رشته عددی"></param>
|
|
|
|
/// <param name="سال به صورت رشته عددی"></param>
|
|
|
|
/// <param name="ماه بصورت رشته عددی"></param>
|
|
|
|
/// <param name="ماه بصورت رشته عددی"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month)
|
|
|
|
public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double
|
|
|
|
|
|
|
|
Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var farisMonthName = Tools.ToFarsiMonthByNumber(month);
|
|
|
|
var farisMonthName = Tools.ToFarsiMonthByNumber(month);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -90,7 +94,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,res.YearsPay);
|
|
|
|
return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,
|
|
|
|
|
|
|
|
res.YearsPay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public EditCheckout GetDetails(long id)
|
|
|
|
public EditCheckout GetDetails(long id)
|
|
|
|
@@ -136,7 +141,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ContractEndGr = x.ContractEnd,
|
|
|
|
ContractEndGr = x.ContractEnd,
|
|
|
|
ContractStart = x.ContractStart.ToFarsi(),
|
|
|
|
ContractStart = x.ContractStart.ToFarsi(),
|
|
|
|
ContractEnd = x.ContractEnd.ToFarsi()
|
|
|
|
ContractEnd = x.ContractEnd.ToFarsi()
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.FirstOrDefault(x => x.Id == id);
|
|
|
|
.FirstOrDefault(x => x.Id == id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -152,7 +156,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
/// <param name="contractEnd"></param>
|
|
|
|
/// <param name="contractEnd"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
public async Task<CreateCheckoutListViewModel> GetContractResultToCreateCheckout(long workshopId, long employeeId, string year, string month, string contractStart,
|
|
|
|
public async Task<CreateCheckoutListViewModel> GetContractResultToCreateCheckout(long workshopId, long employeeId,
|
|
|
|
|
|
|
|
string year, string month, string contractStart,
|
|
|
|
string contractEnd)
|
|
|
|
string contractEnd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DateTime startSreach;
|
|
|
|
DateTime startSreach;
|
|
|
|
@@ -165,7 +170,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (month == "0" && year == "0")
|
|
|
|
if (month == "0" && year == "0")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DateTime now = DateTime.Now;
|
|
|
|
DateTime now = DateTime.Now;
|
|
|
|
@@ -195,8 +199,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
startSreach = startStr.ToGeorgianDateTime();
|
|
|
|
startSreach = startStr.ToGeorgianDateTime();
|
|
|
|
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
|
|
|
|
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var timer = new Stopwatch();
|
|
|
|
var timer = new Stopwatch();
|
|
|
|
timer.Start();
|
|
|
|
timer.Start();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -211,7 +215,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
contractWorkshop => contractWorkshop.contract.EmployeeId,
|
|
|
|
contractWorkshop => contractWorkshop.contract.EmployeeId,
|
|
|
|
employee => employee.id,
|
|
|
|
employee => employee.id,
|
|
|
|
(contractWorkshop, employee) => new { contractWorkshop, employee })
|
|
|
|
(contractWorkshop, employee) => new { contractWorkshop, employee })
|
|
|
|
.Join(_context.LeftWorkList.AsSplitQuery().Where(l => l.WorkshopId == workshopId && l.StartWorkDate < endSearch && l.LeftWorkDate > startSreach),
|
|
|
|
.Join(
|
|
|
|
|
|
|
|
_context.LeftWorkList.AsSplitQuery().Where(l =>
|
|
|
|
|
|
|
|
l.WorkshopId == workshopId && l.StartWorkDate < endSearch && l.LeftWorkDate > startSreach),
|
|
|
|
contractWorkshopEmployee => contractWorkshopEmployee.contractWorkshop.contract.EmployeeId,
|
|
|
|
contractWorkshopEmployee => contractWorkshopEmployee.contractWorkshop.contract.EmployeeId,
|
|
|
|
leftwork => leftwork.EmployeeId,
|
|
|
|
leftwork => leftwork.EmployeeId,
|
|
|
|
(contractWorkshopEmployee, leftwork) => new { contractWorkshopEmployee, leftwork })
|
|
|
|
(contractWorkshopEmployee, leftwork) => new { contractWorkshopEmployee, leftwork })
|
|
|
|
@@ -221,16 +227,15 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
personnelCode => personnelCode.EmployeeId,
|
|
|
|
personnelCode => personnelCode.EmployeeId,
|
|
|
|
(contractWorkshopEmployeeleftWork, personnelCode) =>
|
|
|
|
(contractWorkshopEmployeeleftWork, personnelCode) =>
|
|
|
|
new { contractWorkshopEmployeeleftWork, personnelCode })
|
|
|
|
new { contractWorkshopEmployeeleftWork, personnelCode })
|
|
|
|
|
|
|
|
|
|
|
|
.GroupJoin(_context.CheckoutSet.AsSplitQuery(),
|
|
|
|
.GroupJoin(_context.CheckoutSet.AsSplitQuery(),
|
|
|
|
contractWorkshopEmployeeleftWorkPersonnelCode => contractWorkshopEmployeeleftWorkPersonnelCode
|
|
|
|
contractWorkshopEmployeeleftWorkPersonnelCode => contractWorkshopEmployeeleftWorkPersonnelCode
|
|
|
|
.contractWorkshopEmployeeleftWork.contractWorkshopEmployee.contractWorkshop.contract.id,
|
|
|
|
.contractWorkshopEmployeeleftWork.contractWorkshopEmployee.contractWorkshop.contract.id,
|
|
|
|
checkout => checkout.ContractId,
|
|
|
|
checkout => checkout.ContractId,
|
|
|
|
(contractWorkshopEmployeeleftWorkPersonnelCode, checkout) =>
|
|
|
|
(contractWorkshopEmployeeleftWorkPersonnelCode, checkout) =>
|
|
|
|
new { contractWorkshopEmployeeleftWorkPersonnelCode, checkout })
|
|
|
|
new { contractWorkshopEmployeeleftWorkPersonnelCode, checkout })
|
|
|
|
|
|
|
|
|
|
|
|
.GroupJoin(_context.EmployeeComputeOptionsSet.Where(o => o.WorkshopId == workshopId),
|
|
|
|
.GroupJoin(_context.EmployeeComputeOptionsSet.Where(o => o.WorkshopId == workshopId),
|
|
|
|
x => x.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork.leftwork.EmployeeId,
|
|
|
|
x => x.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork.leftwork
|
|
|
|
|
|
|
|
.EmployeeId,
|
|
|
|
option => option.EmployeeId,
|
|
|
|
option => option.EmployeeId,
|
|
|
|
(x, options) => new { x.checkout, x.contractWorkshopEmployeeleftWorkPersonnelCode, options })
|
|
|
|
(x, options) => new { x.checkout, x.contractWorkshopEmployeeleftWorkPersonnelCode, options })
|
|
|
|
.SelectMany(
|
|
|
|
.SelectMany(
|
|
|
|
@@ -250,11 +255,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
DateTime currentStart = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
|
|
|
|
DateTime currentStart = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
|
|
|
|
DateTime currentEnd = ($"{DateTime.Now.ToFarsi().FindeEndOfMonth()}").ToGeorgianDateTime();
|
|
|
|
DateTime currentEnd = ($"{DateTime.Now.ToFarsi().FindeEndOfMonth()}").ToGeorgianDateTime();
|
|
|
|
|
|
|
|
|
|
|
|
var chekoutCreated = result.checkout.FirstOrDefault(x => x.ContractStart < endSearch && x.ContractEnd > startSreach && x.IsActiveString == "true");
|
|
|
|
var chekoutCreated = result.checkout.FirstOrDefault(x =>
|
|
|
|
|
|
|
|
x.ContractStart < endSearch && x.ContractEnd > startSreach && x.IsActiveString == "true");
|
|
|
|
|
|
|
|
|
|
|
|
if (chekoutCreated != null)
|
|
|
|
if (chekoutCreated != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new CreateCheckoutListViewModel
|
|
|
|
return new CreateCheckoutListViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = chekoutCreated.ContractId,
|
|
|
|
Id = chekoutCreated.ContractId,
|
|
|
|
@@ -273,6 +278,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
EmployeeHasCreateCheckout = true
|
|
|
|
EmployeeHasCreateCheckout = true
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var employeeJoin = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
var employeeJoin = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
.contractWorkshopEmployee.employee.id;
|
|
|
|
.contractWorkshopEmployee.employee.id;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -283,11 +289,13 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
var startStatusSearch = leftWork.StartWorkDate > startSreach && leftWork.StartWorkDate <= endSearch
|
|
|
|
var startStatusSearch = leftWork.StartWorkDate > startSreach && leftWork.StartWorkDate <= endSearch
|
|
|
|
? leftWork.StartWorkDate
|
|
|
|
? leftWork.StartWorkDate
|
|
|
|
: startSreach;
|
|
|
|
: startSreach;
|
|
|
|
var endStatusSearch = leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch
|
|
|
|
var endStatusSearch = leftWork.HasLeft && leftWork.LeftWorkDate > startSreach &&
|
|
|
|
|
|
|
|
leftWork.LeftWorkDate <= endSearch
|
|
|
|
? leftWork.LeftWorkDate.AddDays(-1)
|
|
|
|
? leftWork.LeftWorkDate.AddDays(-1)
|
|
|
|
: startSreach;
|
|
|
|
: startSreach;
|
|
|
|
bool hasRollCall =
|
|
|
|
bool hasRollCall =
|
|
|
|
_rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startStatusSearch, endStatusSearch);
|
|
|
|
_rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startStatusSearch,
|
|
|
|
|
|
|
|
endStatusSearch);
|
|
|
|
|
|
|
|
|
|
|
|
bool extension = true;
|
|
|
|
bool extension = true;
|
|
|
|
bool laterThanEnd = false;
|
|
|
|
bool laterThanEnd = false;
|
|
|
|
@@ -300,11 +308,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
.contractWorkshopEmployee.contractWorkshop.contract.ContarctStart;
|
|
|
|
.contractWorkshopEmployee.contractWorkshop.contract.ContarctStart;
|
|
|
|
var contractEndGr = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
var contractEndGr = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
.contractWorkshopEmployee.contractWorkshop.contract.ContractEnd;
|
|
|
|
.contractWorkshopEmployee.contractWorkshop.contract.ContractEnd;
|
|
|
|
|
|
|
|
|
|
|
|
#region HasRollCall
|
|
|
|
#region HasRollCall
|
|
|
|
|
|
|
|
|
|
|
|
if (hasRollCall)
|
|
|
|
if (hasRollCall)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// اگر ترک کار کرده بود
|
|
|
|
// اگر ترک کار کرده بود
|
|
|
|
// اگر ترک کارش در بازه انتخاب شده بود
|
|
|
|
// اگر ترک کارش در بازه انتخاب شده بود
|
|
|
|
if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch)
|
|
|
|
if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch)
|
|
|
|
@@ -322,7 +330,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
|
|
|
|
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -334,7 +341,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
|
|
|
|
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (endSearch < currentStart)
|
|
|
|
else if (endSearch < currentStart)
|
|
|
|
@@ -357,7 +363,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
|
|
|
|
contractEnd = leftWork.LeftWorkDate.AddDays(-1).ToFarsi();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (leftWork.HasLeft && leftWork.LeftWorkDate <= startSreach)
|
|
|
|
else if (leftWork.HasLeft && leftWork.LeftWorkDate <= startSreach)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -365,7 +370,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
extension = false;
|
|
|
|
extension = false;
|
|
|
|
description = "به دلیل ترک کار پیش از تاریخ انتخاب شده مجاز به ایجاد فیش نمی باشید";
|
|
|
|
description = "به دلیل ترک کار پیش از تاریخ انتخاب شده مجاز به ایجاد فیش نمی باشید";
|
|
|
|
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
|
|
|
|
leftWorkDate = leftWork.LeftWorkDate.ToFarsi();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!leftWork.HasLeft && startSreach == currentStart)
|
|
|
|
else if (!leftWork.HasLeft && startSreach == currentStart)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -376,13 +380,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
contractEnd = endSearch.ToFarsi();
|
|
|
|
contractEnd = endSearch.ToFarsi();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!leftWork.HasLeft && startSreach < currentStart)
|
|
|
|
else if (!leftWork.HasLeft && startSreach < currentStart)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contractStartGr <= startSreach && contractStartGr > endSearch)
|
|
|
|
if (contractStartGr <= startSreach && contractStartGr > endSearch)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
laterThanEnd = true;
|
|
|
|
laterThanEnd = true;
|
|
|
|
@@ -397,12 +397,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
contractStart = leftWork.StartWorkDate > startSreach
|
|
|
|
contractStart = leftWork.StartWorkDate > startSreach
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
? leftWork.StartWorkDate.ToFarsi()
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
: startSreach.ToFarsi();
|
|
|
|
contractEnd = (leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch) ? leftWork.LeftWorkDate.AddDays(-1).ToFarsi() : endSearch.ToFarsi();
|
|
|
|
contractEnd = (leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch)
|
|
|
|
|
|
|
|
? leftWork.LeftWorkDate.AddDays(-1).ToFarsi()
|
|
|
|
|
|
|
|
: endSearch.ToFarsi();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
@@ -468,13 +467,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
contractEnd = endSearch.ToFarsi();
|
|
|
|
contractEnd = endSearch.ToFarsi();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new CreateCheckoutListViewModel
|
|
|
|
return new CreateCheckoutListViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
Id = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
@@ -498,15 +495,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ContractStart = contractStart,
|
|
|
|
ContractStart = contractStart,
|
|
|
|
ContractEnd = contractEnd,
|
|
|
|
ContractEnd = contractEnd,
|
|
|
|
LeftWorkDate = leftWorkDate,
|
|
|
|
LeftWorkDate = leftWorkDate,
|
|
|
|
EmployeeHasCreateCheckout = result.option != null ? result.option.CreateCheckout : result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork.contractWorkshopEmployee.contractWorkshop.workshop.CreateCheckout
|
|
|
|
EmployeeHasCreateCheckout = result.option != null
|
|
|
|
|
|
|
|
? result.option.CreateCheckout
|
|
|
|
|
|
|
|
: result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
|
|
|
|
|
|
|
|
.contractWorkshopEmployee.contractWorkshop.workshop.CreateCheckout
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}).Where(x => x.EmployeeHasCreateCheckout).OrderByDescending(x => x.Extension).ToList();
|
|
|
|
}).Where(x => x.EmployeeHasCreateCheckout).OrderByDescending(x => x.Extension).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("process : " + timer.Elapsed);
|
|
|
|
Console.WriteLine("process : " + timer.Elapsed);
|
|
|
|
|
|
|
|
|
|
|
|
return new CreateCheckoutListViewModel()
|
|
|
|
return new CreateCheckoutListViewModel()
|
|
|
|
@@ -517,7 +513,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
public async Task CreateCkeckout(Checkout command)
|
|
|
|
public async Task CreateCkeckout(Checkout command)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var creationDates = DateTime.Now;
|
|
|
|
var creationDates = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
//var result = await _context.Database.ExecuteSqlInterpolatedAsync($"EXEC InsertQuery_Checkout {id},{employeeFullName},{isActiveString},{signature},{fathersName},{nationalCode},{dateOfBirth},{employeeId},{workshopName},{workshopId},{contractNo},{contractStart},{contractEnd},{month},{year},{contractId},{workingHoursId},{monthlySalary},{baseYearsPay},{consumableItems},{housingAllowance},{overtimePay},{nightworkPay},{fridayPay},{missionPay},{shiftPay},{familyAllowance},{bonusesPay},{yearsPay},{leavePay},{insuranceDeduction},{taxDeducation},{installmentDeduction},{salaryAidDeduction},{absenceDeduction},{creationDate},{archiveCode},{personnelCode},{sumOfWorkingDays},{totalClaims},{taxDeducation},{totalPayment}");
|
|
|
|
//var result = await _context.Database.ExecuteSqlInterpolatedAsync($"EXEC InsertQuery_Checkout {id},{employeeFullName},{isActiveString},{signature},{fathersName},{nationalCode},{dateOfBirth},{employeeId},{workshopName},{workshopId},{contractNo},{contractStart},{contractEnd},{month},{year},{contractId},{workingHoursId},{monthlySalary},{baseYearsPay},{consumableItems},{housingAllowance},{overtimePay},{nightworkPay},{fridayPay},{missionPay},{shiftPay},{familyAllowance},{bonusesPay},{yearsPay},{leavePay},{insuranceDeduction},{taxDeducation},{installmentDeduction},{salaryAidDeduction},{absenceDeduction},{creationDate},{archiveCode},{personnelCode},{sumOfWorkingDays},{totalClaims},{taxDeducation},{totalPayment}");
|
|
|
|
@@ -536,7 +531,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
if (command.HasInsuranceShareTheSameAsList)
|
|
|
|
if (command.HasInsuranceShareTheSameAsList)
|
|
|
|
entity.SetInsuranceShare();
|
|
|
|
entity.SetInsuranceShare();
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -678,9 +672,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
query = query.Where(x => x.ContractStartGr >= startyearGr && x.ContractEndGr <= endYearGr).ToList();
|
|
|
|
query = query.Where(x => x.ContractStartGr >= startyearGr && x.ContractEndGr <= endYearGr).ToList();
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
return query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
return query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
@@ -799,7 +790,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
endDate >= x.ContractEndGr && startDate < x.ContractEndGr).ToList();
|
|
|
|
endDate >= x.ContractEndGr && startDate < x.ContractEndGr).ToList();
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
return query.OrderBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
return query.OrderBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
|
|
|
@@ -813,17 +803,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
return query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
return query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return query.OrderByDescending(x => x.Id)
|
|
|
|
return query.OrderByDescending(x => x.Id)
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).Take(100).ToList();
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).Take(100).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach(var items in query)
|
|
|
|
//foreach(var items in query)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// var employeId = _context.WorkshopEmployers?.Where(x => x.WorkshopId == items.WorkshopId)
|
|
|
|
// var employeId = _context.WorkshopEmployers?.Where(x => x.WorkshopId == items.WorkshopId)
|
|
|
|
@@ -865,7 +850,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
ContractId = x.ContractId,
|
|
|
|
ContractId = x.ContractId,
|
|
|
|
HasRollCall = x.HasRollCall
|
|
|
|
HasRollCall = x.HasRollCall
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.EmployeeId != 0 && searchModel.WorkshopId != 0)
|
|
|
|
if (searchModel.EmployeeId != 0 && searchModel.WorkshopId != 0)
|
|
|
|
@@ -884,11 +868,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var start = searchModel.ContractStart.ToGeorgianDateTime();
|
|
|
|
var start = searchModel.ContractStart.ToGeorgianDateTime();
|
|
|
|
var end = searchModel.ContractEnd.ToGeorgianDateTime();
|
|
|
|
var end = searchModel.ContractEnd.ToGeorgianDateTime();
|
|
|
|
query = query.Where(x => x.ContractStartGr == start && x.ContractEndGr == end && x.EmployeeId == searchModel.EmployeeId && x.WorkshopId == searchModel.WorkshopId);
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
|
|
|
x.ContractStartGr == start && x.ContractEndGr == end && x.EmployeeId == searchModel.EmployeeId &&
|
|
|
|
|
|
|
|
x.WorkshopId == searchModel.WorkshopId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return query.OrderBy(x => x.ContractStartGr).ToList();
|
|
|
|
return query.OrderBy(x => x.ContractStartGr).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<CheckoutViewModel> PrintAll(List<long> id)
|
|
|
|
public List<CheckoutViewModel> PrintAll(List<long> id)
|
|
|
|
@@ -969,7 +954,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
|
|
|
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
|
|
|
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
|
|
|
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
|
|
|
}).ToList(),
|
|
|
|
}).ToList(),
|
|
|
|
CheckoutRollCall = item.CheckoutRollCall != null ? new CheckoutRollCallViewModel()
|
|
|
|
CheckoutRollCall = item.CheckoutRollCall != null
|
|
|
|
|
|
|
|
? new CheckoutRollCallViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TotalPresentTimeSpan = item.CheckoutRollCall.TotalPresentTimeSpan,
|
|
|
|
TotalPresentTimeSpan = item.CheckoutRollCall.TotalPresentTimeSpan,
|
|
|
|
TotalBreakTimeSpan = item.CheckoutRollCall.TotalBreakTimeSpan,
|
|
|
|
TotalBreakTimeSpan = item.CheckoutRollCall.TotalBreakTimeSpan,
|
|
|
|
@@ -977,7 +963,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
TotalPaidLeaveTmeSpan = item.CheckoutRollCall.TotalPaidLeaveTmeSpan,
|
|
|
|
TotalPaidLeaveTmeSpan = item.CheckoutRollCall.TotalPaidLeaveTmeSpan,
|
|
|
|
TotalMandatoryTimeSpan = item.CheckoutRollCall.TotalMandatoryTimeSpan,
|
|
|
|
TotalMandatoryTimeSpan = item.CheckoutRollCall.TotalMandatoryTimeSpan,
|
|
|
|
TotalSickLeaveTimeSpan = item.CheckoutRollCall.TotalSickLeaveTimeSpan,
|
|
|
|
TotalSickLeaveTimeSpan = item.CheckoutRollCall.TotalSickLeaveTimeSpan,
|
|
|
|
RollCallDaysCollection = item.CheckoutRollCall.RollCallDaysCollection.Select(d => new CheckoutRollCallDayViewModel()
|
|
|
|
RollCallDaysCollection = item.CheckoutRollCall.RollCallDaysCollection.Select(d =>
|
|
|
|
|
|
|
|
new CheckoutRollCallDayViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WorkingTimeSpan = d.WorkingTimeSpan,
|
|
|
|
WorkingTimeSpan = d.WorkingTimeSpan,
|
|
|
|
BreakTimeSpan = d.BreakTimeSpan,
|
|
|
|
BreakTimeSpan = d.BreakTimeSpan,
|
|
|
|
@@ -994,11 +981,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
SecondEndDate = d.SecondEndDate,
|
|
|
|
SecondEndDate = d.SecondEndDate,
|
|
|
|
SecondStartDate = d.SecondStartDate,
|
|
|
|
SecondStartDate = d.SecondStartDate,
|
|
|
|
}).ToList(),
|
|
|
|
}).ToList(),
|
|
|
|
|
|
|
|
}
|
|
|
|
} : null,
|
|
|
|
: null,
|
|
|
|
HasAmountConflict = item.HasAmountConflict,
|
|
|
|
HasAmountConflict = item.HasAmountConflict,
|
|
|
|
EmployeeMandatoryHoursTimeSpan = item.EmployeeMandatoryHours,
|
|
|
|
EmployeeMandatoryHoursTimeSpan = item.EmployeeMandatoryHours,
|
|
|
|
EmployeeMandatoryHoursStr = Tools.ToFarsiHoursAndMinutes(Convert.ToInt32(item.EmployeeMandatoryHours.TotalHours),item.EmployeeMandatoryHours.Minutes,"-")
|
|
|
|
EmployeeMandatoryHoursStr = Tools.ToFarsiHoursAndMinutes(
|
|
|
|
|
|
|
|
Convert.ToInt32(item.EmployeeMandatoryHours.TotalHours), item.EmployeeMandatoryHours.Minutes, "-")
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var workshopName = _context.Workshops.FirstOrDefault(x => x.id == ch.WorkshopId);
|
|
|
|
var workshopName = _context.Workshops.FirstOrDefault(x => x.id == ch.WorkshopId);
|
|
|
|
ch.WorkshopName = workshopName.WorkshopName;
|
|
|
|
ch.WorkshopName = workshopName.WorkshopName;
|
|
|
|
@@ -1122,9 +1110,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
var totalPaidLeaveTimeSpans = hourlyPaidLeaveTimeSpans.Concat(dailyPaidLeaveTimeSpans);
|
|
|
|
var totalPaidLeaveTimeSpans = hourlyPaidLeaveTimeSpans.Concat(dailyPaidLeaveTimeSpans);
|
|
|
|
ch.TotalHourlyLeave = new TimeSpan(hourlyPaidLeaveTimeSpans.Sum(x => x.Ticks));
|
|
|
|
ch.TotalHourlyLeave = new TimeSpan(hourlyPaidLeaveTimeSpans.Sum(x => x.Ticks));
|
|
|
|
ch.TotalPaidLeave = new TimeSpan(totalPaidLeaveTimeSpans.Sum(x => x.Ticks)).ToFarsiDaysAndHoursAndMinutes("-");
|
|
|
|
ch.TotalPaidLeave =
|
|
|
|
|
|
|
|
new TimeSpan(totalPaidLeaveTimeSpans.Sum(x => x.Ticks)).ToFarsiDaysAndHoursAndMinutes("-");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1142,7 +1129,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ch.TotalBreakTimeStr = ch.CheckoutRollCall.TotalBreakTimeSpan.ToFarsiHoursAndMinutes("-");
|
|
|
|
ch.TotalBreakTimeStr = ch.CheckoutRollCall.TotalBreakTimeSpan.ToFarsiHoursAndMinutes("-");
|
|
|
|
ch.TotalPresentTimeStr = ch.CheckoutRollCall.TotalPresentTimeSpan.ToFarsiHoursAndMinutes("-");
|
|
|
|
ch.TotalPresentTimeStr = ch.CheckoutRollCall.TotalPresentTimeSpan.ToFarsiHoursAndMinutes("-");
|
|
|
|
ch.TotalMandatoryTimeStr = ch.CheckoutRollCall.TotalMandatoryTimeSpan.ToFarsiHoursAndMinutes("-");
|
|
|
|
ch.TotalMandatoryTimeStr = ch.CheckoutRollCall.TotalMandatoryTimeSpan.ToFarsiHoursAndMinutes("-");
|
|
|
|
ch.TotalPaidLeave = Tools.ToFarsiHoursAndMinutes(Convert.ToInt32(ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.TotalHours), ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.Minutes, "-");
|
|
|
|
ch.TotalPaidLeave = Tools.ToFarsiHoursAndMinutes(
|
|
|
|
|
|
|
|
Convert.ToInt32(ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.TotalHours),
|
|
|
|
|
|
|
|
ch.CheckoutRollCall.TotalPaidLeaveTmeSpan.Minutes, "-");
|
|
|
|
ch.MonthlyRollCall = ch.CheckoutRollCall.RollCallDaysCollection
|
|
|
|
ch.MonthlyRollCall = ch.CheckoutRollCall.RollCallDaysCollection
|
|
|
|
.Select(x => new CheckoutDailyRollCallViewModel
|
|
|
|
.Select(x => new CheckoutDailyRollCallViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1163,13 +1152,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
BreakTimeString = $"{(int)(x.BreakTimeSpan.TotalHours)}:{x.BreakTimeSpan.Minutes:00}",
|
|
|
|
BreakTimeString = $"{(int)(x.BreakTimeSpan.TotalHours)}:{x.BreakTimeSpan.Minutes:00}",
|
|
|
|
RollCallDateFa = x.Date.ToFarsi()
|
|
|
|
RollCallDateFa = x.Date.ToFarsi()
|
|
|
|
}).ToList();
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (ch.HasRollCall)
|
|
|
|
if (ch.HasRollCall)
|
|
|
|
ch.MonthlyRollCall = _rollCallRepository.GetEmployeeRollCallsForMonth(ch.EmployeeId, ch.WorkshopId, ch.ContractStartGr, ch.ContractEndGr);
|
|
|
|
ch.MonthlyRollCall = _rollCallRepository.GetEmployeeRollCallsForMonth(ch.EmployeeId, ch.WorkshopId,
|
|
|
|
|
|
|
|
ch.ContractStartGr, ch.ContractEndGr);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ch.CreateWorkingHoursTemp.ContractStartGr = ch.ContractStartGr;
|
|
|
|
ch.CreateWorkingHoursTemp.ContractStartGr = ch.ContractStartGr;
|
|
|
|
@@ -1178,9 +1166,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ch.CreateWorkingHoursTemp.ContractEnd = ch.ContractEndGr.ToFarsi();
|
|
|
|
ch.CreateWorkingHoursTemp.ContractEnd = ch.ContractEndGr.ToFarsi();
|
|
|
|
ch.CreateWorkingHoursTemp.EmployeeId = ch.EmployeeId;
|
|
|
|
ch.CreateWorkingHoursTemp.EmployeeId = ch.EmployeeId;
|
|
|
|
ch.CreateWorkingHoursTemp.WorkshopId = ch.WorkshopId;
|
|
|
|
ch.CreateWorkingHoursTemp.WorkshopId = ch.WorkshopId;
|
|
|
|
ch.MonthlyRollCall = ConvertStaticToRollCall(ch.CreateWorkingHoursTemp, workshopName.WorkshopHolidayWorking);
|
|
|
|
ch.MonthlyRollCall =
|
|
|
|
|
|
|
|
ConvertStaticToRollCall(ch.CreateWorkingHoursTemp, workshopName.WorkshopHolidayWorking);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
query.Add(ch);
|
|
|
|
query.Add(ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1191,6 +1181,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
printNumer += 1;
|
|
|
|
printNumer += 1;
|
|
|
|
rec.PrintCounter = printNumer;
|
|
|
|
rec.PrintCounter = printNumer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return query;
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1216,7 +1207,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
Id = x.id,
|
|
|
|
Id = x.id,
|
|
|
|
EmployerFullName = x.FName + " " + x.LName,
|
|
|
|
EmployerFullName = x.FName + " " + x.LName,
|
|
|
|
IsLegal = x.IsLegal,
|
|
|
|
IsLegal = x.IsLegal,
|
|
|
|
|
|
|
|
|
|
|
|
}).Where(x => emp.Contains(x.Id)).ToList();
|
|
|
|
}).Where(x => emp.Contains(x.Id)).ToList();
|
|
|
|
if (employerlist.Count > 0)
|
|
|
|
if (employerlist.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1245,7 +1235,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var leaveList = _context.LeaveList.Where(x => x.WorkshopId == ch.WorkshopId && x.EmployeeId == ch.EmployeeId && x.LeaveType == "استحقاقی");
|
|
|
|
var leaveList = _context.LeaveList.Where(x =>
|
|
|
|
|
|
|
|
x.WorkshopId == ch.WorkshopId && x.EmployeeId == ch.EmployeeId && x.LeaveType == "استحقاقی");
|
|
|
|
var leaveViewModel = new List<LeaveViewModel>();
|
|
|
|
var leaveViewModel = new List<LeaveViewModel>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var list in leaveList)
|
|
|
|
foreach (var list in leaveList)
|
|
|
|
@@ -1370,7 +1361,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
|
|
|
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
|
|
|
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
|
|
|
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
|
|
|
}).ToList(),
|
|
|
|
}).ToList(),
|
|
|
|
|
|
|
|
|
|
|
|
}).SingleOrDefault(x => x.Id == id);
|
|
|
|
}).SingleOrDefault(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
|
|
var workshopName = _context.Workshops.FirstOrDefault(x => x.id == ch.WorkshopId);
|
|
|
|
var workshopName = _context.Workshops.FirstOrDefault(x => x.id == ch.WorkshopId);
|
|
|
|
@@ -1390,6 +1380,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
};
|
|
|
|
};
|
|
|
|
employers.Add(employer);
|
|
|
|
employers.Add(employer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ch.MaritalStatus = _context.Employees.Find(ch.EmployeeId)?.MaritalStatus;
|
|
|
|
ch.MaritalStatus = _context.Employees.Find(ch.EmployeeId)?.MaritalStatus;
|
|
|
|
ch.EmployerList = employers;
|
|
|
|
ch.EmployerList = employers;
|
|
|
|
var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(ch.ContractId);
|
|
|
|
var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(ch.ContractId);
|
|
|
|
@@ -1484,7 +1475,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
ch.TotalSickLeave = new TimeSpan(sickLeaveTimeSpans.Sum(x => x.Ticks)).ToFarsiDaysAndHoursAndMinutes("-");
|
|
|
|
ch.TotalSickLeave = new TimeSpan(sickLeaveTimeSpans.Sum(x => x.Ticks)).ToFarsiDaysAndHoursAndMinutes("-");
|
|
|
|
|
|
|
|
|
|
|
|
var hourlyPaidLeaveTimeSpans = hourlyPaidLeave.Select(x => TimeOnly.Parse(x.LeaveHourses).ToTimeSpan()).ToList();
|
|
|
|
var hourlyPaidLeaveTimeSpans =
|
|
|
|
|
|
|
|
hourlyPaidLeave.Select(x => TimeOnly.Parse(x.LeaveHourses).ToTimeSpan()).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var dailyPaidLeaveTimeSpans = dailyPaidLeave.Select(x =>
|
|
|
|
var dailyPaidLeaveTimeSpans = dailyPaidLeave.Select(x =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1497,20 +1489,19 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ch.TotalHourlyLeave = new TimeSpan(hourlyPaidLeaveTimeSpans.Sum(x => x.Ticks));
|
|
|
|
ch.TotalHourlyLeave = new TimeSpan(hourlyPaidLeaveTimeSpans.Sum(x => x.Ticks));
|
|
|
|
ch.TotalPaidLeave = new TimeSpan(totalPaidLeaveTimeSpans.Sum(x => x.Ticks)).ToFarsiDaysAndHoursAndMinutes("-");
|
|
|
|
ch.TotalPaidLeave = new TimeSpan(totalPaidLeaveTimeSpans.Sum(x => x.Ticks)).ToFarsiDaysAndHoursAndMinutes("-");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ch.TotalPaymentHide == false)
|
|
|
|
if (ch.TotalPaymentHide == false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ch.TotalClaims = "";
|
|
|
|
ch.TotalClaims = "";
|
|
|
|
ch.TotalDeductions = "";
|
|
|
|
ch.TotalDeductions = "";
|
|
|
|
ch.TotalPayment = "";
|
|
|
|
ch.TotalPayment = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ch.HasRollCall)
|
|
|
|
if (ch.HasRollCall)
|
|
|
|
ch.MonthlyRollCall = _rollCallRepository.GetEmployeeRollCallsForMonth(ch.EmployeeId, ch.WorkshopId, ch.ContractStartGr, ch.ContractEndGr);
|
|
|
|
ch.MonthlyRollCall = _rollCallRepository.GetEmployeeRollCallsForMonth(ch.EmployeeId, ch.WorkshopId,
|
|
|
|
|
|
|
|
ch.ContractStartGr, ch.ContractEndGr);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ch.CreateWorkingHoursTemp.ContractStartGr = ch.ContractStartGr;
|
|
|
|
ch.CreateWorkingHoursTemp.ContractStartGr = ch.ContractStartGr;
|
|
|
|
@@ -1519,12 +1510,15 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
ch.CreateWorkingHoursTemp.ContractEnd = ch.ContractEndGr.ToFarsi();
|
|
|
|
ch.CreateWorkingHoursTemp.ContractEnd = ch.ContractEndGr.ToFarsi();
|
|
|
|
ch.CreateWorkingHoursTemp.EmployeeId = ch.EmployeeId;
|
|
|
|
ch.CreateWorkingHoursTemp.EmployeeId = ch.EmployeeId;
|
|
|
|
ch.CreateWorkingHoursTemp.WorkshopId = ch.WorkshopId;
|
|
|
|
ch.CreateWorkingHoursTemp.WorkshopId = ch.WorkshopId;
|
|
|
|
ch.MonthlyRollCall = ConvertStaticToRollCall(ch.CreateWorkingHoursTemp, workshopName.WorkshopHolidayWorking);
|
|
|
|
ch.MonthlyRollCall =
|
|
|
|
|
|
|
|
ConvertStaticToRollCall(ch.CreateWorkingHoursTemp, workshopName.WorkshopHolidayWorking);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ch;
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<CheckoutDailyRollCallViewModel> ConvertStaticToRollCall(CreateWorkingHoursTemp workingHours, bool workshopHolidayWorking)
|
|
|
|
private List<CheckoutDailyRollCallViewModel> ConvertStaticToRollCall(CreateWorkingHoursTemp workingHours,
|
|
|
|
|
|
|
|
bool workshopHolidayWorking)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var rollCalls = _rollCallMandatoryRepository.ConvertStaticHoursToRollCall(workingHours,
|
|
|
|
var rollCalls = _rollCallMandatoryRepository.ConvertStaticHoursToRollCall(workingHours,
|
|
|
|
workshopHolidayWorking);
|
|
|
|
workshopHolidayWorking);
|
|
|
|
@@ -1557,7 +1551,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
int dateRange = (int)(lastDayOfCurrentMonth - firstDayOfCurrentMonth).TotalDays + 1;
|
|
|
|
int dateRange = (int)(lastDayOfCurrentMonth - firstDayOfCurrentMonth).TotalDays + 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var holidays = _context.HolidayItems.Where(x => x.HolidayYear.Contains(year.ToString())).Select(x => new HolidayItemViewModel
|
|
|
|
var holidays = _context.HolidayItems.Where(x => x.HolidayYear.Contains(year.ToString())).Select(x =>
|
|
|
|
|
|
|
|
new HolidayItemViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.id,
|
|
|
|
Id = x.id,
|
|
|
|
Holidaydate = x.Holidaydate.ToFarsi(),
|
|
|
|
Holidaydate = x.Holidaydate.ToFarsi(),
|
|
|
|
@@ -1570,7 +1565,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
holidays = [];
|
|
|
|
holidays = [];
|
|
|
|
|
|
|
|
|
|
|
|
//all the dates from start to end, to be compared with present days to get absent dates
|
|
|
|
//all the dates from start to end, to be compared with present days to get absent dates
|
|
|
|
var completeDaysList = Enumerable.Range(0, dateRange).Select(offset => startMonthDay.AddDays(offset).Date).ToList();
|
|
|
|
var completeDaysList = Enumerable.Range(0, dateRange).Select(offset => startMonthDay.AddDays(offset).Date)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var absentRecords = completeDaysList
|
|
|
|
var absentRecords = completeDaysList
|
|
|
|
.ExceptBy(rollCalls.Select(x => x.ShiftDate.Date), y => y.Date)
|
|
|
|
.ExceptBy(rollCalls.Select(x => x.ShiftDate.Date), y => y.Date)
|
|
|
|
@@ -1596,11 +1592,13 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
var presentDays = rollCalls.GroupBy(x => x.ShiftDate.Date).Select(x =>
|
|
|
|
var presentDays = rollCalls.GroupBy(x => x.ShiftDate.Date).Select(x =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var orderedRollcalls = x.OrderBy(y => y.ShiftDate).ToList();
|
|
|
|
var orderedRollcalls = x.OrderBy(y => y.ShiftDate).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var rollCallTimeSpanPerDay =
|
|
|
|
var rollCallTimeSpanPerDay =
|
|
|
|
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => y.ShiftEndWithoutRest == null ? (y.EndDate - y.StartDate).Value!.Ticks : (y.ShiftEndWithoutRest - y.StartDate)!.Value.Ticks));
|
|
|
|
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y =>
|
|
|
|
|
|
|
|
y.ShiftEndWithoutRest == null
|
|
|
|
|
|
|
|
? (y.EndDate - y.StartDate).Value!.Ticks
|
|
|
|
|
|
|
|
: (y.ShiftEndWithoutRest - y.StartDate)!.Value.Ticks));
|
|
|
|
var breakTimePerDay = new TimeSpan(x.Sum(r => r.BreakTimeSpan.Ticks));
|
|
|
|
var breakTimePerDay = new TimeSpan(x.Sum(r => r.BreakTimeSpan.Ticks));
|
|
|
|
|
|
|
|
|
|
|
|
var firstRollCall = orderedRollcalls.FirstOrDefault();
|
|
|
|
var firstRollCall = orderedRollcalls.FirstOrDefault();
|
|
|
|
@@ -1614,7 +1612,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
secondRCEndDate = secondRollCall.ShiftEndWithoutRest ?? secondRollCall.EndDate;
|
|
|
|
secondRCEndDate = secondRollCall.ShiftEndWithoutRest ?? secondRollCall.EndDate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new CheckoutDailyRollCallViewModel()
|
|
|
|
return new CheckoutDailyRollCallViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
StartDate1 = firstRollCall?.StartDate?.ToString("HH:mm") ?? "",
|
|
|
|
StartDate1 = firstRollCall?.StartDate?.ToString("HH:mm") ?? "",
|
|
|
|
@@ -1686,12 +1683,15 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new List<CheckoutViewModel>();
|
|
|
|
return new List<CheckoutViewModel>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var employers =
|
|
|
|
var employers =
|
|
|
|
_context.Employers.Where(x => x.ContractingPartyId == contracingPartyAcc.PersonalContractingPartyId).Select(x => x.id).ToList();
|
|
|
|
_context.Employers.Where(x => x.ContractingPartyId == contracingPartyAcc.PersonalContractingPartyId)
|
|
|
|
|
|
|
|
.Select(x => x.id).ToList();
|
|
|
|
if (employers.Count < 1)
|
|
|
|
if (employers.Count < 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new List<CheckoutViewModel>();
|
|
|
|
return new List<CheckoutViewModel>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var workshopIds = _context.WorkshopEmployers.Where(x => employers.Contains(x.EmployerId))
|
|
|
|
var workshopIds = _context.WorkshopEmployers.Where(x => employers.Contains(x.EmployerId))
|
|
|
|
.Select(x => x.WorkshopId).ToList();
|
|
|
|
.Select(x => x.WorkshopId).ToList();
|
|
|
|
var checkValid = workshopIds.Any(x => x == searchModel.WorkshopId);
|
|
|
|
var checkValid = workshopIds.Any(x => x == searchModel.WorkshopId);
|
|
|
|
@@ -1699,7 +1699,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new List<CheckoutViewModel>();
|
|
|
|
return new List<CheckoutViewModel>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
var query = _context.CheckoutSet.Include(w => w.CheckoutWarningMessageList)
|
|
|
|
var query = _context.CheckoutSet.Include(w => w.CheckoutWarningMessageList)
|
|
|
|
.AsSplitQuery().Select(x => new CheckoutViewModel()
|
|
|
|
.AsSplitQuery().Select(x => new CheckoutViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1741,9 +1743,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
}).Where(x => x.WorkshopId == searchModel.WorkshopId);
|
|
|
|
}).Where(x => x.WorkshopId == searchModel.WorkshopId);
|
|
|
|
if (searchModel.EmployeeId > 0)
|
|
|
|
if (searchModel.EmployeeId > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1857,16 +1857,20 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
y2 = $"{searchModel.Year}/{searchModel.Month}/29";
|
|
|
|
y2 = $"{searchModel.Year}/{searchModel.Month}/29";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var start = y.ToGeorgianDateTime();
|
|
|
|
var start = y.ToGeorgianDateTime();
|
|
|
|
var end = y2.ToGeorgianDateTime();
|
|
|
|
var end = y2.ToGeorgianDateTime();
|
|
|
|
|
|
|
|
|
|
|
|
query = query.Where(x => x.ContractStartGr >= start && x.ContractStartGr < end && x.ContractEndGr > start && x.ContractEndGr <= end ||
|
|
|
|
query = query.Where(x =>
|
|
|
|
x.ContractStartGr <= start && x.ContractEndGr >= end || start <= x.ContractStartGr && end > x.ContractStartGr || end >= x.ContractEndGr && start < x.ContractEndGr);
|
|
|
|
x.ContractStartGr >= start && x.ContractStartGr < end && x.ContractEndGr > start &&
|
|
|
|
|
|
|
|
x.ContractEndGr <= end ||
|
|
|
|
|
|
|
|
x.ContractStartGr <= start && x.ContractEndGr >= end ||
|
|
|
|
|
|
|
|
start <= x.ContractStartGr && end > x.ContractStartGr ||
|
|
|
|
|
|
|
|
end >= x.ContractEndGr && start < x.ContractEndGr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.SearchAll)
|
|
|
|
if (searchModel.SearchAll)
|
|
|
|
return query.OrderByDescending(x => x.Id).ToList();
|
|
|
|
return query.OrderByDescending(x => x.Id).ToList();
|
|
|
|
switch (searchModel.Sorting)
|
|
|
|
switch (searchModel.Sorting)
|
|
|
|
@@ -1897,8 +1901,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default: return query.OrderByDescending(x => x.Id).Skip(searchModel.PageIndex).Take(30).ToList();
|
|
|
|
default: return query.OrderByDescending(x => x.Id).Skip(searchModel.PageIndex).Take(30).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
@@ -1928,12 +1930,10 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var checkout = _context.CheckoutSet.Where(x => x.id == id)?.FirstOrDefault();
|
|
|
|
var checkout = _context.CheckoutSet.Where(x => x.id == id)?.FirstOrDefault();
|
|
|
|
_context.CheckoutSet.Remove(checkout);
|
|
|
|
_context.CheckoutSet.Remove(checkout);
|
|
|
|
_context.SaveChanges();
|
|
|
|
_context.SaveChanges();
|
|
|
|
return op.Succcedded(-1, "حذف با موفقیت انجام شد.");
|
|
|
|
return op.Succcedded(-1, "حذف با موفقیت انجام شد.");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
catch (Exception)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -1951,6 +1951,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
notRemoveList.Add(item);
|
|
|
|
notRemoveList.Add(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return notRemoveList;
|
|
|
|
return notRemoveList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2010,7 +2011,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
var checkouts =
|
|
|
|
var checkouts =
|
|
|
|
_context.CheckoutSet.Include(w=>w.CheckoutWarningMessageList).Where(x => workshopAcounts.Contains(x.WorkshopId))
|
|
|
|
_context.CheckoutSet.Include(w => w.CheckoutWarningMessageList)
|
|
|
|
|
|
|
|
.Where(x => workshopAcounts.Contains(x.WorkshopId))
|
|
|
|
.Join(_context.Workshops.AsSplitQuery(),
|
|
|
|
.Join(_context.Workshops.AsSplitQuery(),
|
|
|
|
ch => ch.WorkshopId,
|
|
|
|
ch => ch.WorkshopId,
|
|
|
|
workshop => workshop.id,
|
|
|
|
workshop => workshop.id,
|
|
|
|
@@ -2033,7 +2035,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.ch,
|
|
|
|
res.ch,
|
|
|
|
res.workshop,
|
|
|
|
res.workshop,
|
|
|
|
option = _context.EmployeeComputeOptionsSet.FirstOrDefault(x=>x.WorkshopId == res.ch.WorkshopId &&x.EmployeeId == res.ch.EmployeeId),
|
|
|
|
option = _context.EmployeeComputeOptionsSet.FirstOrDefault(x =>
|
|
|
|
|
|
|
|
x.WorkshopId == res.ch.WorkshopId && x.EmployeeId == res.ch.EmployeeId),
|
|
|
|
res.workshopEmployer,
|
|
|
|
res.workshopEmployer,
|
|
|
|
contractingParty = _context.PersonalContractingParties
|
|
|
|
contractingParty = _context.PersonalContractingParties
|
|
|
|
.Include(p => p.Employers)
|
|
|
|
.Include(p => p.Employers)
|
|
|
|
@@ -2050,15 +2053,18 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
checkouts = checkouts.Where(x => x.ch.WorkshopId == searchModel.WorkshopId);
|
|
|
|
checkouts = checkouts.Where(x => x.ch.WorkshopId == searchModel.WorkshopId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.EmployeeId != 0)
|
|
|
|
if (searchModel.EmployeeId != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
checkouts = checkouts.Where(x => x.ch.EmployeeId == searchModel.EmployeeId);
|
|
|
|
checkouts = checkouts.Where(x => x.ch.EmployeeId == searchModel.EmployeeId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.EmployerId != 0)
|
|
|
|
if (searchModel.EmployerId != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
checkouts = checkouts.Where(x => x.contractingParty.Employers.Select(c => c.id).Contains(searchModel.EmployerId));
|
|
|
|
checkouts = checkouts.Where(x =>
|
|
|
|
|
|
|
|
x.contractingParty.Employers.Select(c => c.id).Contains(searchModel.EmployerId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo))
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo))
|
|
|
|
@@ -2068,7 +2074,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (searchModel.IsActiveString == null)
|
|
|
|
//if (searchModel.IsActiveString == null)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// checkouts = checkouts.Where(x => x.ch.IsActiveString == "true");
|
|
|
|
// checkouts = checkouts.Where(x => x.ch.IsActiveString == "true");
|
|
|
|
@@ -2100,7 +2105,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
checkouts = checkouts.Where(x => x.ch.ContractStart >= startyearGr && x.ch.ContractEnd <= endYearGr);
|
|
|
|
checkouts = checkouts.Where(x => x.ch.ContractStart >= startyearGr && x.ch.ContractEnd <= endYearGr);
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
checkouts = checkouts.OrderByDescending(x => x.ch.ContractEnd);
|
|
|
|
checkouts = checkouts.OrderByDescending(x => x.ch.ContractEnd);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
@@ -2220,7 +2224,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
endDate >= x.ch.ContractEnd && startDate < x.ch.ContractEnd);
|
|
|
|
endDate >= x.ch.ContractEnd && startDate < x.ch.ContractEnd);
|
|
|
|
//if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
//if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
// checkouts = checkouts.OrderBy(x => x.ch.PersonnelCodeInt);
|
|
|
|
// checkouts = checkouts.OrderBy(x => x.ch.PersonnelCodeInt);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
|
|
|
@@ -2240,22 +2243,20 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
if (!string.IsNullOrEmpty(searchModel.EmployeeName))
|
|
|
|
if (!string.IsNullOrEmpty(searchModel.EmployeeName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasSearch = true;
|
|
|
|
hasSearch = true;
|
|
|
|
var employeeList = _context.Employees.Where(x => (!string.IsNullOrEmpty(x.FName) && x.FName.StartsWith(searchModel.EmployeeName)) ||
|
|
|
|
var employeeList = _context.Employees.Where(x =>
|
|
|
|
(!string.IsNullOrEmpty(x.LName) && x.LName.StartsWith(searchModel.EmployeeName))).Select(x => x.id).ToList();
|
|
|
|
(!string.IsNullOrEmpty(x.FName) && x.FName.StartsWith(searchModel.EmployeeName)) ||
|
|
|
|
|
|
|
|
(!string.IsNullOrEmpty(x.LName) && x.LName.StartsWith(searchModel.EmployeeName))).Select(x => x.id)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
checkouts = checkouts.Where(x => employeeList.Contains(x.ch.EmployeeId));
|
|
|
|
checkouts = checkouts.Where(x => employeeList.Contains(x.ch.EmployeeId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasSearch && !hasEmployeeOrWorkshpSearch)
|
|
|
|
if (!hasSearch && !hasEmployeeOrWorkshpSearch)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
return checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Id = x.ch.id,
|
|
|
|
Id = x.ch.id,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
@@ -2281,26 +2282,21 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm=> new CheckoutWarningMessageModel
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm =>
|
|
|
|
|
|
|
|
new CheckoutWarningMessageModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).OrderByDescending(x => x.Id).Take(3000).ToList().DistinctBy(x => x.Id)
|
|
|
|
}).OrderByDescending(x => x.Id).Take(3000).ToList().DistinctBy(x => x.Id)
|
|
|
|
.OrderByDescending(x => x.Id).ThenByDescending(x => x.Year)
|
|
|
|
.OrderByDescending(x => x.Id).ThenByDescending(x => x.Year)
|
|
|
|
.ThenBy(x => x.PersonnelCodeInt)
|
|
|
|
.ThenBy(x => x.PersonnelCodeInt)
|
|
|
|
.Take(50).ToList();
|
|
|
|
.Take(50).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (hasSearch && !hasEmployeeOrWorkshpSearch)
|
|
|
|
else if (hasSearch && !hasEmployeeOrWorkshpSearch)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var result = checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
var result = checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Id = x.ch.id,
|
|
|
|
Id = x.ch.id,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
@@ -2326,19 +2322,17 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm =>
|
|
|
|
|
|
|
|
new CheckoutWarningMessageModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
}).OrderByDescending(x => x.Id)
|
|
|
|
}).OrderByDescending(x => x.Id)
|
|
|
|
.GroupBy(x => x.Id)
|
|
|
|
.GroupBy(x => x.Id)
|
|
|
|
.Select(x => x.First());
|
|
|
|
.Select(x => x.First());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((string.IsNullOrWhiteSpace(searchModel.ContractStart) ||
|
|
|
|
if ((string.IsNullOrWhiteSpace(searchModel.ContractStart) ||
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractEnd)) && string.IsNullOrWhiteSpace(searchModel.Month))
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractEnd)) && string.IsNullOrWhiteSpace(searchModel.Month))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -2348,7 +2342,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
.OrderByDescending(x => x.ContractStartGr).ToList();
|
|
|
|
.OrderByDescending(x => x.ContractStartGr).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((string.IsNullOrWhiteSpace(searchModel.ContractStart) ||
|
|
|
|
else if ((string.IsNullOrWhiteSpace(searchModel.ContractStart) ||
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractEnd)) && !string.IsNullOrWhiteSpace(searchModel.Month) && !string.IsNullOrWhiteSpace(searchModel.Year))
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractEnd)) &&
|
|
|
|
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.Month) && !string.IsNullOrWhiteSpace(searchModel.Year))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//اگر فقط سال و ماه رو سرچ کرد
|
|
|
|
//اگر فقط سال و ماه رو سرچ کرد
|
|
|
|
return result.Take(300)
|
|
|
|
return result.Take(300)
|
|
|
|
@@ -2366,14 +2361,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
return result.ToList().OrderByDescending(x => x.Id)
|
|
|
|
return result.ToList().OrderByDescending(x => x.Id)
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (hasEmployeeOrWorkshpSearch && !hasSearch)
|
|
|
|
else if (hasEmployeeOrWorkshpSearch && !hasSearch)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
return checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Id = x.ch.id,
|
|
|
|
Id = x.ch.id,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
@@ -2399,13 +2391,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm =>
|
|
|
|
|
|
|
|
new CheckoutWarningMessageModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
}).GroupBy(x => x.Id).Select(x => x.First()).ToList()
|
|
|
|
}).GroupBy(x => x.Id).Select(x => x.First()).ToList()
|
|
|
|
.OrderByDescending(x => x.ContractStartGr).ToList();
|
|
|
|
.OrderByDescending(x => x.ContractStartGr).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -2413,7 +2404,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
return checkouts.Select(x => new CheckoutViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Id = x.ch.id,
|
|
|
|
Id = x.ch.id,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
EmployeeFullName = x.ch.EmployeeFullName,
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
ContractStart = x.ch.ContractStart.ToFarsi(),
|
|
|
|
@@ -2439,26 +2429,21 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
IsBlockCantracingParty = x.contractingParty.IsBlock,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
IsUpdateNeeded = x.ch.IsUpdateNeeded,
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
|
|
|
|
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm =>
|
|
|
|
|
|
|
|
new CheckoutWarningMessageModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
WarningMessage = wm.WarningMessage,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
}).GroupBy(x => x.Id)
|
|
|
|
}).GroupBy(x => x.Id)
|
|
|
|
.Select(x => x.First()).ToList()
|
|
|
|
.Select(x => x.First()).ToList()
|
|
|
|
.OrderByDescending(x => x.Id)
|
|
|
|
.OrderByDescending(x => x.Id)
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<List<CheckoutViewModel>> SearchForMainCheckout(CheckoutSearchModel searchModel)
|
|
|
|
public async Task<List<CheckoutViewModel>> SearchForMainCheckout(CheckoutSearchModel searchModel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool hasSearch = false;
|
|
|
|
bool hasSearch = false;
|
|
|
|
bool hasEmployeeOrWorkshpSearch = false;
|
|
|
|
bool hasEmployeeOrWorkshpSearch = false;
|
|
|
|
//List<CheckoutViewModel> query = null;
|
|
|
|
//List<CheckoutViewModel> query = null;
|
|
|
|
@@ -2476,11 +2461,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
.Select(x => x.WorkshopId).ToList();
|
|
|
|
.Select(x => x.WorkshopId).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var query = _context.CheckoutSet.Select(x => new CheckoutViewModel()
|
|
|
|
var query = _context.CheckoutSet.Select(x => new CheckoutViewModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Id = x.id,
|
|
|
|
Id = x.id,
|
|
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
|
|
//var start = ;
|
|
|
|
//var start = ;
|
|
|
|
@@ -2503,13 +2485,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
Signature = x.Signature,
|
|
|
|
Signature = x.Signature,
|
|
|
|
CreationDate = x.CreationDate,
|
|
|
|
CreationDate = x.CreationDate,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo) && searchModel.ContractId != 0)
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.ContractNo) && searchModel.ContractId != 0)
|
|
|
|
query = query.Where(x =>
|
|
|
|
query = query.Where(x =>
|
|
|
|
x.ContractNo == searchModel.ContractNo && x.ContractId == searchModel.ContractId);
|
|
|
|
x.ContractNo == searchModel.ContractNo && x.ContractId == searchModel.ContractId);
|
|
|
|
@@ -2518,11 +2496,13 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId);
|
|
|
|
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.EmployeeId != 0)
|
|
|
|
if (searchModel.EmployeeId != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.EmployerId != 0)
|
|
|
|
if (searchModel.EmployerId != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
hasEmployeeOrWorkshpSearch = true;
|
|
|
|
@@ -2566,7 +2546,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
query = query.Where(x => x.ContractStartGr >= startyearGr && x.ContractEndGr <= endYearGr);
|
|
|
|
query = query.Where(x => x.ContractStartGr >= startyearGr && x.ContractEndGr <= endYearGr);
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
query = query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt);
|
|
|
|
query = query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
@@ -2686,7 +2665,6 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
endDate >= x.ContractEndGr && startDate < x.ContractEndGr);
|
|
|
|
endDate >= x.ContractEndGr && startDate < x.ContractEndGr);
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
query = query.OrderBy(x => x.PersonnelCodeInt);
|
|
|
|
query = query.OrderBy(x => x.PersonnelCodeInt);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
|
|
|
@@ -2701,16 +2679,18 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
|
|
|
|
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
if (searchModel.WorkshopId > 0 || searchModel.EmployeeId > 0 || searchModel.EmployerId > 0)
|
|
|
|
query = query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt);
|
|
|
|
query = query.OrderByDescending(x => x.ContractEndGr).ThenBy(x => x.PersonnelCodeInt);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(searchModel.EmployeeName))
|
|
|
|
if (!string.IsNullOrEmpty(searchModel.EmployeeName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hasSearch = true;
|
|
|
|
hasSearch = true;
|
|
|
|
var employeeList = _context.Employees.Where(x => (!string.IsNullOrEmpty(x.FName) && x.FName.StartsWith(searchModel.EmployeeName)) ||
|
|
|
|
var employeeList = _context.Employees.Where(x =>
|
|
|
|
(!string.IsNullOrEmpty(x.LName) && x.LName.StartsWith(searchModel.EmployeeName))).Select(x => x.id).ToList();
|
|
|
|
(!string.IsNullOrEmpty(x.FName) && x.FName.StartsWith(searchModel.EmployeeName)) ||
|
|
|
|
|
|
|
|
(!string.IsNullOrEmpty(x.LName) && x.LName.StartsWith(searchModel.EmployeeName))).Select(x => x.id)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
query = query.Where(x => employeeList.Contains(x.EmployeeId));
|
|
|
|
query = query.Where(x => employeeList.Contains(x.EmployeeId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (hasSearch)
|
|
|
|
if (hasSearch)
|
|
|
|
return query.OrderByDescending(x => x.Id)
|
|
|
|
return query.OrderByDescending(x => x.Id)
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).ToList();
|
|
|
|
@@ -2721,22 +2701,17 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).Take(50).ToList();
|
|
|
|
.ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).Take(50).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// Console.WriteLine("return" + watch.Elapsed);
|
|
|
|
// Console.WriteLine("return" + watch.Elapsed);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Pooya
|
|
|
|
#region Pooya
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)>
|
|
|
|
public List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopIdForWorkFlow(long workshopId, DateTime start, DateTime end)
|
|
|
|
GetLastCheckoutsByWorkshopIdForWorkFlow(long workshopId, DateTime start, DateTime end)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return _context.CheckoutSet.AsSplitQuery().Where(x =>
|
|
|
|
|
|
|
|
x.ContractEnd.Date >= start && x.ContractStart.Date <= end && x.WorkshopId == workshopId).Select(x => new
|
|
|
|
|
|
|
|
|
|
|
|
return _context.CheckoutSet.AsSplitQuery().Where(x => x.ContractEnd.Date >= start && x.ContractStart.Date <= end && x.WorkshopId == workshopId).Select(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EmployeeId = x.EmployeeId,
|
|
|
|
EmployeeId = x.EmployeeId,
|
|
|
|
CheckoutEnd = x.ContractEnd,
|
|
|
|
CheckoutEnd = x.ContractEnd,
|
|
|
|
@@ -2751,5 +2726,88 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
|
|
|
x.ContractEnd >= inDate);
|
|
|
|
x.ContractEnd >= inDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PagedResult<CheckoutListClientDto>> GetListForClient(long workshopId,
|
|
|
|
|
|
|
|
CheckoutListClientSearchModel searchModel)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var query = _context.CheckoutSet.Where(x => x.WorkshopId == workshopId);
|
|
|
|
|
|
|
|
if (searchModel.EmployeeId is > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!searchModel.StartDate.TryToGeorgianDateTime(out var startDateGr))
|
|
|
|
|
|
|
|
throw new BadRequestException("تاریخ شروع جستجو نامعتبر است");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!searchModel.EndDate.TryToGeorgianDateTime(out var endDateGr))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new BadRequestException("تاریخ پایان جستجو نامعتبر است");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = query.Where(x => x.ContractStart <= endDateGr && x.ContractEnd >= startDateGr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Year))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
query = query.Where(x => x.Year == searchModel.Year);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var searchedMonth = Convert.ToInt32(searchModel.Month).ToFarsiMonthByIntNumber();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = query.Where(x => x.Month == searchedMonth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = searchModel.OrderType switch
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.ByCheckoutCreationDate =>
|
|
|
|
|
|
|
|
query.OrderBy(x => x.CreationDate),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.ByCheckoutStartDate =>
|
|
|
|
|
|
|
|
query.OrderBy(x => x.ContractStart),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.ByCheckoutStartDateDescending =>
|
|
|
|
|
|
|
|
query.OrderByDescending(x => x.ContractStart),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.ByPersonnelCode =>
|
|
|
|
|
|
|
|
query.OrderBy(x => x.PersonnelCode),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.ByPersonnelCodeDescending =>
|
|
|
|
|
|
|
|
query.OrderByDescending(x => x.PersonnelCode),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.BySignedCheckout =>
|
|
|
|
|
|
|
|
query.OrderByDescending(x => x.Signature == "1"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckoutClientListOrderType.ByUnSignedCheckout =>
|
|
|
|
|
|
|
|
query.OrderBy(x => x.Signature == "1"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ => query.OrderByDescending(x => x.id)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var list =await query.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var resList = list.Select(x => new CheckoutListClientDto()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = x.id,
|
|
|
|
|
|
|
|
ContractStart = x.ContractStart.ToFarsi(),
|
|
|
|
|
|
|
|
ContractEnd = x.ContractEnd.ToFarsi(),
|
|
|
|
|
|
|
|
Year = x.Year,
|
|
|
|
|
|
|
|
Month = x.Month,
|
|
|
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
|
|
|
EmployeeName = x.EmployeeFullName,
|
|
|
|
|
|
|
|
Signature = x.Signature == "1"
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var res = new PagedResult<CheckoutListClientDto>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TotalCount = await query.CountAsync(),
|
|
|
|
|
|
|
|
List = resList
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|