Compare commits
13 Commits
CreateRewa
...
Fix/Custom
| Author | SHA1 | Date | |
|---|---|---|---|
| 1449e83a0f | |||
|
|
caaace7bcc | ||
|
|
c6142b684e | ||
|
|
ef5f80ba91 | ||
|
|
cac3d47c32 | ||
|
|
e2e0171564 | ||
| 7566268534 | |||
| e9805130ad | |||
| d139a36fba | |||
|
|
a9655d6df5 | ||
|
|
b8f8485266 | ||
|
|
22c1847cbe | ||
|
|
807afbae18 |
@@ -182,9 +182,10 @@ public class CustomizeCheckoutMandatoryViewModel
|
||||
public int Year { get; set; }
|
||||
public int Month { get; set; }
|
||||
#endregion
|
||||
public List<FineViewModel> FineViewModels { get; set; }
|
||||
public List<RewardViewModel> RewardViewModels { get; set; }
|
||||
public List<LoanInstallmentViewModel> InstallmentViewModels{ get; set; }
|
||||
public List<SalaryAidViewModel> SalaryAidViewModels { get; set; }
|
||||
|
||||
public List<FineViewModel> FineViewModels { get; set; } = [];
|
||||
public List<RewardViewModel> RewardViewModels { get; set; } = [];
|
||||
public List<LoanInstallmentViewModel> InstallmentViewModels { get; set; } = [];
|
||||
public List<SalaryAidViewModel> SalaryAidViewModels { get; set; } = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,9 @@ namespace CompanyManagment.Application
|
||||
StartDate = x.StartDate,
|
||||
EndDateGr = x.EndDateGr > endOfMonth ? endOfMonth : x.EndDateGr.Date,
|
||||
StartDateGr = x.StartDateGr < startOfMonth ? startOfMonth : x.StartDateGr.Date
|
||||
});
|
||||
}).ToList();
|
||||
|
||||
|
||||
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdInDates(workshopId, startOfMonth, endOfMonth);
|
||||
var personnelCodes = _personnelCodeRepository.Search(new PersonnelCodeSearchModel()
|
||||
@@ -264,7 +266,10 @@ namespace CompanyManagment.Application
|
||||
var statusesWithActiveLeftWorks = statuses
|
||||
.Where(status => workshopLeftWorksInMonth.Any(leftWork => leftWork.EmployeeId == status.EmployeeId &&
|
||||
leftWork.StartWorkDateGr.Date <= status.StartDateGr.Date &&
|
||||
leftWork.LeftWorkDateGr.Date >= status.EndDateGr.Date));
|
||||
leftWork.LeftWorkDateGr.Date >= status.EndDateGr.Date)).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var employeesWithCheckout = statusesWithActiveLeftWorks.Where(x => customizeCheckouts.Any(y => y.EmployeeId == x.EmployeeId));
|
||||
@@ -285,6 +290,24 @@ namespace CompanyManagment.Application
|
||||
eligibleEmloyees = eligibleEmloyees.Where(x => !employeesWithoutSalary.Any(y => y.EmployeeId == x.EmployeeId));
|
||||
|
||||
|
||||
#region CustomForKebabMahdi
|
||||
|
||||
if (workshopId == 170)
|
||||
{
|
||||
List<long> employeesIds = [ 45084, 7980, 5976,45214,45215];
|
||||
foreach (var employeesId in employeesIds)
|
||||
{
|
||||
|
||||
var status = new RollCallEmployeeStatusViewModel()
|
||||
{
|
||||
EmployeeId = employeesId,
|
||||
};
|
||||
statusesWithActiveLeftWorks.Add(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
if (!statusesWithActiveLeftWorks.Any())
|
||||
return op.Failed("امکان ایجاد فیش برای تاریخ انتخاب شده وجود ندارد");
|
||||
|
||||
@@ -234,6 +234,24 @@ namespace CompanyManagment.Application
|
||||
leftWork.LeftWorkDateGr.Date >= status.EndDateGr.Date)).ToList();
|
||||
|
||||
|
||||
#region CustomForKebabMahdi
|
||||
|
||||
if (workshopId == 170)
|
||||
{
|
||||
List<long> employeesIds = [45084, 7980, 5976, 45214,45215];
|
||||
foreach (var employeesId in employeesIds)
|
||||
{
|
||||
|
||||
var status = new RollCallEmployeeStatusViewModel()
|
||||
{
|
||||
EmployeeId = employeesId,
|
||||
};
|
||||
statusesWithActiveLeftWorks.Add(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
if (!statusesWithActiveLeftWorks.Any())
|
||||
return op.Failed("امکان ایجاد فیش برای تاریخ انتخاب شده وجود ندارد");
|
||||
|
||||
@@ -146,21 +146,21 @@ namespace CompanyManagment.Application
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditRollCallEmployeeStatus cmd)
|
||||
{
|
||||
OperationResult op = new();
|
||||
RollCallEmployeeStatus entity = _employeeRollCallStatusRepository.Get(cmd.Id);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
public OperationResult Edit(EditRollCallEmployeeStatus cmd)
|
||||
{
|
||||
OperationResult op = new();
|
||||
RollCallEmployeeStatus entity = _employeeRollCallStatusRepository.Get(cmd.Id);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
|
||||
entity.Edit(cmd.StartDate, cmd.EndDate);
|
||||
_employeeRollCallStatusRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
entity.Edit(cmd.StartDate, cmd.EndDate);
|
||||
_employeeRollCallStatusRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public List<RollCallEmployeeStatusViewModel> GetAll()
|
||||
{
|
||||
return _employeeRollCallStatusRepository.GetAll();
|
||||
}
|
||||
}
|
||||
public List<RollCallEmployeeStatusViewModel> GetAll()
|
||||
{
|
||||
return _employeeRollCallStatusRepository.GetAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,6 +642,13 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
}
|
||||
|
||||
|
||||
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
|
||||
{
|
||||
var leftWork =await _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
||||
.OrderByDescending(x => x.StartWorkDate).FirstOrDefaultAsync();
|
||||
return leftWork;
|
||||
}
|
||||
|
||||
private bool HasActiveRollCallStatus(long workshopId, long employeeId)
|
||||
{
|
||||
var now = DateTime.Today;
|
||||
@@ -684,10 +691,5 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
|
||||
}
|
||||
#endregion
|
||||
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
|
||||
{
|
||||
var leftWork = await _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
||||
.OrderByDescending(x => x.StartWorkDate).FirstOrDefaultAsync();
|
||||
return leftWork;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1613,6 +1613,12 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
public CustomizeCheckoutMandatoryViewModel CustomizeCheckoutMandatoryComputeForKebabMahdi(long employeeId, long workshopId,
|
||||
DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
var checkoutEnd = contractEnd;
|
||||
var checkoutStart = contractStart;
|
||||
if (employeeId is 45084 or 7980 or 5976 or 45214 or 45215)
|
||||
{
|
||||
return CheckoutWithoutCalculationForKebabMahdi(workshopId,employeeId,contractStart,contractEnd);
|
||||
}
|
||||
var firstDayOfMonth = $"{(contractStart.ToFarsi())[..8]}/01".ToGeorgianDateTime();
|
||||
|
||||
#region LeftWork
|
||||
@@ -1964,7 +1970,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#region SalaryAidDeduction
|
||||
|
||||
var salaryAidViewModel = _context.SalaryAids
|
||||
.Where(x => x.SalaryAidDateTime >= contractStart && x.SalaryAidDateTime <= contractEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
.Where(x => x.SalaryAidDateTime >= checkoutStart && x.SalaryAidDateTime <= checkoutEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
@@ -2178,8 +2184,8 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#region Reward
|
||||
|
||||
var rewardViewModels = _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= contractEnd &&
|
||||
x.GrantDate >= contractStart).Select(x => new RewardViewModel
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
||||
x.GrantDate >= checkoutStart).Select(x => new RewardViewModel
|
||||
{
|
||||
Title = x.Title,
|
||||
Amount = x.Amount.ToMoney(),
|
||||
@@ -2379,7 +2385,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
EmployeeId = employeeId,
|
||||
SumOfWorkingDays = totalDays.ToString(),
|
||||
ContractNo = contract?.ContractNo ?? "-",
|
||||
MonthlySalary = Math.Truncate(dailyWage * mandatoryDays),
|
||||
MonthlySalary = dailyWage * mandatoryDays,
|
||||
PersonnelCode = personnelCode,
|
||||
FineViewModels = fineViewModels,
|
||||
InstallmentViewModels = loanInstallments,
|
||||
@@ -2390,6 +2396,112 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
};
|
||||
}
|
||||
|
||||
private CustomizeCheckoutMandatoryViewModel CheckoutWithoutCalculationForKebabMahdi(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
var firstDayOfMonth = $"{(contractStart.ToFarsi())[..8]}/01".ToGeorgianDateTime();
|
||||
|
||||
CustomizeWorkshopEmployeeSettings customizeWorkshopEmployeeSettings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
CustomizeWorkshopSettings customizeWorkshopSettings =
|
||||
_context.CustomizeWorkshopSettings.FirstOrDefault(x => x.WorkshopId == workshopId);
|
||||
//ToDo handel exception if is null
|
||||
var monthySalary = customizeWorkshopEmployeeSettings?.Salary ?? 0;
|
||||
var monthDays = customizeWorkshopSettings.MaxMonthDays == MaxMonthDays.ThirtyDaysForAllMonth
|
||||
? 30
|
||||
: firstDayOfMonth.CountMonthDays();
|
||||
double dailyWage = 0;
|
||||
dailyWage = monthySalary / monthDays;
|
||||
|
||||
var totalDays = (int)(contractEnd - contractStart).TotalDays + 1;
|
||||
var mandatoryDays = totalDays;
|
||||
|
||||
|
||||
#region SalaryAidDeduction
|
||||
|
||||
var salaryAidViewModel = _context.SalaryAids
|
||||
.Where(x => x.SalaryAidDateTime >= contractStart && x.SalaryAidDateTime <= contractEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||
}).ToList();
|
||||
double salaryAidDeduction = salaryAidViewModel.Sum(x => x.AmountDouble);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Loan
|
||||
|
||||
var loanInstallments = _context.Loans
|
||||
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)
|
||||
.SelectMany(x => x.LoanInstallments)
|
||||
.Where(i => i.InstallmentDate > contractStart && i.InstallmentDate < contractEnd && i.IsActive == IsActive.True)
|
||||
.Select(x => new LoanInstallmentViewModel()
|
||||
{
|
||||
Month = x.Month,
|
||||
IsActive = x.IsActive,
|
||||
Amount = x.AmountForMonth.ToMoney(),
|
||||
Year = x.Year,
|
||||
AmountDouble = x.AmountForMonth,
|
||||
RemainingAmount = _context.Loans.SelectMany(l => l.LoanInstallments).Where(i => i.LoanId == x.LoanId && i.IsActive == IsActive.True && i.InstallmentDate > x.InstallmentDate)
|
||||
.Sum(i => i.AmountForMonth).ToMoney()
|
||||
}).ToList();
|
||||
|
||||
double loanDeduction = loanInstallments.Sum(x => x.AmountDouble);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fine
|
||||
|
||||
var fineViewModels = _context.Fines.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.FineDate >= contractStart &&
|
||||
x.FineDate <= contractEnd && x.IsActive == IsActive.True).Select(x => new FineViewModel()
|
||||
{
|
||||
IsActive = x.IsActive,
|
||||
Amount = x.Amount.ToMoney(),
|
||||
FineDate = x.FineDate.ToFarsi(),
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
EmployeeId = x.EmployeeId,
|
||||
CreationDate = x.CreationDate.ToFarsi()
|
||||
}).ToList();
|
||||
double fineDeduction = fineViewModels.Sum(x => x.Amount.MoneyToDouble());
|
||||
|
||||
#endregion
|
||||
#region Reward
|
||||
|
||||
var rewardViewModels = _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= contractEnd &&
|
||||
x.GrantDate >= contractStart).Select(x => new RewardViewModel
|
||||
{
|
||||
Title = x.Title,
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
Description = x.Description,
|
||||
GrantDateGr = x.GrantDate,
|
||||
GrantDateFa = x.GrantDate.ToFarsi(),
|
||||
IsActive = x.IsActive,
|
||||
}).ToList();
|
||||
|
||||
double rewardPay = rewardViewModels.Sum(x => x.AmountDouble);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
return new CustomizeCheckoutMandatoryViewModel()
|
||||
{
|
||||
MonthlySalary = dailyWage * mandatoryDays,
|
||||
RewardPay = rewardPay,
|
||||
RewardViewModels = rewardViewModels,
|
||||
SalaryAidDeduction = salaryAidDeduction,
|
||||
SalaryAidViewModels = salaryAidViewModel,
|
||||
InstallmentDeduction = loanDeduction,
|
||||
InstallmentViewModels = loanInstallments,
|
||||
FineDeduction = fineDeduction,
|
||||
FineViewModels = fineViewModels
|
||||
};
|
||||
}
|
||||
|
||||
private void CreateRewardForBirthDay(long employeeId, long workshopId, double amount, int month, int year,
|
||||
DateTime contractStart)
|
||||
{
|
||||
|
||||
BIN
ServiceHost/wwwroot/Excel/Kebab custom shifts.xlsx
Normal file
BIN
ServiceHost/wwwroot/Excel/Kebab custom shifts.xlsx
Normal file
Binary file not shown.
BIN
ServiceHost/wwwroot/Excel/KebabMahdi Custom Salary Sample.xlsx
Normal file
BIN
ServiceHost/wwwroot/Excel/KebabMahdi Custom Salary Sample.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user