Compare commits
1 Commits
Fix/RollCa
...
Feature/Ma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1e5adf96f |
@@ -458,25 +458,30 @@ public static class Tools
|
||||
public static double MoneyToDouble(this string myMoney)
|
||||
{
|
||||
string bb = string.Empty;
|
||||
bool isNegative = false;
|
||||
|
||||
for (int x = 0; x < myMoney.Length; x++)
|
||||
{
|
||||
if (char.IsDigit(myMoney[x]))
|
||||
{
|
||||
bb += myMoney[x];
|
||||
}
|
||||
else if (myMoney[x] == '-' && bb.Length == 0)
|
||||
{
|
||||
// اگر علامت منفی قبل از اولین عدد آمد، در نظر بگیر
|
||||
isNegative = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bb.Length > 0)
|
||||
{
|
||||
double res = double.Parse(bb);
|
||||
return res;
|
||||
return isNegative ? -res : res;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public static string ToFileName(this DateTime date)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
@@ -18,20 +19,20 @@ public class CustomizeCheckout : EntityBase
|
||||
private CustomizeCheckout()
|
||||
{ }
|
||||
public CustomizeCheckout(DateTime contractStart, DateTime contractEnd, long employeeId, string employeeFName,
|
||||
string employeeLName, DateTime employeeDateOfBirth,
|
||||
string employeeNationalCode, string workshopFullName, long workshopId, long? contractId,
|
||||
double monthlySalary, double fridayPay, double overTimePay, double baseYearsPay, double bonusesPay,
|
||||
double nightWorkPay,
|
||||
double marriedAllowance, double shiftPay, double familyAllowance, double leavePay, double insuranceDeduction,
|
||||
double fineAbsenceDeduction,
|
||||
double lateToWorkDeduction, double earlyExitDeduction, double rewardPay, double salaryAidDeduction,
|
||||
double installmentDeduction,
|
||||
double fineDeduction, double taxDeduction, string sumOfWorkingDays, string totalClaims, string totalDeductions,
|
||||
double totalPayment, string contractNo, ICollection<CustomizeCheckoutFine> checkoutFines,
|
||||
ICollection<CustomizeCheckoutLoanInstallments> customizeCheckoutLoanInstallments,
|
||||
ICollection<CustomizeCheckoutSalaryAid> customizeCheckoutSalaryAids,
|
||||
ICollection<CustomizeCheckoutReward> customizeCheckoutRewards, TimeSpan lateToWorkValue, double settingSalary,
|
||||
double dailyWage, WorkshopShiftStatus shiftStatus, IrregularShift irregularShift,
|
||||
string employeeLName, DateTime employeeDateOfBirth,
|
||||
string employeeNationalCode, string workshopFullName, long workshopId, long? contractId,
|
||||
double monthlySalary, double fridayPay, double overTimePay, double baseYearsPay, double bonusesPay,
|
||||
double nightWorkPay,
|
||||
double marriedAllowance, double shiftPay, double familyAllowance, double leavePay, double insuranceDeduction,
|
||||
double fineAbsenceDeduction,
|
||||
double lateToWorkDeduction, double earlyExitDeduction, double rewardPay, double salaryAidDeduction,
|
||||
double installmentDeduction,
|
||||
double fineDeduction, double taxDeduction, string sumOfWorkingDays, string totalClaims, string totalDeductions,
|
||||
double totalPayment, string contractNo, ICollection<CustomizeCheckoutFine> checkoutFines,
|
||||
ICollection<CustomizeCheckoutLoanInstallments> customizeCheckoutLoanInstallments,
|
||||
ICollection<CustomizeCheckoutSalaryAid> customizeCheckoutSalaryAids,
|
||||
ICollection<CustomizeCheckoutReward> customizeCheckoutRewards, TimeSpan lateToWorkValue, double settingSalary,
|
||||
double dailyWage, WorkshopShiftStatus shiftStatus, IrregularShift irregularShift,
|
||||
ICollection<CustomizeRotatingShift> customizeRotatingShifts, ICollection<CustomizeCheckoutRegularShift> employeeSettingsShifts)
|
||||
{
|
||||
YearInt = Convert.ToInt32(contractStart.ToFarsi().Substring(0, 4));
|
||||
@@ -77,8 +78,8 @@ public class CustomizeCheckout : EntityBase
|
||||
|
||||
LateToWorkValue = lateToWorkValue;
|
||||
SettingSalary = settingSalary;
|
||||
DailyWage = dailyWage;
|
||||
ShiftStatus = shiftStatus;
|
||||
DailyWage = dailyWage;
|
||||
ShiftStatus = shiftStatus;
|
||||
IrregularShift = irregularShift;
|
||||
CustomizeRotatingShifts = customizeRotatingShifts;
|
||||
RegularShifts = employeeSettingsShifts;
|
||||
@@ -257,17 +258,17 @@ public class CustomizeCheckout : EntityBase
|
||||
/// </summary>
|
||||
public double TotalPayment { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// مزد روزانه
|
||||
/// </summary>
|
||||
public double DailyWage { get; private set; }
|
||||
/// <summary>
|
||||
/// مزد روزانه
|
||||
/// </summary>
|
||||
public double DailyWage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// حقوق تعیین شده
|
||||
/// </summary>
|
||||
public double SettingSalary { get; private set; }
|
||||
/// <summary>
|
||||
/// حقوق تعیین شده
|
||||
/// </summary>
|
||||
public double SettingSalary { get; private set; }
|
||||
|
||||
public WorkshopShiftStatus ShiftStatus { get; set; }
|
||||
public WorkshopShiftStatus ShiftStatus { get; set; }
|
||||
|
||||
|
||||
#region Values
|
||||
@@ -301,4 +302,78 @@ public class CustomizeCheckout : EntityBase
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetValueObjects(ICollection<CustomizeCheckoutFine> checkoutFines,
|
||||
ICollection<CustomizeCheckoutLoanInstallments> customizeCheckoutLoanInstallments,
|
||||
ICollection<CustomizeCheckoutSalaryAid> customizeCheckoutSalaryAids,
|
||||
ICollection<CustomizeCheckoutReward> customizeCheckoutRewards)
|
||||
{
|
||||
CheckoutFines = checkoutFines;
|
||||
CustomizeCheckoutLoanInstallments = customizeCheckoutLoanInstallments;
|
||||
CustomizeCheckoutSalaryAids = customizeCheckoutSalaryAids;
|
||||
CustomizeCheckoutRewards = customizeCheckoutRewards;
|
||||
}
|
||||
|
||||
public void SetRewards(ICollection<CustomizeCheckoutReward> rewards)
|
||||
{
|
||||
var previousTotalAmount = CustomizeCheckoutRewards.Sum(x => x.Amount.MoneyToDouble());
|
||||
var newTotalAmount = rewards.Sum(x => x.Amount.MoneyToDouble());
|
||||
RewardPay = newTotalAmount;
|
||||
IncreaseTotalPayment(previousTotalAmount, newTotalAmount);
|
||||
RecalculateTotalClaims(previousTotalAmount, newTotalAmount);
|
||||
CustomizeCheckoutRewards = rewards;
|
||||
}
|
||||
|
||||
public void SetSalaryAids(ICollection<CustomizeCheckoutSalaryAid> salaryAids)
|
||||
{
|
||||
var previousTotalAmount = CustomizeCheckoutSalaryAids.Sum(x => x.Amount.MoneyToDouble());
|
||||
var newTotalAmount = salaryAids.Sum(x => x.Amount.MoneyToDouble());
|
||||
SalaryAidDeduction = newTotalAmount;
|
||||
ReduceTotalPayment(previousTotalAmount, newTotalAmount);
|
||||
RecalculateTotalDeduction(previousTotalAmount, newTotalAmount);
|
||||
CustomizeCheckoutSalaryAids = salaryAids;
|
||||
}
|
||||
|
||||
public void SetFines(ICollection<CustomizeCheckoutFine> fines)
|
||||
{
|
||||
var previousTotalAmount = CheckoutFines.Sum(x => x.Amount.MoneyToDouble());
|
||||
var newTotalAmount = fines.Sum(x => x.Amount.MoneyToDouble());
|
||||
FineDeduction = newTotalAmount;
|
||||
ReduceTotalPayment(previousTotalAmount, newTotalAmount);
|
||||
RecalculateTotalDeduction(previousTotalAmount, newTotalAmount);
|
||||
CheckoutFines = fines;
|
||||
}
|
||||
|
||||
public void SetLoanInstallment(ICollection<CustomizeCheckoutLoanInstallments> installments)
|
||||
{
|
||||
var previousTotalAmount = CustomizeCheckoutLoanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
||||
var newTotalAmount = installments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
||||
InstallmentDeduction = newTotalAmount;
|
||||
ReduceTotalPayment(previousTotalAmount, newTotalAmount);
|
||||
RecalculateTotalDeduction(previousTotalAmount, newTotalAmount);
|
||||
CustomizeCheckoutLoanInstallments = installments;
|
||||
}
|
||||
|
||||
|
||||
private void RecalculateTotalClaims(double previousTotalAmount, double newTotalAmount)
|
||||
{
|
||||
TotalClaims = (TotalClaims.MoneyToDouble() - previousTotalAmount + newTotalAmount).ToMoney();
|
||||
}
|
||||
|
||||
|
||||
private void RecalculateTotalDeduction(double previousTotalAmount, double newTotalAmount)
|
||||
{
|
||||
TotalDeductions = (TotalDeductions.MoneyToDouble() - previousTotalAmount + newTotalAmount).ToMoney();
|
||||
}
|
||||
|
||||
private void ReduceTotalPayment(double previousAmount, double newAmount)
|
||||
{
|
||||
TotalPayment = TotalPayment + previousAmount - newAmount;
|
||||
}
|
||||
private void IncreaseTotalPayment(double previousAmount, double newAmount)
|
||||
{
|
||||
TotalPayment = TotalPayment - previousAmount + newAmount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.CustomizeCheckoutAgg
|
||||
{
|
||||
@@ -15,5 +15,12 @@ namespace Company.Domain.CustomizeCheckoutAgg
|
||||
void RemoveEmployeeCustomizeCheckoutInDates(long workshopId, long employeeId, DateTime startOfMonth, DateTime endOfMonth);
|
||||
IEnumerable<CustomizeCheckout> GetRange(long workshopId, List<long> ids);
|
||||
void RemoveRange(IEnumerable<CustomizeCheckout> entities);
|
||||
List<CustomizeCheckout> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime startDate, DateTime endDate);
|
||||
|
||||
Task<CustomizeCheckout> GetByWorkshopIdEmployeeIdMonthYear(long workshopId, long employeeId, int year,
|
||||
int month);
|
||||
|
||||
(bool Checkout, bool CustomizeCheckout, bool CustomizeCheckoutTemp) ValidateExistsCheckouts(
|
||||
DateTime startDate, DateTime endDate, long workshopId, List<long> employeeId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
|
||||
public record CustomizeCheckoutFine
|
||||
{
|
||||
public CustomizeCheckoutFine(string title, string amount, string fineDateFa, DateTime fineDateGr, IsActive isActive, DateTime creationDate)
|
||||
public CustomizeCheckoutFine(string title, string amount, string fineDateFa, DateTime fineDateGr, IsActive isActive, DateTime creationDate, long entityId)
|
||||
{
|
||||
Title = title;
|
||||
Amount = amount;
|
||||
@@ -13,6 +13,7 @@ public record CustomizeCheckoutFine
|
||||
FineDateGr = fineDateGr;
|
||||
IsActive = isActive;
|
||||
CreationDate = creationDate;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
public string Title { get; private set; }
|
||||
@@ -21,4 +22,5 @@ public record CustomizeCheckoutFine
|
||||
public DateTime FineDateGr { get; private set; }
|
||||
public IsActive IsActive { get; private set; }
|
||||
public DateTime CreationDate { get; private set; }
|
||||
public long EntityId { get; set; }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
|
||||
public class CustomizeCheckoutLoanInstallments
|
||||
{
|
||||
public CustomizeCheckoutLoanInstallments(string amountForMonth, string month, string year, IsActive isActive, string loanRemaining, string loanAmount)
|
||||
public CustomizeCheckoutLoanInstallments(string amountForMonth, string month, string year, IsActive isActive, string loanRemaining, string loanAmount, long entityId)
|
||||
{
|
||||
AmountForMonth = amountForMonth;
|
||||
Month = month;
|
||||
@@ -13,6 +13,7 @@ public class CustomizeCheckoutLoanInstallments
|
||||
IsActive = isActive;
|
||||
LoanRemaining = loanRemaining;
|
||||
LoanAmount = loanAmount;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
public string AmountForMonth { get; private set; }
|
||||
@@ -21,5 +22,7 @@ public class CustomizeCheckoutLoanInstallments
|
||||
public string LoanRemaining { get; set; }
|
||||
public IsActive IsActive { get; private set; }
|
||||
public string LoanAmount { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
|
||||
public class CustomizeCheckoutReward
|
||||
{
|
||||
public CustomizeCheckoutReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive, string title)
|
||||
public CustomizeCheckoutReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive, string title, long entityId)
|
||||
{
|
||||
Amount = amount;
|
||||
Description = description;
|
||||
@@ -13,6 +13,7 @@ public class CustomizeCheckoutReward
|
||||
GrantDateFa = grantDateFa;
|
||||
IsActive = isActive;
|
||||
Title = title;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,5 +40,7 @@ public class CustomizeCheckoutReward
|
||||
|
||||
|
||||
public IsActive IsActive { get; private set; }
|
||||
public long EntityId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -4,14 +4,23 @@ namespace Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
|
||||
public class CustomizeCheckoutSalaryAid
|
||||
{
|
||||
public CustomizeCheckoutSalaryAid(string amount, DateTime salaryAidDateTime, string salaryAidDateTimeFa)
|
||||
public CustomizeCheckoutSalaryAid(string amount, DateTime salaryAidDateTime, string salaryAidDateTimeFa,DateTime calculationDateTime,string calculationDateTimeFa, long entityId)
|
||||
{
|
||||
Amount = amount;
|
||||
SalaryAidDateTime = salaryAidDateTime;
|
||||
SalaryAidDateTimeFa = salaryAidDateTimeFa;
|
||||
CalculationDateTime = calculationDateTime;
|
||||
CalculationDateTimeFa = calculationDateTimeFa;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
public string Amount { get; private set; }
|
||||
public DateTime SalaryAidDateTime { get; private set; }
|
||||
public string SalaryAidDateTimeFa { get; private set; }
|
||||
|
||||
public DateTime CalculationDateTime { get; private set; }
|
||||
public string CalculationDateTimeFa { get; private set; }
|
||||
|
||||
public long EntityId { get; set; }
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace Company.Domain.CustomizeCheckoutTempAgg;
|
||||
@@ -303,6 +304,77 @@ public class CustomizeCheckoutTemp : EntityBase
|
||||
public Workshop Workshop { get; set; }
|
||||
public Employee Employee { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public void SetValueObjects(ICollection<CustomizeCheckoutTempFine> checkoutFines,
|
||||
ICollection<CustomizeCheckoutTempLoanInstallments> customizeCheckoutLoanInstallments,
|
||||
ICollection<CustomizeCheckoutTempSalaryAid> customizeCheckoutSalaryAids,
|
||||
ICollection<CustomizeCheckoutTempReward> customizeCheckoutRewards)
|
||||
{
|
||||
CheckoutFines = checkoutFines;
|
||||
CustomizeCheckoutLoanInstallments = customizeCheckoutLoanInstallments;
|
||||
CustomizeCheckoutSalaryAids = customizeCheckoutSalaryAids;
|
||||
CustomizeCheckoutRewards = customizeCheckoutRewards;
|
||||
}
|
||||
|
||||
public void SetRewards(ICollection<CustomizeCheckoutTempReward> rewards)
|
||||
{
|
||||
var previousTotalAmount = CustomizeCheckoutRewards.Sum(x => x.Amount.MoneyToDouble());
|
||||
var newTotalAmount = rewards.Sum(x => x.Amount.MoneyToDouble());
|
||||
RewardPay = newTotalAmount;
|
||||
IncreaseTotalPayment(previousTotalAmount,newTotalAmount);
|
||||
RecalculateTotalClaims(previousTotalAmount, newTotalAmount);
|
||||
CustomizeCheckoutRewards = rewards;
|
||||
}
|
||||
|
||||
public void SetSalaryAids(ICollection<CustomizeCheckoutTempSalaryAid> salaryAids)
|
||||
{
|
||||
var previousTotalAmount = CustomizeCheckoutSalaryAids.Sum(x => x.Amount.MoneyToDouble());
|
||||
var newTotalAmount = salaryAids.Sum(x => x.Amount.MoneyToDouble());
|
||||
SalaryAidDeduction = newTotalAmount;
|
||||
ReduceTotalPayment(previousTotalAmount,newTotalAmount);
|
||||
RecalculateTotalDeduction(previousTotalAmount, newTotalAmount);
|
||||
CustomizeCheckoutSalaryAids = salaryAids;
|
||||
}
|
||||
|
||||
public void SetFines(ICollection<CustomizeCheckoutTempFine> fines)
|
||||
{
|
||||
var previousTotalAmount = CheckoutFines.Sum(x => x.Amount.MoneyToDouble());
|
||||
var newTotalAmount = fines.Sum(x => x.Amount.MoneyToDouble());
|
||||
FineDeduction = newTotalAmount;
|
||||
ReduceTotalPayment(previousTotalAmount,newTotalAmount);
|
||||
RecalculateTotalDeduction(previousTotalAmount, newTotalAmount);
|
||||
CheckoutFines = fines;
|
||||
}
|
||||
|
||||
public void SetLoanInstallment(ICollection<CustomizeCheckoutTempLoanInstallments> installments)
|
||||
{
|
||||
var previousTotalAmount = CustomizeCheckoutLoanInstallments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
||||
var newTotalAmount = installments.Sum(x => x.AmountForMonth.MoneyToDouble());
|
||||
InstallmentDeduction = newTotalAmount;
|
||||
ReduceTotalPayment(previousTotalAmount,newTotalAmount);
|
||||
RecalculateTotalDeduction(previousTotalAmount, newTotalAmount);
|
||||
CustomizeCheckoutLoanInstallments = installments;
|
||||
}
|
||||
|
||||
|
||||
private void RecalculateTotalClaims(double previousTotalAmount, double newTotalAmount)
|
||||
{
|
||||
TotalClaims = (TotalClaims.MoneyToDouble() - previousTotalAmount + newTotalAmount).ToMoney();
|
||||
}
|
||||
|
||||
|
||||
private void RecalculateTotalDeduction(double previousTotalAmount, double newTotalAmount)
|
||||
{
|
||||
TotalDeductions = (TotalDeductions.MoneyToDouble() - previousTotalAmount + newTotalAmount).ToMoney();
|
||||
}
|
||||
|
||||
private void ReduceTotalPayment(double previousAmount, double newAmount)
|
||||
{
|
||||
TotalPayment = TotalPayment + previousAmount - newAmount;
|
||||
}
|
||||
private void IncreaseTotalPayment(double previousAmount, double newAmount)
|
||||
{
|
||||
TotalPayment = TotalPayment - previousAmount + newAmount;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Company.Domain.CustomizeCheckoutAgg;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.CustomizeCheckoutTempAgg
|
||||
{
|
||||
@@ -19,5 +20,7 @@ namespace Company.Domain.CustomizeCheckoutTempAgg
|
||||
|
||||
IEnumerable<CustomizeCheckoutTemp> GetRange(long workshopId, List<long> ids);
|
||||
void RemoveRange(IEnumerable<CustomizeCheckoutTemp> entities);
|
||||
List<CustomizeCheckoutTemp> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime startDate, DateTime endDate);
|
||||
Task<CustomizeCheckoutTemp> GetByWorkshopIdEmployeeIdInDate(long workshopId, long employeeId, DateTime inDate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,23 @@ namespace Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
|
||||
public class CustomizeCheckoutTempSalaryAid
|
||||
{
|
||||
public CustomizeCheckoutTempSalaryAid(string amount, DateTime salaryAidDateTime, string salaryAidDateTimeFa)
|
||||
public CustomizeCheckoutTempSalaryAid(string amount, DateTime salaryAidDateTime, string salaryAidDateTimeFa,
|
||||
DateTime calculationDateTime, string calculationDateTimeFa, long entityId)
|
||||
{
|
||||
Amount = amount;
|
||||
SalaryAidDateTime = salaryAidDateTime;
|
||||
SalaryAidDateTimeFa = salaryAidDateTimeFa;
|
||||
CalculationDateTime = calculationDateTime;
|
||||
CalculationDateTimeFa = calculationDateTimeFa;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
public string Amount { get; private set; }
|
||||
public DateTime SalaryAidDateTime { get; private set; }
|
||||
public string SalaryAidDateTimeFa { get; private set; }
|
||||
|
||||
public DateTime CalculationDateTime { get; private set; }
|
||||
public string CalculationDateTimeFa { get; private set; }
|
||||
public long EntityId { get; set; }
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
|
||||
public record CustomizeCheckoutTempFine
|
||||
{
|
||||
public CustomizeCheckoutTempFine(string title, string amount, string fineDateFa, DateTime fineDateGr, IsActive isActive, DateTime creationDate)
|
||||
public CustomizeCheckoutTempFine(string title, string amount, string fineDateFa, DateTime fineDateGr, IsActive isActive, DateTime creationDate, long entityId)
|
||||
{
|
||||
Title = title;
|
||||
Amount = amount;
|
||||
@@ -14,7 +14,7 @@ public record CustomizeCheckoutTempFine
|
||||
FineDateGr = fineDateGr;
|
||||
IsActive = isActive;
|
||||
CreationDate = creationDate;
|
||||
|
||||
EntityId = entityId;
|
||||
}
|
||||
public string Title { get; private set; }
|
||||
public string Amount { get; private set; }
|
||||
@@ -22,4 +22,6 @@ public record CustomizeCheckoutTempFine
|
||||
public DateTime FineDateGr { get; private set; }
|
||||
public IsActive IsActive { get; private set; }
|
||||
public DateTime CreationDate { get; private set; }
|
||||
public long EntityId { get; set; }
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
|
||||
public class CustomizeCheckoutTempLoanInstallments
|
||||
{
|
||||
public CustomizeCheckoutTempLoanInstallments(string amountForMonth, string month, string year, IsActive isActive, string loanRemaining, string loanAmount)
|
||||
public CustomizeCheckoutTempLoanInstallments(string amountForMonth, string month, string year, IsActive isActive, string loanRemaining, string loanAmount, long entityId)
|
||||
{
|
||||
AmountForMonth = amountForMonth;
|
||||
Month = month;
|
||||
@@ -12,6 +12,7 @@ public class CustomizeCheckoutTempLoanInstallments
|
||||
IsActive = isActive;
|
||||
LoanRemaining = loanRemaining;
|
||||
LoanAmount = loanAmount;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
public string AmountForMonth { get; private set; }
|
||||
@@ -20,5 +21,7 @@ public class CustomizeCheckoutTempLoanInstallments
|
||||
public IsActive IsActive { get; private set; }
|
||||
public string LoanRemaining { get; set; }
|
||||
public string LoanAmount { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
|
||||
public class CustomizeCheckoutTempReward
|
||||
{
|
||||
public CustomizeCheckoutTempReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive, string title)
|
||||
public CustomizeCheckoutTempReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive, string title, long entityId)
|
||||
{
|
||||
Amount = amount;
|
||||
Description = description;
|
||||
@@ -13,6 +13,7 @@ public class CustomizeCheckoutTempReward
|
||||
GrantDateFa = grantDateFa;
|
||||
IsActive = isActive;
|
||||
Title = title;
|
||||
EntityId = entityId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -37,4 +38,6 @@ public class CustomizeCheckoutTempReward
|
||||
|
||||
public IsActive IsActive { get; private set; }
|
||||
public string Title { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@ using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Drawing.Chart;
|
||||
using System.Collections;
|
||||
|
||||
namespace Company.Domain.RollCallAgg.DomainService;
|
||||
|
||||
@@ -26,7 +25,7 @@ public interface IRollCallDomainService
|
||||
long workshopId);
|
||||
|
||||
TimeOnly GetEmployeeOffSetForRegularSettings(long employeeId, long workshopId);
|
||||
DateTime GetEmployeeShiftDateByRollCallStartDate(long workshopId, long employeeId, DateTime rollCallStartDate, DateTime rollCallEndDate);
|
||||
DateTime GetEmployeeShiftDateByRollCallStartDate(long workshopId, long employeeId, DateTime rollCallStartDate,DateTime rollCallEndDate);
|
||||
|
||||
void CalculateTimeDifferences(RollCall rollCall);
|
||||
|
||||
@@ -174,16 +173,16 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
}
|
||||
|
||||
public DateTime GetEmployeeShiftDateByRollCallStartDate(long workshopId, long employeeId,
|
||||
DateTime rollCallStartDate, DateTime rollCallEndDate)
|
||||
DateTime rollCallStartDate,DateTime rollCallEndDate)
|
||||
{
|
||||
var shiftDetails = GetEmployeeShiftDetails(employeeId, workshopId);
|
||||
|
||||
|
||||
var offset = GetEmployeeOffSetForRegularSettings(employeeId, workshopId);
|
||||
|
||||
return shiftDetails.shiftType switch
|
||||
{
|
||||
WorkshopShiftStatus.Regular => CalculateRegularShiftDate(rollCallStartDate, offset),
|
||||
WorkshopShiftStatus.Rotating => FindRotatingShift(rollCallStartDate, rollCallEndDate, shiftDetails.rotatingShifts).start.Date,
|
||||
WorkshopShiftStatus.Rotating => FindRotatingShift(rollCallStartDate,rollCallEndDate,shiftDetails.rotatingShifts).start.Date,
|
||||
WorkshopShiftStatus.Irregular => rollCallStartDate.Date,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
@@ -217,7 +216,6 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
rollCalls.Remove(deletedRollCall);
|
||||
rollCalls.Add(rollCall);
|
||||
|
||||
rollCall.ClearTimeDiff();
|
||||
switch (shiftDetails.shiftType)
|
||||
{
|
||||
case WorkshopShiftStatus.Regular:
|
||||
@@ -257,9 +255,8 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
var earlyEntryRollCall = rollCallsInShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate < employeeShift.start);
|
||||
|
||||
var lateEntryRollCall = rollCallsInShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate > employeeShift.start);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var previousShift = employeeShifts.OrderByDescending(x => x.start)
|
||||
.FirstOrDefault(x => x.end < employeeShift.start);
|
||||
@@ -302,6 +299,8 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
var lateExitRollCall = rollCallsInShift.OrderBy(x => x.EndDate).FirstOrDefault(x => x.EndDate > employeeShift.end);
|
||||
|
||||
|
||||
|
||||
// تعجیل در خروج - زود رفتن
|
||||
var nextShift = employeeShifts.OrderBy(x => x.start)
|
||||
.FirstOrDefault(x => x.start > employeeShift.end);
|
||||
@@ -374,8 +373,8 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
var earlyEntryRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate < shift.start);
|
||||
|
||||
var lateEntryRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate > shift.start);
|
||||
earlyEntryRollCallRotating?.ClearTimeDiff();
|
||||
lateEntryRollCallRotating?.ClearTimeDiff();
|
||||
|
||||
|
||||
|
||||
if (earlyEntryRollCallRotating != null)
|
||||
{
|
||||
@@ -404,10 +403,9 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
var earlyExitRollCallRotating = rollCallsInRotatingShift.OrderByDescending(x => x.EndDate).FirstOrDefault(x => x.EndDate < shift.end);
|
||||
|
||||
var lateExitRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.EndDate).FirstOrDefault(x => x.EndDate > shift.end);
|
||||
earlyExitRollCallRotating?.ClearTimeDiff();
|
||||
lateExitRollCallRotating?.ClearTimeDiff();
|
||||
|
||||
|
||||
|
||||
|
||||
if (earlyExitRollCallRotating != null && (rollCallsInRotatingShift.Any(x =>
|
||||
x.StartDate < rotatingShiftEnd && x.StartDate > earlyExitRollCallRotating.EndDate) == false))
|
||||
@@ -455,10 +453,10 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
DateTime startEntryWithDate = startDate.Add(startRollCall.TimeOfDay);
|
||||
DateTime endEntryWithDate = endDate.Add(endRollCall.TimeOfDay);
|
||||
|
||||
DateTime twoHourBeforeStart = startEntryWithDate.AddHours(-2);
|
||||
DateTime twoHourAfterStart = startEntryWithDate.AddHours(2);
|
||||
DateTime twoHourBeforeEnd = endEntryWithDate.AddHours(-2);
|
||||
DateTime twoHourAfterEnd = endEntryWithDate.AddHours(2);
|
||||
DateTime oneHourBeforeStart = startEntryWithDate.AddHours(-1);
|
||||
DateTime oneHourAfterStart = startEntryWithDate.AddHours(1);
|
||||
DateTime oneHourBeforeEnd = endEntryWithDate.AddHours(-1);
|
||||
DateTime oneHourAfterEnd = endEntryWithDate.AddHours(1);
|
||||
|
||||
|
||||
var shiftDateTimes = rotatingShifts.SelectMany(shift =>
|
||||
@@ -479,68 +477,56 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
#region مقایسه شروع حضور غیاب با شیفت
|
||||
|
||||
//var startFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
// (twoHourBeforeStart <= shift.Start && twoHourAfterStart >= shift.Start) ||
|
||||
// (twoHourBeforeStart <= shift.End && twoHourAfterStart >= shift.End)).ToList();
|
||||
var startFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
(oneHourBeforeStart <= shift.Start && oneHourAfterStart >= shift.Start) ||
|
||||
(oneHourBeforeStart <= shift.End && oneHourAfterStart >= shift.End)).ToList();
|
||||
|
||||
//if (startFilteredTimes.Count == 0)
|
||||
//{
|
||||
// startFilteredTimes = shiftDateTimes;
|
||||
//}
|
||||
//else if (startFilteredTimes.Count == 1)
|
||||
//{
|
||||
// var startChosenShift = startFilteredTimes.First();
|
||||
if (startFilteredTimes.Count == 0)
|
||||
{
|
||||
startFilteredTimes = shiftDateTimes;
|
||||
}
|
||||
else if (startFilteredTimes.Count == 1)
|
||||
{
|
||||
var startChosenShift = startFilteredTimes.First();
|
||||
|
||||
// if (startChosenShift.End < startChosenShift.Start)
|
||||
// startChosenShift.End = startChosenShift.End.AddDays(1);
|
||||
if (startChosenShift.End < startChosenShift.Start)
|
||||
startChosenShift.End = startChosenShift.End.AddDays(1);
|
||||
|
||||
// return startChosenShift;
|
||||
//}
|
||||
return startChosenShift;
|
||||
}
|
||||
|
||||
|
||||
//#endregion
|
||||
#endregion
|
||||
|
||||
//#region مقایسه پایان حضورغیاب با شیفت
|
||||
#region مقایسه پایان حضورغیاب با شیفت
|
||||
|
||||
var endFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
(oneHourBeforeEnd <= shift.Start && oneHourAfterEnd >= shift.Start) ||
|
||||
(oneHourBeforeEnd <= shift.End && oneHourAfterEnd >= shift.End)).ToList();
|
||||
if (endFilteredTimes.Count == 0)
|
||||
{
|
||||
endFilteredTimes = startFilteredTimes;
|
||||
}
|
||||
else if (endFilteredTimes.Count == 1)
|
||||
{
|
||||
var endChosenShift = endFilteredTimes.First();
|
||||
return endChosenShift;
|
||||
}
|
||||
|
||||
//var endFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
// (twoHourBeforeEnd <= shift.Start && twoHourAfterEnd >= shift.Start) ||
|
||||
// (twoHourBeforeEnd <= shift.End && twoHourAfterEnd >= shift.End)).ToList();
|
||||
//if (endFilteredTimes.Count == 0)
|
||||
//{
|
||||
// endFilteredTimes = startFilteredTimes;
|
||||
//}
|
||||
//else if (endFilteredTimes.Count == 1)
|
||||
//{
|
||||
// var endChosenShift = endFilteredTimes.First();
|
||||
// return endChosenShift;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
#region اشتراک حضور غیاب و شیفت
|
||||
|
||||
var overlapShifts = shiftDateTimes
|
||||
.Select(shift => new
|
||||
{
|
||||
Shift = shift,
|
||||
Overlap = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, endRollCall.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, startRollCall.Ticks))),
|
||||
// زمان حضور فرد در شیفت (مجموع Overlap با شیفت)
|
||||
TotalTimeInShift = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, endRollCall.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, startRollCall.Ticks))),
|
||||
StartDistance = Math.Abs((shift.Start - startRollCall).Ticks),
|
||||
EndDistance = Math.Abs((shift.End - endRollCall).Ticks),
|
||||
TotalDistance = Math.Abs((shift.Start - startRollCall).Ticks) + Math.Abs((shift.End - endRollCall).Ticks)
|
||||
})
|
||||
.OrderByDescending(s => s.TotalTimeInShift) // 1. بیشترین زمان حضور فرد
|
||||
.ThenByDescending(s => s.Overlap) // 2. بیشترین Overlap
|
||||
.ThenBy(s => s.TotalDistance)
|
||||
.ThenBy(s => s.StartDistance)
|
||||
.ThenBy(x => x.EndDistance); // 3. اگر برابر بود، Start نزدیکتر
|
||||
var overlapShifts = endFilteredTimes.Select(shift => new
|
||||
{
|
||||
Shift = shift,
|
||||
Overlap = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, oneHourAfterEnd.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, oneHourBeforeStart.Ticks)))
|
||||
});
|
||||
|
||||
var overlapChosenShift = overlapShifts.First();
|
||||
var overlapChosenShift = overlapShifts.MaxBy(s => s.Overlap);
|
||||
var end = overlapChosenShift.Shift.End;
|
||||
if (overlapChosenShift.Shift.End < overlapChosenShift.Shift.Start)
|
||||
end = overlapChosenShift.Shift.End.AddDays(1);
|
||||
|
||||
@@ -5,13 +5,13 @@ using Hangfire.Annotations;
|
||||
|
||||
namespace Company.Domain.SalaryAidAgg;
|
||||
|
||||
public class SalaryAid:EntityBase
|
||||
public class SalaryAid : EntityBase
|
||||
{
|
||||
private SalaryAid()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public SalaryAid(long employeeId, long workshopId, double amount, DateTime salaryAidDateTime, long createdByAccountId, UserType createdByUserType)
|
||||
public SalaryAid(long employeeId, long workshopId, double amount, DateTime salaryAidDateTime, long createdByAccountId, UserType createdByUserType, int calculationMonth, int calculationYear)
|
||||
{
|
||||
EmployeeId = employeeId;
|
||||
WorkshopId = workshopId;
|
||||
@@ -19,12 +19,26 @@ public class SalaryAid:EntityBase
|
||||
SalaryAidDateTime = salaryAidDateTime;
|
||||
CreatedByUserType = createdByUserType;
|
||||
CreatedByAccountId = createdByAccountId;
|
||||
CalculationDate = $"{calculationYear:0000}/{calculationMonth:00}/01".ToGeorgianDateTime();
|
||||
CalculationMonth = calculationMonth;
|
||||
CalculationYear = calculationYear;
|
||||
}
|
||||
|
||||
public long EmployeeId { get; private set; }
|
||||
public long WorkshopId { get; private set; }
|
||||
public double Amount { get; private set; }
|
||||
/// <summary>
|
||||
/// تاریخ پرداخت
|
||||
/// </summary>
|
||||
public DateTime SalaryAidDateTime { get; private set; }
|
||||
/// <summary>
|
||||
/// تاریخ محاسبه
|
||||
/// </summary>
|
||||
public DateTime CalculationDate { get; private set; }
|
||||
|
||||
public int CalculationMonth { get; set; }
|
||||
public int CalculationYear { get; set; }
|
||||
|
||||
|
||||
|
||||
public long CreatedByAccountId { get; private set; }
|
||||
@@ -36,11 +50,14 @@ public class SalaryAid:EntityBase
|
||||
public UserType LastModifiedByUserType { get; private set; }
|
||||
|
||||
|
||||
public void Edit(double amount, DateTime salaryAidTime, long modifiedByAccountId, UserType modifiedByUserType)
|
||||
public void Edit(double amount, DateTime salaryAidTime, long modifiedByAccountId, UserType modifiedByUserType, int calculationMonth, int calculationYear)
|
||||
{
|
||||
Amount = amount;
|
||||
SalaryAidDateTime = salaryAidTime;
|
||||
LastModifiedByAccountId = modifiedByAccountId;
|
||||
LastModifiedByUserType = modifiedByUserType;
|
||||
CalculationDate = $"{calculationYear:0000}/{calculationMonth:00}/01".ToGeorgianDateTime();
|
||||
CalculationMonth = calculationMonth;
|
||||
CalculationYear = calculationYear;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using LicenseContext = OfficeOpenXml.LicenseContext;
|
||||
|
||||
namespace CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||
|
||||
public record SalaryAidImportData(long EmployeeId, long WorkshopId, string FullName, double Amount, string AccountNumber, string NationalCode, string SalaryAidDateTime, int Row, bool Duplicated);
|
||||
public record SalaryAidImportData(long EmployeeId, long WorkshopId, string FullName, double Amount, string AccountNumber, string NationalCode, string SalaryAidDateTime, int calculationMonth, int calculationYear, int Row, bool Duplicated);
|
||||
|
||||
public class ExcelValidation<T>
|
||||
{
|
||||
@@ -80,35 +80,59 @@ public class SalaryAidImportExcel
|
||||
|
||||
|
||||
// بررسی اینکه هدرها همان چیزی هستند که ما انتظار داریم
|
||||
if (worksheet.Cells[2, 1].Text != "نام و نام خانوادگی" ||
|
||||
worksheet.Cells[2, 2].Text != "کد ملی" ||
|
||||
worksheet.Cells[2, 3].Text != "شماره حساب" ||
|
||||
worksheet.Cells[2, 4].Text != "مبلغ قابل پرداخت" ||
|
||||
worksheet.Cells[1, 1].Text != "تاریخ پرداخت")
|
||||
if (worksheet.Cells[3, 1].Text != "نام و نام خانوادگی" ||
|
||||
worksheet.Cells[3, 2].Text != "کد ملی" ||
|
||||
worksheet.Cells[3, 3].Text != "شماره حساب" ||
|
||||
worksheet.Cells[3, 4].Text != "مبلغ قابل پرداخت" ||
|
||||
worksheet.Cells[1, 3].Text != "تاریخ پرداخت" ||
|
||||
worksheet.Cells[1, 1].Text != "سال محاسبه" ||
|
||||
worksheet.Cells[1, 2].Text != "ماه محسابه")
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("ساختار فایل اکسل اشتباه است.", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
return result;
|
||||
}
|
||||
|
||||
var salaryDateFa = worksheet.Cells[1, 4].Text;
|
||||
var salaryDateFa = worksheet.Cells[2, 3].Text;
|
||||
|
||||
var calculationMonth = Convert.ToInt32(string.IsNullOrWhiteSpace(worksheet.Cells[2, 2].Text) ? "0" : worksheet.Cells[2, 2].Text);
|
||||
var calculationYear = Convert.ToInt32(string.IsNullOrWhiteSpace(worksheet.Cells[2, 1].Text) ? "0" : worksheet.Cells[2, 1].Text);
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(salaryDateFa))
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("لطفا در سلول زرد رنگ تاریخ پرداخت را وارد کنید", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
return result;
|
||||
}
|
||||
if (calculationMonth == 0)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("لطفا در سلول آبی رنگ ماه محاسبه را وارد کنید", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
return result;
|
||||
}
|
||||
if (calculationYear == 0)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("لطفا در سلول آبی رنگ سال محاسبه را وارد کنید", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
return result;
|
||||
}
|
||||
|
||||
var calculationDate = $"{calculationYear:0000}/{calculationMonth:00}/01";
|
||||
|
||||
if (salaryDateFa.TryToGeorgianDateTime(out var salaryDateTime) == false)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("تاریخ وارد شده نامعتبر است", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
}
|
||||
|
||||
if (calculationDate.TryToGeorgianDateTime(out var calculationDateTime) == false)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("تاریخ محاسبه وارد شده نامعتبر است", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
}
|
||||
|
||||
if (salaryDateTime > DateTime.Now)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("تاریخ پرداخت مساعده می بایست تاریخ امروز یا قبل تر باشد", 0, SalaryAidExcelColumns.None.ToString()));
|
||||
}
|
||||
int rowCount = worksheet.Dimension.Rows;
|
||||
|
||||
int rowStart = 3;
|
||||
int rowStart = 4;
|
||||
|
||||
if (rowCount < rowStart)
|
||||
{
|
||||
@@ -127,11 +151,11 @@ public class SalaryAidImportExcel
|
||||
if (!double.TryParse(amountText, out double amount) || amount <= 0)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError("مبلغ خالی یا نامعتبر است", row, SalaryAidExcelColumns.Amount.ToString()));
|
||||
|
||||
}
|
||||
result.RawData.Add(new SalaryAidImportData(0, workshopId, fullName, amount, accountNumber, nationalCode, salaryDateFa, row, false));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(fullName))
|
||||
}
|
||||
result.RawData.Add(new SalaryAidImportData(0, workshopId, fullName, amount, accountNumber, nationalCode, salaryDateFa, calculationMonth, calculationYear, row, false));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(fullName))
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError(" نام و نام خانوادگی خالی است", row, SalaryAidExcelColumns.FullName.ToString()));
|
||||
|
||||
@@ -204,25 +228,61 @@ public class SalaryAidImportExcel
|
||||
var year = Convert.ToInt32(salaryDateFa.Substring(0, 4));
|
||||
|
||||
|
||||
if (_companyContext.CustomizeCheckouts.Any(x => x.WorkshopId == workshopId && x.EmployeeId == employee.id && x.YearInt == year && x.MonthInt == month))
|
||||
//if (_companyContext.CustomizeCheckouts.Any(x => x.WorkshopId == workshopId && x.EmployeeId == employee.id && x.YearInt == year && x.MonthInt == month))
|
||||
//{
|
||||
// result.Errors.Add(new SalaryAidImportExcelError($" پرسنل {fullName} در تاریخ {salaryDateFa} دارای فیش حقوقی غیررسمی است.", row, SalaryAidExcelColumns.None.ToString()));
|
||||
//}
|
||||
|
||||
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > calculationDateTime)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError($" پرسنل {fullName} در تاریخ {salaryDateFa} دارای فیش حقوقی غیررسمی است.", row, SalaryAidExcelColumns.None.ToString()));
|
||||
bool customizeCheckout = false;
|
||||
bool customizeCheckoutTemp = false;
|
||||
bool checkout = false;
|
||||
if (_companyContext.CustomizeCheckouts.Any(x => x.WorkshopId == workshopId && employee.id == x.EmployeeId &&
|
||||
x.ContractStart <= oneMonthAgoGr && x.ContractEnd >= calculationDateTime))
|
||||
{
|
||||
customizeCheckout = true;
|
||||
}
|
||||
|
||||
if (_companyContext.CustomizeCheckoutTemps.Any(x => x.WorkshopId == workshopId && employee.id == x.EmployeeId &&
|
||||
x.ContractStart <= calculationDateTime && x.ContractEnd >= oneMonthAgoGr))
|
||||
{
|
||||
customizeCheckoutTemp = true;
|
||||
}
|
||||
|
||||
if (_companyContext.CheckoutSet.Any(x => x.WorkshopId == workshopId && employee.id == x.EmployeeId &&
|
||||
x.ContractStart <= calculationDateTime && x.ContractEnd >= oneMonthAgoGr))
|
||||
{
|
||||
checkout = true;
|
||||
}
|
||||
if (customizeCheckout || customizeCheckoutTemp)
|
||||
{
|
||||
result.Errors.Add(new SalaryAidImportExcelError($"شما نمیتوانید به پرسنل {fullName} در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد مساعده دهید", row, SalaryAidExcelColumns.None.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
//if(_companyContext.CheckoutSet.Any(x => x.WorkshopId == workshopId && employee.id == x.EmployeeId &&
|
||||
// x.ContractStart <= calculationDateTime && x.ContractEnd >= calculationDateTime))
|
||||
// result.Errors.Add(new SalaryAidImportExcelError($"پرسنل {fullName} در تاریخ {calculationDate} دارای فیش رسمی میباشد", row, SalaryAidExcelColumns.None.ToString()));
|
||||
|
||||
|
||||
if (_companyContext.SalaryAids.Any(x => x.Amount == amount && x.EmployeeId == employee.id && x.WorkshopId == workshopId && x.SalaryAidDateTime == salaryDateTime))
|
||||
{
|
||||
// TODO MAHAN: Vafa Add this Code! Please Check it!
|
||||
|
||||
result.RawData.Add(new SalaryAidImportData(employee.id, workshopId, fullName, amount, accountNumber, nationalCode, salaryDateFa, row, true));
|
||||
continue;
|
||||
result.RawData.Add(new SalaryAidImportData(employee.id, workshopId, fullName, amount, accountNumber, nationalCode, salaryDateFa, calculationMonth, calculationYear, row, true));
|
||||
continue;
|
||||
}
|
||||
result.ValidData.Add(new SalaryAidImportData(employee.id, workshopId, fullName, amount, accountNumber, nationalCode, salaryDateFa, row, false));
|
||||
result.ValidData.Add(new SalaryAidImportData(employee.id, workshopId, fullName, amount, accountNumber, nationalCode, salaryDateFa, calculationMonth, calculationYear, row, false));
|
||||
}
|
||||
|
||||
result.RawData = result.RawData.GroupBy(x => x.Row).Select(x => new SalaryAidImportData(x.First().EmployeeId,
|
||||
x.First().WorkshopId, x.First().FullName,
|
||||
x.First().Amount, x.First().AccountNumber, x.First().NationalCode, x.First().SalaryAidDateTime, x.Key,
|
||||
x.Any(s => s.Duplicated))).ToList();
|
||||
result.RawData = result.RawData.GroupBy(x => x.Row).Select(x => new SalaryAidImportData(x.Last().EmployeeId,
|
||||
x.First().WorkshopId, x.First().FullName,
|
||||
x.First().Amount, x.First().AccountNumber, x.First().NationalCode, x.First().SalaryAidDateTime, x.First().calculationMonth, x.First().calculationYear, x.Key,
|
||||
x.Any(s => s.Duplicated))).ToList();
|
||||
|
||||
|
||||
//result.Errors.GroupBy(x => x.Row).Select(x => new
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -17,5 +18,9 @@ namespace CompanyManagment.App.Contracts.CustomizeCheckout
|
||||
OperationResult GroupRemove(long workshopId,List<long> idList);
|
||||
OperationResult Create(CreateCustomizeCheckout command);
|
||||
|
||||
}
|
||||
(bool Checkout, bool CustomizeCheckout, bool CustomizeCheckoutTemp) ValidateExistsCheckouts(
|
||||
DateTime startDate, DateTime endDate, long workshopId, List<long> employeeId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace CompanyManagment.App.Contracts.Loan;
|
||||
|
||||
public class LoanInstallmentViewModel
|
||||
{
|
||||
public string Year { get; set; }
|
||||
public long Id { get; set; }
|
||||
public string Year { get; set; }
|
||||
public string Month { get; set; }
|
||||
public string Amount { get; set; }
|
||||
public double AmountDouble { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Reward;
|
||||
@@ -6,7 +7,7 @@ namespace CompanyManagment.App.Contracts.Reward;
|
||||
public interface IRewardApplication
|
||||
{
|
||||
OperationResult Create(CreateRewardViewModel command);
|
||||
OperationResult Edit(EditRewardViewModel command);
|
||||
OperationResult Edit(EditRewardViewModel command);
|
||||
List<RewardViewModel> GetSearchList(RewardSearchModel searchViewModel);
|
||||
EditRewardViewModel GetDetails(long id);
|
||||
OperationResult Remove(long id);
|
||||
|
||||
@@ -9,4 +9,6 @@ public class CreateSalaryAidViewModel
|
||||
public string Amount { get; set; }
|
||||
public string SalaryDateTime { get; set; }
|
||||
public string NationalCode { get; set; }
|
||||
}
|
||||
public int CalculationMonth { get; set; }
|
||||
public int CalculationYear { get; set; }
|
||||
}
|
||||
|
||||
@@ -22,5 +22,5 @@ public interface ISalaryAidApplication
|
||||
SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel);
|
||||
#endregion
|
||||
|
||||
Task<OperationResult> CreateRange(List<CreateSalaryAidViewModel> commands);
|
||||
OperationResult CreateRange(List<CreateSalaryAidViewModel> commands);
|
||||
}
|
||||
@@ -4,17 +4,21 @@ namespace CompanyManagment.App.Contracts.SalaryAid;
|
||||
|
||||
public class SalaryAidViewModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public string Amount { get; set; }
|
||||
public long Id { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public string Amount { get; set; }
|
||||
public double AmountDouble { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string CreationDate { get; set; }
|
||||
public string SalaryAidDateTimeFa { get; set; }
|
||||
public DateTime SalaryAidDateTimeGe { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string CreationDate { get; set; }
|
||||
public string SalaryAidDateTimeFa { get; set; }
|
||||
public DateTime SalaryAidDateTimeGe { get; set; }
|
||||
public string CalculationDateTimeFa { get; set; }
|
||||
public DateTime CalculationDateTimeGe { get; set; }
|
||||
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
|
||||
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
public string MonthFa { get; set; }
|
||||
public string YearFa { get; set; }
|
||||
}
|
||||
@@ -16,10 +16,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
using Company.Domain.PersonnelCodeAgg;
|
||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||
|
||||
namespace CompanyManagment.Application
|
||||
{
|
||||
@@ -34,10 +36,14 @@ namespace CompanyManagment.Application
|
||||
private readonly IContractRepository _contractRepository;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly ICheckoutRepository _checkoutRepository;
|
||||
|
||||
private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository;
|
||||
|
||||
public CustomizeCheckoutApplication(ICustomizeCheckoutRepository customizeCheckoutRepository,
|
||||
IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, ILeftWorkRepository leftWorkRepository, IEmployeeRepository employeeRepository,
|
||||
IRollCallMandatoryRepository rollCallMandatoryRepository, IContractRepository contractRepository, IWorkshopRepository workshopRepository, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository)
|
||||
IRollCallMandatoryRepository rollCallMandatoryRepository, IContractRepository contractRepository, IWorkshopRepository workshopRepository, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, ICheckoutRepository checkoutRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository)
|
||||
{
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
|
||||
@@ -48,6 +54,8 @@ namespace CompanyManagment.Application
|
||||
_workshopRepository = workshopRepository;
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
_personnelCodeRepository = personnelCodeRepository;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
_checkoutRepository = checkoutRepository;
|
||||
_customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
|
||||
}
|
||||
|
||||
@@ -89,18 +97,19 @@ namespace CompanyManagment.Application
|
||||
x.Amount,
|
||||
x.FineDate,
|
||||
x.FineDate.ToGeorgianDateTime(),
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime())
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime(),
|
||||
x.Id)
|
||||
).ToList();
|
||||
|
||||
var rewards = result.RewardViewModels.Select(x =>
|
||||
new CustomizeCheckoutReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
|
||||
x.IsActive,x.Title)).ToList();
|
||||
x.IsActive, x.Title,x.Id)).ToList();
|
||||
|
||||
var loanInstallments = result.InstallmentViewModels.Select(x =>
|
||||
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive,x.RemainingAmount,x.LoanAmount)).ToList();
|
||||
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount, x.LoanAmount,x.Id)).ToList();
|
||||
|
||||
var salaryAids = result.SalaryAidViewModels.Select(x =>
|
||||
new CustomizeCheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();
|
||||
new CustomizeCheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa, x.CalculationDateTimeGe, x.CalculationDateTimeFa,x.Id)).ToList();
|
||||
|
||||
|
||||
var regularShift = result.EmployeeSettingsShifts.Select(x =>
|
||||
@@ -113,15 +122,23 @@ namespace CompanyManagment.Application
|
||||
result.FamilyAllowance, result.LeavePay, result.InsuranceDeduction, result.FineAbsenceDeduction,
|
||||
result.LateToWorkDeduction, result.EarlyExitDeduction, result.RewardPay, result.SalaryAidDeduction, result.InstallmentDeduction, result.FineDeduction,
|
||||
result.TaxDeduction, result.SumOfWorkingDays, result.TotalClaimsStr, result.TotalDeductionsStr, result.TotalPayment, contract?.ContractNo ?? "-",
|
||||
fines,loanInstallments,salaryAids,rewards, result.LateToWorkValue, result.SettingSalary, result.DailyWage, result.ShiftStatus,result.IrregularShift,result.CustomizeRotatingShifts,
|
||||
fines, loanInstallments, salaryAids, rewards, result.LateToWorkValue, result.SettingSalary, result.DailyWage, result.ShiftStatus, result.IrregularShift, result.CustomizeRotatingShifts,
|
||||
regularShift);
|
||||
|
||||
|
||||
_customizeCheckoutRepository.Create(entity);
|
||||
_customizeCheckoutRepository.Create(entity);
|
||||
_customizeCheckoutRepository.RemoveEmployeeCustomizeCheckoutInDates(command.WorkshopId, employee.id, command.ContractStart, command.ContractEnd);
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public (bool Checkout, bool CustomizeCheckout, bool CustomizeCheckoutTemp) ValidateExistsCheckouts(DateTime startDate,
|
||||
DateTime endDate, long workshopId, List<long> employeeId)
|
||||
{
|
||||
return _customizeCheckoutRepository.ValidateExistsCheckouts(startDate, endDate, workshopId, employeeId);
|
||||
}
|
||||
|
||||
|
||||
public OperationResult GroupCreate(CreateCustomizeCheckoutGroup command)
|
||||
{
|
||||
OperationResult op = new();
|
||||
@@ -146,18 +163,18 @@ namespace CompanyManagment.Application
|
||||
x.Amount,
|
||||
x.FineDate,
|
||||
x.FineDate.ToGeorgianDateTime(),
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime())
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime(), x.Id)
|
||||
).ToList();
|
||||
|
||||
var rewards = computations.RewardViewModels.Select(x =>
|
||||
new CustomizeCheckoutReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
|
||||
x.IsActive,x.Title)).ToList();
|
||||
x.IsActive, x.Title,x.Id)).ToList();
|
||||
|
||||
var loanInstallments = computations.InstallmentViewModels.Select(x =>
|
||||
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive,x.RemainingAmount, x.LoanAmount)).ToList();
|
||||
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount, x.LoanAmount, x.Id)).ToList();
|
||||
|
||||
var salaryAids = computations.SalaryAidViewModels.Select(x =>
|
||||
new CustomizeCheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();
|
||||
new CustomizeCheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa, x.CalculationDateTimeGe, x.CalculationDateTimeFa,x.Id)).ToList();
|
||||
|
||||
var regularShift = computations.EmployeeSettingsShifts.Select(x =>
|
||||
new CustomizeCheckoutRegularShift(x.StartTime, x.EndTime, x.Placement)).ToList();
|
||||
@@ -169,20 +186,20 @@ namespace CompanyManagment.Application
|
||||
computations.FamilyAllowance, computations.LeavePay, computations.InsuranceDeduction, computations.FineAbsenceDeduction,
|
||||
computations.LateToWorkDeduction, computations.EarlyExitDeduction, computations.RewardPay, computations.SalaryAidDeduction, computations.InstallmentDeduction, computations.FineDeduction,
|
||||
computations.TaxDeduction, computations.SumOfWorkingDays, computations.TotalClaimsStr, computations.TotalDeductionsStr, computations.TotalPayment, contract?.ContractNo ?? "-",
|
||||
fines,loanInstallments,salaryAids,rewards, computations.LateToWorkValue, computations.SettingSalary, computations.DailyWage, computations.ShiftStatus,computations.IrregularShift,
|
||||
fines, loanInstallments, salaryAids, rewards, computations.LateToWorkValue, computations.SettingSalary, computations.DailyWage, computations.ShiftStatus, computations.IrregularShift,
|
||||
computations.CustomizeRotatingShifts, regularShift);
|
||||
|
||||
_customizeCheckoutRepository.Create(entity);
|
||||
_customizeCheckoutRepository.Create(entity);
|
||||
_customizeCheckoutRepository.RemoveEmployeeCustomizeCheckoutInDates(command.WorkshopId, employeeId, command.ContractStart, command.ContractEnd);
|
||||
}
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult GroupRemove(long workshopId,List<long> idList)
|
||||
public OperationResult GroupRemove(long workshopId, List<long> idList)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var entities = _customizeCheckoutRepository.GetRange(workshopId,idList);
|
||||
var entities = _customizeCheckoutRepository.GetRange(workshopId, idList);
|
||||
if (entities == null)
|
||||
return op.Succcedded();
|
||||
_customizeCheckoutRepository.RemoveRange(entities);
|
||||
@@ -218,12 +235,12 @@ namespace CompanyManagment.Application
|
||||
return op.Failed("خطای سیستمی");
|
||||
|
||||
var pc = new PersianCalendar();
|
||||
var checkoutDate = new DateTime(yearFa, monthFa, 1,pc);
|
||||
var checkoutDate = new DateTime(yearFa, monthFa, 1, pc);
|
||||
var nextMonth = checkoutDate.AddMonthsFa(1, out _).ToGeorgianDateTime().Date;
|
||||
var today = DateTime.Today;
|
||||
|
||||
if (nextMonth > today)
|
||||
return op.Failed("امکان ایجاد فیش برای ماه جاری یا آینده وجود ندارد");
|
||||
return op.Failed("امکان ایجاد فیش برای ماه جاری یا آینده وجود ندارد");
|
||||
|
||||
//validate parsed datetime
|
||||
var startOfMonth = new DateTime(yearFa, monthFa, 1, new PersianCalendar()).Date;
|
||||
@@ -261,7 +278,7 @@ namespace CompanyManagment.Application
|
||||
WorkshopId = workshopId
|
||||
});
|
||||
var workshopGroups = _customizeWorkshopSettingsRepository
|
||||
.GetWorkshopIncludeGroupsByWorkshopId(workshopId)?
|
||||
.GetWorkshopIncludeGroupsByWorkshopId(workshopId)?
|
||||
.GroupSettings.Where(x => x.MainGroup == false);
|
||||
var employeeSettings = _customizeWorkshopSettingsRepository.GetEmployeeSettingsByWorkshopId(workshopId);
|
||||
|
||||
@@ -302,7 +319,7 @@ namespace CompanyManagment.Application
|
||||
|
||||
if (workshopId == 170)
|
||||
{
|
||||
var exceptionEmployeeIds =_customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(117).Select(x=>x.EmployeeId).ToList();
|
||||
var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(117).Select(x => x.EmployeeId).ToList();
|
||||
foreach (var employeesId in exceptionEmployeeIds)
|
||||
{
|
||||
|
||||
@@ -334,16 +351,16 @@ namespace CompanyManagment.Application
|
||||
}
|
||||
color = reason switch
|
||||
{
|
||||
"فاقد تعیین حقوق" => "orange",
|
||||
"فاقد تعیین حقوق" => "orange",
|
||||
|
||||
"فاقد گروهبندی" => "red",
|
||||
"فاقد گروهبندی" => "red",
|
||||
|
||||
"خطای سیستمی" => "black",
|
||||
"خطای سیستمی" => "black",
|
||||
|
||||
"دارای فیش غیر رسمی" =>"green",
|
||||
"دارای فیش غیر رسمی" => "green",
|
||||
|
||||
_ => "white"
|
||||
};
|
||||
_ => "white"
|
||||
};
|
||||
return new EligibleEmployeesForCustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.Id,
|
||||
@@ -353,7 +370,7 @@ namespace CompanyManagment.Application
|
||||
Color = color,
|
||||
PersonnelCode = personnelCodes.FirstOrDefault(y => x.Id == y.EmployeeId)?.PersonnelCode.ToString() ?? "-"
|
||||
};
|
||||
}).OrderByDescending(x=>x.IsEligible).ThenByDescending(x=>x.Reason).ToList();
|
||||
}).OrderByDescending(x => x.IsEligible).ThenByDescending(x => x.Reason).ToList();
|
||||
return op.Succcedded(employees);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,18 +74,18 @@ namespace CompanyManagment.Application
|
||||
x.Amount,
|
||||
x.FineDate,
|
||||
x.FineDate.ToGeorgianDateTime(),
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime())
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime(), x.Id)
|
||||
).ToList();
|
||||
|
||||
var rewards = result.RewardViewModels.Select(x =>
|
||||
new CustomizeCheckoutTempReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
|
||||
x.IsActive,x.Title)).ToList();
|
||||
x.IsActive, x.Title, x.Id)).ToList();
|
||||
|
||||
var loanInstallments = result.InstallmentViewModels.Select(x =>
|
||||
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount,x.LoanAmount)).ToList();
|
||||
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount, x.LoanAmount, x.Id)).ToList();
|
||||
|
||||
var salaryAids = result.SalaryAidViewModels.Select(x =>
|
||||
new CustomizeCheckoutTempSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();
|
||||
new CustomizeCheckoutTempSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa, x.CalculationDateTimeGe, x.CalculationDateTimeFa, x.Id)).ToList();
|
||||
|
||||
var regularShift = result.EmployeeSettingsShifts.Select(x =>
|
||||
new CustomizeCheckoutRegularShift(x.StartTime, x.EndTime, x.Placement)).ToList();
|
||||
@@ -97,11 +97,11 @@ namespace CompanyManagment.Application
|
||||
result.FamilyAllowance, result.LeavePay, result.InsuranceDeduction, result.FineAbsenceDeduction,
|
||||
result.LateToWorkDeduction, result.EarlyExitDeduction, result.RewardPay, result.SalaryAidDeduction, result.InstallmentDeduction, result.FineDeduction,
|
||||
result.TaxDeduction, result.SumOfWorkingDays, result.TotalClaimsStr, result.TotalDeductionsStr, result.TotalPayment, contract?.ContractNo ?? "-",
|
||||
fines, loanInstallments, salaryAids, rewards,result.LateToWorkValue, result.SettingSalary,result.DailyWage, result.ShiftStatus, result.IrregularShift, result.CustomizeRotatingShifts,
|
||||
fines, loanInstallments, salaryAids, rewards, result.LateToWorkValue, result.SettingSalary, result.DailyWage, result.ShiftStatus, result.IrregularShift, result.CustomizeRotatingShifts,
|
||||
regularShift);
|
||||
|
||||
|
||||
_customizeCheckoutTempRepository.Create(entity);
|
||||
_customizeCheckoutTempRepository.Create(entity);
|
||||
_customizeCheckoutTempRepository.RemoveEmployeeTemporaryCheckoutInDates(command.WorkshopId, employee.id, command.ContractStart, command.ContractEnd);
|
||||
_customizeCheckoutTempRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
@@ -127,18 +127,18 @@ namespace CompanyManagment.Application
|
||||
x.Amount,
|
||||
x.FineDate,
|
||||
x.FineDate.ToGeorgianDateTime(),
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime())
|
||||
x.IsActive, x.CreationDate.ToGeorgianDateTime(), x.Id)
|
||||
).ToList();
|
||||
|
||||
var rewards = computations.RewardViewModels.Select(x =>
|
||||
new CustomizeCheckoutTempReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
|
||||
x.IsActive,x.Title)).ToList();
|
||||
x.IsActive, x.Title, x.Id)).ToList();
|
||||
|
||||
var loanInstallments = computations.InstallmentViewModels.Select(x =>
|
||||
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount,x.LoanAmount)).ToList();
|
||||
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount, x.LoanAmount, x.Id)).ToList();
|
||||
|
||||
var salaryAids = computations.SalaryAidViewModels.Select(x =>
|
||||
new CustomizeCheckoutTempSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();
|
||||
new CustomizeCheckoutTempSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa, x.CalculationDateTimeGe, x.CalculationDateTimeFa, x.Id)).ToList();
|
||||
|
||||
var contract = contracts.Where(x => x.IsActiveString == "true").FirstOrDefault(x => x.EmployeeId == employeeId);
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace CompanyManagment.Application
|
||||
computations.FamilyAllowance, computations.LeavePay, computations.InsuranceDeduction, computations.FineAbsenceDeduction,
|
||||
computations.LateToWorkDeduction, computations.EarlyExitDeduction, computations.RewardPay, computations.SalaryAidDeduction, computations.InstallmentDeduction, computations.FineDeduction,
|
||||
computations.TaxDeduction, computations.SumOfWorkingDays, computations.TotalClaimsStr, computations.TotalDeductionsStr, computations.TotalPayment, contract?.ContractNo ?? "-",
|
||||
fines, loanInstallments, salaryAids, rewards,computations.LateToWorkValue, computations.SettingSalary, computations.DailyWage, computations.ShiftStatus, computations.IrregularShift,
|
||||
fines, loanInstallments, salaryAids, rewards, computations.LateToWorkValue, computations.SettingSalary, computations.DailyWage, computations.ShiftStatus, computations.IrregularShift,
|
||||
computations.CustomizeRotatingShifts, regularShift);
|
||||
_customizeCheckoutTempRepository.Create(entity);
|
||||
_customizeCheckoutTempRepository.RemoveEmployeeTemporaryCheckoutInDates(command.WorkshopId, employeeId, command.ContractStart, command.ContractEnd);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
@@ -9,7 +10,10 @@ using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.File1;
|
||||
using Company.Domain.FineAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Fine;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
@@ -22,18 +26,26 @@ public class FineApplication : IFineApplication
|
||||
private readonly ICustomizeCheckoutRepository _customizeCheckoutRepository;
|
||||
public readonly ICustomizeCheckoutTempRepository CustomizeCheckoutTempRepository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly ICustomizeCheckoutTempApplication _customizeCheckoutTempApplication;
|
||||
|
||||
|
||||
|
||||
public FineApplication(IFineRepository fineRepository, IEmployeeRepository employeeRepository,
|
||||
IWorkshopRepository workshopRepository, ICustomizeCheckoutRepository customizeCheckoutRepository,
|
||||
IAuthHelper authHelper,ICustomizeCheckoutTempRepository customizeCheckoutTempRepository)
|
||||
IAuthHelper authHelper, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, ICustomizeCheckoutApplication customizeCheckoutApplication, ICustomizeCheckoutTempApplication customizeCheckoutTempApplication)
|
||||
{
|
||||
_fineRepository = fineRepository;
|
||||
_employeeRepository = employeeRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
_authHelper = authHelper;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
|
||||
CustomizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
_customizeCheckoutTempApplication = customizeCheckoutTempApplication;
|
||||
}
|
||||
|
||||
public List<FineViewModel> GetSearchList(FineSearchViewModel searchModel)
|
||||
@@ -127,36 +139,94 @@ public class FineApplication : IFineApplication
|
||||
|
||||
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x =>
|
||||
x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year &&
|
||||
x.MonthInt == month))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است جریمه ای دهید");
|
||||
//if (_customizeCheckoutRepository.Exists(x =>
|
||||
// x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year &&
|
||||
// x.MonthInt == month))
|
||||
//{
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است جریمه ای دهید");
|
||||
|
||||
//}
|
||||
|
||||
//if (CustomizeCheckoutTempRepository.Exists(x =>
|
||||
// x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year &&
|
||||
// x.MonthInt == month &&
|
||||
// x.ContractStart <= fineDate && x.ContractEnd >= fineDate))
|
||||
//{
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است جریمه ای دهید");
|
||||
|
||||
//}
|
||||
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > fineDate)
|
||||
{
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(fineDate,
|
||||
oneMonthAgoGr, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد جریمه ای دهید");
|
||||
}
|
||||
}
|
||||
|
||||
if (CustomizeCheckoutTempRepository.Exists(x =>
|
||||
x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year &&
|
||||
x.MonthInt == month &&
|
||||
x.ContractStart <= fineDate && x.ContractEnd >= fineDate))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است جریمه ای دهید");
|
||||
|
||||
}
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(fineDate,
|
||||
fineDate, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
//if (existsCheckouts.Checkout)
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی رسمی صادر شده است جریمه ای دهید");
|
||||
|
||||
#endregion
|
||||
|
||||
DateTime date = command.FineDate.ToGeorgianDateTime();
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
using var transaction = new TransactionScope();
|
||||
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
{
|
||||
Fine entity = new Fine(employeeId, command.WorkshopId, command.Title, command.Amount.MoneyToDouble(), date,
|
||||
userId, userType);
|
||||
_fineRepository.Create(entity);
|
||||
_fineRepository.SaveChanges();
|
||||
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
command.WorkshopId, employeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
|
||||
if (customizeCheckouts != null)
|
||||
{
|
||||
|
||||
var fines = customizeCheckouts.CheckoutFines.ToList();
|
||||
|
||||
fines.Add(new(entity.Title,entity.Amount.ToMoney(),
|
||||
entity.FineDate.ToFarsi(),entity.FineDate,entity.IsActive,entity.CreationDate,entity.id));
|
||||
customizeCheckouts.SetFines(fines);
|
||||
}
|
||||
}
|
||||
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
command.WorkshopId, employeeId, fineDate).GetAwaiter().GetResult();
|
||||
|
||||
if (customizeCheckoutTemp != null)
|
||||
{
|
||||
var fines = customizeCheckoutTemp.CheckoutFines.ToList();
|
||||
|
||||
|
||||
fines.Add(new(entity.Title, entity.Amount.ToMoney(),
|
||||
entity.FineDate.ToFarsi(), entity.FineDate, entity.IsActive, entity.CreationDate, entity.id));
|
||||
customizeCheckoutTemp.SetFines(fines);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
_fineRepository.SaveChanges();
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
transaction.Complete();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -196,20 +266,17 @@ public class FineApplication : IFineApplication
|
||||
}
|
||||
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x =>
|
||||
x.WorkshopId == command.WorkshopId && command.EmployeeId == x.EmployeeId && x.YearInt == year &&
|
||||
x.MonthInt == month))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است جریمه ای دهید");
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
}
|
||||
|
||||
if (CustomizeCheckoutTempRepository.Exists(x =>
|
||||
x.WorkshopId == command.WorkshopId && command.EmployeeId == x.EmployeeId && x.YearInt == year &&
|
||||
x.MonthInt == month &&
|
||||
x.ContractStart <= fineDate && x.ContractEnd >= fineDate))
|
||||
if (oneMonthAgoGr > fineDate)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است جریمه ای دهید");
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(fineDate,
|
||||
oneMonthAgoGr, entity.WorkshopId, [entity.EmployeeId]);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد جریمه ای دهید");
|
||||
}
|
||||
}
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == command.EmployeeId))
|
||||
@@ -217,14 +284,63 @@ public class FineApplication : IFineApplication
|
||||
return op.Failed("شخص وارد شده معتبر نمیباشد");
|
||||
}
|
||||
|
||||
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(fineDate,
|
||||
fineDate, entity.WorkshopId, [entity.EmployeeId]);
|
||||
|
||||
DateTime date = command.FineDate.ToGeorgianDateTime();
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
using var transaction = new TransactionScope();
|
||||
|
||||
|
||||
|
||||
entity.Edit(command.EmployeeId, command.WorkshopId, command.Title, command.Amount.MoneyToDouble(), date,
|
||||
userId, userType);
|
||||
|
||||
_fineRepository.SaveChanges();
|
||||
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
entity.WorkshopId, entity.EmployeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
|
||||
var fines = customizeCheckouts.CheckoutFines.ToList();
|
||||
|
||||
var existsSalaryAid = fines.FirstOrDefault(x => x.EntityId == entity.id);
|
||||
if (existsSalaryAid != null)
|
||||
{
|
||||
fines.Remove(existsSalaryAid);
|
||||
}
|
||||
|
||||
fines.Add(new(entity.Title, entity.Amount.ToMoney(), entity.FineDate.ToFarsi(), entity.FineDate,
|
||||
entity.IsActive, entity.CreationDate, entity.id));
|
||||
|
||||
customizeCheckouts.SetFines(fines);
|
||||
|
||||
}
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
entity.WorkshopId, entity.EmployeeId, fineDate).GetAwaiter().GetResult();
|
||||
|
||||
var fines = customizeCheckoutTemp.CheckoutFines.ToList();
|
||||
|
||||
var existsFines = fines.FirstOrDefault(x => x.EntityId == entity.id);
|
||||
if (existsFines!= null)
|
||||
{
|
||||
fines.Remove(existsFines);
|
||||
}
|
||||
|
||||
|
||||
fines.Add(new(entity.Title, entity.Amount.ToMoney(), entity.FineDate.ToFarsi(), entity.FineDate,
|
||||
entity.IsActive, entity.CreationDate, entity.id));
|
||||
|
||||
customizeCheckoutTemp.SetFines(fines);
|
||||
|
||||
}
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
transaction.Complete();
|
||||
return op.Succcedded(entity.id);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
using Company.Domain.LoanAgg;
|
||||
using Company.Domain.LoanAgg.Entities;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Loan;
|
||||
using Hangfire.States;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
@@ -23,12 +25,16 @@ public class LoanApplication : ILoanApplication
|
||||
private readonly ICustomizeCheckoutRepository _customizeCheckoutRepository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
private readonly ICustomizeCheckoutTempApplication _customizeCheckoutTempApplication;
|
||||
|
||||
public LoanApplication(ILoanRepository loanRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IAuthHelper authHelper)
|
||||
public LoanApplication(ILoanRepository loanRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IAuthHelper authHelper, ICustomizeCheckoutApplication customizeCheckoutApplication, ICustomizeCheckoutTempApplication customizeCheckoutTempApplication)
|
||||
{
|
||||
_loanRepository = loanRepository;
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
_authHelper = authHelper;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
_customizeCheckoutTempApplication = customizeCheckoutTempApplication;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
}
|
||||
|
||||
@@ -63,11 +69,11 @@ public class LoanApplication : ILoanApplication
|
||||
return op.Failed("تاریخ شروع وام نمیتواند در گذشته باشد");
|
||||
}
|
||||
|
||||
if (loanGrantDate>now)
|
||||
if (loanGrantDate > now)
|
||||
{
|
||||
return op.Failed("تاریخ پرداخت وام می بایست تاریخ امروز یا قبل تر باشد");
|
||||
}
|
||||
|
||||
|
||||
if (!command.LoanGrantDate.TryToGeorgianDateTime(out var grantDate))
|
||||
{
|
||||
return op.Failed("تاریخ وارد شده نامعتبر است");
|
||||
@@ -75,34 +81,87 @@ public class LoanApplication : ILoanApplication
|
||||
if (amountD < 1000000)
|
||||
return op.Failed("حداقل مبلغ وام 1.000.000 ریال میباشد");
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x =>
|
||||
command.EmployeeIds.Contains(x.EmployeeId) && x.WorkshopId == command.WorkshopId &&
|
||||
(x.ContractStart > startInstallmentDate && x.ContractStart < lastInstallment)))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است وام دهید");
|
||||
}
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(startInstallmentDate, lastInstallment,
|
||||
command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x =>
|
||||
command.EmployeeIds.Contains(x.EmployeeId) && x.WorkshopId == command.WorkshopId &&
|
||||
(x.ContractStart >= startInstallmentDate && x.ContractStart <= lastInstallment)))
|
||||
if (existsCheckouts.Checkout)
|
||||
{
|
||||
return op.Failed("پرسنل در بازه اقساط خود دارای فیش غیررسمی است");
|
||||
return op.Failed("پرسنل در این تاریخ دارای فیش حقوقی رسمی است");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
using var transaction = new TransactionScope();
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
{
|
||||
|
||||
var entity = new Loan(employeeId, command.WorkshopId, startInstallmentDate, command.Count.ToString(),
|
||||
command.Amount.MoneyToDouble(),
|
||||
installment.First().Amount.MoneyToDouble(),
|
||||
installment.Select(x =>
|
||||
new LoanInstallment(x.Amount.MoneyToDouble(), x.Month, x.Year, x.DateGr)).ToList()
|
||||
, command.GetRounded, grantDate,userId,userType);
|
||||
, command.GetRounded, grantDate, userId, userType);
|
||||
_loanRepository.Create(entity);
|
||||
|
||||
//var existInCheckout = _customizeCheckoutApplication.ValidateExistsCheckouts(startInstallmentDate, lastInstallment,
|
||||
// command.WorkshopId, [employeeId]);
|
||||
//if (existInCheckout.CustomizeCheckout)
|
||||
//{
|
||||
// var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdInDates(command.WorkshopId, employeeId,
|
||||
// startInstallmentDate, lastInstallment);
|
||||
|
||||
// var ccRemoveResult = _customizeCheckoutApplication.GroupRemove(command.WorkshopId,
|
||||
// customizeCheckouts.Select(x => x.id).ToList());
|
||||
|
||||
// if (!ccRemoveResult.IsSuccedded)
|
||||
// return op.Failed("خطا در حذف فیش غیررسمی نهایی:"+ccRemoveResult.Message);
|
||||
|
||||
// var groupedCustomizeCheckouts= customizeCheckouts.GroupBy(x => new { x.Month, x.Year }).ToList();
|
||||
|
||||
// foreach (var groupedCustomizeCheckout in groupedCustomizeCheckouts)
|
||||
// {
|
||||
// var ccCreateResult = _customizeCheckoutApplication.GroupCreate(new CreateCustomizeCheckoutGroup()
|
||||
// {
|
||||
// WorkshopId = command.WorkshopId,
|
||||
// EmployeeIds = groupedCustomizeCheckout.Select(x => x.EmployeeId).ToList(),
|
||||
// MonthFa = groupedCustomizeCheckout.First().MonthInt,
|
||||
// YearFa = groupedCustomizeCheckout.First().YearInt,
|
||||
// });
|
||||
|
||||
// if (!ccCreateResult.IsSuccedded)
|
||||
// return op.Failed("خطا در ایجاد فیش غیررسمی نهایی:" + ccCreateResult.Message);
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
//if (existInCheckout.CustomizeCheckoutTemp)
|
||||
//{
|
||||
// var customizeCheckoutsTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDates(command.WorkshopId, employeeId,
|
||||
// startInstallmentDate, lastInstallment);
|
||||
|
||||
// var groupedCustomizeCheckoutsTemp = customizeCheckoutsTemp.GroupBy(x => new { x.Month, x.Year}).ToList();
|
||||
|
||||
// foreach (var groupedCustomizeCheckout in groupedCustomizeCheckoutsTemp)
|
||||
// {
|
||||
// var ccCreateResult = _customizeCheckoutTempApplication.GroupCreate(new CreateCustomizeCheckoutTempGroup()
|
||||
// {
|
||||
// WorkshopId = command.WorkshopId,
|
||||
// EmployeeIds = groupedCustomizeCheckout.Select(x=>x.EmployeeId).ToList(),
|
||||
// MonthFa = groupedCustomizeCheckout.First().MonthInt,
|
||||
// YearFa =
|
||||
// });
|
||||
|
||||
// if (!ccCreateResult.IsSuccedded)
|
||||
// return op.Failed("خطا در ایجاد فیش غیررسمی نهایی:" + ccCreateResult.Message);
|
||||
// }
|
||||
|
||||
// if (!ccRemoveResult.IsSuccedded)
|
||||
// return op.Failed("خطا در حذف فیش غیررسمی نهایی:" + ccRemoveResult.Message);
|
||||
|
||||
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
_loanRepository.SaveChanges();
|
||||
@@ -117,7 +176,7 @@ public class LoanApplication : ILoanApplication
|
||||
|
||||
var installments = new List<LoanInstallmentViewModel>();
|
||||
|
||||
|
||||
|
||||
bool endOfMonth = day == 31;
|
||||
|
||||
double amountD = amount.MoneyToDouble();
|
||||
@@ -171,7 +230,7 @@ public class LoanApplication : ILoanApplication
|
||||
Year = loanStartDate.Substring(0, 4),
|
||||
Day = loanStartDate.Substring(8, 2)
|
||||
|
||||
};
|
||||
};
|
||||
installments.Add(lastInstallment);
|
||||
return installments;
|
||||
}
|
||||
@@ -224,7 +283,7 @@ public class LoanApplication : ILoanApplication
|
||||
Year = loanStartDate.Substring(0, 4),
|
||||
Day = loanStartDate.Substring(8, 2)
|
||||
|
||||
};
|
||||
};
|
||||
installments.Add(lastInstallment);
|
||||
return installments;
|
||||
}
|
||||
@@ -273,6 +332,6 @@ public class LoanApplication : ILoanApplication
|
||||
|
||||
public LoanGroupedViewModel GetSearchListAsGrouped(LoanSearchViewModel searchModel)
|
||||
{
|
||||
return _loanRepository.GetSearchListAsGrouped(searchModel);
|
||||
return _loanRepository.GetSearchListAsGrouped(searchModel);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
using Company.Domain.RewardAgg;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Reward;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -19,13 +17,17 @@ public class RewardApplication : IRewardApplication
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ICustomizeCheckoutRepository _customizeCheckoutRepository;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
private readonly ICustomizeCheckoutTempApplication _customizeCheckoutTempApplication;
|
||||
|
||||
public RewardApplication(IRewardRepository rewardRepository, IAuthHelper authHelper, ICustomizeCheckoutRepository customizeCheckoutRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository)
|
||||
public RewardApplication(IRewardRepository rewardRepository, IAuthHelper authHelper, ICustomizeCheckoutRepository customizeCheckoutRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, ICustomizeCheckoutTempApplication customizeCheckoutTempApplication, ICustomizeCheckoutApplication customizeCheckoutApplication)
|
||||
{
|
||||
_rewardRepository = rewardRepository;
|
||||
_authHelper = authHelper;
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
_customizeCheckoutTempApplication = customizeCheckoutTempApplication;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
}
|
||||
|
||||
public List<RewardViewModel> GetSearchList(RewardSearchModel searchModel)
|
||||
@@ -34,10 +36,6 @@ public class RewardApplication : IRewardApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public EditRewardViewModel GetDetails(long id)
|
||||
{
|
||||
return _rewardRepository.GetDetails(id);
|
||||
@@ -65,6 +63,9 @@ public class RewardApplication : IRewardApplication
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
_rewardRepository.Remove(entity);
|
||||
_rewardRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
@@ -105,16 +106,37 @@ public class RewardApplication : IRewardApplication
|
||||
var month = Convert.ToInt32(command.GrantDate.Substring(5, 2));
|
||||
var year = Convert.ToInt32(command.GrantDate.Substring(0, 4));
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year && x.MonthInt == month))
|
||||
//if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year && x.MonthInt == month))
|
||||
//{
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است پاداشی دهید");
|
||||
//}
|
||||
|
||||
//if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) &&
|
||||
// x.YearInt == year && x.MonthInt == month && x.ContractStart <= grantDate && x.ContractEnd >= grantDate))
|
||||
//{
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است پاداشی دهید");
|
||||
//}
|
||||
|
||||
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > grantDate)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است پاداشی دهید");
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(grantDate,
|
||||
oneMonthAgoGr, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد پاداشی دهید");
|
||||
}
|
||||
}
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) &&
|
||||
x.YearInt == year && x.MonthInt == month && x.ContractStart <= grantDate && x.ContractEnd >= grantDate))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است پاداشی دهید");
|
||||
}
|
||||
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(grantDate,
|
||||
grantDate, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
//if (existsCheckouts.Checkout)
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی رسمی صادر شده است پاداشی دهید");
|
||||
|
||||
|
||||
|
||||
@@ -122,16 +144,50 @@ public class RewardApplication : IRewardApplication
|
||||
#endregion
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
using var transaction = new TransactionScope();
|
||||
|
||||
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
{
|
||||
var entity = new Reward(employeeId, command.WorkshopId, command.Amount.MoneyToDouble(), command.Description,
|
||||
userId, userType,grantDate,command.Title);
|
||||
var entity = new Reward(employeeId, command.WorkshopId, command.Amount.MoneyToDouble(), command.Description,
|
||||
userId, userType, grantDate, command.Title);
|
||||
|
||||
_rewardRepository.Create(entity);
|
||||
}
|
||||
_rewardRepository.SaveChanges();
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
command.WorkshopId, employeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
if (customizeCheckouts != null)
|
||||
{
|
||||
|
||||
_rewardRepository.SaveChanges();
|
||||
var rewards = customizeCheckouts.CustomizeCheckoutRewards.ToList();
|
||||
|
||||
rewards.Add(new(entity.Amount.ToMoney(), entity.Description, entity.GrantDate, entity.GrantDate.ToFarsi(), entity.IsActive, entity.Title, entity.id));
|
||||
customizeCheckouts.SetRewards(rewards);
|
||||
}
|
||||
}
|
||||
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
command.WorkshopId, employeeId, grantDate).GetAwaiter().GetResult();
|
||||
if (customizeCheckoutTemp != null)
|
||||
{
|
||||
var rewards = customizeCheckoutTemp.CustomizeCheckoutRewards.ToList();
|
||||
|
||||
rewards.Add(new(entity.Amount.ToMoney(), entity.Description, entity.GrantDate, entity.GrantDate.ToFarsi(), entity.IsActive, entity.Title, entity.id));
|
||||
customizeCheckoutTemp.SetRewards(rewards);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
|
||||
transaction.Complete();
|
||||
return op.Succcedded();
|
||||
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditRewardViewModel command)
|
||||
@@ -160,34 +216,85 @@ public class RewardApplication : IRewardApplication
|
||||
var month = Convert.ToInt32(command.GrantDate.Substring(5, 2));
|
||||
var year = Convert.ToInt32(command.GrantDate.Substring(0, 4));
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeId == x.EmployeeId && x.YearInt == year && x.MonthInt == month))
|
||||
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > grantDate)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است پاداشی دهید");
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(grantDate,
|
||||
oneMonthAgoGr, entity.WorkshopId, [entity.EmployeeId]);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد پاداشی دهید");
|
||||
}
|
||||
}
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == command.WorkshopId && entity.EmployeeId == x.EmployeeId &&
|
||||
x.YearInt == year && x.MonthInt == month && x.ContractStart <= grantDate && x.ContractEnd >= grantDate))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است پاداشی دهید");
|
||||
}
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(grantDate,
|
||||
grantDate, entity.WorkshopId, [entity.EmployeeId]);
|
||||
|
||||
|
||||
entity.Edit(command.Amount.MoneyToDouble(),command.Description,userId,userType, grantDate,command.Title);
|
||||
using var transaction = new TransactionScope();
|
||||
|
||||
entity.Edit(command.Amount.MoneyToDouble(), command.Description, userId, userType, grantDate, command.Title);
|
||||
_rewardRepository.SaveChanges();
|
||||
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
entity.WorkshopId, entity.EmployeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
if (customizeCheckouts != null)
|
||||
{
|
||||
|
||||
var rewards = customizeCheckouts.CustomizeCheckoutRewards.ToList();
|
||||
|
||||
var existsReward = rewards.FirstOrDefault(x => x.EntityId == entity.id);
|
||||
if (existsReward != null)
|
||||
{
|
||||
rewards.Remove(existsReward);
|
||||
}
|
||||
|
||||
rewards.Add(new(entity.Amount.ToMoney(), entity.Description, entity.GrantDate, entity.GrantDate.ToFarsi(), entity.IsActive, entity.Title, entity.id));
|
||||
customizeCheckouts.SetRewards(rewards);
|
||||
}
|
||||
}
|
||||
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
command.WorkshopId, entity.EmployeeId, grantDate).GetAwaiter().GetResult();
|
||||
if (customizeCheckoutTemp != null)
|
||||
{
|
||||
|
||||
var rewards = customizeCheckoutTemp.CustomizeCheckoutRewards.ToList();
|
||||
|
||||
var existsReward = rewards.FirstOrDefault(x => x.EntityId == entity.id);
|
||||
if (existsReward != null)
|
||||
{
|
||||
rewards.Remove(existsReward);
|
||||
}
|
||||
|
||||
rewards.Add(new(entity.Amount.ToMoney(), entity.Description, entity.GrantDate, entity.GrantDate.ToFarsi(), entity.IsActive, entity.Title, entity.id));
|
||||
customizeCheckoutTemp.SetRewards(rewards);
|
||||
}
|
||||
}
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
transaction.Complete();
|
||||
return op.Succcedded(entity.id);
|
||||
}
|
||||
|
||||
#region Pooya
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
|
||||
/// </summary>
|
||||
public RewardsGroupedViewModel GetSearchListAsGrouped(RewardSearchModel searchModel)
|
||||
{
|
||||
return _rewardRepository.GetSearchListAsGrouped(searchModel);
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
|
||||
/// </summary>
|
||||
public RewardsGroupedViewModel GetSearchListAsGrouped(RewardSearchModel searchModel)
|
||||
{
|
||||
return _rewardRepository.GetSearchListAsGrouped(searchModel);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -504,12 +504,6 @@ public class RollCallApplication : IRollCallApplication
|
||||
_rollCallRepository.AddRange(rollCallsAsEntityModels);
|
||||
_rollCallRepository.SaveChanges();
|
||||
foreach (var rollCallsAsEntityModel in rollCallsAsEntityModels)
|
||||
{
|
||||
rollCallsAsEntityModel.ClearTimeDiff();
|
||||
rollCallsAsEntityModel.SetShiftDate(_rollCallDomainService);
|
||||
}
|
||||
_rollCallRepository.SaveChanges();
|
||||
foreach (var rollCallsAsEntityModel in rollCallsAsEntityModels)
|
||||
{
|
||||
rollCallsAsEntityModel.Edit(rollCallsAsEntityModel.StartDate.Value, rollCallsAsEntityModel.EndDate.Value, _rollCallDomainService);
|
||||
}
|
||||
@@ -679,12 +673,6 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
_rollCallRepository.AddRange(rollCallsAsEntityModels);
|
||||
_rollCallRepository.SaveChanges();
|
||||
foreach (var rollCallsAsEntityModel in rollCallsAsEntityModels)
|
||||
{
|
||||
rollCallsAsEntityModel.ClearTimeDiff();
|
||||
rollCallsAsEntityModel.SetShiftDate(_rollCallDomainService);
|
||||
}
|
||||
_rollCallRepository.SaveChanges();
|
||||
|
||||
foreach (var rollCallsAsEntityModel in rollCallsAsEntityModels)
|
||||
{
|
||||
|
||||
@@ -7,11 +7,14 @@ using Company.Domain.CheckoutAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Reward;
|
||||
using OfficeOpenXml.Drawing.Chart;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -22,14 +25,18 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
private readonly ICustomizeCheckoutTempApplication _customizeCheckoutTempApplication;
|
||||
|
||||
|
||||
public SalaryAidApplication(ISalaryAidRepository salaryAidRepository, ICustomizeCheckoutRepository customizeCheckoutRepository,
|
||||
IEmployeeRepository employeeRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IAuthHelper authHelper)
|
||||
IEmployeeRepository employeeRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IAuthHelper authHelper, ICustomizeCheckoutApplication customizeCheckoutApplication, ICustomizeCheckoutTempApplication customizeCheckoutTempApplication)
|
||||
{
|
||||
_salaryAidRepository = salaryAidRepository;
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
_authHelper = authHelper;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
_customizeCheckoutTempApplication = customizeCheckoutTempApplication;
|
||||
_employeeRepository = employeeRepository;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
}
|
||||
@@ -48,44 +55,95 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
public OperationResult Create(CreateSalaryAidViewModel command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
if (!command.SalaryDateTime.TryToGeorgianDateTime(out var startDate))
|
||||
{
|
||||
return op.Failed("تاریخ وارد شده نامعتبر است");
|
||||
}
|
||||
var calculationDate = $"{command.CalculationYear:0000}/{command.CalculationMonth:00}/01";
|
||||
if (!calculationDate.TryToGeorgianDateTime(out var calculationDateGr))
|
||||
{
|
||||
return op.Failed("تاریخ محاسبه وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (startDate > DateTime.Now)
|
||||
{
|
||||
return op.Failed("تاریخ پرداخت مساعده می بایست تاریخ امروز یا قبل تر باشد");
|
||||
|
||||
}
|
||||
|
||||
if (command.Amount.Length > 15)
|
||||
{
|
||||
return op.Failed("مبلغ وارد شده معتبر نیست");
|
||||
}
|
||||
|
||||
var month = Convert.ToInt32(command.SalaryDateTime.Substring(5, 2));
|
||||
var year = Convert.ToInt32(command.SalaryDateTime.Substring(0, 4));
|
||||
var month = Convert.ToInt32(command.CalculationMonth);
|
||||
var year = Convert.ToInt32(command.CalculationYear);
|
||||
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year && x.MonthInt == month))
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > calculationDateGr)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است مساعده ای دهید");
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(calculationDateGr,
|
||||
oneMonthAgoGr, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد مساعده دهید");
|
||||
}
|
||||
}
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) &&
|
||||
x.YearInt == year && x.MonthInt == month && x.ContractStart <= startDate && x.ContractEnd >= startDate))
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است مساعده ای دهید");
|
||||
}
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(calculationDateGr,
|
||||
calculationDateGr, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
//if (existsCheckouts.Checkout)
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی رسمی صادر شده است مساعده ای دهید");
|
||||
|
||||
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
using var transaction = new TransactionScope();
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
{
|
||||
|
||||
var entity = new SalaryAid(employeeId, command.WorkshopId, command.Amount.MoneyToDouble(), startDate,userId,userType);
|
||||
var entity = new SalaryAid(employeeId, command.WorkshopId, command.Amount.MoneyToDouble(), startDate,userId,userType,command.CalculationMonth,command.CalculationYear);
|
||||
_salaryAidRepository.Create(entity);
|
||||
_salaryAidRepository.SaveChanges();
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
command.WorkshopId, employeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
|
||||
if (customizeCheckouts != null)
|
||||
{
|
||||
|
||||
var salaryAids = customizeCheckouts.CustomizeCheckoutSalaryAids.ToList();
|
||||
|
||||
salaryAids.Add(new(entity.Amount.ToMoney(), entity.SalaryAidDateTime, entity.SalaryAidDateTime.ToFarsi(), entity.CalculationDate, entity.CalculationDate.ToFarsi(), entity.id));
|
||||
customizeCheckouts.SetSalaryAids(salaryAids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
|
||||
|
||||
if (customizeCheckoutTemp != null)
|
||||
{
|
||||
var salaryAids = customizeCheckoutTemp.CustomizeCheckoutSalaryAids.ToList();
|
||||
|
||||
salaryAids.Add(new(entity.Amount.ToMoney(), entity.SalaryAidDateTime, entity.SalaryAidDateTime.ToFarsi(), entity.CalculationDate, entity.CalculationDate.ToFarsi(), entity.id));
|
||||
customizeCheckoutTemp.SetSalaryAids(salaryAids);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
_salaryAidRepository.SaveChanges();
|
||||
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
transaction.Complete();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -98,6 +156,12 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
return op.Failed("تاریخ وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var calculationDate = $"{command.CalculationYear:0000}/{command.CalculationMonth:00}/01";
|
||||
if (!calculationDate.TryToGeorgianDateTime(out var calculationDateGr))
|
||||
{
|
||||
return op.Failed("تاریخ محاسبه وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (startDate > DateTime.Now)
|
||||
{
|
||||
return op.Failed("تاریخ پرداخت مساعده می بایست تاریخ امروز یا قبل تر باشد");
|
||||
@@ -111,21 +175,78 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
if (entity == null)
|
||||
return op.Failed("چنین مساعده ای وجود ندارد");
|
||||
|
||||
var month = Convert.ToInt32(command.SalaryDateTime.Substring(5, 2));
|
||||
var year = Convert.ToInt32(command.SalaryDateTime.Substring(0, 4));
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == entity.WorkshopId && entity.EmployeeId == x.EmployeeId && x.YearInt == year && x.MonthInt == month))
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است مساعده ای دهید");
|
||||
var month = Convert.ToInt32(command.CalculationMonth);
|
||||
var year = Convert.ToInt32(command.CalculationYear);
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) &&
|
||||
x.YearInt == year && x.MonthInt == month && x.ContractStart <= startDate && x.ContractEnd >= startDate))
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > calculationDateGr)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی موقت صادر شده است مساعده ای دهید");
|
||||
}
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(calculationDateGr,
|
||||
oneMonthAgoGr, entity.WorkshopId, [entity.EmployeeId]);
|
||||
|
||||
entity.Edit(Tools.MoneyToDouble(command.Amount),startDate,userId,userType);
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد مساعده ای دهید");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(calculationDateGr,
|
||||
calculationDateGr, entity.WorkshopId, [entity.EmployeeId]);
|
||||
|
||||
//if (existsCheckouts.Checkout)
|
||||
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی رسمی صادر شده است مساعده ای دهید");
|
||||
|
||||
|
||||
using var transaction = new TransactionScope();
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
entity.Edit(Tools.MoneyToDouble(command.Amount),startDate,userId,userType,command.CalculationMonth,command.CalculationYear);
|
||||
_salaryAidRepository.SaveChanges();
|
||||
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
entity.WorkshopId, entity.EmployeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
|
||||
var salaryAids = customizeCheckouts.CustomizeCheckoutSalaryAids.ToList();
|
||||
|
||||
var existsSalaryAid = salaryAids.FirstOrDefault(x => x.EntityId == entity.id);
|
||||
if (existsSalaryAid != null)
|
||||
{
|
||||
salaryAids.Remove(existsSalaryAid);
|
||||
}
|
||||
|
||||
salaryAids.Add(new(entity.Amount.ToMoney(), entity.SalaryAidDateTime, entity.SalaryAidDateTime.ToFarsi(),
|
||||
entity.CalculationDate, entity.CalculationDate.ToFarsi(), entity.id));
|
||||
|
||||
customizeCheckouts.SetSalaryAids(salaryAids);
|
||||
|
||||
}
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
entity.WorkshopId, entity.EmployeeId, calculationDateGr).GetAwaiter().GetResult();
|
||||
|
||||
var salaryAids = customizeCheckoutTemp.CustomizeCheckoutSalaryAids.ToList();
|
||||
|
||||
var existsSalaryAid = salaryAids.FirstOrDefault(x => x.EntityId == entity.id);
|
||||
if (existsSalaryAid != null)
|
||||
{
|
||||
salaryAids.Remove(existsSalaryAid);
|
||||
}
|
||||
|
||||
salaryAids.Add(new(entity.Amount.ToMoney(), entity.SalaryAidDateTime, entity.SalaryAidDateTime.ToFarsi(),
|
||||
entity.CalculationDate, entity.CalculationDate.ToFarsi(), entity.id));
|
||||
|
||||
customizeCheckoutTemp.SetSalaryAids(salaryAids);
|
||||
|
||||
}
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
transaction.Complete();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -136,15 +257,15 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
if (entity == null)
|
||||
return op.Failed("این آیتم وجود ندارد");
|
||||
|
||||
var month = Convert.ToInt32(entity.SalaryAidDateTime.ToFarsi().Substring(5, 2));
|
||||
var year = Convert.ToInt32(entity.SalaryAidDateTime.ToFarsi().Substring(0, 4));
|
||||
var month = Convert.ToInt32(entity.CalculationDate.ToFarsi().Substring(5, 2));
|
||||
var year = Convert.ToInt32(entity.CalculationDate.ToFarsi().Substring(0, 4));
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == entity.WorkshopId && entity.EmployeeId == x.EmployeeId && x.YearInt == year && x.MonthInt == month))
|
||||
return op.Failed("این پرسنل در این تاریخ دارای فیش حقوقی است");
|
||||
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == entity.WorkshopId && entity.EmployeeId == x.EmployeeId &&
|
||||
x.YearInt == year && x.MonthInt == month && x.ContractStart <= entity.SalaryAidDateTime && x.ContractEnd >= entity.SalaryAidDateTime))
|
||||
x.YearInt == year && x.MonthInt == month && x.ContractStart <= entity.CalculationDate && x.ContractEnd >= entity.CalculationDate))
|
||||
{
|
||||
return op.Failed("این پرسنل در این تاریخ دارای فیش حقوقی موقت است");
|
||||
}
|
||||
@@ -164,9 +285,10 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> CreateRange(List<CreateSalaryAidViewModel> commands)
|
||||
public OperationResult CreateRange(List<CreateSalaryAidViewModel> commands)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
using var transaction = new TransactionScope();
|
||||
foreach (var command in commands)
|
||||
{
|
||||
|
||||
@@ -174,6 +296,11 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
{
|
||||
return op.Failed("تاریخ وارد شده نامعتبر است");
|
||||
}
|
||||
var calculationDate = $"{command.CalculationYear:0000}/{command.CalculationMonth:00}/01";
|
||||
if (!calculationDate.TryToGeorgianDateTime(out var calculationDateGr))
|
||||
{
|
||||
return op.Failed("تاریخ محاسبه وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (startDate > DateTime.Now)
|
||||
{
|
||||
@@ -184,17 +311,30 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
{
|
||||
return op.Failed("مبلغ وارد شده معتبر نیست");
|
||||
}
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
var month = Convert.ToInt32(command.SalaryDateTime.Substring(5, 2));
|
||||
var year = Convert.ToInt32(command.SalaryDateTime.Substring(0, 4));
|
||||
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == command.WorkshopId && command.EmployeeIds.Contains(x.EmployeeId) && x.YearInt == year && x.MonthInt == month))
|
||||
if (oneMonthAgoGr > calculationDateGr)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است مساعده ای دهید");
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(calculationDateGr,
|
||||
oneMonthAgoGr, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.Checkout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد مساعده دهید");
|
||||
}
|
||||
}
|
||||
var (userId, userType, _) = _authHelper.GetUserTypeWithId();
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(calculationDateGr,
|
||||
calculationDateGr, command.WorkshopId, command.EmployeeIds);
|
||||
|
||||
var month = Convert.ToInt32(command.CalculationMonth);
|
||||
var year = Convert.ToInt32(command.CalculationYear);
|
||||
|
||||
|
||||
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
{
|
||||
var id = employeeId;
|
||||
if (employeeId == 0)
|
||||
@@ -203,11 +343,44 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
id = employee.id;
|
||||
}
|
||||
|
||||
var entity = new SalaryAid(id, command.WorkshopId, command.Amount.MoneyToDouble(), startDate, userId, userType);
|
||||
await _salaryAidRepository.CreateAsync(entity);
|
||||
var entity = new SalaryAid(id, command.WorkshopId, command.Amount.MoneyToDouble(), startDate, userId, userType, command.CalculationMonth, command.CalculationYear);
|
||||
_salaryAidRepository.Create(entity);
|
||||
_salaryAidRepository.SaveChanges();
|
||||
|
||||
if (existsCheckouts.CustomizeCheckout)
|
||||
{
|
||||
var customizeCheckouts = _customizeCheckoutRepository.GetByWorkshopIdEmployeeIdMonthYear(
|
||||
command.WorkshopId, employeeId,
|
||||
year, month).GetAwaiter().GetResult();
|
||||
|
||||
if (customizeCheckouts != null)
|
||||
{
|
||||
|
||||
var salaryAids = customizeCheckouts.CustomizeCheckoutSalaryAids.ToList();
|
||||
|
||||
salaryAids.Add(new(entity.Amount.ToMoney(), entity.SalaryAidDateTime, entity.SalaryAidDateTime.ToFarsi(), entity.CalculationDate, entity.CalculationDate.ToFarsi(), entity.id));
|
||||
customizeCheckouts.SetSalaryAids(salaryAids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (existsCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
var customizeCheckoutTemp = _customizeCheckoutTempRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
|
||||
|
||||
if (customizeCheckoutTemp != null)
|
||||
{
|
||||
var salaryAids = customizeCheckoutTemp.CustomizeCheckoutSalaryAids.ToList();
|
||||
|
||||
salaryAids.Add(new(entity.Amount.ToMoney(), entity.SalaryAidDateTime, entity.SalaryAidDateTime.ToFarsi(), entity.CalculationDate, entity.CalculationDate.ToFarsi(), entity.id));
|
||||
customizeCheckoutTemp.SetSalaryAids(salaryAids);
|
||||
}
|
||||
}
|
||||
}
|
||||
_customizeCheckoutRepository.SaveChanges();
|
||||
}
|
||||
await _salaryAidRepository.SaveChangesAsync();
|
||||
transaction.Complete();
|
||||
return op.Succcedded();
|
||||
}
|
||||
#region Pooya
|
||||
@@ -219,6 +392,6 @@ public class SalaryAidApplication : ISalaryAidApplication
|
||||
return _salaryAidRepository.GetSearchListAsGrouped(searchModel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -85,6 +85,8 @@ public class CustomizeCheckoutMapping : IEntityTypeConfiguration<CustomizeChecko
|
||||
{
|
||||
salaryAid.Property(x => x.SalaryAidDateTimeFa).HasMaxLength(15);
|
||||
salaryAid.Property(x => x.Amount).HasMaxLength(25);
|
||||
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
|
||||
|
||||
});
|
||||
|
||||
builder.OwnsMany(x => x.CustomizeCheckoutRewards, rewards =>
|
||||
|
||||
@@ -84,6 +84,8 @@ public class CustomizeCheckoutTempMapping : IEntityTypeConfiguration<CustomizeCh
|
||||
{
|
||||
salaryAid.Property(x => x.SalaryAidDateTimeFa).HasMaxLength(15);
|
||||
salaryAid.Property(x => x.Amount).HasMaxLength(25);
|
||||
salaryAid.Property(x => x.CalculationDateTimeFa).HasMaxLength(15);
|
||||
|
||||
});
|
||||
|
||||
builder.OwnsMany(x => x.CustomizeCheckoutRewards, rewards =>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addcalculationdatetosalaryaidandaddentityidtocustomizecheckoutvalueobjects : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CalculationDate",
|
||||
table: "SalaryAids",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CalculationMonth",
|
||||
table: "SalaryAids",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CalculationYear",
|
||||
table: "SalaryAids",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CalculationDateTime",
|
||||
table: "CustomizeCheckoutTempSalaryAid",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CalculationDateTimeFa",
|
||||
table: "CustomizeCheckoutTempSalaryAid",
|
||||
type: "nvarchar(15)",
|
||||
maxLength: 15,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempSalaryAid",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempReward",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempLoanInstallments",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempFine",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CalculationDateTime",
|
||||
table: "CustomizeCheckoutSalaryAid",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CalculationDateTimeFa",
|
||||
table: "CustomizeCheckoutSalaryAid",
|
||||
type: "nvarchar(15)",
|
||||
maxLength: 15,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutSalaryAid",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutReward",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutLoanInstallments",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutFine",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationDate",
|
||||
table: "SalaryAids");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationMonth",
|
||||
table: "SalaryAids");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationYear",
|
||||
table: "SalaryAids");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationDateTime",
|
||||
table: "CustomizeCheckoutTempSalaryAid");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationDateTimeFa",
|
||||
table: "CustomizeCheckoutTempSalaryAid");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempSalaryAid");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempReward");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempLoanInstallments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutTempFine");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationDateTime",
|
||||
table: "CustomizeCheckoutSalaryAid");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CalculationDateTimeFa",
|
||||
table: "CustomizeCheckoutSalaryAid");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutSalaryAid");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutReward");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutLoanInstallments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EntityId",
|
||||
table: "CustomizeCheckoutFine");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4720,6 +4720,15 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<double>("Amount")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime>("CalculationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CalculationMonth")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("CalculationYear")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("CreatedByAccountId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
@@ -6289,6 +6298,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b1.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("FineDateFa")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("nvarchar(12)");
|
||||
@@ -6328,6 +6340,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("IsActive")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
@@ -6375,6 +6390,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b1.Property<string>("Description")
|
||||
.HasColumnType("ntext");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<DateTime>("GrantDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@@ -6414,6 +6432,16 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b1.Property<DateTime>("CalculationDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<string>("CalculationDateTimeFa")
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<DateTime>("SalaryAidDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@@ -6564,6 +6592,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b1.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("FineDateFa")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("nvarchar(12)");
|
||||
@@ -6603,6 +6634,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("IsActive")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
@@ -6650,6 +6684,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b1.Property<string>("Description")
|
||||
.HasColumnType("ntext");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<DateTime>("GrantDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@@ -6689,6 +6726,16 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b1.Property<DateTime>("CalculationDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<string>("CalculationDateTimeFa")
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b1.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<DateTime>("SalaryAidDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
|
||||
@@ -17,17 +17,15 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
|
||||
using Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||
using CompanyManagment.App.Contracts.Fine;
|
||||
using CompanyManagment.App.Contracts.Loan;
|
||||
using CompanyManagment.App.Contracts.Reward;
|
||||
using CompanyManagment.App.Contracts.SalaryAid;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.IO;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository
|
||||
{
|
||||
@@ -37,7 +35,8 @@ namespace CompanyManagment.EFCore.Repository
|
||||
private readonly IRollCallRepository _rollCallRepository;
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
public CustomizeCheckoutRepository(CompanyContext context, IRollCallRepository rollCallRepository, AccountContext accountContext, IWebHostEnvironment webHostEnvironment) : base(context)
|
||||
|
||||
public CustomizeCheckoutRepository(CompanyContext context, IRollCallRepository rollCallRepository, AccountContext accountContext, IWebHostEnvironment webHostEnvironment) : base(context)
|
||||
{
|
||||
_companyContext = context;
|
||||
_rollCallRepository = rollCallRepository;
|
||||
@@ -77,152 +76,152 @@ namespace CompanyManagment.EFCore.Repository
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
{
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
{
|
||||
|
||||
//var pc = new PersianCalendar();
|
||||
//var year = pc.GetYear(monthStart);
|
||||
//var month = pc.GetMonth(monthStart);
|
||||
//var pc = new PersianCalendar();
|
||||
//var year = pc.GetYear(monthStart);
|
||||
//var month = pc.GetMonth(monthStart);
|
||||
|
||||
IQueryable<CustomizeCheckout> customizeCheckoutsQuery = _companyContext.CustomizeCheckouts.AsSplitQuery()
|
||||
.Where(x => customizeCheckoutIds.Contains(x.id)).Include(x => x.CheckoutFines);
|
||||
IQueryable<CustomizeCheckout> customizeCheckoutsQuery = _companyContext.CustomizeCheckouts.AsSplitQuery()
|
||||
.Where(x => customizeCheckoutIds.Contains(x.id)).Include(x => x.CheckoutFines);
|
||||
|
||||
IQueryable<Workshop> workshopsQuery = _companyContext.Workshops.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.id));
|
||||
IQueryable<Workshop> workshopsQuery = _companyContext.Workshops.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.id));
|
||||
|
||||
IQueryable<long> workshopEmployersIdsQuery = _companyContext.WorkshopEmployers.Where(x => x.WorkshopId == workshopId).Select(x => x.EmployerId);
|
||||
IQueryable<Employer> employersQuery = _companyContext.Employers.Where(x => workshopEmployersIdsQuery.Contains(x.id));
|
||||
IQueryable<long> workshopEmployersIdsQuery = _companyContext.WorkshopEmployers.Where(x => x.WorkshopId == workshopId).Select(x => x.EmployerId);
|
||||
IQueryable<Employer> employersQuery = _companyContext.Employers.Where(x => workshopEmployersIdsQuery.Contains(x.id));
|
||||
|
||||
IQueryable<PersonnelCodeDomain> personnelCodesQuery = _companyContext.PersonnelCodeSet
|
||||
.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId));
|
||||
IQueryable<PersonnelCodeDomain> personnelCodesQuery = _companyContext.PersonnelCodeSet
|
||||
.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId));
|
||||
|
||||
//IQueryable<LeftWork> leftWorksQuery = _companyContext.LeftWorkList
|
||||
// .Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
// x.LeftWorkDate.AddDays(-1) >= monthStart && x.StartWorkDate <= monthEnd);
|
||||
//IQueryable<LeftWork> leftWorksQuery = _companyContext.LeftWorkList
|
||||
// .Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
// x.LeftWorkDate.AddDays(-1) >= monthStart && x.StartWorkDate <= monthEnd);
|
||||
|
||||
//IQueryable<Employee> employeesQuery = _companyContext.Employees.Where(x => customizeCheckoutsQuery.Any(y => y.EmployeeId == x.id));
|
||||
//IQueryable<Employee> employeesQuery = _companyContext.Employees.Where(x => customizeCheckoutsQuery.Any(y => y.EmployeeId == x.id));
|
||||
|
||||
var loans = _companyContext.Loans.AsSplitQuery().Where(x => x.WorkshopId == workshopId).ToList();
|
||||
var loans = _companyContext.Loans.AsSplitQuery().Where(x => x.WorkshopId == workshopId).ToList();
|
||||
|
||||
List<(string Picture, long Id)> employeePictures;
|
||||
List<(string Picture, long Id)> employeePictures;
|
||||
|
||||
|
||||
var employeePicMediaIdInEmployeeDoc = _companyContext.EmployeeDocumentItems.Where(x => customizeCheckoutsQuery
|
||||
.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
x.DocumentLabel == DocumentItemLabel.EmployeePicture &&
|
||||
x.DocumentStatus == DocumentStatus.Confirmed)
|
||||
?.Select(x => new { x.EmployeeId, x.MediaId }).ToList();
|
||||
var employeePicMediaIdInEmployeeDoc = _companyContext.EmployeeDocumentItems.Where(x => customizeCheckoutsQuery
|
||||
.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
x.DocumentLabel == DocumentItemLabel.EmployeePicture &&
|
||||
x.DocumentStatus == DocumentStatus.Confirmed)
|
||||
?.Select(x => new { x.EmployeeId, x.MediaId }).ToList();
|
||||
|
||||
var mediasInEmployeeDoc = _accountContext.Medias.Where(x => employeePicMediaIdInEmployeeDoc.Select(y => y.MediaId).Contains(x.id)).ToList();
|
||||
employeePictures = employeePicMediaIdInEmployeeDoc.Select(x =>
|
||||
{
|
||||
var media = mediasInEmployeeDoc.First(m => m.id == x.MediaId);
|
||||
var filePath = media.Path;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
throw new FileNotFoundException("فایل مورد نظر یافت نشد.", filePath);
|
||||
var mediasInEmployeeDoc = _accountContext.Medias.Where(x => employeePicMediaIdInEmployeeDoc.Select(y => y.MediaId).Contains(x.id)).ToList();
|
||||
employeePictures = employeePicMediaIdInEmployeeDoc.Select(x =>
|
||||
{
|
||||
var media = mediasInEmployeeDoc.First(m => m.id == x.MediaId);
|
||||
var filePath = media.Path;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
throw new FileNotFoundException("فایل مورد نظر یافت نشد.", filePath);
|
||||
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
|
||||
return (base64, x.EmployeeId);
|
||||
}).ToList();
|
||||
return (base64, x.EmployeeId);
|
||||
}).ToList();
|
||||
|
||||
|
||||
|
||||
var employeeIds = customizeCheckoutsQuery.Select(x => x.EmployeeId).ToList()
|
||||
.Where(x => !employeePictures.Select(e => e.Id).Contains(x)).ToList();
|
||||
var employeeIds = customizeCheckoutsQuery.Select(x => x.EmployeeId).ToList()
|
||||
.Where(x => !employeePictures.Select(e => e.Id).Contains(x)).ToList();
|
||||
|
||||
|
||||
foreach (var employeeId in employeeIds)
|
||||
{
|
||||
var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\1.jpg";
|
||||
foreach (var employeeId in employeeIds)
|
||||
{
|
||||
var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\1.jpg";
|
||||
|
||||
if (!System.IO.File.Exists(directoryPath))
|
||||
continue;
|
||||
if (!System.IO.File.Exists(directoryPath))
|
||||
continue;
|
||||
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(directoryPath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(directoryPath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
|
||||
employeePictures.Add((base64, employeeId));
|
||||
}
|
||||
employeePictures.Add((base64, employeeId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
List<CustomizeCheckoutViewModel> customizeCheckoutsList = customizeCheckoutsQuery.Select(x => new CustomizeCheckoutViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ContractId = x.ContractId == null ? 0 : x.ContractId.Value,
|
||||
EmployeeId = x.EmployeeId,
|
||||
Month = x.Month,
|
||||
Year = x.Year,
|
||||
ContractNo = x.ContractNo,
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
ContractStartGr = x.ContractStart,
|
||||
ContractEndGr = x.ContractEnd,
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
CreationDate = x.CreationDate,
|
||||
SumOfWorkingDays = x.SumOfWorkingDays,
|
||||
WorkshopName = x.WorkshopFullName,
|
||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||
NationalCode = x.NationalCode,
|
||||
EmployeeFName = x.EmployeeFName,
|
||||
EmployeeLName = x.EmployeeLName,
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FineViewModelList = x.CheckoutFines.Select(y => new FineViewModel()
|
||||
{
|
||||
Amount = y.Amount,
|
||||
FineDate = y.FineDateFa,
|
||||
Title = y.Title
|
||||
}).ToList(),
|
||||
InstallmentViewModels = x.CustomizeCheckoutLoanInstallments.Select(i => new LoanInstallmentViewModel()
|
||||
{
|
||||
Amount = i.AmountForMonth,
|
||||
AmountDouble = i.AmountForMonth.MoneyToDouble(),
|
||||
Year = i.Year,
|
||||
Month = i.Month,
|
||||
IsActive = i.IsActive,
|
||||
RemainingAmount = i.LoanRemaining,
|
||||
LoanAmount = i.LoanAmount
|
||||
}).ToList(),
|
||||
RewardViewModels = x.CustomizeCheckoutRewards.Select(r => new RewardViewModel()
|
||||
{
|
||||
IsActive = r.IsActive,
|
||||
Title = r.Title,
|
||||
Amount = r.Amount,
|
||||
AmountDouble = r.Amount.MoneyToDouble(),
|
||||
Description = r.Description,
|
||||
GrantDateFa = r.GrantDateFa,
|
||||
GrantDateGr = r.GrantDate
|
||||
}).ToList(),
|
||||
SalaryAidViewModels = x.CustomizeCheckoutSalaryAids.Select(s => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = s.Amount,
|
||||
AmountDouble = s.Amount.MoneyToDouble(),
|
||||
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
||||
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
||||
}).ToList(),
|
||||
List<CustomizeCheckoutViewModel> customizeCheckoutsList = customizeCheckoutsQuery.Select(x => new CustomizeCheckoutViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ContractId = x.ContractId == null ? 0 : x.ContractId.Value,
|
||||
EmployeeId = x.EmployeeId,
|
||||
Month = x.Month,
|
||||
Year = x.Year,
|
||||
ContractNo = x.ContractNo,
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
ContractStartGr = x.ContractStart,
|
||||
ContractEndGr = x.ContractEnd,
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
CreationDate = x.CreationDate,
|
||||
SumOfWorkingDays = x.SumOfWorkingDays,
|
||||
WorkshopName = x.WorkshopFullName,
|
||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||
NationalCode = x.NationalCode,
|
||||
EmployeeFName = x.EmployeeFName,
|
||||
EmployeeLName = x.EmployeeLName,
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FineViewModelList = x.CheckoutFines.Select(y => new FineViewModel()
|
||||
{
|
||||
Amount = y.Amount,
|
||||
FineDate = y.FineDateFa,
|
||||
Title = y.Title
|
||||
}).ToList(),
|
||||
InstallmentViewModels = x.CustomizeCheckoutLoanInstallments.Select(i => new LoanInstallmentViewModel()
|
||||
{
|
||||
Amount = i.AmountForMonth,
|
||||
AmountDouble = i.AmountForMonth.MoneyToDouble(),
|
||||
Year = i.Year,
|
||||
Month = i.Month,
|
||||
IsActive = i.IsActive,
|
||||
RemainingAmount = i.LoanRemaining,
|
||||
LoanAmount = i.LoanAmount
|
||||
}).ToList(),
|
||||
RewardViewModels = x.CustomizeCheckoutRewards.Select(r => new RewardViewModel()
|
||||
{
|
||||
IsActive = r.IsActive,
|
||||
Title = r.Title,
|
||||
Amount = r.Amount,
|
||||
AmountDouble = r.Amount.MoneyToDouble(),
|
||||
Description = r.Description,
|
||||
GrantDateFa = r.GrantDateFa,
|
||||
GrantDateGr = r.GrantDate
|
||||
}).ToList(),
|
||||
SalaryAidViewModels = x.CustomizeCheckoutSalaryAids.Select(s => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = s.Amount,
|
||||
AmountDouble = s.Amount.MoneyToDouble(),
|
||||
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
||||
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
||||
}).ToList(),
|
||||
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}",
|
||||
|
||||
@@ -231,7 +230,7 @@ namespace CompanyManagment.EFCore.Repository
|
||||
ShiftStatus = x.ShiftStatus,
|
||||
IrregularShift = x.IrregularShift,
|
||||
CustomizeRotatingShifts = x.CustomizeRotatingShifts.ToList(),
|
||||
RegularShift = x.RegularShifts.Select(s=> (CustomizeSifts)s).ToList()
|
||||
RegularShift = x.RegularShifts.Select(s => (CustomizeSifts)s).ToList()
|
||||
|
||||
}).ToList();
|
||||
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel
|
||||
@@ -268,45 +267,44 @@ namespace CompanyManagment.EFCore.Repository
|
||||
PersonnelCode = Convert.ToInt64(x.PersonnelCode)
|
||||
}).ToList();
|
||||
|
||||
var date = customizeCheckoutsList.FirstOrDefault();
|
||||
var date = customizeCheckoutsList.FirstOrDefault();
|
||||
|
||||
if (date == null)
|
||||
return new();
|
||||
if (date == null)
|
||||
return new();
|
||||
|
||||
var startDate = date.ContractStartGr.AddMonthsFa(0, out _).ToGeorgianDateTime().Date;
|
||||
var endDate = startDate.AddMonthsFa(1, out _).ToGeorgianDateTime().Date.AddTicks(-1);
|
||||
var startDate = date.ContractStartGr.AddMonthsFa(0, out _).ToGeorgianDateTime().Date;
|
||||
var endDate = startDate.AddMonthsFa(1, out _).ToGeorgianDateTime().Date.AddTicks(-1);
|
||||
|
||||
|
||||
List<PersonnelCheckoutDailyRollCallViewModel> personnelRollCalls = _rollCallRepository
|
||||
.GetEmployeeRollCallsForMonth(customizeCheckoutsList.Select(x => x.EmployeeId), workshopId, startDate, endDate);
|
||||
List<PersonnelCheckoutDailyRollCallViewModel> personnelRollCalls = _rollCallRepository
|
||||
.GetEmployeeRollCallsForMonth(customizeCheckoutsList.Select(x => x.EmployeeId), workshopId, startDate, endDate);
|
||||
|
||||
int counter = 1;
|
||||
int counter = 1;
|
||||
|
||||
foreach (var checkout in customizeCheckoutsList)
|
||||
{
|
||||
checkout.EmployeePicture =
|
||||
employeePictures.FirstOrDefault(p => p.Id == checkout.EmployeeId).Picture ?? "";
|
||||
foreach (var checkout in customizeCheckoutsList)
|
||||
{
|
||||
checkout.EmployeePicture =
|
||||
employeePictures.FirstOrDefault(p => p.Id == checkout.EmployeeId).Picture ?? "";
|
||||
|
||||
checkout.PrintCounter = counter++;
|
||||
checkout.PrintCounter = counter++;
|
||||
|
||||
//var leftwork = leftWorksList.FirstOrDefault(x => checkout.WorkshopId == x.WorkshopId && x.EmployeeId == checkout.EmployeeId);
|
||||
//checkout.LeftWorkDateGr = leftwork.LeftWorkDateGr;
|
||||
//var leftwork = leftWorksList.FirstOrDefault(x => checkout.WorkshopId == x.WorkshopId && x.EmployeeId == checkout.EmployeeId);
|
||||
//checkout.LeftWorkDateGr = leftwork.LeftWorkDateGr;
|
||||
|
||||
//var employee = employees.FirstOrDefault(x => x.Id == checkout.EmployeeId);
|
||||
//var employee = employees.FirstOrDefault(x => x.Id == checkout.EmployeeId);
|
||||
|
||||
checkout.EmployerList = workshopEmployersList;
|
||||
checkout.EmployerName = workshopEmployersList.FirstOrDefault()?.FullName ?? "-";
|
||||
checkout.EmployerList = workshopEmployersList;
|
||||
checkout.EmployerName = workshopEmployersList.FirstOrDefault()?.FullName ?? "-";
|
||||
|
||||
|
||||
checkout.MonthlyRollCall = personnelRollCalls.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId);
|
||||
checkout.PersonnelCode = personnelCodeList.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId)?.PersonnelCode ?? 0;
|
||||
checkout.MonthlyRollCall = personnelRollCalls.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId);
|
||||
checkout.PersonnelCode = personnelCodeList.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId)?.PersonnelCode ?? 0;
|
||||
|
||||
}
|
||||
return customizeCheckoutsList.OrderBy(x => x.EmployeeFullName).ToList();
|
||||
}
|
||||
return customizeCheckoutsList.OrderBy(x => x.EmployeeFullName).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RemoveEmployeeCustomizeCheckoutInDates(long workshopId, long employeeId, DateTime startOfMonth, DateTime endOfMonth)
|
||||
{
|
||||
var checkout = _companyContext.CustomizeCheckouts.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
||||
@@ -315,143 +313,185 @@ namespace CompanyManagment.EFCore.Repository
|
||||
_companyContext.CustomizeCheckouts.Remove(checkout);
|
||||
}
|
||||
|
||||
public IEnumerable<CustomizeCheckout> GetRange(long workshopId,List<long> ids)
|
||||
public IEnumerable<CustomizeCheckout> GetRange(long workshopId, List<long> ids)
|
||||
{
|
||||
return _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId==workshopId && ids.Contains(x.id)).AsEnumerable();
|
||||
return _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId == workshopId && ids.Contains(x.id)).AsEnumerable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
public List<CustomizeCheckout> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime startDate,
|
||||
DateTime endDate)
|
||||
{
|
||||
var checkouts = _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
||||
x.ContractStart <= endDate && x.ContractEnd >= startDate).ToList();
|
||||
return checkouts;
|
||||
}
|
||||
|
||||
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 async Task<CustomizeCheckout> GetByWorkshopIdEmployeeIdMonthYear(long workshopId, long employeeId,
|
||||
int year, int month)
|
||||
{
|
||||
return await _companyContext.CustomizeCheckouts.FirstOrDefaultAsync(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.MonthInt == month && x.YearInt == year);
|
||||
}
|
||||
|
||||
////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);
|
||||
|
||||
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);
|
||||
}
|
||||
public (bool Checkout, bool CustomizeCheckout, bool CustomizeCheckoutTemp) ValidateExistsCheckouts(
|
||||
DateTime startDate, DateTime endDate, long workshopId, List<long> employeeIds)
|
||||
{
|
||||
(bool Checkout, bool CustomizeCheckout, bool CustomizeCheckoutTemp) data = new();
|
||||
|
||||
|
||||
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 (_companyContext.CustomizeCheckouts.Any(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) &&
|
||||
x.ContractStart <= endDate && x.ContractEnd >= startDate))
|
||||
{
|
||||
data.CustomizeCheckout = true;
|
||||
}
|
||||
|
||||
if (_companyContext.CustomizeCheckoutTemps.Any(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) &&
|
||||
x.ContractStart <= endDate && x.ContractEnd >= startDate))
|
||||
{
|
||||
data.CustomizeCheckoutTemp = true;
|
||||
}
|
||||
|
||||
if (_companyContext.CheckoutSet.Any(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) &&
|
||||
x.ContractStart <= endDate && x.ContractEnd >= startDate))
|
||||
{
|
||||
data.Checkout = true;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
////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);
|
||||
|
||||
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 >= DateTime.Today)
|
||||
//{
|
||||
// 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);
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
if (queryEndDate >= DateTime.Today)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
|
||||
else if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
|
||||
query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
|
||||
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
#endregion
|
||||
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
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(),
|
||||
|
||||
}).ToList();
|
||||
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));
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository
|
||||
{
|
||||
@@ -33,14 +35,13 @@ namespace CompanyManagment.EFCore.Repository
|
||||
private readonly IRollCallRepository _rollCallRepository;
|
||||
private readonly CompanyContext _companyContext;
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
|
||||
public CustomizeCheckoutTempRepository(CompanyContext context, IRollCallRepository rollCallRepository, IWebHostEnvironment webHostEnvironment, AccountContext accountContext) : base(context)
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
public CustomizeCheckoutTempRepository(CompanyContext context, IRollCallRepository rollCallRepository, AccountContext accountContext, IWebHostEnvironment webHostEnvironment) : base(context)
|
||||
{
|
||||
_companyContext = context;
|
||||
_rollCallRepository = rollCallRepository;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_accountContext = accountContext;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
}
|
||||
#region Pooya
|
||||
public List<CustomizeCheckoutViewModel> GetByWorkshopIdInDates(long workshopId, DateTime startOfMonth, DateTime endOfMonth)
|
||||
@@ -75,294 +76,294 @@ 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)
|
||||
{
|
||||
}
|
||||
|
||||
//var pc = new PersianCalendar();
|
||||
//var year = pc.GetYear(monthStart);
|
||||
//var month = pc.GetMonth(monthStart);
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
{
|
||||
|
||||
IQueryable<CustomizeCheckoutTemp> customizeCheckoutsQuery = _companyContext.CustomizeCheckoutTemps.AsSplitQuery()
|
||||
//var pc = new PersianCalendar();
|
||||
//var year = pc.GetYear(monthStart);
|
||||
//var month = pc.GetMonth(monthStart);
|
||||
|
||||
IQueryable<CustomizeCheckoutTemp> customizeCheckoutsQuery = _companyContext.CustomizeCheckoutTemps.AsSplitQuery()
|
||||
.Where(x => customizeCheckoutIds.Contains(x.id));
|
||||
|
||||
IQueryable<Workshop> workshopsQuery = _companyContext.Workshops.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.id));
|
||||
IQueryable<Workshop> workshopsQuery = _companyContext.Workshops.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.id));
|
||||
|
||||
IQueryable<long> workshopEmployersIdsQuery = _companyContext.WorkshopEmployers.Where(x => x.WorkshopId == workshopId).Select(x => x.EmployerId);
|
||||
IQueryable<Employer> employersQuery = _companyContext.Employers.Where(x => workshopEmployersIdsQuery.Contains(x.id));
|
||||
IQueryable<long> workshopEmployersIdsQuery = _companyContext.WorkshopEmployers.Where(x => x.WorkshopId == workshopId).Select(x => x.EmployerId);
|
||||
IQueryable<Employer> employersQuery = _companyContext.Employers.Where(x => workshopEmployersIdsQuery.Contains(x.id));
|
||||
|
||||
IQueryable<PersonnelCodeDomain> personnelCodesQuery = _companyContext.PersonnelCodeSet
|
||||
.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId));
|
||||
IQueryable<PersonnelCodeDomain> personnelCodesQuery = _companyContext.PersonnelCodeSet
|
||||
.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId));
|
||||
|
||||
//IQueryable<LeftWork> leftWorksQuery = _companyContext.LeftWorkList
|
||||
// .Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
// x.LeftWorkDate.AddDays(-1) >= monthStart && x.StartWorkDate <= monthEnd);
|
||||
//IQueryable<LeftWork> leftWorksQuery = _companyContext.LeftWorkList
|
||||
// .Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
// x.LeftWorkDate.AddDays(-1) >= monthStart && x.StartWorkDate <= monthEnd);
|
||||
|
||||
//IQueryable<Employee> employeesQuery = _companyContext.Employees.Where(x => customizeCheckoutsQuery.Any(y => y.EmployeeId == x.id));
|
||||
//IQueryable<Employee> employeesQuery = _companyContext.Employees.Where(x => customizeCheckoutsQuery.Any(y => y.EmployeeId == x.id));
|
||||
|
||||
|
||||
List<(string Picture, long Id)> employeePictures;
|
||||
List<(string Picture, long Id)> employeePictures;
|
||||
|
||||
|
||||
var employeePicMediaIdInEmployeeDoc = _companyContext.EmployeeDocumentItems.Where(x => customizeCheckoutsQuery
|
||||
.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
x.DocumentLabel == DocumentItemLabel.EmployeePicture &&
|
||||
x.DocumentStatus == DocumentStatus.Confirmed)
|
||||
?.Select(x => new { x.EmployeeId, x.MediaId }).ToList();
|
||||
var employeePicMediaIdInEmployeeDoc = _companyContext.EmployeeDocumentItems.Where(x => customizeCheckoutsQuery
|
||||
.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) &&
|
||||
x.DocumentLabel == DocumentItemLabel.EmployeePicture &&
|
||||
x.DocumentStatus == DocumentStatus.Confirmed)
|
||||
?.Select(x => new { x.EmployeeId, x.MediaId }).ToList();
|
||||
|
||||
var mediasInEmployeeDoc = _accountContext.Medias.Where(x => employeePicMediaIdInEmployeeDoc.Select(y => y.MediaId).Contains(x.id)).ToList();
|
||||
employeePictures = employeePicMediaIdInEmployeeDoc.Select(x =>
|
||||
{
|
||||
var media = mediasInEmployeeDoc.First(m => m.id == x.MediaId);
|
||||
var filePath = media.Path;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
throw new FileNotFoundException("فایل مورد نظر یافت نشد.", filePath);
|
||||
var mediasInEmployeeDoc = _accountContext.Medias.Where(x => employeePicMediaIdInEmployeeDoc.Select(y => y.MediaId).Contains(x.id)).ToList();
|
||||
employeePictures = employeePicMediaIdInEmployeeDoc.Select(x =>
|
||||
{
|
||||
var media = mediasInEmployeeDoc.First(m => m.id == x.MediaId);
|
||||
var filePath = media.Path;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
throw new FileNotFoundException("فایل مورد نظر یافت نشد.", filePath);
|
||||
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
|
||||
return (base64, x.EmployeeId);
|
||||
}).ToList();
|
||||
return (base64, x.EmployeeId);
|
||||
}).ToList();
|
||||
|
||||
|
||||
|
||||
var employeeIds = customizeCheckoutsQuery.Select(x => x.EmployeeId).ToList()
|
||||
.Where(x => !employeePictures.Select(e => e.Id).Contains(x)).ToList();
|
||||
var employeeIds = customizeCheckoutsQuery.Select(x => x.EmployeeId).ToList()
|
||||
.Where(x => !employeePictures.Select(e => e.Id).Contains(x)).ToList();
|
||||
|
||||
foreach (var employeeId in employeeIds)
|
||||
{
|
||||
var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\1.jpg";
|
||||
foreach (var employeeId in employeeIds)
|
||||
{
|
||||
var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employeeId}\\1.jpg";
|
||||
|
||||
if (!System.IO.File.Exists(directoryPath))
|
||||
continue;
|
||||
if (!System.IO.File.Exists(directoryPath))
|
||||
continue;
|
||||
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(directoryPath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
byte[] fileBytes = System.IO.File.ReadAllBytes(directoryPath);
|
||||
var base64 = Convert.ToBase64String(fileBytes);
|
||||
|
||||
employeePictures.Add((base64, employeeId));
|
||||
}
|
||||
employeePictures.Add((base64, employeeId));
|
||||
}
|
||||
|
||||
|
||||
List<CustomizeCheckoutViewModel> customizeCheckoutsList = customizeCheckoutsQuery.Select(x => new CustomizeCheckoutViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ContractId = x.ContractId == null ? 0 : x.ContractId.Value,
|
||||
EmployeeId = x.EmployeeId,
|
||||
Month = x.Month,
|
||||
Year = x.Year,
|
||||
ContractNo = x.ContractNo,
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
ContractStartGr = x.ContractStart,
|
||||
ContractEndGr = x.ContractEnd,
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
CreationDate = x.CreationDate,
|
||||
SumOfWorkingDays = x.SumOfWorkingDays,
|
||||
WorkshopName = x.WorkshopFullName,
|
||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||
NationalCode = x.NationalCode,
|
||||
EmployeeFName = x.EmployeeFName,
|
||||
EmployeeLName = x.EmployeeLName,
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FineViewModelList = x.CheckoutFines.Select(y => new FineViewModel()
|
||||
{
|
||||
Amount = y.Amount,
|
||||
FineDate = y.FineDateFa,
|
||||
Title = y.Title
|
||||
}).ToList(),
|
||||
InstallmentViewModels = x.CustomizeCheckoutLoanInstallments.Select(i => new LoanInstallmentViewModel()
|
||||
{
|
||||
Amount = i.AmountForMonth,
|
||||
AmountDouble = i.AmountForMonth.MoneyToDouble(),
|
||||
Year = i.Year,
|
||||
Month = i.Month,
|
||||
IsActive = i.IsActive,
|
||||
RemainingAmount = i.LoanRemaining,
|
||||
LoanAmount = i.LoanAmount
|
||||
}).ToList(),
|
||||
RewardViewModels = x.CustomizeCheckoutRewards.Select(r => new RewardViewModel()
|
||||
{
|
||||
IsActive = r.IsActive,
|
||||
Title = r.Title,
|
||||
Amount = r.Amount,
|
||||
AmountDouble = r.Amount.MoneyToDouble(),
|
||||
Description = r.Description,
|
||||
GrantDateFa = r.GrantDateFa,
|
||||
GrantDateGr = r.GrantDate
|
||||
}).ToList(),
|
||||
SalaryAidViewModels = x.CustomizeCheckoutSalaryAids.Select(s => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = s.Amount,
|
||||
AmountDouble = s.Amount.MoneyToDouble(),
|
||||
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
||||
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
||||
}).ToList(),
|
||||
List<CustomizeCheckoutViewModel> customizeCheckoutsList = customizeCheckoutsQuery.Select(x => new CustomizeCheckoutViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ContractId = x.ContractId == null ? 0 : x.ContractId.Value,
|
||||
EmployeeId = x.EmployeeId,
|
||||
Month = x.Month,
|
||||
Year = x.Year,
|
||||
ContractNo = x.ContractNo,
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
TotalClaims = x.TotalClaims,
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
ContractStartGr = x.ContractStart,
|
||||
ContractEndGr = x.ContractEnd,
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
CreationDate = x.CreationDate,
|
||||
SumOfWorkingDays = x.SumOfWorkingDays,
|
||||
WorkshopName = x.WorkshopFullName,
|
||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||
NationalCode = x.NationalCode,
|
||||
EmployeeFName = x.EmployeeFName,
|
||||
EmployeeLName = x.EmployeeLName,
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FineViewModelList = x.CheckoutFines.Select(y => new FineViewModel()
|
||||
{
|
||||
Amount = y.Amount,
|
||||
FineDate = y.FineDateFa,
|
||||
Title = y.Title
|
||||
}).ToList(),
|
||||
InstallmentViewModels = x.CustomizeCheckoutLoanInstallments.Select(i => new LoanInstallmentViewModel()
|
||||
{
|
||||
Amount = i.AmountForMonth,
|
||||
AmountDouble = i.AmountForMonth.MoneyToDouble(),
|
||||
Year = i.Year,
|
||||
Month = i.Month,
|
||||
IsActive = i.IsActive,
|
||||
RemainingAmount = i.LoanRemaining,
|
||||
LoanAmount = i.LoanAmount
|
||||
}).ToList(),
|
||||
RewardViewModels = x.CustomizeCheckoutRewards.Select(r => new RewardViewModel()
|
||||
{
|
||||
IsActive = r.IsActive,
|
||||
Title = r.Title,
|
||||
Amount = r.Amount,
|
||||
AmountDouble = r.Amount.MoneyToDouble(),
|
||||
Description = r.Description,
|
||||
GrantDateFa = r.GrantDateFa,
|
||||
GrantDateGr = r.GrantDate
|
||||
}).ToList(),
|
||||
SalaryAidViewModels = x.CustomizeCheckoutSalaryAids.Select(s => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = s.Amount,
|
||||
AmountDouble = s.Amount.MoneyToDouble(),
|
||||
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
|
||||
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
||||
}).ToList(),
|
||||
|
||||
//LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{x.LateToWorkValue.Minutes:D2}"
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}",
|
||||
SettingSalary = x.SettingSalary.ToMoney(),
|
||||
DailyWage = x.DailyWage.ToMoney(),
|
||||
@@ -371,103 +372,102 @@ namespace CompanyManagment.EFCore.Repository
|
||||
CustomizeRotatingShifts = x.CustomizeRotatingShifts.ToList(),
|
||||
RegularShift = x.RegularShifts.Select(x => (CustomizeSifts)x).ToList()
|
||||
|
||||
}).ToList();
|
||||
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel
|
||||
{
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
Id = x.id
|
||||
}).ToList();
|
||||
List<EmployerViewModel> workshopEmployersList = employersQuery.Select(x => new EmployerViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
FullName = x.FullName
|
||||
}).ToList();
|
||||
//List<LeftWorkViewModel> leftWorksList = leftWorksQuery.Select(x => new LeftWorkViewModel
|
||||
//{
|
||||
// EmployeeId = x.EmployeeId,
|
||||
// WorkshopId = x.WorkshopId,
|
||||
// Id = x.id,
|
||||
// StartWorkDateGr = x.StartWorkDate,
|
||||
// LeftWorkDateGr = x.LeftWorkDate
|
||||
//}).ToList();
|
||||
//List<EmployeeViewModel> employees = employeesQuery.Select(x => new EmployeeViewModel()
|
||||
//{
|
||||
// Id = x.id,
|
||||
// FName = x.FName,
|
||||
// LName = x.LName,
|
||||
// FatherName = x.FatherName,
|
||||
// NationalCode = x.NationalCode,
|
||||
// DateOfBirth = x.DateOfBirth.ToFarsi()
|
||||
//}).ToList();
|
||||
List<PersonnelCodeViewModel> personnelCodeList = personnelCodesQuery.Select(x => new PersonnelCodeViewModel
|
||||
{
|
||||
EmployeeId = x.EmployeeId,
|
||||
WorkshopId = x.WorkshopId,
|
||||
PersonnelCode = Convert.ToInt64(x.PersonnelCode)
|
||||
}).ToList();
|
||||
|
||||
}).ToList();
|
||||
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel
|
||||
{
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
Id = x.id
|
||||
}).ToList();
|
||||
List<EmployerViewModel> workshopEmployersList = employersQuery.Select(x => new EmployerViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
FullName = x.FullName
|
||||
}).ToList();
|
||||
//List<LeftWorkViewModel> leftWorksList = leftWorksQuery.Select(x => new LeftWorkViewModel
|
||||
//{
|
||||
// EmployeeId = x.EmployeeId,
|
||||
// WorkshopId = x.WorkshopId,
|
||||
// Id = x.id,
|
||||
// StartWorkDateGr = x.StartWorkDate,
|
||||
// LeftWorkDateGr = x.LeftWorkDate
|
||||
//}).ToList();
|
||||
//List<EmployeeViewModel> employees = employeesQuery.Select(x => new EmployeeViewModel()
|
||||
//{
|
||||
// Id = x.id,
|
||||
// FName = x.FName,
|
||||
// LName = x.LName,
|
||||
// FatherName = x.FatherName,
|
||||
// NationalCode = x.NationalCode,
|
||||
// DateOfBirth = x.DateOfBirth.ToFarsi()
|
||||
//}).ToList();
|
||||
List<PersonnelCodeViewModel> personnelCodeList = personnelCodesQuery.Select(x => new PersonnelCodeViewModel
|
||||
{
|
||||
EmployeeId = x.EmployeeId,
|
||||
WorkshopId = x.WorkshopId,
|
||||
PersonnelCode = Convert.ToInt64(x.PersonnelCode)
|
||||
}).ToList();
|
||||
var date = customizeCheckoutsList.FirstOrDefault();
|
||||
|
||||
var date = customizeCheckoutsList.FirstOrDefault();
|
||||
if (date == null)
|
||||
return new();
|
||||
|
||||
if (date == null)
|
||||
return new();
|
||||
|
||||
var startDate = date.ContractStartGr.Date;
|
||||
var endDate = date.ContractEndGr.AddDays(1).Date.AddTicks(-1);
|
||||
var startDate = date.ContractStartGr.Date;
|
||||
var endDate = date.ContractEndGr.AddDays(1).Date.AddTicks(-1);
|
||||
|
||||
|
||||
List<PersonnelCheckoutDailyRollCallViewModel> personnelRollCalls = _rollCallRepository
|
||||
.GetEmployeeRollCallsForCustomizeCheckoutTemp(customizeCheckoutsList.Select(x => x.Id).ToList(), workshopId);
|
||||
List<PersonnelCheckoutDailyRollCallViewModel> personnelRollCalls = _rollCallRepository
|
||||
.GetEmployeeRollCallsForCustomizeCheckoutTemp(customizeCheckoutsList.Select(x => x.Id).ToList(), workshopId);
|
||||
|
||||
int counter = 1;
|
||||
foreach (var checkout in customizeCheckoutsList)
|
||||
{
|
||||
checkout.EmployeePicture =
|
||||
employeePictures.FirstOrDefault(p => p.Id == checkout.EmployeeId).Picture ?? "";
|
||||
checkout.PrintCounter = counter++;
|
||||
//var leftwork = leftWorksList.FirstOrDefault(x => checkout.WorkshopId == x.WorkshopId && x.EmployeeId == checkout.EmployeeId);
|
||||
//checkout.LeftWorkDateGr = leftwork.LeftWorkDateGr;
|
||||
int counter = 1;
|
||||
foreach (var checkout in customizeCheckoutsList)
|
||||
{
|
||||
checkout.EmployeePicture =
|
||||
employeePictures.FirstOrDefault(p => p.Id == checkout.EmployeeId).Picture ?? "";
|
||||
checkout.PrintCounter = counter++;
|
||||
//var leftwork = leftWorksList.FirstOrDefault(x => checkout.WorkshopId == x.WorkshopId && x.EmployeeId == checkout.EmployeeId);
|
||||
//checkout.LeftWorkDateGr = leftwork.LeftWorkDateGr;
|
||||
|
||||
//var employee = employees.FirstOrDefault(x => x.Id == checkout.EmployeeId);
|
||||
var rollCalls = personnelRollCalls.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId);
|
||||
//var employee = employees.FirstOrDefault(x => x.Id == checkout.EmployeeId);
|
||||
var rollCalls = personnelRollCalls.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId);
|
||||
|
||||
checkout.EmployerList = workshopEmployersList;
|
||||
checkout.EmployerName = workshopEmployersList.FirstOrDefault()?.FullName ?? "-";
|
||||
checkout.EmployerList = workshopEmployersList;
|
||||
checkout.EmployerName = workshopEmployersList.FirstOrDefault()?.FullName ?? "-";
|
||||
|
||||
checkout.MonthlyRollCall = rollCalls;
|
||||
checkout.MonthlyRollCall.DailyRollCalls = rollCalls.DailyRollCalls.Select(x =>
|
||||
{
|
||||
var isInRange = x.DateTimeGr >= checkout.ContractStartGr && x.DateTimeGr <= checkout.ContractEndGr;
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
StartDate1 = isInRange ? x.StartDate1 : "",
|
||||
EndDate1 = isInRange ? x.EndDate1 : "",
|
||||
EndDate2 = isInRange ? x.EndDate2 : "",
|
||||
StartDate2 = isInRange ? x.StartDate2 : "",
|
||||
TotalWorkingHours = isInRange ? x.TotalWorkingHours : "",
|
||||
DayOfWeek = x.DayOfWeek,
|
||||
RollCallDateFa = x.RollCallDateFa,
|
||||
DateTimeGr = x.DateTimeGr,
|
||||
IsSliced = isInRange && x.IsSliced,
|
||||
LeaveType = x.LeaveType,
|
||||
IsBirthDay = x.IsBirthDay,
|
||||
IsAbsent = x.IsAbsent,
|
||||
IsFriday = x.IsFriday,
|
||||
EnterDifferencesMinutes1 = isInRange ? x.EnterDifferencesMinutes1 : "",
|
||||
EnterDifferencesMinutes2 = isInRange ? x.EnterDifferencesMinutes2 : "",
|
||||
ExitDifferencesMinutes1 = isInRange ? x.ExitDifferencesMinutes1 : "",
|
||||
ExitDifferencesMinutes2 = isInRange ? x.ExitDifferencesMinutes2 : ""
|
||||
checkout.MonthlyRollCall = rollCalls;
|
||||
checkout.MonthlyRollCall.DailyRollCalls = rollCalls.DailyRollCalls.Select(x =>
|
||||
{
|
||||
var isInRange = x.DateTimeGr >= checkout.ContractStartGr && x.DateTimeGr <= checkout.ContractEndGr;
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
StartDate1 = isInRange ? x.StartDate1 : "",
|
||||
EndDate1 = isInRange ? x.EndDate1 : "",
|
||||
EndDate2 = isInRange ? x.EndDate2 : "",
|
||||
StartDate2 = isInRange ? x.StartDate2 : "",
|
||||
TotalWorkingHours = isInRange ? x.TotalWorkingHours : "",
|
||||
DayOfWeek = x.DayOfWeek,
|
||||
RollCallDateFa = x.RollCallDateFa,
|
||||
DateTimeGr = x.DateTimeGr,
|
||||
IsSliced = isInRange && x.IsSliced,
|
||||
LeaveType = x.LeaveType,
|
||||
IsBirthDay = x.IsBirthDay,
|
||||
IsAbsent = x.IsAbsent,
|
||||
IsFriday = x.IsFriday,
|
||||
EnterDifferencesMinutes1 = isInRange ? x.EnterDifferencesMinutes1 : "",
|
||||
EnterDifferencesMinutes2 = isInRange ? x.EnterDifferencesMinutes2 : "",
|
||||
ExitDifferencesMinutes1 = isInRange ? x.ExitDifferencesMinutes1 : "",
|
||||
ExitDifferencesMinutes2 = isInRange ? x.ExitDifferencesMinutes2 : ""
|
||||
|
||||
};
|
||||
}).ToList();
|
||||
checkout.PersonnelCode = personnelCodeList.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId)?.PersonnelCode ?? 0;
|
||||
};
|
||||
}).ToList();
|
||||
checkout.PersonnelCode = personnelCodeList.FirstOrDefault(x => x.EmployeeId == checkout.EmployeeId)?.PersonnelCode ?? 0;
|
||||
|
||||
}
|
||||
return customizeCheckoutsList.OrderBy(x => x.EmployeeFullName).ToList();
|
||||
}
|
||||
return customizeCheckoutsList.OrderBy(x => x.EmployeeFullName).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveEmployeeTemporaryCheckoutInDates(long workshopId, long employeeId, DateTime startOfMonth, DateTime endOfMonth)
|
||||
public void RemoveEmployeeTemporaryCheckoutInDates(long workshopId, long employeeId, DateTime startOfMonth, DateTime endOfMonth)
|
||||
{
|
||||
var checkout = _companyContext.CustomizeCheckoutTemps.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
||||
x.ContractStart.Date <= endOfMonth.Date && x.ContractEnd.Date >= startOfMonth.Date);
|
||||
@@ -480,5 +480,19 @@ namespace CompanyManagment.EFCore.Repository
|
||||
{
|
||||
return _companyContext.CustomizeCheckoutTemps.Where(x => x.WorkshopId == workshopId && ids.Contains(x.id));
|
||||
}
|
||||
|
||||
public List<CustomizeCheckoutTemp> GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var checkouts = _companyContext.CustomizeCheckoutTemps.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
||||
x.ContractStart <= endDate && x.ContractEnd >= startDate).ToList();
|
||||
return checkouts;
|
||||
}
|
||||
|
||||
public async Task<CustomizeCheckoutTemp> GetByWorkshopIdEmployeeIdInDate(long workshopId, long employeeId, DateTime inDate)
|
||||
{
|
||||
return await _companyContext.CustomizeCheckoutTemps.FirstOrDefaultAsync(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.ContractStart <= inDate &&
|
||||
x.ContractEnd >= inDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,7 +1223,8 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
public CustomizeCheckoutMandatoryViewModel CustomizeCheckoutMandatoryCompute(long employeeId, long workshopId, DateTime contractStart,
|
||||
DateTime contractEnd)
|
||||
{
|
||||
|
||||
var checkoutEnd = contractEnd;
|
||||
var checkoutStart = contractStart;
|
||||
if (workshopId == 170)
|
||||
return CustomizeCheckoutMandatoryComputeForKebabMahdi(employeeId, workshopId, contractStart, contractEnd);
|
||||
|
||||
@@ -1483,34 +1484,14 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#endregion
|
||||
#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();
|
||||
var salaryAidViewModel = SalaryAidsForCheckout(employeeId, workshopId, checkoutStart, checkoutEnd);
|
||||
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();
|
||||
var loanInstallments = LoanInstallmentForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
|
||||
double loanDeduction = loanInstallments.Sum(x => x.AmountDouble);
|
||||
|
||||
@@ -1518,18 +1499,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
#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();
|
||||
var fineViewModels = FinesForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
double fineDeduction = fineViewModels.Sum(x => x.Amount.MoneyToDouble());
|
||||
|
||||
#endregion
|
||||
@@ -1676,18 +1646,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#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();
|
||||
var rewardViewModels = RewardForCheckout(employeeId, workshopId, checkoutEnd, checkoutStart);
|
||||
|
||||
double rewardPay = rewardViewModels.Sum(x => x.AmountDouble);
|
||||
#endregion
|
||||
@@ -2289,38 +2248,14 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
#region SalaryAidDeduction
|
||||
|
||||
var salaryAidViewModel = _context.SalaryAids
|
||||
.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,
|
||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||
}).ToList();
|
||||
var salaryAidViewModel = SalaryAidsForCheckout(employeeId, workshopId, checkoutStart, checkoutEnd);
|
||||
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(),
|
||||
LoanAmount = _context.Loans.FirstOrDefault(l => l.id == x.LoanId).Amount.ToMoney()
|
||||
}).ToList();
|
||||
var loanInstallments = LoanInstallmentForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
|
||||
double loanDeduction = loanInstallments.Sum(x => x.AmountDouble);
|
||||
|
||||
@@ -2328,18 +2263,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
#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();
|
||||
var fineViewModels = FinesForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
double fineDeduction = fineViewModels.Sum(x => x.Amount.MoneyToDouble());
|
||||
|
||||
#endregion
|
||||
@@ -2557,18 +2481,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
#region Reward
|
||||
|
||||
var rewardViewModels = _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
||||
x.GrantDate >= checkoutStart).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();
|
||||
var rewardViewModels = RewardForCheckout(employeeId, workshopId, checkoutEnd, checkoutStart);
|
||||
|
||||
double rewardPay = rewardViewModels.Sum(x => x.AmountDouble);
|
||||
|
||||
@@ -2844,34 +2757,14 @@ 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()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||
}).ToList();
|
||||
var salaryAidViewModel = SalaryAidsForCheckout(employeeId, workshopId, contractEnd, contractEnd);
|
||||
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();
|
||||
var loanInstallments = LoanInstallmentForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
|
||||
double loanDeduction = loanInstallments.Sum(x => x.AmountDouble);
|
||||
|
||||
@@ -2879,35 +2772,13 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
#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();
|
||||
var fineViewModels = FinesForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
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();
|
||||
var rewardViewModels = RewardForCheckout(employeeId, workshopId, contractStart, contractEnd);
|
||||
|
||||
double rewardPay = rewardViewModels.Sum(x => x.AmountDouble);
|
||||
#endregion
|
||||
@@ -2931,6 +2802,75 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<RewardViewModel> RewardForCheckout(long employeeId, long workshopId, DateTime checkoutEnd, DateTime checkoutStart)
|
||||
{
|
||||
return _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
||||
x.GrantDate >= checkoutStart).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,
|
||||
Id = x.id
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private List<FineViewModel> FinesForCheckout(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
return _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();
|
||||
}
|
||||
|
||||
private List<LoanInstallmentViewModel> LoanInstallmentForCheckout(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
return _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()
|
||||
{
|
||||
Id = x.Id,
|
||||
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(),
|
||||
LoanAmount = _context.Loans.FirstOrDefault(l => l.id == x.LoanId).Amount.ToMoney()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private List<SalaryAidViewModel> SalaryAidsForCheckout(long employeeId, long workshopId, DateTime checkoutStart, DateTime checkoutEnd)
|
||||
{
|
||||
return _context.SalaryAids
|
||||
.Where(x => x.CalculationDate >= checkoutStart && x.CalculationDate <= checkoutEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||
CalculationDateTimeGe = x.CalculationDate,
|
||||
CalculationDateTimeFa = x.CalculationDate.ToFarsi(),
|
||||
Id = x.id
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private void CreateRewardForBirthDay(long employeeId, long workshopId, double amount, int month, int year,
|
||||
DateTime contractStart)
|
||||
{
|
||||
@@ -3815,7 +3755,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
|
||||
public static (DateTime start, DateTime end) FindRotatingShift(DateTime startRollCall, DateTime endRollCall,
|
||||
ICollection<CustomizeRotatingShift> rotatingShifts)
|
||||
ICollection<CustomizeRotatingShift> rotatingShifts)
|
||||
{
|
||||
DateTime startDate = startRollCall.Date;
|
||||
DateTime endDate = endRollCall.Date;
|
||||
@@ -3825,10 +3765,10 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
DateTime startEntryWithDate = startDate.Add(startRollCall.TimeOfDay);
|
||||
DateTime endEntryWithDate = endDate.Add(endRollCall.TimeOfDay);
|
||||
|
||||
DateTime twoHourBeforeStart = startEntryWithDate.AddHours(-2);
|
||||
DateTime twoHourAfterStart = startEntryWithDate.AddHours(2);
|
||||
DateTime twoHourBeforeEnd = endEntryWithDate.AddHours(-2);
|
||||
DateTime twoHourAfterEnd = endEntryWithDate.AddHours(2);
|
||||
DateTime oneHourBeforeStart = startEntryWithDate.AddHours(-1);
|
||||
DateTime oneHourAfterStart = startEntryWithDate.AddHours(1);
|
||||
DateTime oneHourBeforeEnd = endEntryWithDate.AddHours(-1);
|
||||
DateTime oneHourAfterEnd = endEntryWithDate.AddHours(1);
|
||||
|
||||
|
||||
var shiftDateTimes = rotatingShifts.SelectMany(shift =>
|
||||
@@ -3849,68 +3789,56 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
#region مقایسه شروع حضور غیاب با شیفت
|
||||
|
||||
//var startFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
// (twoHourBeforeStart <= shift.Start && twoHourAfterStart >= shift.Start) ||
|
||||
// (twoHourBeforeStart <= shift.End && twoHourAfterStart >= shift.End)).ToList();
|
||||
var startFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
(oneHourBeforeStart <= shift.Start && oneHourAfterStart >= shift.Start) ||
|
||||
(oneHourBeforeStart <= shift.End && oneHourAfterStart >= shift.End)).ToList();
|
||||
|
||||
//if (startFilteredTimes.Count == 0)
|
||||
//{
|
||||
// startFilteredTimes = shiftDateTimes;
|
||||
//}
|
||||
//else if (startFilteredTimes.Count == 1)
|
||||
//{
|
||||
// var startChosenShift = startFilteredTimes.First();
|
||||
if (startFilteredTimes.Count == 0)
|
||||
{
|
||||
startFilteredTimes = shiftDateTimes;
|
||||
}
|
||||
else if (startFilteredTimes.Count == 1)
|
||||
{
|
||||
var startChosenShift = startFilteredTimes.First();
|
||||
|
||||
// if (startChosenShift.End < startChosenShift.Start)
|
||||
// startChosenShift.End = startChosenShift.End.AddDays(1);
|
||||
if (startChosenShift.End < startChosenShift.Start)
|
||||
startChosenShift.End = startChosenShift.End.AddDays(1);
|
||||
|
||||
// return startChosenShift;
|
||||
//}
|
||||
return startChosenShift;
|
||||
}
|
||||
|
||||
|
||||
//#endregion
|
||||
#endregion
|
||||
|
||||
//#region مقایسه پایان حضورغیاب با شیفت
|
||||
#region مقایسه پایان حضورغیاب با شیفت
|
||||
|
||||
var endFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
(oneHourBeforeEnd <= shift.Start && oneHourAfterEnd >= shift.Start) ||
|
||||
(oneHourBeforeEnd <= shift.End && oneHourAfterEnd >= shift.End)).ToList();
|
||||
if (endFilteredTimes.Count == 0)
|
||||
{
|
||||
endFilteredTimes = startFilteredTimes;
|
||||
}
|
||||
else if (endFilteredTimes.Count == 1)
|
||||
{
|
||||
var endChosenShift = endFilteredTimes.First();
|
||||
return endChosenShift;
|
||||
}
|
||||
|
||||
//var endFilteredTimes = shiftDateTimes.Where(shift =>
|
||||
// (twoHourBeforeEnd <= shift.Start && twoHourAfterEnd >= shift.Start) ||
|
||||
// (twoHourBeforeEnd <= shift.End && twoHourAfterEnd >= shift.End)).ToList();
|
||||
//if (endFilteredTimes.Count == 0)
|
||||
//{
|
||||
// endFilteredTimes = startFilteredTimes;
|
||||
//}
|
||||
//else if (endFilteredTimes.Count == 1)
|
||||
//{
|
||||
// var endChosenShift = endFilteredTimes.First();
|
||||
// return endChosenShift;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
#region اشتراک حضور غیاب و شیفت
|
||||
|
||||
var overlapShifts = shiftDateTimes
|
||||
.Select(shift => new
|
||||
{
|
||||
Shift = shift,
|
||||
Overlap = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, endRollCall.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, startRollCall.Ticks))),
|
||||
// زمان حضور فرد در شیفت (مجموع Overlap با شیفت)
|
||||
TotalTimeInShift = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, endRollCall.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, startRollCall.Ticks))),
|
||||
StartDistance = Math.Abs((shift.Start - startRollCall).Ticks),
|
||||
EndDistance = Math.Abs((shift.End - endRollCall).Ticks),
|
||||
TotalDistance = Math.Abs((shift.Start - startRollCall).Ticks) + Math.Abs((shift.End - endRollCall).Ticks)
|
||||
})
|
||||
.OrderByDescending(s => s.TotalTimeInShift) // 1. بیشترین زمان حضور فرد
|
||||
.ThenByDescending(s => s.Overlap) // 2. بیشترین Overlap
|
||||
.ThenBy(s => s.TotalDistance)
|
||||
.ThenBy(s => s.StartDistance)
|
||||
.ThenBy(x => x.EndDistance); // 3. اگر برابر بود، Start نزدیکتر
|
||||
var overlapShifts = endFilteredTimes.Select(shift => new
|
||||
{
|
||||
Shift = shift,
|
||||
Overlap = new TimeSpan(Math.Max(0,
|
||||
Math.Min(shift.End.Ticks, oneHourAfterEnd.Ticks) -
|
||||
Math.Max(shift.Start.Ticks, oneHourBeforeStart.Ticks)))
|
||||
});
|
||||
|
||||
var overlapChosenShift = overlapShifts.First();
|
||||
var overlapChosenShift = overlapShifts.MaxBy(s => s.Overlap);
|
||||
var end = overlapChosenShift.Shift.End;
|
||||
if (overlapChosenShift.Shift.End < overlapChosenShift.Shift.Start)
|
||||
end = overlapChosenShift.Shift.End.AddDays(1);
|
||||
|
||||
@@ -72,7 +72,9 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
||||
WorkshopId = entity.WorkshopId,
|
||||
EmployeeId = entity.EmployeeId,
|
||||
Amount = entity.Amount.ToMoney(),
|
||||
SalaryDateTime = entity.SalaryAidDateTime.ToFarsi()
|
||||
SalaryDateTime = entity.SalaryAidDateTime.ToFarsi(),
|
||||
CalculationMonth = entity.CalculationMonth,
|
||||
CalculationYear = entity.CalculationYear,
|
||||
};
|
||||
|
||||
res.EmployeeFullName = _companyContext.Employees.Find(entity.EmployeeId)?.FullName;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Domain.AccountLeftWorkAgg;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
using Company.Domain.RewardAgg;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using CompanyManagment.App.Contracts.AndroidApkVersion;
|
||||
@@ -53,15 +55,17 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
//var notEndedRollCalls = rollCalls.Where(x => x.EndDate == null).ToList();
|
||||
//RefactorAllTheRollCallsOnEsfand(endedRollCalls, notEndedRollCalls);
|
||||
//CreateRewardForKebabMahdi().GetAwaiter().GetResult();
|
||||
SetEntityIdForCheckoutValues();
|
||||
SetEntityIdForCheckoutValuesTemp();
|
||||
ViewData["message"] = "ایجاد شد";
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnPostShiftDateNew()
|
||||
{
|
||||
var startRollCall = new DateTime(2025, 4, 21);
|
||||
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.EndDate != null ).ToList();
|
||||
var r1 = rollCalls.ToList();
|
||||
var startRollCall = new DateTime(2025, 3, 21);
|
||||
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.EndDate != null).ToList();
|
||||
var r1 = rollCalls.Take(10000).ToList();
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
Console.WriteLine("endStep 1 ============");
|
||||
@@ -72,6 +76,140 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
private void SetEntityIdForCheckoutValuesTemp()
|
||||
{
|
||||
var customizeCheckouts = _context.CustomizeCheckoutTemps.ToList();
|
||||
foreach (var customizeCheckout in customizeCheckouts)
|
||||
{
|
||||
var newRewards = new List<CustomizeCheckoutTempReward>();
|
||||
foreach (var customizeCheckoutReward in customizeCheckout.CustomizeCheckoutRewards)
|
||||
{
|
||||
var reward = _context.Rewards.FirstOrDefault(x => x.GrantDate == customizeCheckoutReward.GrantDate && x.Title == customizeCheckoutReward.Title && x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId);
|
||||
if (reward != null)
|
||||
{
|
||||
newRewards.Add(new CustomizeCheckoutTempReward(reward.Amount.ToMoney(), reward.Description, reward.GrantDate, reward.GrantDate.ToFarsi(), reward.IsActive, reward.Title, reward.id));
|
||||
}
|
||||
}
|
||||
|
||||
var newSalary = new List<CustomizeCheckoutTempSalaryAid>();
|
||||
foreach (var customizeCheckoutSalaryAid in customizeCheckout.CustomizeCheckoutSalaryAids)
|
||||
{
|
||||
var salary = _context.SalaryAids.FirstOrDefault(x => x.SalaryAidDateTime == customizeCheckoutSalaryAid.SalaryAidDateTime &&
|
||||
x.Amount == customizeCheckoutSalaryAid.Amount.MoneyToDouble() &&
|
||||
x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId);
|
||||
|
||||
if (salary != null)
|
||||
{
|
||||
newSalary.Add(new CustomizeCheckoutTempSalaryAid(salary.Amount.ToMoney(), salary.SalaryAidDateTime,
|
||||
salary.SalaryAidDateTime.ToFarsi(), salary.CalculationDate, salary.CalculationDate.ToFarsi(), salary.id));
|
||||
}
|
||||
}
|
||||
|
||||
var newFines = new List<CustomizeCheckoutTempFine>();
|
||||
foreach (var checkoutFine in customizeCheckout.CheckoutFines)
|
||||
{
|
||||
var fines = _context.Fines.FirstOrDefault(x => x.Amount == checkoutFine.Amount.MoneyToDouble() && x.FineDate == checkoutFine.FineDateGr &&
|
||||
x.Title == checkoutFine.Title && x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId);
|
||||
if (fines != null)
|
||||
{
|
||||
newFines.Add(new CustomizeCheckoutTempFine(fines.Title, fines.Amount.ToMoney(), fines.FineDate.ToFarsi(), fines.FineDate, fines.IsActive, fines.CreationDate, fines.id));
|
||||
}
|
||||
}
|
||||
|
||||
var newInstallments = new List<CustomizeCheckoutTempLoanInstallments>();
|
||||
|
||||
foreach (var customizeCheckoutLoanInstallment in customizeCheckout.CustomizeCheckoutLoanInstallments)
|
||||
{
|
||||
|
||||
var installments = _context.Loans.SelectMany(x => x.LoanInstallments).AsNoTracking().Where(x => x.Month == customizeCheckoutLoanInstallment.Month && x.Year == customizeCheckoutLoanInstallment.Year && x.AmountForMonth == customizeCheckoutLoanInstallment.AmountForMonth.MoneyToDouble()).ToList();
|
||||
var loans = _context.Loans
|
||||
.Where(x => x.Amount == customizeCheckoutLoanInstallment.LoanAmount.MoneyToDouble() && x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId).ToList();
|
||||
|
||||
var installment = installments.First(x => loans.Any(l => l.id == x.LoanId));
|
||||
|
||||
if (installment != null)
|
||||
{
|
||||
newInstallments.Add(new CustomizeCheckoutTempLoanInstallments(installment.AmountForMonth.ToMoney(),
|
||||
installment.Month, installment.Year, installment.IsActive,
|
||||
customizeCheckoutLoanInstallment.LoanRemaining, customizeCheckoutLoanInstallment.LoanAmount,
|
||||
installment.Id));
|
||||
}
|
||||
}
|
||||
customizeCheckout.SetValueObjects(newFines, newInstallments, newSalary, newRewards);
|
||||
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
}
|
||||
}
|
||||
private void SetEntityIdForCheckoutValues()
|
||||
{
|
||||
var customizeCheckouts = _context.CustomizeCheckouts.ToList();
|
||||
foreach (var customizeCheckout in customizeCheckouts)
|
||||
{
|
||||
var newRewards = new List<CustomizeCheckoutReward>();
|
||||
foreach (var customizeCheckoutReward in customizeCheckout.CustomizeCheckoutRewards)
|
||||
{
|
||||
var reward = _context.Rewards.FirstOrDefault(x => x.GrantDate == customizeCheckoutReward.GrantDate && x.Title == customizeCheckoutReward.Title && x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId);
|
||||
if (reward != null)
|
||||
{
|
||||
newRewards.Add(new CustomizeCheckoutReward(reward.Amount.ToMoney(), reward.Description, reward.GrantDate, reward.GrantDate.ToFarsi(), reward.IsActive, reward.Title, reward.id));
|
||||
}
|
||||
}
|
||||
|
||||
var newSalary = new List<CustomizeCheckoutSalaryAid>();
|
||||
foreach (var customizeCheckoutSalaryAid in customizeCheckout.CustomizeCheckoutSalaryAids)
|
||||
{
|
||||
var salary = _context.SalaryAids.FirstOrDefault(x => x.SalaryAidDateTime == customizeCheckoutSalaryAid.SalaryAidDateTime &&
|
||||
x.Amount == customizeCheckoutSalaryAid.Amount.MoneyToDouble() &&
|
||||
x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId);
|
||||
|
||||
if (salary != null)
|
||||
{
|
||||
newSalary.Add(new CustomizeCheckoutSalaryAid(salary.Amount.ToMoney(), salary.SalaryAidDateTime,
|
||||
salary.SalaryAidDateTime.ToFarsi(), salary.CalculationDate, salary.CalculationDate.ToFarsi(), salary.id));
|
||||
}
|
||||
}
|
||||
|
||||
var newFines = new List<CustomizeCheckoutFine>();
|
||||
foreach (var checkoutFine in customizeCheckout.CheckoutFines)
|
||||
{
|
||||
var fines = _context.Fines.FirstOrDefault(x => x.Amount == checkoutFine.Amount.MoneyToDouble() && x.FineDate == checkoutFine.FineDateGr &&
|
||||
x.Title == checkoutFine.Title && x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId);
|
||||
if (fines != null)
|
||||
{
|
||||
newFines.Add(new CustomizeCheckoutFine(fines.Title, fines.Amount.ToMoney(), fines.FineDate.ToFarsi(), fines.FineDate, fines.IsActive, fines.CreationDate, fines.id));
|
||||
}
|
||||
}
|
||||
|
||||
var newInstallments = new List<CustomizeCheckoutLoanInstallments>();
|
||||
|
||||
foreach (var customizeCheckoutLoanInstallment in customizeCheckout.CustomizeCheckoutLoanInstallments)
|
||||
{
|
||||
|
||||
var installments = _context.Loans.SelectMany(x => x.LoanInstallments).AsNoTracking().Where(x => x.Month == customizeCheckoutLoanInstallment.Month && x.Year == customizeCheckoutLoanInstallment.Year && x.AmountForMonth == customizeCheckoutLoanInstallment.AmountForMonth.MoneyToDouble()).ToList();
|
||||
var loans = _context.Loans
|
||||
.Where(x => x.Amount == customizeCheckoutLoanInstallment.LoanAmount.MoneyToDouble() && x.EmployeeId == customizeCheckout.EmployeeId && x.WorkshopId == customizeCheckout.WorkshopId).ToList();
|
||||
|
||||
var installment = installments.First(x => loans.Any(l => l.id == x.LoanId));
|
||||
|
||||
if (installment != null)
|
||||
{
|
||||
newInstallments.Add(new CustomizeCheckoutLoanInstallments(installment.AmountForMonth.ToMoney(),
|
||||
installment.Month, installment.Year, installment.IsActive,
|
||||
customizeCheckoutLoanInstallment.LoanRemaining, customizeCheckoutLoanInstallment.LoanAmount,
|
||||
installment.Id));
|
||||
}
|
||||
}
|
||||
customizeCheckout.SetValueObjects(newFines, newInstallments, newSalary, newRewards);
|
||||
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostShiftDateNew2()
|
||||
{
|
||||
//var startRollCall = new DateTime(2025, 3, 21);
|
||||
@@ -294,15 +432,9 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
var endedRollCalls2 = r1.Where(x => x.EndDate != null).ToList();
|
||||
var countSetTDRollCall = endedRollCalls2.Count;
|
||||
var stepSetTDRollCal = 1;
|
||||
|
||||
foreach (var rollCall in endedRollCalls2)
|
||||
{
|
||||
rollCall.ClearTimeDiff();
|
||||
}
|
||||
_context.SaveChanges();
|
||||
foreach (var endedRollCall in endedRollCalls2)
|
||||
{
|
||||
endedRollCall.Edit(endedRollCall.StartDate.Value, endedRollCall.EndDate.Value, _rollCallDomainService);
|
||||
endedRollCall.SetShiftDate(_rollCallDomainService);
|
||||
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
|
||||
stepSetTDRollCal += 1;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Security.Claims;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Infrastructure;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Error;
|
||||
using CompanyManagment.App.Contracts.Fine;
|
||||
@@ -25,10 +26,11 @@ namespace ServiceHost.Areas.Client.Pages.Company.Fine
|
||||
private readonly long _workshopId;
|
||||
public string WorkshopFullName;
|
||||
public int PageIndex = 0;
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
|
||||
public IndexModel(IFineApplication fineApplication, IWorkshopApplication workshopApplication,
|
||||
public IndexModel(IFineApplication fineApplication, IWorkshopApplication workshopApplication,
|
||||
IPasswordHasher passwordHasher, IFineSubjectApplication fineSubjectApplication,
|
||||
IEmployeeApplication employeeApplication, IAuthHelper authHelper)
|
||||
IEmployeeApplication employeeApplication, IAuthHelper authHelper, ICustomizeCheckoutApplication customizeCheckoutApplication)
|
||||
{
|
||||
_fineApplication = fineApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
@@ -36,8 +38,9 @@ namespace ServiceHost.Areas.Client.Pages.Company.Fine
|
||||
_fineSubjectApplication = fineSubjectApplication;
|
||||
_employeeApplication = employeeApplication;
|
||||
_authHelper = authHelper;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
|
||||
var workshopHash = _authHelper.GetWorkshopSlug();
|
||||
var workshopHash = _authHelper.GetWorkshopSlug();
|
||||
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
|
||||
|
||||
if (_workshopId < 1)
|
||||
@@ -193,5 +196,19 @@ namespace ServiceHost.Areas.Client.Pages.Company.Fine
|
||||
data = result
|
||||
});
|
||||
}
|
||||
}
|
||||
public IActionResult OnGetCheckoutExists(string fineDate, List<long> employeeIds)
|
||||
{
|
||||
var fineDateGr = fineDate.ToGeorgianDateTime();
|
||||
|
||||
var validateExistsCheckouts =
|
||||
_customizeCheckoutApplication.ValidateExistsCheckouts(fineDateGr, fineDateGr, _workshopId, employeeIds);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
checkout = validateExistsCheckouts.Checkout,
|
||||
customizeCheckout = validateExistsCheckouts.CustomizeCheckout,
|
||||
customizeCheckoutTemp = validateExistsCheckouts.CustomizeCheckoutTemp,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
</div>
|
||||
<div class="col-12 my-1" style="height: 30px;">
|
||||
<div class="d-block">
|
||||
<div id="amountRials" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountTomans" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountRials" class="scroll-container-amount"></div>
|
||||
<div id="amountTomans" class="scroll-container-amount"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
@@ -93,7 +93,7 @@
|
||||
<div id="CRUDFineSubjectModal" style="display: none">
|
||||
<div class="modal-dialog modal-dialog-centered FineSubjectSection">
|
||||
<div class="" id="ModalCRUDSearchSubject">
|
||||
<partial name="CRUDFineSubjectModal"/>
|
||||
<partial name="CRUDFineSubjectModal" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -110,6 +110,7 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveNewFineAjax = `@Url.Page("./Index", "Create")`;
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
var employeeListAjax = `@Url.Page("./Index", "EmployeeList")`;
|
||||
var searchFineSubjectModal = '@Url.Page("./Index", "SearchFineSubject")';
|
||||
var fineSubjectModal = '@Url.Page("./Index", "FineSubject")';
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12 my-1">
|
||||
<input type="hidden" asp-for="@Model.Id" />
|
||||
<input type="hidden" asp-for="@Model.EmployeeId" />
|
||||
<input type="hidden" asp-for="@Model.EmployeeId" id="employeeSelectId"/>
|
||||
<span class="spanTitleText">نام و نام خانوادگی پرسنل</span>
|
||||
<input type="text" class="form-control" value="@Model.EmployeeFullname" disabled placeholder="نام پرسنل" />
|
||||
</div>
|
||||
@@ -36,8 +36,8 @@
|
||||
</div>
|
||||
<div class="col-12 my-1" style="height: 30px;">
|
||||
<div class="d-block">
|
||||
<div id="amountRials" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountTomans" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountRials" class="scroll-container-amount"></div>
|
||||
<div id="amountTomans" class="scroll-container-amount"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
@@ -78,6 +78,7 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveEditFineAjax = `@Url.Page("./Index", "Edit")`;
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
var employeeListAjax = `@Url.Page("./Index", "EmployeeList")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/Fine/js/ModalEditFine.js?ver=@clientVersion"></script>
|
||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Security.Claims;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Infrastructure;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Error;
|
||||
using CompanyManagment.App.Contracts.Reward;
|
||||
@@ -21,11 +22,12 @@ namespace ServiceHost.Areas.Client.Pages.Company.Reward
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly IHttpContextAccessor _contextAccessor;
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
private readonly long _workshopId;
|
||||
public string WorkshopFullName;
|
||||
public int PageIndex = 0;
|
||||
|
||||
public IndexModel(IWorkshopApplication workshopApplication, IPasswordHasher passwordHasher, IRewardApplication rewardApplication, IAuthHelper authHelper, IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor)
|
||||
public IndexModel(IWorkshopApplication workshopApplication, IPasswordHasher passwordHasher, IRewardApplication rewardApplication, IAuthHelper authHelper, IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, ICustomizeCheckoutApplication customizeCheckoutApplication)
|
||||
{
|
||||
_workshopApplication = workshopApplication;
|
||||
_passwordHasher = passwordHasher;
|
||||
@@ -33,6 +35,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.Reward
|
||||
_authHelper = authHelper;
|
||||
_employeeApplication = employeeApplication;
|
||||
_contextAccessor = contextAccessor;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
|
||||
var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug");
|
||||
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
|
||||
@@ -142,5 +145,20 @@ namespace ServiceHost.Areas.Client.Pages.Company.Reward
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetCheckoutExists(string grantDate,List<long> employeeIds)
|
||||
{
|
||||
var grantDateGr = grantDate.ToGeorgianDateTime();
|
||||
|
||||
var validateExistsCheckouts =
|
||||
_customizeCheckoutApplication.ValidateExistsCheckouts(grantDateGr, grantDateGr, _workshopId, employeeIds);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
checkout = validateExistsCheckouts.Checkout,
|
||||
customizeCheckout = validateExistsCheckouts.CustomizeCheckout,
|
||||
customizeCheckoutTemp = validateExistsCheckouts.CustomizeCheckoutTemp,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
</div>
|
||||
<div class="col-12 my-1" style="height: 30px;">
|
||||
<div class="d-block">
|
||||
<div id="amountRials" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountTomans" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountRials" class="scroll-container-amount"></div>
|
||||
<div id="amountTomans" class="scroll-container-amount"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
@@ -81,6 +81,7 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveNewRewardAjax = `@Url.Page("./Index", "Create")`;
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
var employeeListAjax = `@Url.Page("./Index", "EmployeeList")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/Reward/js/ModalCreateNewReward.js?ver=@clientVersion"></script>
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12 my-1">
|
||||
<input type="hidden" asp-for="@Model.Id" />
|
||||
<input type="hidden" asp-for="@Model.EmployeeId" id="employeeSelectId" />
|
||||
<span class="spanTitleText">نام و نام خانوادگی پرسنل</span>
|
||||
<input type="text" class="form-control" value="@Model.EmployeeFullName" disabled placeholder="نام پرسنل" />
|
||||
</div>
|
||||
@@ -35,8 +36,8 @@
|
||||
</div>
|
||||
<div class="col-12 my-1" style="height: 30px;">
|
||||
<div class="d-block">
|
||||
<div id="amountRials" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountTomans" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountRials" class="scroll-container-amount"></div>
|
||||
<div id="amountTomans" class="scroll-container-amount"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
@@ -80,6 +81,7 @@
|
||||
<script src="~/assetsclient/libs/wordifyfa/wordifyfa.min.js"></script>
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
var saveEditRewardAjax = `@Url.Page("./Index", "Edit")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/Reward/js/ModalEditReward.js?ver=@clientVersion"></script>
|
||||
@@ -7,9 +7,12 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Security.Claims;
|
||||
using _0_Framework.Infrastructure;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||
using CompanyManagment.App.Contracts.CustomizeCheckout;
|
||||
using CompanyManagment.App.Contracts.SalaryAid;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.YearlySalary;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
{
|
||||
@@ -20,23 +23,29 @@ namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
private readonly ISalaryAidApplication _salaryAidApplication;
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly IYearlySalaryApplication _yearlySalaryApplication;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly ICustomizeCheckoutApplication _customizeCheckoutApplication;
|
||||
private readonly SalaryAidImportExcel _salaryAidImportExcel;
|
||||
|
||||
private readonly long _workshopId;
|
||||
public string WorkshopFullName;
|
||||
public int PageIndex = 0;
|
||||
private readonly ICustomizeCheckoutRepository _customizeCheckoutRepository;
|
||||
|
||||
public IndexModel(IPasswordHasher passwordHasher, ISalaryAidApplication salaryAidApplication,
|
||||
IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel)
|
||||
public IndexModel(IPasswordHasher passwordHasher, ISalaryAidApplication salaryAidApplication,
|
||||
IEmployeeApplication employeeApplication, IHttpContextAccessor contextAccessor, IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel, ICustomizeCheckoutApplication customizeCheckoutApplication, ICustomizeCheckoutRepository customizeCheckoutRepository, IYearlySalaryApplication yearlySalaryApplication)
|
||||
{
|
||||
_passwordHasher = passwordHasher;
|
||||
_salaryAidApplication = salaryAidApplication;
|
||||
_employeeApplication = employeeApplication;
|
||||
_authHelper = authHelper;
|
||||
_salaryAidImportExcel = salaryAidImportExcel;
|
||||
_yearlySalaryApplication = yearlySalaryApplication;
|
||||
_customizeCheckoutApplication = customizeCheckoutApplication;
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
|
||||
var workshopHash = _authHelper.GetWorkshopSlug();
|
||||
var workshopHash = _authHelper.GetWorkshopSlug();
|
||||
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
|
||||
|
||||
if (_workshopId < 1)
|
||||
@@ -50,6 +59,16 @@ namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnGetYearlyList()
|
||||
{
|
||||
var resultData = _yearlySalaryApplication.GetYears();
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
data = resultData
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetLoadDataAjax(SalaryAidSearchViewModel searchViewModel)
|
||||
{
|
||||
searchViewModel.WorkshopId = _workshopId;
|
||||
@@ -156,7 +175,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostCreateFromExcelData(List<SalaryAidImportData> data)
|
||||
public IActionResult OnPostCreateFromExcelData(List<SalaryAidImportData> data)
|
||||
{
|
||||
var commands = data.Select(x => new CreateSalaryAidViewModel()
|
||||
{
|
||||
@@ -164,9 +183,11 @@ namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
Amount = x.Amount.ToMoney(),
|
||||
EmployeeIds = [x.EmployeeId],
|
||||
SalaryDateTime = x.SalaryAidDateTime,
|
||||
NationalCode = x.NationalCode
|
||||
NationalCode = x.NationalCode,
|
||||
CalculationMonth = x.calculationMonth,
|
||||
CalculationYear = x.calculationYear
|
||||
}).ToList();
|
||||
OperationResult result = await _salaryAidApplication.CreateRange(commands);
|
||||
OperationResult result = _salaryAidApplication.CreateRange(commands);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
@@ -175,6 +196,50 @@ namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetCreateValidation(DateTime dateTime,List<long> employeeIds,long workshopId)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
_ = DateTime.Now.Date.AddMonthsFa(-1, out var oneMonthAgoGr);
|
||||
|
||||
if (oneMonthAgoGr > dateTime)
|
||||
{
|
||||
var prevCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(dateTime,
|
||||
oneMonthAgoGr, workshopId, employeeIds);
|
||||
|
||||
if (prevCheckouts.CustomizeCheckout || prevCheckouts.Checkout || prevCheckouts.CustomizeCheckoutTemp)
|
||||
{
|
||||
op.Failed("شما نمیتوانید در تاریخ قبل از یک ماه گذشته که فیش صادر شده باشد مساعده دهید");
|
||||
return new JsonResult(new
|
||||
{
|
||||
op.IsSuccedded,
|
||||
op.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var existsCheckouts = _customizeCheckoutRepository.ValidateExistsCheckouts(dateTime,
|
||||
dateTime, workshopId, employeeIds);
|
||||
|
||||
if (existsCheckouts.Checkout)
|
||||
{
|
||||
op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی رسمی صادر شده است مساعده دهید");
|
||||
return new JsonResult(new
|
||||
{
|
||||
op.IsSuccedded,
|
||||
op.Message
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
op.Succcedded();
|
||||
return new JsonResult(new
|
||||
{
|
||||
op.IsSuccedded,
|
||||
op.Message,
|
||||
data = existsCheckouts
|
||||
});
|
||||
|
||||
}
|
||||
public IActionResult OnGetSearch(SalaryAidSearchViewModel searchModel)
|
||||
{
|
||||
searchModel.WorkshopId = _workshopId;
|
||||
@@ -184,6 +249,20 @@ namespace ServiceHost.Areas.Client.Pages.Company.SalaryAid
|
||||
data = result
|
||||
});
|
||||
}
|
||||
public IActionResult OnGetCheckoutExists(string calculationDate, List<long> employeeIds)
|
||||
{
|
||||
var calculationDateGr = calculationDate.ToGeorgianDateTime();
|
||||
|
||||
}
|
||||
var validateExistsCheckouts =
|
||||
_customizeCheckoutApplication.ValidateExistsCheckouts(calculationDateGr, calculationDateGr, _workshopId, employeeIds);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
checkout = validateExistsCheckouts.Checkout,
|
||||
customizeCheckout = validateExistsCheckouts.CustomizeCheckout,
|
||||
customizeCheckoutTemp = validateExistsCheckouts.CustomizeCheckoutTemp,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
}
|
||||
|
||||
<form role="form" method="post" name="create-form" id="create-form" autocomplete="off">
|
||||
|
||||
<div class="modal-content">
|
||||
<div class="modal-header pb-0 d-flex align-items-center justify-content-center text-center">
|
||||
<button type="button" class="btn-close position-absolute text-start" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
@@ -33,14 +32,58 @@
|
||||
</div>
|
||||
<div class="col-12 my-1" style="height: 30px;">
|
||||
<div class="d-block">
|
||||
<div id="amountRials" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountTomans" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountRials" class="scroll-container-amount"></div>
|
||||
<div id="amountTomans" class="scroll-container-amount"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-12 my-1">
|
||||
<span class="spanTitleText">تاریخ</span>
|
||||
<input class="form-control form-control-date text-center dateTime" asp-for="@Model.SalaryDateTime" placeholder="تاریخ را وارد نمائید" style="direction: ltr" />
|
||||
<span class="spanTitleText">تاریخ پرداخت</span>
|
||||
<input class="form-control form-control-date text-center dateTime" asp-for="@Model.SalaryDateTime" placeholder="تاریخ پرداخت را وارد نمائید" style="direction: ltr" />
|
||||
</div>
|
||||
|
||||
<div class="col-12 my-1">
|
||||
<span class="spanTitleText">تاریخ محاسبه</span>
|
||||
@* <input class="form-control form-control-date text-center dateTime" asp-for="@Model.CalculationDateTime" placeholder="تاریخ محاسبه را وارد نمائید" style="direction: ltr" /> *@
|
||||
|
||||
<div class="d-flex align-content-around gap-2">
|
||||
<div class="calculationYear w-100" style="overflow: unset;">
|
||||
<select id="calculationYear" asp-for="@Model.CalculationYear">
|
||||
<option value="0">سال</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="calculationMonth w-100" style="overflow: unset;">
|
||||
<select id="calculationMonth" asp-for="@Model.CalculationMonth">
|
||||
<option value="0">ماه</option>
|
||||
<option value="01">فروردین</option>
|
||||
<option value="02">اردیبهشت</option>
|
||||
<option value="03">خرداد</option>
|
||||
<option value="04">تیر</option>
|
||||
<option value="05">مرداد</option>
|
||||
<option value="06">شهریور</option>
|
||||
<option value="07">مهر</option>
|
||||
<option value="08">آبان</option>
|
||||
<option value="09">آذر</option>
|
||||
<option value="10">دی</option>
|
||||
<option value="11">بهمن</option>
|
||||
<option value="12">اسفند</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* <div class="col-12 my-1">
|
||||
<span class="spanTitleText">تاریخ پرداخت</span>
|
||||
<input class="form-control form-control-date text-center dateTime" asp-for="@Model.SalaryDateTime" placeholder="تاریخ پرداخت را وارد نمائید" style="direction: ltr" />
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
<span class="spanTitleText">تاریخ محاسبه</span>
|
||||
<input class="form-control form-control-date text-center dateTime" asp-for="@Model.CalculationDateTime" placeholder="تاریخ محاسبه را وارد نمائید" style="direction: ltr" />
|
||||
|
||||
|
||||
</div> *@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -65,6 +108,7 @@
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="~/assetsclient/js/site.js?ver=@clientVersion"></script>
|
||||
<script src="~/assetsclient/libs/jalaali-js/jalaali.js"></script>
|
||||
<script src="~/admintheme/js/jquery.mask_1.14.16.min.js"></script>
|
||||
@@ -73,6 +117,8 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveNewSalaryAidAjax = `@Url.Page("./Index", "Create")`;
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
var employeeListAjax = `@Url.Page("./Index", "EmployeeList")`;
|
||||
var yearlyListUrl = `@Url.Page("./Index", "YearlyList")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/SalaryAid/js/ModalCreateNewSalaryAid.js?ver=@clientVersion"></script>
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12 my-1">
|
||||
<input type="hidden" asp-for="@Model.Id"/>
|
||||
<input type="hidden" asp-for="@Model.EmployeeId" id="employeeSelectId" />
|
||||
<span class="spanTitleText">نام و نام خانوادگی پرسنل</span>
|
||||
<input type="text" class="form-control" value="@Model.EmployeeFullName" disabled placeholder="نام پرسنل"/>
|
||||
</div>
|
||||
@@ -31,14 +32,43 @@
|
||||
</div>
|
||||
<div class="col-12 my-1" style="height: 30px;">
|
||||
<div class="d-block">
|
||||
<div id="amountRials" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountTomans" style="font-size: 12px;color: #4f4f4f;"></div>
|
||||
<div id="amountRials" class="scroll-container-amount"></div>
|
||||
<div id="amountTomans" class="scroll-container-amount"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
<span class="spanTitleText">تاریخ</span>
|
||||
<input class="form-control form-control-date text-center dateTime" asp-for="@Model.SalaryDateTime" placeholder="تاریخ را وارد نمائید" style="direction: ltr"/>
|
||||
</div>
|
||||
<div class="col-12 my-1">
|
||||
<span class="spanTitleText">تاریخ محاسبه</span>
|
||||
@* <input class="form-control form-control-date text-center dateTime" asp-for="@Model.CalculationDateTime" placeholder="تاریخ محاسبه را وارد نمائید" style="direction: ltr" /> *@
|
||||
|
||||
<div class="d-flex align-content-around gap-2">
|
||||
<div class="calculationYear w-100" style="overflow: unset;">
|
||||
<select id="calculationYear" asp-for="@Model.CalculationYear">
|
||||
<option value="0">سال</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="calculationMonth w-100" style="overflow: unset;">
|
||||
<select id="calculationMonth" asp-for="@Model.CalculationMonth">
|
||||
<option value="0">ماه</option>
|
||||
<option value="1">فروردین</option>
|
||||
<option value="2">اردیبهشت</option>
|
||||
<option value="3">خرداد</option>
|
||||
<option value="4">تیر</option>
|
||||
<option value="5">مرداد</option>
|
||||
<option value="6">شهریور</option>
|
||||
<option value="7">مهر</option>
|
||||
<option value="8">آبان</option>
|
||||
<option value="9">آذر</option>
|
||||
<option value="10">دی</option>
|
||||
<option value="11">بهمن</option>
|
||||
<option value="12">اسفند</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,5 +100,8 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var saveEditSalaryAidAjax = `@Url.Page("./Index", "Edit")`;
|
||||
var yearlyListUrl = `@Url.Page("./Index", "YearlyList")`;
|
||||
var year = `@Model.CalculationYear`;
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/SalaryAid/js/ModalEditSalaryAid.js?ver=@clientVersion"></script>
|
||||
@@ -60,7 +60,7 @@
|
||||
<div id="errorsTheStructureOfExcel" class="errorMessageOfExcel"></div>
|
||||
|
||||
|
||||
<div class="spinner-loading loading" style="display: none">
|
||||
<div class="spinner-loading loading" style="display: none; z-index: 2000;">
|
||||
<span class="spinner-border spinner-border-sm loading text-white" role="status" aria-hidden="true"></span>
|
||||
</div>
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
<script>
|
||||
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
|
||||
var uploadAndValidate = `@Url.Page("./Index", "ValidateExcel")`;
|
||||
var checkoutExistsAjaxUrl = `@Url.Page("./Index", "CheckoutExists")`;
|
||||
var sendExcelDataAjax = `@Url.Page("./Index", "CreateFromExcelData")`;
|
||||
</script>
|
||||
<script src="~/assetsclient/pages/SalaryAid/js/ModalImportExcel.js?ver=@clientVersion"></script>
|
||||
@@ -280,7 +280,108 @@ function fineSubjectModal() {
|
||||
}
|
||||
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
var employeeSelect = $('#employeeSelect').val();
|
||||
var Title = $('#Title ');
|
||||
var Amount = $('#Amount ');
|
||||
var FineDate = $('#FineDate');
|
||||
|
||||
if (employeeSelect.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا اسامی پرسنل را کلیک و مشخص نمائید');
|
||||
$('.select-alert').addClass('errored');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.select-alert').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Title.val()) {
|
||||
Title.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا عنوان را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Title.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Amount.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FineDate.val()) {
|
||||
FineDate.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا تاریخ را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
FineDate.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
fineDate: FineDate.val(),
|
||||
employeeIds: employeeSelect
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
@@ -176,7 +176,98 @@ function fineSubjectModal() {
|
||||
}
|
||||
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
var employeeSelect = $('#employeeSelectId').val();
|
||||
var Title = $('#Title ');
|
||||
var Amount = $('#Amount ');
|
||||
var FineDate = $('#FineDate');
|
||||
|
||||
if (!Title.val()) {
|
||||
Title.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا عنوان را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Title.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Amount.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FineDate.val()) {
|
||||
FineDate.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا تاریخ را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
FineDate.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
fineDate: FineDate.val(),
|
||||
employeeIds: employeeSelect
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
@@ -240,6 +331,7 @@ function SaveDataAjax() {
|
||||
$('.alert-success-msg p').text('');
|
||||
}, 1500);
|
||||
|
||||
$('#fineEmployeesList').html('');
|
||||
$('#fineListAjax').html('');
|
||||
$('#PageIndex').val(0);
|
||||
pageIndexJs = 0;
|
||||
|
||||
@@ -7,11 +7,35 @@ var groupTypeDataInput = '';
|
||||
var loadData = true;
|
||||
var isMobile = "false";
|
||||
var groupData = false;
|
||||
var isMobileInput = window.matchMedia('(max-width: 767px)').matches;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadRewardList();
|
||||
ajaxPersonals();
|
||||
|
||||
const { showType, employeeId, startDate, endDate } = getSearchParamsFromUrl();
|
||||
if (showType === 'group') {
|
||||
$("#group,#groupMobile").prop('checked', true);
|
||||
}
|
||||
if (showType === 'list') {
|
||||
$("#list,#listMobile").prop('checked', true);
|
||||
}
|
||||
|
||||
isMobileInput ? $('#start-date-mobile').val(startDate) : $('#start-date').val(startDate);
|
||||
isMobileInput ? $('#end-date-mobile').val(endDate) : $('#end-date').val(endDate);
|
||||
|
||||
if (employeeId !== "0" || startDate !== '' || endDate !== '', showType !== '') {
|
||||
$('.btn-clear-filter').removeClass('disable');
|
||||
} else {
|
||||
$('.btn-clear-filter').addClass('disable');
|
||||
}
|
||||
|
||||
searchStartDateTime = isMobile ? $('#start-date-mobile').val(startDate) : $('#start-date').val(startDate);
|
||||
searchEndDateTime = isMobile ? $('#end-date-mobile').val(endDate) : $('#end-date').val(endDate);
|
||||
searchName = isMobile ? $('#employeeSelectIndexMobile') : $('#employeeSelectIndex');
|
||||
listTypeDataInput = isMobile ? $('#listMobile') : $('#list');
|
||||
groupTypeDataInput = isMobile ? $('#groupMobile') : $('#group');
|
||||
|
||||
loadRewardList();
|
||||
|
||||
$(".select2OptionIndex").select2({
|
||||
language: "fa",
|
||||
@@ -201,6 +225,8 @@ $(document).on('click', '.btn-search-click, .btn-search-click-mobile', function
|
||||
|
||||
groupData = $("#group,#groupMobile").is(":checked") ? true : false;
|
||||
|
||||
paramsUrl(searchName.val(), searchStartDateTime, searchEndDateTime);
|
||||
|
||||
pageIndexJs = 0;
|
||||
$('#rewardListAjax').html('');
|
||||
$('#rewardEmployeesList').html('');
|
||||
@@ -209,7 +235,7 @@ $(document).on('click', '.btn-search-click, .btn-search-click-mobile', function
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-clear-filter', function () {
|
||||
window.location.reload();
|
||||
window.location.href = `${window.location.origin}/Client/Company/Reward`;
|
||||
});
|
||||
|
||||
// همگامسازی متن ورودی برای موبایل و دسکتاپ
|
||||
@@ -274,8 +300,13 @@ function ajaxPersonals() {
|
||||
var black = employee.black ? "blackSelect" : "";
|
||||
employeeOptionsHtml += `<option class="${black}" value="${employee.id}">${employee.employeeFullName}</option>`;
|
||||
});
|
||||
|
||||
$('#employeeSelectIndex').html(employeeOptionsHtml);
|
||||
$('#employeeSelectIndexMobile').html(employeeOptionsHtml);
|
||||
|
||||
const { showType, employeeId, startDate, endDate } = getSearchParamsFromUrl();
|
||||
isMobileInput ? $('#employeeSelectIndexMobile').val(employeeId).trigger('change') : $('#employeeSelectIndex').val(employeeId).trigger('change');
|
||||
|
||||
} else {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text(response.message);
|
||||
@@ -297,12 +328,17 @@ function loadRewardList() {
|
||||
var pageIndex = Number($('#PageIndex').val());
|
||||
var html = '';
|
||||
|
||||
|
||||
const { showType, employeeId, startDate, endDate } = getSearchParamsFromUrl();
|
||||
|
||||
groupData = $("#group,#groupMobile").is(":checked") ? true : false;
|
||||
|
||||
var searchViewModel = {
|
||||
'PageIndex': pageIndex,
|
||||
'EmployeeId': $('#employeeSelectIndex').val(),
|
||||
'StartDate': $('#start-date').val(),
|
||||
'EndDate': $('#end-date').val(),
|
||||
'ShowAsGrouped':groupData,
|
||||
'EmployeeId': employeeId,
|
||||
'StartDate': startDate,
|
||||
'EndDate': endDate,
|
||||
'ShowAsGrouped': groupData,
|
||||
}
|
||||
|
||||
|
||||
@@ -1294,3 +1330,58 @@ function removeAjax(id) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function paramsUrl(employeeId, startDate, endDate) {
|
||||
const params = new URLSearchParams();
|
||||
let hasAnyFilter = false
|
||||
|
||||
var isGroup = $("#group,#groupMobile").is(":checked") ? true : false;
|
||||
if (isGroup) {
|
||||
params.set("show-type", 'group');
|
||||
hasAnyFilter = true;
|
||||
} else {
|
||||
params.set("show-type", 'list');
|
||||
hasAnyFilter = true;
|
||||
}
|
||||
//const checkboxSelected = $('.dataType:checked').first().attr('id');
|
||||
//if (checkboxSelected === "group") {
|
||||
// params.set("show-type", checkboxSelected);
|
||||
// hasAnyFilter = true;
|
||||
//} else {
|
||||
// params.set("show-type", 'list');
|
||||
// hasAnyFilter = true;
|
||||
//}
|
||||
|
||||
if (startDate !== '') {
|
||||
params.set("start-date", startDate);
|
||||
hasAnyFilter = true;
|
||||
}
|
||||
|
||||
if (endDate !== '') {
|
||||
params.set("end-date", endDate);
|
||||
hasAnyFilter = true;
|
||||
}
|
||||
|
||||
if (employeeId !== "0") {
|
||||
params.set("employee-id", employeeId);
|
||||
hasAnyFilter = true;
|
||||
}
|
||||
|
||||
const newUrl = hasAnyFilter
|
||||
? `${window.location.origin}/Client/Company/Reward?${params.toString()}`
|
||||
: `${window.location.origin}/Client/Company/Reward`;
|
||||
|
||||
window.history.pushState({}, '', newUrl);
|
||||
}
|
||||
|
||||
function getSearchParamsFromUrl() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
return {
|
||||
showType: urlParams.get("show-type") || "",
|
||||
startDate: urlParams.get("start-date") || "",
|
||||
endDate: urlParams.get("end-date") || "",
|
||||
employeeId: urlParams.get("employee-id") || "0"
|
||||
};
|
||||
}
|
||||
@@ -145,7 +145,97 @@ function ajaxPersonals() {
|
||||
}
|
||||
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
var employeeSelect = $('#employeeSelect').val();
|
||||
var Amount = $('#Amount ');
|
||||
var GrantDate = $('#GrantDate');
|
||||
|
||||
if (employeeSelect.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا اسامی پرسنل را کلیک و مشخص نمائید');
|
||||
$('.select-alert').addClass('errored');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.select-alert').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Amount.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GrantDate.val()) {
|
||||
GrantDate.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا تاریخ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
GrantDate.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
grantDate: GrantDate.val(),
|
||||
employeeIds: employeeSelect
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
|
||||
@@ -94,7 +94,112 @@ $(document).ready(function () {
|
||||
ajaxPersonals();
|
||||
});
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
var employeeSelect = $('#employeeSelectId').val();
|
||||
var Amount = $('#Amount ');
|
||||
var title = $('#Title ');
|
||||
var Description = $('#Description');
|
||||
var GrantDate = $('#GrantDate');
|
||||
|
||||
if (!title.val() || title.val() === " ") {
|
||||
title.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا عنوان پاداش را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
title.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Amount.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GrantDate.val()) {
|
||||
GrantDate.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا تاریخ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
GrantDate.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Description.val()) {
|
||||
Description.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا علت توضیحات را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Description.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
grantDate: GrantDate.val(),
|
||||
employeeIds: employeeSelect
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
@@ -118,7 +223,7 @@ function SaveDataAjax() {
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ پاداش را وارد نمائید');
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
.scroll-container-amount {
|
||||
.modal-dialog-scrollable .modal-content {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.modal-dialog-scrollable .modal-body {
|
||||
overflow-y: visible;
|
||||
}
|
||||
|
||||
.scroll-container-amount {
|
||||
font-size: 12px;
|
||||
color: #4f4f4f;
|
||||
white-space: nowrap;
|
||||
@@ -94,4 +102,179 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*select option*/
|
||||
|
||||
select {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.dropdown-select {
|
||||
background-image: linear-gradient( to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 100% );
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#40FFFFFF', endColorstr='#00FFFFFF', GradientType=0);
|
||||
background-color: #fff;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #DADADA;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
float: right;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
outline: none;
|
||||
padding-left: 18px;
|
||||
padding-right: 20px;
|
||||
position: relative;
|
||||
text-align: right !important;
|
||||
transition: all 0.2s ease-in-out;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
width: auto;
|
||||
background-color:
|
||||
}
|
||||
|
||||
.dropdown-select:focus {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.dropdown-select:hover {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.dropdown-select:active,
|
||||
.dropdown-select.open {
|
||||
background-color: #fff !important;
|
||||
border-color: #bbb;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) inset;
|
||||
}
|
||||
|
||||
.dropdown-select:after {
|
||||
height: 0;
|
||||
width: 0;
|
||||
border-left: 4px solid transparent;
|
||||
border-right: 4px solid transparent;
|
||||
border-top: 4px solid #777;
|
||||
-webkit-transform: origin(50% 20%);
|
||||
transform: origin(50% 20%);
|
||||
transition: all 0.125s ease-in-out;
|
||||
content: "";
|
||||
display: block;
|
||||
margin-top: -2px;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.dropdown-select.open:after {
|
||||
-webkit-transform: rotate(-180deg);
|
||||
transform: rotate(-180deg);
|
||||
}
|
||||
|
||||
.dropdown-select.open .list {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.dropdown-select.open .option {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dropdown-select.wide {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dropdown-select.wide .list {
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
}
|
||||
|
||||
.dropdown-select .list {
|
||||
box-sizing: border-box;
|
||||
transition: all 0.15s cubic-bezier(0.25, 0, 0.25, 1.75), opacity 0.1s linear;
|
||||
-webkit-transform: scale(0.75);
|
||||
transform: scale(0.75);
|
||||
-webkit-transform-origin: 50% 0;
|
||||
transform-origin: 50% 0;
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.09);
|
||||
background-color: #fff;
|
||||
border-radius: 6px;
|
||||
margin-top: 4px;
|
||||
padding: 3px 0;
|
||||
opacity: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
z-index: 999222222;
|
||||
max-height: 250px;
|
||||
overflow: auto;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.dropdown-select .list:hover .option:not(:hover) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.dropdown-select .list ul {
|
||||
padding: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.dropdown-select .option {
|
||||
cursor: default;
|
||||
font-weight: 400;
|
||||
outline: none;
|
||||
padding: 0 15px;
|
||||
text-align: right;
|
||||
transition: all 0.2s;
|
||||
list-style: none;
|
||||
border-radius: 6px;
|
||||
margin: 2px auto;
|
||||
height: 35px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dropdown-select .option:hover,
|
||||
.dropdown-select .option:focus {
|
||||
/* background-color: #f6f6f6 !important;*/
|
||||
background: linear-gradient(180deg, #41D1D1 0%, #2CD0D0 100%) !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dropdown-select .option.selected {
|
||||
/* color: #12cbc4;*/
|
||||
background: linear-gradient(180deg, #41D1D1 0%, #2CD0D0 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dropdown-select .option.selected:focus {
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
.dropdown-select a {
|
||||
color: #aaa;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.dropdown-select a:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
dl, ol, ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -223,6 +223,10 @@
|
||||
width: 10% !important;
|
||||
}
|
||||
|
||||
.Rtable .Rtable-row .Rtable-cell .Rtable-cell--content > .numberIndex {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.radio-group {
|
||||
display: flex;
|
||||
|
||||
@@ -350,7 +350,7 @@ function loadSalaryAidList() {
|
||||
function htmlLoadSimpleListData(loadSalaryAidListData) {
|
||||
var html = '';
|
||||
//var pageIndex = Number($('#PageIndex').val());
|
||||
console.log(loadSalaryAidListData);
|
||||
//console.log(loadSalaryAidListData);
|
||||
if (loadSalaryAidListData.length > 0) {
|
||||
loadSalaryAidListData.forEach(function (item) {
|
||||
var n = pageIndexJs + 1;
|
||||
@@ -741,7 +741,7 @@ function htmlLoadWithEmployeeDataByFullname(loadSalaryAidListData) {
|
||||
|
||||
if (loadSalaryAidListData.length > 0) {
|
||||
loadSalaryAidListData.forEach(function (itemSalaryAids) {
|
||||
console.log(itemSalaryAids);
|
||||
//console.log(itemSalaryAids);
|
||||
n = 1;
|
||||
html += `
|
||||
<div class="salaryAid-grid-list personal-grid-row d-grid gap-2 grid-cols-12 w-100">
|
||||
@@ -927,10 +927,8 @@ function htmlLoadWithEmployeeMobileDataByFullname(loadSalaryAidListData) {
|
||||
var n = 1;
|
||||
if (loadSalaryAidListData) {
|
||||
loadSalaryAidListData.forEach(function (item) {
|
||||
console.log(item);
|
||||
|
||||
html += `
|
||||
<div></div>
|
||||
//console.log(item);
|
||||
html += `<div></div>
|
||||
<div class="Rtable-row align-items-center position-relative openAction">
|
||||
<div class="w-100 d-flex align-items-center justify-content-between">
|
||||
|
||||
@@ -1064,12 +1062,10 @@ function htmlLoadWithEmployeeMobileDataByDate(loadSalaryAidListData) {
|
||||
var n = 1;
|
||||
|
||||
if (loadSalaryAidListData) {
|
||||
console.log(loadSalaryAidListData)
|
||||
//console.log(loadSalaryAidListData)
|
||||
loadSalaryAidListData.forEach(function (item) {
|
||||
console.log(item);
|
||||
|
||||
html += `
|
||||
<div></div>
|
||||
//console.log(item);
|
||||
html += `<div></div>
|
||||
<div class="Rtable-row align-items-center position-relative openAction">
|
||||
<div class="w-100 d-flex align-items-center justify-content-between">
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@ $(document).ready(function () {
|
||||
updateDateInput(0);
|
||||
|
||||
ajaxPersonals();
|
||||
ajaxYears();
|
||||
create_custom_dropdowns();
|
||||
});
|
||||
|
||||
function updateDateInput(daysToAdd) {
|
||||
@@ -126,8 +128,7 @@ function ajaxPersonals() {
|
||||
var employees = response.data;
|
||||
var employeeOptionsHtml = '<option value="" disabled>انتخاب پرسنل ...</option>';
|
||||
employees.forEach(function (employee) {
|
||||
var black = employee.black ? "blackSelect" : "";
|
||||
employeeOptionsHtml += `<option class="${black}" value="${employee.id}">${employee.employeeFullName}</option>`;
|
||||
employeeOptionsHtml += `<option value="${employee.id}">${employee.employeeFullName}</option>`;
|
||||
});
|
||||
$('#employeeSelect').html(employeeOptionsHtml);
|
||||
} else {
|
||||
@@ -145,7 +146,232 @@ function ajaxPersonals() {
|
||||
});
|
||||
}
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
function ajaxYears() {
|
||||
$.ajax({
|
||||
url: yearlyListUrl,
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
var data = response.data;
|
||||
var optionsHtml = ' <option value="0">سال</option>';
|
||||
data.forEach(function (item) {
|
||||
optionsHtml += `<option value="${item}">${item}</option>`;
|
||||
});
|
||||
$('#calculationYear').html(optionsHtml);
|
||||
|
||||
$('#calculationYear').next('.dropdown-select').remove();
|
||||
create_custom_dropdowns();
|
||||
} else {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text(response.message);
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function create_custom_dropdowns() {
|
||||
$('select').each(function (i, select) {
|
||||
if (!$(this).next().hasClass('dropdown-select')) {
|
||||
$(this).after('<div class="dropdown-select wide ' + ($(this).attr('class') || '') + '" tabindex="0"><span class="current"></span><div class="list"><ul></ul></div></div>');
|
||||
var dropdown = $(this).next();
|
||||
var options = $(select).find('option');
|
||||
var selected = $(this).find('option:selected');
|
||||
dropdown.find('.current').html(selected.data('display-text') || selected.text());
|
||||
options.each(function (j, o) {
|
||||
var display = $(o).data('display-text') || '';
|
||||
dropdown.find('ul').append('<li class="option ' + ($(o).is(':selected') ? 'selected' : '') + '" data-value="' + $(o).val() + '" data-display-text="' + display + '">' + $(o).text() + '</li>');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).off('click', '.dropdown-select').on('click', '.dropdown-select', function (event) {
|
||||
if ($(event.target).hasClass('dd-searchbox')) {
|
||||
return;
|
||||
}
|
||||
$('.dropdown-select').not($(this)).removeClass('open');
|
||||
$(this).toggleClass('open');
|
||||
if ($(this).hasClass('open')) {
|
||||
$(this).find('.option').attr('tabindex', 0);
|
||||
$(this).find('.selected').focus();
|
||||
} else {
|
||||
$(this).find('.option').removeAttr('tabindex');
|
||||
$(this).focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', function (event) {
|
||||
if ($(event.target).closest('.dropdown-select').length === 0) {
|
||||
$('.dropdown-select').removeClass('open');
|
||||
$('.dropdown-select .option').removeAttr('tabindex');
|
||||
}
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
function filter() {
|
||||
var valThis = $('#txtSearchValue').val();
|
||||
$('.dropdown-select ul > li').each(function () {
|
||||
var text = $(this).text();
|
||||
(text.toLowerCase().indexOf(valThis.toLowerCase()) > -1) ? $(this).show() : $(this).hide();
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('click', '.dropdown-select .option', function (event) {
|
||||
$(this).closest('.list').find('.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
var text = $(this).data('display-text') || $(this).text();
|
||||
$(this).closest('.dropdown-select').find('.current').text(text);
|
||||
$(this).closest('.dropdown-select').prev('select').val($(this).data('value')).trigger('change');
|
||||
});
|
||||
|
||||
$(document).on('keydown', '.dropdown-select', function (event) {
|
||||
var focused_option = $($(this).find('.list .option:focus')[0] || $(this).find('.list .option.selected')[0]);
|
||||
if (event.keyCode === 13) {
|
||||
if ($(this).hasClass('open')) {
|
||||
focused_option.trigger('click');
|
||||
} else {
|
||||
$(this).trigger('click');
|
||||
}
|
||||
return false;
|
||||
// Down
|
||||
} else if (event.keyCode === 40) {
|
||||
if (!$(this).hasClass('open')) {
|
||||
$(this).trigger('click');
|
||||
} else {
|
||||
focused_option.next().focus();
|
||||
}
|
||||
return false;
|
||||
// Up
|
||||
} else if (event.keyCode === 38) {
|
||||
if (!$(this).hasClass('open')) {
|
||||
$(this).trigger('click');
|
||||
} else {
|
||||
var focused_option = $($(this).find('.list .option:focus')[0] || $(this).find('.list .option.selected')[0]);
|
||||
focused_option.prev().focus();
|
||||
}
|
||||
return false;
|
||||
// Esc
|
||||
} else if (event.keyCode === 27) {
|
||||
if ($(this).hasClass('open')) {
|
||||
$(this).trigger('click');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
var employeeSelect = $('#employeeSelect').val();
|
||||
var Amount = $('#Amount ');
|
||||
var SalaryDateTime = $('#SalaryDateTime');
|
||||
var calculationYear = $('#calculationYear');
|
||||
var calculationMonth = $('#calculationMonth');
|
||||
|
||||
if (employeeSelect.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا اسامی پرسنل را کلیک و مشخص نمائید');
|
||||
$('.select-alert').addClass('errored');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.select-alert').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Amount.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SalaryDateTime.val()) {
|
||||
SalaryDateTime.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا تاریخ را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
SalaryDateTime.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (calculationYear.val() === "0" || calculationMonth.val() === "0") {
|
||||
$('.calculationYear').addClass('errored');
|
||||
$('.calculationMonth').addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا سال و ماه را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.calculationYear').removeClass('errored');
|
||||
$('.calculationMonth').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
calculationDate: `${calculationYear.val()}/${calculationMonth.val()}/01`,
|
||||
employeeIds: employeeSelect
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
@@ -153,6 +379,8 @@ function SaveDataAjax() {
|
||||
var employeeSelect = $('#employeeSelect').val();
|
||||
var Amount = $('#Amount ');
|
||||
var SalaryDateTime = $('#SalaryDateTime');
|
||||
var calculationYear = $('#calculationYear');
|
||||
var calculationMonth = $('#calculationMonth');
|
||||
|
||||
if (employeeSelect.length === 0) {
|
||||
$('.alert-msg').show();
|
||||
@@ -190,6 +418,21 @@ function SaveDataAjax() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (calculationYear.val() === "0" || calculationMonth.val() === "0") {
|
||||
$('.calculationYear').addClass('errored');
|
||||
$('.calculationMonth').addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا سال و ماه را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.calculationYear').removeClass('errored');
|
||||
$('.calculationMonth').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
var data = $('#create-form').serialize();
|
||||
@@ -211,7 +454,7 @@ function SaveDataAjax() {
|
||||
}, 1500);
|
||||
|
||||
if (urlPathname.indexOf('/Client/Company/SalaryAid') > -1) {
|
||||
$('#salaryAidListAjax').html('');
|
||||
$('#salaryaidListAjax').html('');
|
||||
$('#PageIndex').val(0);
|
||||
pageIndexJs = 0;
|
||||
loadSalaryAidList();
|
||||
|
||||
@@ -80,20 +80,147 @@ $(document).ready(function () {
|
||||
// datePattern: ['Y', 'm', 'd']
|
||||
// });
|
||||
});
|
||||
|
||||
|
||||
ajaxYears();
|
||||
create_custom_dropdowns();
|
||||
});
|
||||
|
||||
$('#createData').on('click', SaveDataAjax);
|
||||
function SaveDataAjax() {
|
||||
function ajaxYears() {
|
||||
$.ajax({
|
||||
url: yearlyListUrl,
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
var data = response.data;
|
||||
var optionsHtml = ' <option value="0">سال</option>';
|
||||
data.forEach(function (item) {
|
||||
optionsHtml += `<option value="${item}" ${item === year ? "selected" : ""}>${item}</option>`;
|
||||
});
|
||||
$('#calculationYear').html(optionsHtml);
|
||||
|
||||
$('#calculationYear').next('.dropdown-select').remove();
|
||||
create_custom_dropdowns();
|
||||
} else {
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text(response.message);
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
}, 3500);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function create_custom_dropdowns() {
|
||||
$('select').each(function (i, select) {
|
||||
if (!$(this).next().hasClass('dropdown-select')) {
|
||||
$(this).after('<div class="dropdown-select wide ' + ($(this).attr('class') || '') + '" tabindex="0"><span class="current"></span><div class="list"><ul></ul></div></div>');
|
||||
var dropdown = $(this).next();
|
||||
var options = $(select).find('option');
|
||||
var selected = $(this).find('option:selected');
|
||||
dropdown.find('.current').html(selected.data('display-text') || selected.text());
|
||||
options.each(function (j, o) {
|
||||
var display = $(o).data('display-text') || '';
|
||||
dropdown.find('ul').append('<li class="option ' + ($(o).is(':selected') ? 'selected' : '') + '" data-value="' + $(o).val() + '" data-display-text="' + display + '">' + $(o).text() + '</li>');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).off('click', '.dropdown-select').on('click', '.dropdown-select', function (event) {
|
||||
if ($(event.target).hasClass('dd-searchbox')) {
|
||||
return;
|
||||
}
|
||||
$('.dropdown-select').not($(this)).removeClass('open');
|
||||
$(this).toggleClass('open');
|
||||
if ($(this).hasClass('open')) {
|
||||
$(this).find('.option').attr('tabindex', 0);
|
||||
$(this).find('.selected').focus();
|
||||
} else {
|
||||
$(this).find('.option').removeAttr('tabindex');
|
||||
$(this).focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', function (event) {
|
||||
if ($(event.target).closest('.dropdown-select').length === 0) {
|
||||
$('.dropdown-select').removeClass('open');
|
||||
$('.dropdown-select .option').removeAttr('tabindex');
|
||||
}
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
function filter() {
|
||||
var valThis = $('#txtSearchValue').val();
|
||||
$('.dropdown-select ul > li').each(function () {
|
||||
var text = $(this).text();
|
||||
(text.toLowerCase().indexOf(valThis.toLowerCase()) > -1) ? $(this).show() : $(this).hide();
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('click', '.dropdown-select .option', function (event) {
|
||||
$(this).closest('.list').find('.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
var text = $(this).data('display-text') || $(this).text();
|
||||
$(this).closest('.dropdown-select').find('.current').text(text);
|
||||
$(this).closest('.dropdown-select').prev('select').val($(this).data('value')).trigger('change');
|
||||
});
|
||||
|
||||
$(document).on('keydown', '.dropdown-select', function (event) {
|
||||
var focused_option = $($(this).find('.list .option:focus')[0] || $(this).find('.list .option.selected')[0]);
|
||||
if (event.keyCode === 13) {
|
||||
if ($(this).hasClass('open')) {
|
||||
focused_option.trigger('click');
|
||||
} else {
|
||||
$(this).trigger('click');
|
||||
}
|
||||
return false;
|
||||
// Down
|
||||
} else if (event.keyCode === 40) {
|
||||
if (!$(this).hasClass('open')) {
|
||||
$(this).trigger('click');
|
||||
} else {
|
||||
focused_option.next().focus();
|
||||
}
|
||||
return false;
|
||||
// Up
|
||||
} else if (event.keyCode === 38) {
|
||||
if (!$(this).hasClass('open')) {
|
||||
$(this).trigger('click');
|
||||
} else {
|
||||
var focused_option = $($(this).find('.list .option:focus')[0] || $(this).find('.list .option.selected')[0]);
|
||||
focused_option.prev().focus();
|
||||
}
|
||||
return false;
|
||||
// Esc
|
||||
} else if (event.keyCode === 27) {
|
||||
if ($(this).hasClass('open')) {
|
||||
$(this).trigger('click');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
var employeeSelect = $('#employeeSelectId').val();
|
||||
var Amount = $('#Amount ');
|
||||
var SalaryDateTime = $('#SalaryDateTime');
|
||||
var calculationYear = $('#calculationYear');
|
||||
var calculationMonth = $('#calculationMonth');
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ پاداش را وارد نمائید');
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
@@ -114,6 +241,114 @@ function SaveDataAjax() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (calculationYear.val() === "0" || calculationMonth.val() === "0") {
|
||||
$('.calculationYear').addClass('errored');
|
||||
$('.calculationMonth').addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا سال و ماه را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.calculationYear').removeClass('errored');
|
||||
$('.calculationMonth').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
var month = calculationMonth.val() < 10 ? calculationMonth.val().padStart(2, '0') : calculationMonth.val();
|
||||
var dateCalculate = `${calculationYear.val()}/${month}/01`;
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
calculationDate: dateCalculate,
|
||||
employeeIds: employeeSelect
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function SaveDataAjax() {
|
||||
var loading = $('#createData .spinner-loading');
|
||||
|
||||
var Amount = $('#Amount ');
|
||||
var SalaryDateTime = $('#SalaryDateTime');
|
||||
var calculationYear = $('#calculationYear');
|
||||
var calculationMonth = $('#calculationMonth');
|
||||
|
||||
if (!Amount.val() || Amount.val() === "0") {
|
||||
Amount.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
Amount.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SalaryDateTime.val()) {
|
||||
SalaryDateTime.addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا تاریخ را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
SalaryDateTime.removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (calculationYear.val() === "0" || calculationMonth.val() === "0") {
|
||||
$('.calculationYear').addClass('errored');
|
||||
$('.calculationMonth').addClass('errored');
|
||||
$('.alert-msg').show();
|
||||
$('.alert-msg p').text('لطفا سال و ماه را مشخص نمائید');
|
||||
setTimeout(function () {
|
||||
$('.alert-msg').hide();
|
||||
$('.alert-msg p').text('');
|
||||
$('.calculationYear').removeClass('errored');
|
||||
$('.calculationMonth').removeClass('errored');
|
||||
}, 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
var data = $('#create-form').serialize();
|
||||
@@ -133,7 +368,8 @@ function SaveDataAjax() {
|
||||
$('.alert-success-msg').hide();
|
||||
$('.alert-success-msg p').text('');
|
||||
}, 1500);
|
||||
|
||||
|
||||
$('#salaryaidEmployeeListAjax').html('');
|
||||
$('#salaryAidListAjax').html('');
|
||||
$('#PageIndex').val(0);
|
||||
pageIndexJs = 0;
|
||||
|
||||
@@ -131,11 +131,12 @@ function showAlertMessage(selector, message, timeout) {
|
||||
}
|
||||
|
||||
function loadErrorExcelDataAjax(data) {
|
||||
|
||||
|
||||
|
||||
var htmlTable = '';
|
||||
|
||||
if (data.errors.length > 0) {
|
||||
var month = data.rawData[0]?.calculationMonth < 10 ? data.rawData[0]?.calculationMonth.toString().padStart(2, '0') : data.rawData[0]?.calculationMonth.toString();
|
||||
var dateCalculate = `${data.rawData[0]?.calculationYear}/${month}/01`;
|
||||
|
||||
//let allRows = new Array(Math.max(data.rawData.length, data.errors.length)).fill(null);
|
||||
//let rowErrorsDataArray = data.rawData.filter(x => data.errors.some(e => e.row === x.row));
|
||||
|
||||
@@ -144,7 +145,10 @@ function loadErrorExcelDataAjax(data) {
|
||||
<div class="excelTable Rtable Rtable--5cols Rtable--collapse rowCustom px-1">
|
||||
<div class="Rtable-row Rtable-row--head align-items-center d-flex flex-column w-100 error-header sticky p-0">
|
||||
|
||||
<div class="Rtable-cell column-heading rowHeaderCustom text-center justify-content-center w-100 px-1">تاریخ ${data.rawData[0]?.salaryAidDateTime ?? ""}</div>
|
||||
<div class="Rtable-cell column-heading rowHeaderCustom text-center d-flex justify-content-between w-100 px-3">
|
||||
<div>تاریخ پرداخت ${data.rawData[0]?.salaryAidDateTime ?? ""}</div>
|
||||
<div>تاریخ محاسبه ${data.rawData[0]?.calculationMonth ? dateCalculate : ""}</div>
|
||||
</div>
|
||||
<div class="lineHead w-100"></div>
|
||||
<div class="d-flex w-100 px-1 gap-2">
|
||||
<div class="Rtable-cell column-heading rowHeaderCustom width1">
|
||||
@@ -222,7 +226,7 @@ function loadErrorExcelDataAjax(data) {
|
||||
|
||||
htmlTable += `<div class="Rtable-cell width1">
|
||||
<label class="Rtable-cell--content prevent-select">
|
||||
<span class="d-flex align-items-center justify-content-center gap-1">${index + 1}</span>
|
||||
<span class="d-flex align-items-center justify-content-center gap-1 numberIndex">${index + 1}</span>
|
||||
</label>
|
||||
</div>`;
|
||||
|
||||
@@ -390,11 +394,15 @@ function loadFinalExcelDataAjax(data) {
|
||||
if (data.rawData.length > 0) {
|
||||
const rowValidDataDuplicateExist = data.rawData.filter(x => x.duplicated);
|
||||
|
||||
var month = data.rawData[0]?.calculationMonth < 10 ? data.rawData[0]?.calculationMonth.toString().padStart(2, '0') : data.rawData[0]?.calculationMonth.toString();
|
||||
var dateCalculate = `${data.rawData[0]?.calculationYear}/${month}/01`;
|
||||
|
||||
htmlTable += `<div class="wrapper">
|
||||
<div class="excelValidTable Rtable Rtable--5cols Rtable--collapse rowCustom px-1">
|
||||
<div class="Rtable-row Rtable-row--head align-items-center d-flex flex-column w-100 sticky p-0">
|
||||
<div class="Rtable-cell column-heading rowHeaderCustom d-flex align-items-center ${rowValidDataDuplicateExist.length > 0 ? 'justify-content-between' : 'justify-content-center'} w-100 px-2">
|
||||
<div>تاریخ ${data.rawData[0].salaryAidDateTime}</div>`;
|
||||
<div class="Rtable-cell column-heading rowHeaderCustom d-flex align-items-center justify-content-between w-100 px-2">
|
||||
<div>تاریخ پرداخت ${data.rawData[0].salaryAidDateTime}</div>
|
||||
<div>تاریخ محاسبه ${dateCalculate ?? ""}</div>`;
|
||||
|
||||
|
||||
if (rowValidDataDuplicateExist.length > 0) {
|
||||
@@ -721,7 +729,72 @@ function checkInputsEnabled() {
|
||||
}
|
||||
|
||||
|
||||
$('#createData').click(function () {
|
||||
$('#createData').on('click', CheckExistAjax);
|
||||
|
||||
function CheckExistAjax() {
|
||||
var employeeSelectArray = [];
|
||||
|
||||
validDataArray.forEach(function(item) {
|
||||
employeeSelectArray.push(item.employeeId);
|
||||
});
|
||||
|
||||
if (!validDataArray) {
|
||||
showAlertMessage('.alert-msg', 'داده ای برای ارسال وجود ندارد.', 3500);
|
||||
return;
|
||||
}
|
||||
|
||||
var month = validDataArray[0].calculationMonth < 10 ? validDataArray[0].calculationMonth.toString().padStart(2, '0') : validDataArray[0].calculationMonth.toString();
|
||||
var dateCalculate = `${validDataArray[0].calculationYear}/${month}/01`;
|
||||
|
||||
var loading = $("#createData").find('.spinner-loading').show();
|
||||
$('#createData').addClass('disable');
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: checkoutExistsAjaxUrl,
|
||||
headers: { "RequestVerificationToken": antiForgeryToken },
|
||||
traditional: true,
|
||||
data: {
|
||||
calculationDate: dateCalculate,
|
||||
employeeIds: employeeSelectArray
|
||||
},
|
||||
success: function (response) {
|
||||
//if (response.checkout)
|
||||
if (response.customizeCheckout || response.customizeCheckoutTemp) {
|
||||
swal({
|
||||
title: "آیا میخواهید ادامه دهید؟",
|
||||
text: "",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "بله",
|
||||
cancelButtonText: "خیر",
|
||||
closeOnConfirm: true,
|
||||
closeOnCancel: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
SaveDataAjax();
|
||||
} else {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SaveDataAjax();
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
loading.hide();
|
||||
$('#createData').removeClass('disable');
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function SaveDataAjax() {
|
||||
if (!validDataArray) {
|
||||
showAlertMessage('.alert-msg', 'داده ای برای ارسال وجود ندارد.', 3500);
|
||||
return;
|
||||
@@ -772,7 +845,7 @@ $('#createData').click(function () {
|
||||
$('#createData').removeClass('disable');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function downloadExcelTemplate(url) {
|
||||
$.ajax({
|
||||
@@ -797,8 +870,4 @@ function downloadExcelTemplate(url) {
|
||||
console.error('Error downloading file:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//$(#createData).click(function() {
|
||||
|
||||
//});
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user