merge from customizeChekoutBug to Master
This commit is contained in:
@@ -168,9 +168,9 @@ namespace CompanyManagment.EFCore.Repository
|
||||
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
||||
}).ToList(),
|
||||
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{x.LateToWorkValue.Minutes:D2}"
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{Convert.ToInt32(x.LateToWorkValue.TotalHours)}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}"
|
||||
|
||||
}).ToList();
|
||||
}).ToList();
|
||||
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel
|
||||
{
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
@@ -256,138 +256,138 @@ namespace CompanyManagment.EFCore.Repository
|
||||
return _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId==workshopId && ids.Contains(x.id)).AsEnumerable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee)
|
||||
.ThenInclude(x => x.PersonnelCodeList).
|
||||
Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee)
|
||||
.ThenInclude(x => x.PersonnelCodeList).
|
||||
Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
|
||||
////start of search is the first day of the current month by default and end of search is today
|
||||
//var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date;
|
||||
//var endSearchDate = DateTime.Today;
|
||||
////start of search is the first day of the current month by default and end of search is today
|
||||
//var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date;
|
||||
//var endSearchDate = DateTime.Today;
|
||||
|
||||
var pc = new PersianCalendar();
|
||||
var currentYear = pc.GetYear(DateTime.Now);
|
||||
var currentMonth = pc.GetMonth(DateTime.Now);
|
||||
var pc = new PersianCalendar();
|
||||
var currentYear = pc.GetYear(DateTime.Now);
|
||||
var currentMonth = pc.GetMonth(DateTime.Now);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) &&
|
||||
searchModel.Year == 0 && searchModel.Month == 0)
|
||||
{
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) &&
|
||||
searchModel.Year == 0 && searchModel.Month == 0)
|
||||
{
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
|
||||
//if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
//query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate);
|
||||
query = query.Where(x => x.ContractEnd.Date >= queryStartDate && x.ContractStart.Date <= queryEndDate);
|
||||
}
|
||||
//if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
//query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate);
|
||||
query = query.Where(x => x.ContractEnd.Date >= queryStartDate && x.ContractStart.Date <= queryEndDate);
|
||||
}
|
||||
|
||||
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 12)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
queryEndDate = queryEndDate.Date.AddTicks(-1);
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
queryEndDate = queryEndDate.Date.AddTicks(-1);
|
||||
|
||||
|
||||
if (queryEndDate >= DateTime.Today)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
//if (queryEndDate >= DateTime.Today)
|
||||
//{
|
||||
// queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
//}
|
||||
|
||||
else if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
|
||||
query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate);
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate);
|
||||
}
|
||||
|
||||
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
|
||||
|
||||
if (searchModel.BankId > 0)
|
||||
query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId));
|
||||
if (searchModel.BankId > 0)
|
||||
query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId));
|
||||
|
||||
switch (searchModel.OrderBy)
|
||||
{
|
||||
case CustomizeCheckoutOrderByEnum.ContractStartDesc:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractStart:
|
||||
query = query.OrderBy(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNoDesc:
|
||||
query = query.OrderByDescending(x => x.ContractNo);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNo:
|
||||
query = query.OrderBy(x => x.ContractNo);
|
||||
break;
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
switch (searchModel.OrderBy)
|
||||
{
|
||||
case CustomizeCheckoutOrderByEnum.ContractStartDesc:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractStart:
|
||||
query = query.OrderBy(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNoDesc:
|
||||
query = query.OrderByDescending(x => x.ContractNo);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNo:
|
||||
query = query.OrderBy(x => x.ContractNo);
|
||||
break;
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
|
||||
}
|
||||
if (searchModel.Year == 0 || searchModel.Month == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
}
|
||||
if (searchModel.Year == 0 || searchModel.Month == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
ContractNo = x.ContractNo,
|
||||
EmployeeFName = x.Employee.FName,
|
||||
EmployeeLName = x.Employee.LName,
|
||||
PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode,
|
||||
Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(),
|
||||
Year = pc.GetYear(x.ContractStart).ToString(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment,
|
||||
TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
ContractNo = x.ContractNo,
|
||||
EmployeeFName = x.Employee.FName,
|
||||
EmployeeLName = x.Employee.LName,
|
||||
PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode,
|
||||
Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(),
|
||||
Year = pc.GetYear(x.ContractStart).ToString(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment,
|
||||
TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
|
||||
}).ToList();
|
||||
}).ToList();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,151 +65,151 @@ namespace CompanyManagment.EFCore.Repository
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
|
||||
var query = _companyContext.CustomizeCheckoutTemps.Include(x => x.Employee)
|
||||
.ThenInclude(x => x.PersonnelCodeList)
|
||||
.Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
var query = _companyContext.CustomizeCheckoutTemps.Include(x => x.Employee)
|
||||
.ThenInclude(x => x.PersonnelCodeList)
|
||||
.Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
|
||||
//start of search is the first day of the current month by default and end of search is today
|
||||
var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date;
|
||||
var endSearchDate = DateTime.Today;
|
||||
//start of search is the first day of the current month by default and end of search is today
|
||||
var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date;
|
||||
var endSearchDate = DateTime.Today;
|
||||
|
||||
var pc = new PersianCalendar();
|
||||
var currentYear = pc.GetYear(DateTime.Now);
|
||||
var currentMonth = pc.GetMonth(DateTime.Now);
|
||||
var pc = new PersianCalendar();
|
||||
var currentYear = pc.GetYear(DateTime.Now);
|
||||
var currentMonth = pc.GetMonth(DateTime.Now);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) &&
|
||||
searchModel.Year == 0 && searchModel.Month == 0)
|
||||
{
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) &&
|
||||
searchModel.Year == 0 && searchModel.Month == 0)
|
||||
{
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
|
||||
if (queryEndDate > queryStartDate)
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate);
|
||||
}
|
||||
if (queryEndDate > queryStartDate)
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate);
|
||||
}
|
||||
|
||||
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
queryEndDate = queryEndDate.AddDays(-1);
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
queryEndDate = queryEndDate.AddDays(-1);
|
||||
|
||||
|
||||
|
||||
|
||||
//if (queryEndDate < DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
//if (queryEndDate < DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
|
||||
if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Today.AddDays(-1);
|
||||
if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Today.AddDays(-1);
|
||||
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd.Date <= endSearchDate && x.ContractEnd.Date >= startSearchDate);
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
startSearchDate = queryStartDate;
|
||||
endSearchDate = queryEndDate;
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd.Date <= endSearchDate && x.ContractEnd.Date >= startSearchDate);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
|
||||
if (searchModel.BankId > 0)
|
||||
query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId));
|
||||
if (searchModel.BankId > 0)
|
||||
query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId));
|
||||
|
||||
switch (searchModel.OrderBy)
|
||||
{
|
||||
case CustomizeCheckoutOrderByEnum.ContractStartDesc:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractStart:
|
||||
query = query.OrderBy(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNoDesc:
|
||||
query = query.OrderByDescending(x => x.ContractNo);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNo:
|
||||
query = query.OrderBy(x => x.ContractNo);
|
||||
break;
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
switch (searchModel.OrderBy)
|
||||
{
|
||||
case CustomizeCheckoutOrderByEnum.ContractStartDesc:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractStart:
|
||||
query = query.OrderBy(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNoDesc:
|
||||
query = query.OrderByDescending(x => x.ContractNo);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNo:
|
||||
query = query.OrderBy(x => x.ContractNo);
|
||||
break;
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (searchModel.Month == 0 || searchModel.Year == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
if (searchModel.Month == 0 || searchModel.Year == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
|
||||
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
ContractNo = x.ContractNo,
|
||||
EmployeeFName = x.EmployeeFName,
|
||||
EmployeeLName = x.EmployeeLName,
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
ContractNo = x.ContractNo,
|
||||
EmployeeFName = x.EmployeeFName,
|
||||
EmployeeLName = x.EmployeeLName,
|
||||
|
||||
PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode,
|
||||
Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(),
|
||||
Year = pc.GetYear(x.ContractStart).ToString(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment,
|
||||
TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
}).ToList();
|
||||
PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode,
|
||||
Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(),
|
||||
Year = pc.GetYear(x.ContractStart).ToString(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment,
|
||||
TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
}).ToList();
|
||||
|
||||
|
||||
}
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
}
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
{
|
||||
|
||||
//var pc = new PersianCalendar();
|
||||
|
||||
@@ -1791,43 +1791,62 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
IsBirthDay = isBirthday
|
||||
};
|
||||
});
|
||||
var presentDays = rollCalls.Where(x => x.EmployeeId == employeeId).GroupBy(x => x.ShiftDate.Date).Select(x =>
|
||||
{
|
||||
var orderedRollcalls = x.OrderBy(y => y.StartDate!.Value).ToList();
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
StartDate1 = orderedRollcalls.FirstOrDefault()?.StartDate?.ToString("HH:mm"),
|
||||
EndDate1 = orderedRollcalls.FirstOrDefault()?.EndDate?.ToString("HH:mm"),
|
||||
var presentDays = rollCalls.Where(x => x.EmployeeId == employeeId).GroupBy(x => x.ShiftDate.Date).Select(x =>
|
||||
{
|
||||
var orderedRollcalls = x.OrderBy(y => y.StartDate!.Value).ToList();
|
||||
var firstRollCall = orderedRollcalls.FirstOrDefault();
|
||||
var secondRollCall = orderedRollcalls.Skip(1).FirstOrDefault();
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
StartDate1 = orderedRollcalls.FirstOrDefault()?.StartDate?.ToString("HH:mm"),
|
||||
EndDate1 = orderedRollcalls.FirstOrDefault()?.EndDate?.ToString("HH:mm"),
|
||||
|
||||
StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "",
|
||||
EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "",
|
||||
StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "",
|
||||
EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "",
|
||||
|
||||
TotalhourseSpan =
|
||||
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks)),
|
||||
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
|
||||
RollCallDateFa = x.Key.Date.ToFarsi(),
|
||||
DateTimeGr = x.Key.Date,
|
||||
IsSliced = x.Count() > 2,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = pc.GetMonth(x.Key) == pc.GetMonth(birthDay) && pc.GetDayOfMonth(x.Key) == pc.GetDayOfMonth(birthDay)
|
||||
};
|
||||
});
|
||||
presentDays = presentDays.Select(x => new CheckoutDailyRollCallViewModel
|
||||
{
|
||||
StartDate1 = x.StartDate1,
|
||||
EndDate1 = x.EndDate1,
|
||||
EndDate2 = x.EndDate2,
|
||||
StartDate2 = x.StartDate2,
|
||||
TotalWorkingHours = $"{(int)(x.TotalhourseSpan.TotalHours)}:{x.TotalhourseSpan.Minutes.ToString("00")}",
|
||||
DayOfWeek = x.DayOfWeek,
|
||||
RollCallDateFa = x.RollCallDateFa,
|
||||
DateTimeGr = x.DateTimeGr,
|
||||
IsSliced = x.IsSliced,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = x.IsBirthDay
|
||||
});
|
||||
TotalhourseSpan =
|
||||
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks)),
|
||||
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
|
||||
RollCallDateFa = x.Key.Date.ToFarsi(),
|
||||
DateTimeGr = x.Key.Date,
|
||||
IsSliced = x.Count() > 2,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = pc.GetMonth(x.Key) == pc.GetMonth(birthDay) && pc.GetDayOfMonth(x.Key) == pc.GetDayOfMonth(birthDay),
|
||||
|
||||
List<CheckoutDailyRollCallViewModel> checkoutDailyRollCalls = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList();
|
||||
EnterDifferencesMinutes1 = firstRollCall != null && firstRollCall.LateEntryDuration > TimeSpan.Zero && workshopId == 170
|
||||
? CalculateEntryMinuteDifference(firstRollCall.EarlyEntryDuration,
|
||||
firstRollCall.LateEntryDuration)
|
||||
: "",
|
||||
ExitDifferencesMinutes1 = "",
|
||||
|
||||
EnterDifferencesMinutes2 = secondRollCall != null && secondRollCall.LateEntryDuration > TimeSpan.Zero && workshopId == 170
|
||||
? CalculateEntryMinuteDifference(secondRollCall.EarlyEntryDuration,
|
||||
secondRollCall.LateEntryDuration)
|
||||
: "",
|
||||
ExitDifferencesMinutes2 = ""
|
||||
};
|
||||
});
|
||||
presentDays = presentDays.Select(x => new CheckoutDailyRollCallViewModel
|
||||
{
|
||||
StartDate1 = x.StartDate1,
|
||||
EndDate1 = x.EndDate1,
|
||||
EndDate2 = x.EndDate2,
|
||||
StartDate2 = x.StartDate2,
|
||||
TotalWorkingHours = $"{(int)(x.TotalhourseSpan.TotalHours)}:{x.TotalhourseSpan.Minutes.ToString("00")}",
|
||||
DayOfWeek = x.DayOfWeek,
|
||||
RollCallDateFa = x.RollCallDateFa,
|
||||
DateTimeGr = x.DateTimeGr,
|
||||
IsSliced = x.IsSliced,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = x.IsBirthDay,
|
||||
EnterDifferencesMinutes1 = x.EnterDifferencesMinutes1,
|
||||
ExitDifferencesMinutes1 = x.ExitDifferencesMinutes1,
|
||||
EnterDifferencesMinutes2 = x.EnterDifferencesMinutes2,
|
||||
ExitDifferencesMinutes2 = x.ExitDifferencesMinutes2,
|
||||
});
|
||||
|
||||
|
||||
List<CheckoutDailyRollCallViewModel> checkoutDailyRollCalls = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList();
|
||||
|
||||
checkoutDailyRollCalls.ForEach(x =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user