Compare commits
118 Commits
Fix/Custom
...
Feature/Ma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1e5adf96f | ||
|
|
8e8e9ef5de | ||
|
|
1e18fe1067 | ||
|
|
d1aef862cf | ||
|
|
fc18985334 | ||
|
|
92d36f2966 | ||
|
|
0c6a8821ac | ||
|
|
4b9d39f1e7 | ||
|
|
9e5e7b57c7 | ||
|
|
a6984e5f1b | ||
|
|
fe8eb5d92b | ||
|
|
24e661252c | ||
|
|
e7d5716317 | ||
|
|
a6be044dbb | ||
|
|
c91f7e7a90 | ||
|
|
42de15b3db | ||
|
|
ffcfb4ea3f | ||
|
|
a49e2dbb75 | ||
|
|
d8cd33732a | ||
|
|
5aa714e81d | ||
|
|
6eec454685 | ||
|
|
13cad28356 | ||
|
|
9cdb922aa1 | ||
|
|
6699909b2f | ||
|
|
718a7d42b7 | ||
|
|
9637b6a581 | ||
|
|
ec29d3b869 | ||
|
|
4648113a28 | ||
|
|
f4f6fd1bf6 | ||
|
|
d9b7245cee | ||
|
|
85bec9d7fb | ||
|
|
f93d0b7e89 | ||
|
|
f8f7e7d3cf | ||
|
|
e159738b3d | ||
|
|
ebde36ad8d | ||
|
|
6f160a85ab | ||
|
|
ebaef13c4d | ||
|
|
a29e148753 | ||
|
|
625200bed1 | ||
|
|
4e81b6a2ef | ||
|
|
e03aabf88b | ||
|
|
d1158b95cb | ||
|
|
dbc73509b5 | ||
|
|
b6ac3073d3 | ||
|
|
9592960a40 | ||
|
|
4ec4935a1d | ||
|
|
e423df6fbb | ||
|
|
7bc7cd3422 | ||
|
|
dec934214d | ||
|
|
dd922a72d5 | ||
|
|
76f32c5c38 | ||
|
|
8f015aa124 | ||
|
|
1a8886be50 | ||
|
|
cf6f677816 | ||
|
|
366d42dec9 | ||
|
|
5bce350701 | ||
|
|
d322f2b8db | ||
|
|
cd83ca4379 | ||
|
|
edc017b4d4 | ||
|
|
4a0153e1e8 | ||
|
|
7f9a2ac597 | ||
|
|
f9298e1320 | ||
|
|
ce088fc432 | ||
|
|
3e02cd711f | ||
|
|
64dffd6d25 | ||
|
|
ffdc71401e | ||
|
|
21f8a399b4 | ||
|
|
cad2c152e5 | ||
|
|
247e2f2069 | ||
|
|
cb845afdf6 | ||
|
|
530a263fd8 | ||
|
|
aba8960b1d | ||
|
|
e2ba7d9450 | ||
|
|
a316b2a5f1 | ||
|
|
4b045440c4 | ||
| 10c35f6f10 | |||
|
|
af30c7f088 | ||
|
|
d95ca28cd4 | ||
|
|
89a8e1c027 | ||
|
|
e584605c4e | ||
|
|
734699b319 | ||
|
|
e8407868a7 | ||
| 7ad1a2f376 | |||
| e190408504 | |||
| e520c8c14b | |||
| bd0e79fadf | |||
|
|
b880721dfa | ||
|
|
e0a68690c1 | ||
|
|
817a848eef | ||
|
|
f77fa7a324 | ||
|
|
e44dad08ef | ||
|
|
f901f8a682 | ||
|
|
08913d38f2 | ||
|
|
15156c06fc | ||
|
|
5da9d23875 | ||
|
|
c14da7ad5b | ||
|
|
1629b121d3 | ||
|
|
3a60ddf449 | ||
|
|
c90fe4cb29 | ||
|
|
57930aae4f | ||
|
|
d816e73fed | ||
|
|
10bfbad3cb | ||
|
|
671f6be87a | ||
|
|
2901a9ecf4 | ||
|
|
aff835fd7f | ||
|
|
7055839538 | ||
|
|
2166e7c5ee | ||
|
|
d4dc65b4e8 | ||
| 38dd1b1818 | |||
|
|
8c5b21b726 | ||
|
|
77d9c42823 | ||
|
|
214882108c | ||
|
|
ececd99d07 | ||
|
|
d54e3c4a67 | ||
|
|
4e8a7d74a2 | ||
|
|
d1414b0b90 | ||
|
|
aeb65dc152 | ||
|
|
e69525b1ad |
@@ -245,21 +245,24 @@ public class AuthHelper : IAuthHelper
|
||||
|
||||
#region Pooya
|
||||
|
||||
public (long Id, UserType userType) GetUserTypeWithId()
|
||||
public (long Id, UserType userType, long roleId) GetUserTypeWithId()
|
||||
{
|
||||
if (!IsAuthenticated())
|
||||
return (0, UserType.Anonymous);
|
||||
return (0, UserType.Anonymous, 0);
|
||||
var claims = _contextAccessor.HttpContext.User.Claims.ToList();
|
||||
|
||||
var subAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId")?.Value ?? "0");
|
||||
if (subAccountId > 0)
|
||||
return (subAccountId, UserType.SubAccount);
|
||||
return (subAccountId, UserType.SubAccount, 0);
|
||||
|
||||
var id = long.Parse(_contextAccessor.HttpContext.User.Claims.First(x => x.Type == "AccountId")?.Value);
|
||||
if (claims.FirstOrDefault(x => x.Type == "AdminAreaPermission")?.Value == "true")
|
||||
return (id, UserType.Admin);
|
||||
{
|
||||
var roleId = long.Parse(claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value ?? "0");
|
||||
return (id, UserType.Admin, roleId);
|
||||
}
|
||||
|
||||
return (id, UserType.Client);
|
||||
return (id, UserType.Client, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -23,5 +23,5 @@ public interface IAuthHelper
|
||||
long CurrentSubAccountId();
|
||||
string GetWorkshopSlug();
|
||||
string GetWorkshopName();
|
||||
(long Id, UserType userType) GetUserTypeWithId();
|
||||
(long Id, UserType userType, long roleId) GetUserTypeWithId();
|
||||
}
|
||||
@@ -22,4 +22,11 @@ public interface ISmsService
|
||||
string DeliveryStatus(byte? dv);
|
||||
string DeliveryColorStatus(byte? dv);
|
||||
string UnixTimeStampToDateTime(int? unixTimeStamp);
|
||||
|
||||
#region Mahan
|
||||
|
||||
Task<double> GetCreditAmount();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -17,10 +17,14 @@ namespace _0_Framework.Application.Sms;
|
||||
public class SmsService : ISmsService
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public SmsIr SmsIr { get; set; }
|
||||
|
||||
|
||||
public SmsService(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
|
||||
}
|
||||
|
||||
public void Send(string number, string message)
|
||||
@@ -311,4 +315,23 @@ public class SmsService : ISmsService
|
||||
//var tokenService = new Token();
|
||||
//return tokenService.GetToken("x-api-key", "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
|
||||
public async Task<double> GetCreditAmount()
|
||||
{
|
||||
try
|
||||
{
|
||||
var credit = await SmsIr.GetCreditAsync();
|
||||
return (double)credit.Data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -14,6 +14,15 @@ public static class StaticWorkshopAccounts
|
||||
/// </summary>
|
||||
public static List<long> SelectedAccountsRoleIds = [3, 5, 7, 8];
|
||||
|
||||
/// <summary>
|
||||
/// لیستی آی دی نقش هایی که دردسترسی به تب افزودن پرسنل و مدارک کلاینت دارند
|
||||
/// 3 : قرارداد ارشد
|
||||
/// 5 : قرارداد ساده
|
||||
/// 19 : برنامه نویسان
|
||||
/// 1 : مدیر سیستم
|
||||
/// </summary>
|
||||
public static List<long> EmployeeDocumentWorkFlowRoleIds = [1,3, 5, 19];
|
||||
|
||||
/// <summary>
|
||||
/// لیست اکانتهایی که به همه کارگاه ها باید دسترسی داشته باشند
|
||||
/// 2 - صادق فرخی
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -598,90 +603,90 @@ public static class Tools
|
||||
/// <returns></returns>
|
||||
public static int YearTotalDays(this string date)
|
||||
{
|
||||
int y2 = 365;
|
||||
int y2 = 366;
|
||||
var year = Convert.ToInt32(date.Substring(0, 4));
|
||||
|
||||
|
||||
switch (year)
|
||||
{
|
||||
case 1346:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1350:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1354:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1358:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1362:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1366:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1370:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1375:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1379:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1383:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1387:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1391:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1395:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1399:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1403:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1408:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1412:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1416:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1420:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1424:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1428:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1432:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1436:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1441:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
case 1445:
|
||||
y2 = 366;
|
||||
y2 = 367;
|
||||
break;
|
||||
|
||||
default:
|
||||
y2 = 365;
|
||||
y2 = 366;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,20 +32,22 @@ public class UidService : IUidService
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var requestResult = await _httpClient.PostAsync("person/v2", contentType);
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("person/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName.ToPersian();
|
||||
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName.ToPersian();
|
||||
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName.ToPersian();
|
||||
|
||||
if (responseResult.BasicInformation != null)
|
||||
{
|
||||
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian();
|
||||
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian();
|
||||
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian();
|
||||
}
|
||||
|
||||
return responseResult;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
|
||||
return null;
|
||||
@@ -63,19 +65,12 @@ public class UidService : IUidService
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
}
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
@@ -1866,7 +1866,7 @@ public class TaskRepository : RepositoryBase<long, Tasks>, ITaskRepository
|
||||
.Include(x => x.Task).ThenInclude(x => x.TaskSchedule)
|
||||
.Where(x =>
|
||||
x.Task.IsActiveString == "true" && x.Task.SenderId == accountId
|
||||
&& x.Task.TaskScheduleId != null && x.Task.TaskScheduleId > 0 && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest));
|
||||
&& x.Task.TaskScheduleId != null && x.Task.TaskScheduleId > 0 && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest) && x.Task.TaskSchedule.IsActive == IsActive.True);
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
|
||||
{
|
||||
raw = raw.Where(x =>
|
||||
|
||||
@@ -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,4 +15,5 @@ public interface ICustomizeWorkshopEmployeeSettingsRepository : IRepository<long
|
||||
List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingNotInMainGroup(long entityWorkshopId);
|
||||
void RemoveByWorkshopIdAndEmployeeId(long workshopId, long employeeId);
|
||||
|
||||
bool CheckEmployeeShiftHasChanged(EditCustomizeEmployeeSettings command);
|
||||
}
|
||||
@@ -20,14 +20,14 @@ public class Employee : EntityBase
|
||||
{
|
||||
public Employee(string fName, string lName, string fatherName,
|
||||
DateTime dateOfBirth, DateTime dateOfIssue, string placeOfIssue,
|
||||
string nationalCode, string idNumber, string gender, string nationality,
|
||||
string nationalCode, string idNumber, string gender, string nationality, string idNumberSerial , string idNumberSeri ,
|
||||
string phone = null, string address = null, string state = null, string city = null,
|
||||
string maritalStatus = null, string militaryService = null, string levelOfEducation = null, string fieldOfStudy = null,
|
||||
string bankCardNumber = null, string bankBranch = null, string insuranceCode = null, string insuranceHistoryByYear = null,
|
||||
string insuranceHistoryByMonth = null, string numberOfChildren = null, string officePhone = null,
|
||||
string mclsUserName = null, string mclsPassword = null,
|
||||
string eserviceUserName = null, string eservicePassword = null,
|
||||
string taxOfficeUserName = null, string taxOfficepassword = null, string sanaUserName = null, string sanaPassword = null)
|
||||
string taxOfficeUserName = null, string taxOfficepassword = null, string sanaUserName = null, string sanaPassword = null )
|
||||
{
|
||||
FName = fName;
|
||||
LName = lName;
|
||||
@@ -146,6 +146,15 @@ public class Employee : EntityBase
|
||||
/// آیا پرسنل احراز هویت شده است
|
||||
/// </summary>
|
||||
public bool IsAuthorized { get; set; }
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -234,5 +243,39 @@ public class Employee : EntityBase
|
||||
IsAuthorized = true;
|
||||
}
|
||||
|
||||
public void EditAuthorizeEmployee(DateTime dateOfIssue, string placeOfIssue,
|
||||
string phone, string address, string state, string citi,
|
||||
string maritalStatus, string militaryService, string levelOfEducation, string fieldOfStudy,
|
||||
string bankCardNumber, string bankBranch, string insuranceCode, string insuranceHistoryByYear,
|
||||
string insuranceHistoryByMonth, string numberOfChildren, string officePhone,
|
||||
string mclsUserName, string mclsPassword, string eserviceUserName, string eservicePassword, string taxOfficeUserName, string taxOfficepassword, string sanaUserName, string sanaPassword)
|
||||
{
|
||||
DateOfIssue = dateOfIssue;
|
||||
PlaceOfIssue = placeOfIssue;
|
||||
Phone = phone;
|
||||
Address = address;
|
||||
State = state;
|
||||
City = citi;
|
||||
MaritalStatus = maritalStatus;
|
||||
MilitaryService = militaryService;
|
||||
LevelOfEducation = levelOfEducation;
|
||||
FieldOfStudy = fieldOfStudy;
|
||||
BankCardNumber = bankCardNumber;
|
||||
BankBranch = bankBranch;
|
||||
InsuranceCode = insuranceCode;
|
||||
InsuranceHistoryByYear = insuranceHistoryByYear;
|
||||
InsuranceHistoryByMonth = insuranceHistoryByMonth;
|
||||
NumberOfChildren = numberOfChildren;
|
||||
OfficePhone = OfficePhone;
|
||||
MclsUserName = mclsUserName;
|
||||
MclsPassword = mclsPassword;
|
||||
EserviceUserName = eserviceUserName;
|
||||
EservicePassword = eservicePassword;
|
||||
TaxOfficeUserName = taxOfficeUserName;
|
||||
TaxOfficepassword = taxOfficepassword;
|
||||
SanaUserName = sanaUserName;
|
||||
SanaPassword = sanaPassword;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
|
||||
namespace Company.Domain.EmployeeAuthorizeTempAgg;
|
||||
|
||||
public class EmployeeAuthorizeTemp:EntityBase
|
||||
{
|
||||
public EmployeeAuthorizeTemp(Gender gender, string fName, string lName, string fatherName, DateTime birthDate, string nationalCode, string idNumber, string idNumberSerial, string idNumberSeri)
|
||||
{
|
||||
Gender = gender;
|
||||
FName = fName;
|
||||
LName = lName;
|
||||
FatherName = fatherName;
|
||||
BirthDate = birthDate;
|
||||
NationalCode = nationalCode;
|
||||
IdNumber = idNumber;
|
||||
IdNumberSerial = idNumberSerial;
|
||||
IdNumberSeri = idNumberSeri;
|
||||
}
|
||||
|
||||
public Gender Gender { get; private set; }
|
||||
public string FName { get; private set; }
|
||||
public string LName { get; private set; }
|
||||
public string FatherName { get; private set; }
|
||||
public DateTime BirthDate { get; private set; }
|
||||
/// <summary>
|
||||
/// کدملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; set; }
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; set; }
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
|
||||
namespace Company.Domain.EmployeeAuthorizeTempAgg;
|
||||
|
||||
public interface IEmployeeAuthorizeTempRepository:IRepository<long,EmployeeAuthorizeTemp>
|
||||
{
|
||||
Task<EmployeeAuthorizeTemp> GetByNationalCode(string nationalCode);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using _0_Framework.Domain;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
namespace Company.Domain.EmployeeClientTempAgg;
|
||||
@@ -8,4 +10,5 @@ public interface IEmployeeClientTempRepository : IRepository<long, EmployeeClien
|
||||
EmployeeClientTemp GetByEmployeeIdAndWorkshopId(long employeeId, long commandWorkshopId);
|
||||
EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId);
|
||||
void Remove(EmployeeClientTemp entity);
|
||||
Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId);
|
||||
}
|
||||
@@ -7,100 +7,105 @@ using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using Microsoft.AspNetCore.JsonPatch.Operations;
|
||||
|
||||
namespace Company.Domain.EmployeeDocumentItemAgg
|
||||
namespace Company.Domain.EmployeeDocumentItemAgg;
|
||||
|
||||
public class EmployeeDocumentItem : EntityBase
|
||||
{
|
||||
public class EmployeeDocumentItem : EntityBase
|
||||
private EmployeeDocumentItem() { }
|
||||
public long WorkshopId { get; private set; }
|
||||
public long EmployeeId { get; private set; }
|
||||
|
||||
public long UploaderId { get; private set; }
|
||||
public UserType UploaderType { get; private set; }
|
||||
public long UploaderRoleId { get; set; }
|
||||
|
||||
|
||||
public long ReviewedById { get; private set; }
|
||||
public string RejectionReason { get; private set; }
|
||||
public DocumentStatus DocumentStatus { get; private set; }
|
||||
public long MediaId { get; private set; }
|
||||
|
||||
public DateTime? ConfirmationDateTime { get; private set; }
|
||||
public DocumentItemLabel DocumentLabel { get; private set; }
|
||||
|
||||
public long EmployeeDocumentId { get; private set; }
|
||||
public virtual EmployeeDocuments EmployeeDocuments { get; private set; }
|
||||
|
||||
public long? EmployeeDocumentsAdminViewId { get; private set; }
|
||||
public EmployeeDocumentsAdminSelection EmployeeDocumentsAdminSelection { get; private set; }
|
||||
|
||||
public List<EmployeeDocumentItemLog> ItemLogs { get; private set; }
|
||||
|
||||
|
||||
public EmployeeDocumentItem(long workshopId, long employeeId, long mediaId, long employeeDocumentId, DocumentItemLabel documentLabel, long uploaderId,
|
||||
UserType uploaderType, long roleId, DocumentStatus documentStatus = DocumentStatus.Unsubmitted)
|
||||
{
|
||||
|
||||
public long WorkshopId { get; private set; }
|
||||
public long EmployeeId { get; private set; }
|
||||
|
||||
public long UploaderId { get; private set; }
|
||||
public UserType UploaderType { get; private set; }
|
||||
|
||||
|
||||
public long ReviewedById { get; private set; }
|
||||
public string RejectionReason { get; private set; }
|
||||
public DocumentStatus DocumentStatus { get; private set; }
|
||||
public long MediaId { get; private set; }
|
||||
|
||||
public DateTime? ConfirmationDateTime { get; private set; }
|
||||
public DocumentItemLabel DocumentLabel { get; private set; }
|
||||
|
||||
public long EmployeeDocumentId { get; private set; }
|
||||
public virtual EmployeeDocuments EmployeeDocuments { get; private set; }
|
||||
|
||||
public long? EmployeeDocumentsAdminViewId { get; private set; }
|
||||
public EmployeeDocumentsAdminSelection EmployeeDocumentsAdminSelection { get; private set; }
|
||||
|
||||
public List<EmployeeDocumentItemLog> ItemLogs { get; private set; }
|
||||
|
||||
|
||||
public EmployeeDocumentItem(long workshopId,long employeeId, long mediaId, long employeeDocumentId, DocumentItemLabel documentLabel, long uploaderId,
|
||||
UserType uploaderType, DocumentStatus documentStatus = DocumentStatus.Unsubmitted)
|
||||
{
|
||||
MediaId = mediaId;
|
||||
UploaderId = uploaderId;
|
||||
UploaderType = uploaderType;
|
||||
EmployeeId = employeeId;
|
||||
WorkshopId = workshopId;
|
||||
DocumentStatus = documentStatus;
|
||||
if (documentStatus == DocumentStatus.Confirmed)
|
||||
ConfirmationDateTime = DateTime.Now;
|
||||
DocumentLabel = documentLabel;
|
||||
EmployeeDocumentId = employeeDocumentId;
|
||||
ItemLogs =
|
||||
[
|
||||
new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.CreatedNewItem, uploaderId, uploaderType)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public void Confirm(long operatorId, UserType userType)
|
||||
{
|
||||
ReviewedById = operatorId;
|
||||
DocumentStatus = DocumentStatus.Confirmed;
|
||||
MediaId = mediaId;
|
||||
UploaderId = uploaderId;
|
||||
UploaderType = uploaderType;
|
||||
UploaderRoleId = uploaderType == UserType.Admin ? roleId : -1;
|
||||
EmployeeId = employeeId;
|
||||
WorkshopId = workshopId;
|
||||
DocumentStatus = documentStatus;
|
||||
if (documentStatus == DocumentStatus.Confirmed)
|
||||
ConfirmationDateTime = DateTime.Now;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.ConfirmedItem, operatorId, userType));
|
||||
}
|
||||
|
||||
public void Reject(long operatorId, string rejectionReason, UserType userType)
|
||||
{
|
||||
RejectionReason = rejectionReason;
|
||||
DocumentStatus = DocumentStatus.Rejected;
|
||||
EmployeeDocuments.UpdateHasRejectedItems();
|
||||
ReviewedById = operatorId;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.RejectedItem, operatorId, userType, rejectionReason));
|
||||
}
|
||||
|
||||
public void Delete(long operatorId, UserType operatorType)
|
||||
{
|
||||
DocumentStatus = DocumentStatus.Deleted;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.DeletedItem, operatorId, operatorType));
|
||||
}
|
||||
|
||||
public void AdminSelect(long adminViewId)
|
||||
{
|
||||
EmployeeDocumentsAdminViewId = adminViewId;
|
||||
}
|
||||
|
||||
public void AdminDeselect()
|
||||
{
|
||||
EmployeeDocumentsAdminViewId = 0;
|
||||
}
|
||||
public void SubmitByClient(long operatorId,UserType operatorType)
|
||||
{
|
||||
DocumentStatus = DocumentStatus.SubmittedByClient;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.SubmittedItems, operatorId, operatorType));
|
||||
EmployeeDocuments.UpdateHasRejectedItems();
|
||||
}
|
||||
|
||||
public void SubmitByAdmin(long operatorId, UserType operatorType)
|
||||
{
|
||||
DocumentStatus = DocumentStatus.SubmittedByAdmin;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.SubmittedItems, operatorId, operatorType));
|
||||
EmployeeDocuments.UpdateHasRejectedItems();
|
||||
}
|
||||
DocumentLabel = documentLabel;
|
||||
EmployeeDocumentId = employeeDocumentId;
|
||||
ItemLogs =
|
||||
[
|
||||
new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.CreatedNewItem, uploaderId, uploaderType)
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Confirm(long operatorId, UserType userType)
|
||||
{
|
||||
ReviewedById = operatorId;
|
||||
DocumentStatus = DocumentStatus.Confirmed;
|
||||
ConfirmationDateTime = DateTime.Now;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.ConfirmedItem, operatorId, userType));
|
||||
}
|
||||
|
||||
public void Reject(long operatorId, string rejectionReason, UserType userType)
|
||||
{
|
||||
RejectionReason = rejectionReason;
|
||||
DocumentStatus = DocumentStatus.Rejected;
|
||||
EmployeeDocuments.UpdateHasRejectedItems();
|
||||
ReviewedById = operatorId;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.RejectedItem, operatorId, userType, rejectionReason));
|
||||
}
|
||||
|
||||
public void Delete(long operatorId, UserType operatorType)
|
||||
{
|
||||
DocumentStatus = DocumentStatus.Deleted;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.DeletedItem, operatorId, operatorType));
|
||||
}
|
||||
|
||||
public void AdminSelect(long adminViewId)
|
||||
{
|
||||
EmployeeDocumentsAdminViewId = adminViewId;
|
||||
}
|
||||
|
||||
public void AdminDeselect()
|
||||
{
|
||||
EmployeeDocumentsAdminViewId = 0;
|
||||
}
|
||||
public void SubmitByClient(long operatorId, UserType operatorType)
|
||||
{
|
||||
DocumentStatus = DocumentStatus.SubmittedByClient;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.SubmittedItems, operatorId, operatorType));
|
||||
EmployeeDocuments.UpdateHasRejectedItems();
|
||||
}
|
||||
|
||||
public void SubmitByAdmin(long operatorId, UserType operatorType)
|
||||
{
|
||||
DocumentStatus = DocumentStatus.SubmittedByAdmin;
|
||||
ItemLogs.Add(new EmployeeDocumentItemLog(EmployeeDocumentItemOperation.SubmittedItems, operatorId, operatorType));
|
||||
EmployeeDocuments.UpdateHasRejectedItems();
|
||||
}
|
||||
|
||||
public void SetRoleId(long roleId)
|
||||
{
|
||||
UploaderRoleId = roleId;
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,12 @@ namespace Company.Domain.EmployeeDocumentsAgg
|
||||
{
|
||||
List<DocumentItemLabel> requiredDocuments =
|
||||
[
|
||||
DocumentItemLabel.IdCardPage1, DocumentItemLabel.IdCardPage2, DocumentItemLabel.IdCardPage3, DocumentItemLabel.NationalCardRear,
|
||||
DocumentItemLabel.NationalCardFront,DocumentItemLabel.EmployeePicture
|
||||
DocumentItemLabel.IdCardPage1,/* DocumentItemLabel.IdCardPage2, DocumentItemLabel.IdCardPage3, DocumentItemLabel.NationalCardRear,*/
|
||||
DocumentItemLabel.NationalCardFront,/*DocumentItemLabel.EmployeePicture*/
|
||||
];
|
||||
|
||||
if (gender == "مرد")
|
||||
requiredDocuments.Add(DocumentItemLabel.MilitaryServiceCard);
|
||||
//if (gender == "مرد")
|
||||
// requiredDocuments.Add(DocumentItemLabel.MilitaryServiceCard);
|
||||
|
||||
return requiredDocuments;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using CompanyManagment.App.Contracts.Workshop;
|
||||
namespace Company.Domain.EmployeeDocumentsAgg
|
||||
{
|
||||
public interface IEmployeeDocumentsRepository : IRepository<long, EmployeeDocuments>
|
||||
{
|
||||
{
|
||||
EmployeeDocuments GetByEmployeeIdWorkshopId(long employeeId, long workshopId);
|
||||
EmployeeDocumentsViewModel GetViewModelByEmployeeIdWorkshopId(long employeeId, long workshopId);
|
||||
List<EmployeeDocumentsViewModel> SearchForClient(SearchEmployeeDocuments cmd);
|
||||
@@ -30,5 +30,76 @@ namespace Company.Domain.EmployeeDocumentsAgg
|
||||
Task<int> GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds);
|
||||
Task<int> GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds);
|
||||
List<EmployeeDocumentsViewModel> GetDocumentsAwaitingReviewByWorkshopIdForCheckerWorkFlow(long workshopId);
|
||||
|
||||
#region Mahan
|
||||
/// <summary>
|
||||
/// کارگاهی که افزودن پرسنل کرده اند. بر اساس نقش فیلتر میشوند
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ICollection<WorkshopWithEmployeeDocumentsViewModel>> GetWorkshopDocumentCreatedEmployeeForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
///کارگاه های مدارک های برگشت خورده براساس دسترسی افراد و نقششان. یک مدرک برگشت خورده به تمامی کسانی که به آن کارگاه دسترسی دارند و تمامی کسانی که هم نقش آپلود کننده بوده اند نمایش داده میشود
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ICollection<WorkshopWithEmployeeDocumentsViewModel>> GetWorkshopDocumentRejectedForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های برگشت خورده براساس دسترسی افراد و نقششان. یک مدرک برگشت خورده به تمامی کسانی که به آن کارگاه دسترسی دارند و تمامی کسانی که هم نقش آپلود کننده بوده اند نمایش داده میشود
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetRejectedItemsByWorkshopIdAndRoleForAdminWorkFlow(long workshopId,
|
||||
long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// کارگاه هایی که افزودن پرسنل کرده اند و مدارک آنها ناقص است
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetCreatedEmployeesWorkshopDocumentForAdmin(
|
||||
List<long> workshops,long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// پرسنلی که افزوده شده اند در کارگاه و آپلود مدارک آنها ناقص است
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetCreatedEmployeesDocumentByWorkshopIdForAdmin(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// لیست کارگاه هایی که مدارک آپلود شده توسط کلاینت برگشت خورده است در کارپوشه ادمین
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetClientRejectedDocumentWorkshopsForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های آپلود شده توسط کلاینت در کارگاه که برگشت خورده اند در کارپوشه ادمین
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentByWorkshopIdForAdmin(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های برگشت خورده برای کلاینت
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentForClient(long workshopId, long accountId);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
@@ -14,4 +15,6 @@ public interface ILeftWorkTempRepository:IRepository<long,LeftWorkTemp>
|
||||
/// <returns></returns>
|
||||
Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId);
|
||||
void Remove(LeftWorkTemp entity);
|
||||
List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId);
|
||||
Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
return shiftDetails.shiftType switch
|
||||
{
|
||||
WorkshopShiftStatus.Regular => CalculateRegularShiftDate(rollCallStartDate, offset),
|
||||
WorkshopShiftStatus.Rotating => FindRotatingShift(rollCallEndDate,rollCallEndDate,shiftDetails.rotatingShifts).start.Date,
|
||||
WorkshopShiftStatus.Rotating => FindRotatingShift(rollCallStartDate,rollCallEndDate,shiftDetails.rotatingShifts).start.Date,
|
||||
WorkshopShiftStatus.Irregular => rollCallStartDate.Date,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
@@ -22,4 +23,7 @@ public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
|
||||
|
||||
List<LateToWorkEarlyExistSpannig> LateToWorkEarlyExit(List<GroupedRollCalls> groupedRollCall,
|
||||
ICollection<CustomizeWorkshopEmployeeSettingsShift> shiftSettings, List<LeaveViewModel> leavList);
|
||||
|
||||
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
||||
DateTime contractEnd, string shiftwork);
|
||||
}
|
||||
@@ -87,6 +87,9 @@ namespace Company.Domain.RollCallAgg
|
||||
long workshopId);
|
||||
|
||||
Task<List<RollCall>> GetRollCallsInShiftDate(DateTime rollCallShiftDate, long employeeId, long workshopId);
|
||||
|
||||
Task<List<RollCall>> GetRollCallsUntilNowWithWorkshopIdEmployeeIds(long workshopId, List<long> employeeIds,
|
||||
DateTime fromDate);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace Company.Domain.RollCallAgg
|
||||
return this;
|
||||
}
|
||||
|
||||
private void SetShiftDate(IRollCallDomainService service)
|
||||
public void SetShiftDate(IRollCallDomainService service)
|
||||
{
|
||||
ShiftDate = service.GetEmployeeShiftDateByRollCallStartDate(WorkshopId, EmployeeId, StartDate!.Value,EndDate.Value);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
|
||||
using OfficeOpenXml.Style;
|
||||
using OfficeOpenXml;
|
||||
using System.Drawing;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagement.Infrastructure.Excel.CWS;
|
||||
public class CustomizeWorkshopGroupExcelViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ShiftType { get; set; }
|
||||
public string Shifts { get; set; }
|
||||
public string Salary { get; set; }
|
||||
public List<CustomizeWorkshopEmployeeExcelViewModel> EmployeeSettings { get; set; }
|
||||
}
|
||||
|
||||
public class CustomizeWorkshopEmployeeExcelViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ShiftType { get; set; }
|
||||
public string Shifts { get; set; }
|
||||
public int LeavePermitted { get; set; }
|
||||
public string Salary { get; set; }
|
||||
}
|
||||
public class CustomizeWorkshopGroupSettingExcelGenerator
|
||||
{
|
||||
public static byte[] Generate(List<CustomizeWorkshopGroupExcelViewModel> groups)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
using (var package = new ExcelPackage())
|
||||
{
|
||||
var worksheet = package.Workbook.Worksheets.Add("GroupsAndEmployees");
|
||||
|
||||
// Headers
|
||||
worksheet.Cells[1, 1].Value = "نام گروه";
|
||||
worksheet.Cells[1, 2].Value = "نوع شیفت گروه";
|
||||
worksheet.Cells[1, 3].Value = "شیفت گروه";
|
||||
worksheet.Cells[1, 4].Value = "حقوق گروه";
|
||||
|
||||
worksheet.Cells[1, 5].Value = "نام پرسنل";
|
||||
worksheet.Cells[1, 6].Value = "مجاز مرخصی پرسنل";
|
||||
worksheet.Cells[1, 7].Value = "نوع شیفت پرسنل";
|
||||
worksheet.Cells[1, 8].Value = "شیفت پرسنل";
|
||||
worksheet.Cells[1, 9].Value = "حقوق پرسنل";
|
||||
|
||||
using (var range = worksheet.Cells[1, 1, 1, 9])
|
||||
{
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
range.Style.Font.Bold = true;
|
||||
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
range.Style.Fill.BackgroundColor.SetColor(Color.LightGray); // رنگ پس زمینه خاکستری
|
||||
|
||||
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
}
|
||||
|
||||
int row = 2;
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
var employees = group.EmployeeSettings ?? new List<CustomizeWorkshopEmployeeExcelViewModel>();
|
||||
int groupStartRow = row;
|
||||
int groupEndRow = employees.Count > 0 ? (row + employees.Count - 1) : row;
|
||||
|
||||
if (employees.Count == 0)
|
||||
{
|
||||
// گروه بدون پرسنل
|
||||
worksheet.Cells[row, 1].Value = group.Name;
|
||||
worksheet.Cells[row, 2].Value = group.ShiftType;
|
||||
worksheet.Cells[row, 3].Value = group.Shifts;
|
||||
worksheet.Cells[row, 4].Value = Convert.ToInt32(group.Salary);
|
||||
|
||||
ApplyGroupStyle(worksheet, row, row);
|
||||
worksheet.Cells[row, 4].Style.Numberformat.Format = "#,##0";
|
||||
using (var thickBorderRange = worksheet.Cells[groupEndRow, 1, groupEndRow, 9])
|
||||
{
|
||||
thickBorderRange.Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var employee in employees)
|
||||
{
|
||||
worksheet.Cells[row, 5].Value = employee.Name;
|
||||
worksheet.Cells[row, 6].Value = employee.LeavePermitted;
|
||||
worksheet.Cells[row, 7].Value = employee.ShiftType;
|
||||
worksheet.Cells[row, 8].Value = employee.Shifts;
|
||||
worksheet.Cells[row, 9].Value = Convert.ToInt32(employee.Salary);
|
||||
|
||||
ApplyEmployeeStyle(worksheet, row);
|
||||
worksheet.Cells[row, 9].Style.Numberformat.Format = "#,##0";
|
||||
row++;
|
||||
}
|
||||
|
||||
// Merge اطلاعات گروه برای تمام پرسنل
|
||||
worksheet.Cells[groupStartRow, 1, groupEndRow, 1].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 1].Value = group.Name;
|
||||
|
||||
worksheet.Cells[groupStartRow, 2, groupEndRow, 2].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 2].Value = group.ShiftType;
|
||||
|
||||
worksheet.Cells[groupStartRow, 3, groupEndRow, 3].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 3].Value = group.Shifts;
|
||||
|
||||
worksheet.Cells[groupStartRow, 4, groupEndRow, 4].Merge = true;
|
||||
worksheet.Cells[groupStartRow, 4].Value = Convert.ToInt32(group.Salary);
|
||||
|
||||
ApplyGroupStyle(worksheet, groupStartRow, groupEndRow);
|
||||
|
||||
worksheet.Cells[groupStartRow, 4, groupEndRow, 4].Style.Numberformat.Format = "#,##0";
|
||||
|
||||
|
||||
worksheet.Cells[groupEndRow, 1, groupEndRow, 9].Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
|
||||
|
||||
}
|
||||
}
|
||||
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
|
||||
for (int i = 2; i <= worksheet.Dimension.Rows; i++)
|
||||
{
|
||||
worksheet.Row(i).Height = 50;
|
||||
}
|
||||
|
||||
int groupShiftCol = 3;
|
||||
int employeeShiftCol = 8;
|
||||
int groupSalary = 4;
|
||||
int employeeSalary = 9;
|
||||
int employeeName =5;
|
||||
worksheet.Columns[groupShiftCol].Width = 15;
|
||||
worksheet.Columns[employeeShiftCol].Width = 15;
|
||||
worksheet.Columns[groupSalary].Width = 16;
|
||||
worksheet.Columns[employeeSalary].Width = 16;
|
||||
worksheet.Columns[employeeName].Width = 24;
|
||||
worksheet.View.RightToLeft = true; // فارسی
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyEmployeeStyle(ExcelWorksheet worksheet, int row)
|
||||
{
|
||||
using (var range = worksheet.Cells[row, 5, row, 9])
|
||||
{
|
||||
//range.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
//range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(198, 239, 206)); // سبز خیلی روشن
|
||||
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
|
||||
// اضافه کردن بوردر به همهی سلولهای ردیف پرسنل
|
||||
range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
|
||||
|
||||
range.Style.WrapText = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyGroupStyle(ExcelWorksheet worksheet, int startRow, int endRow)
|
||||
{
|
||||
using (var range = worksheet.Cells[startRow, 1, endRow, 4])
|
||||
{
|
||||
//range.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
//range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 255, 204)); // زرد خیلی روشن
|
||||
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
|
||||
// اضافه کردن بوردر به همهی سلولهای گروه
|
||||
range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
|
||||
|
||||
range.Style.WrapText = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,17 @@ public class CaseManagementExcelGenerator
|
||||
{
|
||||
OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
using var package = new ExcelPackage();
|
||||
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
|
||||
CreateSheet(data, package,"همه");
|
||||
CreateSheet(data.Where(x=>x.Status ==2).ToList(), package,"فعال");
|
||||
CreateSheet(data.Where(x=>x.Status == 1).ToList(), package,"غیرفعال");
|
||||
CreateSheet(data.Where(x=>x.Status == 3).ToList(), package,"خروج موقت");
|
||||
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
|
||||
private static void CreateSheet(List<FileExcelViewModel> data, ExcelPackage package,string sheetName)
|
||||
{
|
||||
var worksheet = package.Workbook.Worksheets.Add(sheetName);
|
||||
|
||||
var indexCell = worksheet.Cells[1, 1];
|
||||
indexCell.Value = "ردیف";
|
||||
@@ -85,7 +95,6 @@ public class CaseManagementExcelGenerator
|
||||
|
||||
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
worksheet.View.RightToLeft = true;
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
|
||||
private static bool RequiresMoneyToDouble(string propertyName)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -36,8 +36,12 @@ public class ComputingViewModel
|
||||
public string MarriedAllowance { get; set; }
|
||||
public string RotatingShiftValue { get; set; }
|
||||
public List<RotatingShiftViewModel> RotatingResultList { get; set; }
|
||||
public bool HasRollCall { get; set; }
|
||||
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string YearAndMonth { get; set; }
|
||||
|
||||
public bool HasRotatingShift { get; set; }
|
||||
|
||||
//public List<string> holidays;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
@@ -9,4 +10,6 @@ public class CustomizeWorkshopSettingsViewModel
|
||||
public string Name { get; set; }
|
||||
public WorkshopShiftStatus WorkshopShiftStatus { get; set; }
|
||||
public List<CustomizeWorkshopGroupSettingsViewModel> GroupSettings { get; set; }
|
||||
public TimeOnly Offset { get; set; }
|
||||
|
||||
}
|
||||
@@ -2,8 +2,10 @@
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
|
||||
@@ -34,7 +36,8 @@ public interface ICustomizeWorkshopSettingsApplication
|
||||
OperationResult EditSimpleRollCallGroupSetting(EditCustomizeWorkshopGroupSettings command);
|
||||
|
||||
#region Vafa
|
||||
OperationResult EditSimpleRollCallEmployeeSetting(EditCustomizeEmployeeSettings command);
|
||||
OperationResult EditSimpleRollCallEmployeeSetting(EditCustomizeEmployeeSettings command,
|
||||
List<ReCalculateRollCallValues> reCalculateCommand);
|
||||
#endregion
|
||||
|
||||
OperationResult RemoveGroupSettings(long employeeSettingsId);
|
||||
@@ -89,4 +92,10 @@ public interface ICustomizeWorkshopSettingsApplication
|
||||
|
||||
|
||||
bool HasAnyEmployeeWithoutGroup(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// این متد چک میکند که آیا شیفت پرسنل تغییر کرده است یا نه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool CheckEmployeeShiftHasChanged(EditCustomizeEmployeeSettings command);
|
||||
}
|
||||
@@ -94,4 +94,14 @@ public class CreateEmployee
|
||||
public long WorkshopId { get; set; }
|
||||
public long? PersonelCode { get; set; }
|
||||
|
||||
public bool IsAuthorized { get; set; }
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; set; }
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public class EmployeeDataFromApiViewModel
|
||||
{
|
||||
public Gender Gender { get; set; }
|
||||
public string FName { get; set; }
|
||||
public string LName { get; set; }
|
||||
public string FatherName { get; set; }
|
||||
public string BirthDate { get; set; }
|
||||
/// <summary>
|
||||
/// کدملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; set; }
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; set; }
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
using AccountManagement.Application.Contracts.Media;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public class GetEditEmployeeInEmployeeDocumentViewModel
|
||||
{
|
||||
@@ -14,4 +16,5 @@ public class GetEditEmployeeInEmployeeDocumentViewModel
|
||||
public string Nationality { get; set; } = string.Empty;
|
||||
public string Gender { get; set; } = string.Empty;
|
||||
public bool IsAuthorized { get; set; }
|
||||
public MediaViewModel Media { get; set; }
|
||||
}
|
||||
@@ -75,6 +75,8 @@ public interface IEmployeeApplication
|
||||
|
||||
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
||||
|
||||
Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
@@ -8,7 +10,19 @@ public interface IEmployeeClientTempApplication
|
||||
OperationResult Create(CreateEmployeeClientTemp command);
|
||||
|
||||
EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId);
|
||||
Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class EmployeeClientTempViewModel
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public DateTime StartWorkDate { get; set; }
|
||||
|
||||
public string MaritalStatus { get; set; }
|
||||
}
|
||||
|
||||
public class EmployeeClientTempGetDetailsViewModel
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace CompanyManagment.App.Contracts.EmployeeDocuments
|
||||
public long WorkshopId { get; set; }
|
||||
public IFormFile PictureFile { get; set; }
|
||||
public DocumentItemLabel Label { get; set; }
|
||||
}
|
||||
public bool WithoutPicture { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,77 @@ namespace CompanyManagment.App.Contracts.EmployeeDocuments
|
||||
/// </summary>
|
||||
OperationResult AddRangeEmployeeDocumentItemsByAdmin(long workshopId, long employeeId,
|
||||
List<AddEmployeeDocumentItem> command);
|
||||
|
||||
#region Mahan
|
||||
/// <summary>
|
||||
/// کارگاهی که افزودن پرسنل کرده اند. بر اساس نقش فیلتر میشوند
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ICollection<WorkshopWithEmployeeDocumentsViewModel>> GetWorkshopDocumentCreatedEmployeeForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های برگشت خورده براساس دسترسی افراد و نقششان. یک مدرک برگشت خورده به تمامی کسانی که به آن کارگاه دسترسی دارند و تمامی کسانی که هم نقش آپلود کننده بوده اند نمایش داده میشود
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ICollection<WorkshopWithEmployeeDocumentsViewModel>> GetWorkshopDocumentRejectedForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های برگشت خورده براساس دسترسی افراد و نقششان. یک مدرک برگشت خورده به تمامی کسانی که به آن کارگاه دسترسی دارند و تمامی کسانی که هم نقش آپلود کننده بوده اند نمایش داده میشود
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetRejectedItemsByWorkshopIdAndRoleForAdminWorkFlow(long workshopId,
|
||||
long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// کارگاه هایی که افزودن پرسنل کرده اند و مدارک آنها ناقص است
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetCreatedEmployeesWorkshopDocumentForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// پرسنلی که افزوده شده اند در کارگاه و آپلود مدارک آنها ناقص است
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetCreatedEmployeesDocumentByWorkshopIdForAdmin(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// لیست کارگاه هایی که مدارک آپلود شده توسط کلاینت برگشت خورده است در کارپوشه ادمین
|
||||
/// </summary>
|
||||
/// <param name="workshops"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetClientRejectedDocumentWorkshopsForAdmin(
|
||||
List<long> workshops, long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های آپلود شده توسط کلاینت در کارگاه که برگشت خورده اند در کارپوشه ادمین
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentByWorkshopIdForAdmin(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// مدارک های برگشت خورده برای کلاینت
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentForClient(long workshopId, long accountId);
|
||||
|
||||
#endregion
|
||||
EmployeeDocumentItemViewModel GetOneDocumentItemDetailsForAdmin(long employeeId, long workshopId,long documentItemId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
@@ -30,6 +31,23 @@ public interface ILeftWorkTempApplication
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> AcceptLeftWork(AcceptLeftWorkTemp command);
|
||||
|
||||
Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId);
|
||||
|
||||
|
||||
List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId);
|
||||
}
|
||||
|
||||
public class LeftWorkTempViewModel
|
||||
{
|
||||
public long LeftWorkId { get; set; }
|
||||
public DateTime StartWork { get; set; }
|
||||
public DateTime LeftWork { get; set; }
|
||||
public DateTime LastDayStanding { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public long JobId { get; set; }
|
||||
public LeftWorkTempType LeftWorkType { get; set; }
|
||||
}
|
||||
|
||||
public class AcceptLeftWorkTemp
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -42,6 +42,9 @@ namespace CompanyManagment.App.Contracts.RollCall
|
||||
DateTime end);
|
||||
|
||||
List<RollCallsByDateViewModel> GetUndefinedRollCallWorkFlowsService(long workshopId, DateTime durationStart, DateTime durationEnd);
|
||||
|
||||
|
||||
|
||||
OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa);
|
||||
|
||||
|
||||
@@ -114,5 +117,18 @@ namespace CompanyManagment.App.Contracts.RollCall
|
||||
|
||||
OperationResult SetModifyTypeToEditByEmployerForRollCallsInDate(long workshopId, long employeeId, string absenceDate);
|
||||
List<RollCallViewModel> GetWorkshopEmployeeRollCallsWithUndefinedForDate(long workshopId, long employeeId, string date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه مجدد مقادیر حضور غیاب
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
OperationResult RecalculateValues(long workshopId, List<ReCalculateRollCallValues> command);
|
||||
}
|
||||
public class ReCalculateRollCallValues
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
public string FromDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
|
||||
@@ -8,4 +9,6 @@ public interface IRollCallMandatoryApplication
|
||||
{
|
||||
bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart);
|
||||
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking);
|
||||
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
||||
DateTime contractEnd, string shiftwork);
|
||||
}
|
||||
@@ -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,5 +16,6 @@ public class RotatingShiftViewModel
|
||||
public bool IsEveningShift { get; set; }
|
||||
public bool IsNightShift { get; set; }
|
||||
public string RotatingDate { get; set; }
|
||||
public int WinRate { get; set; }
|
||||
|
||||
}
|
||||
@@ -16,9 +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.CustomizeCheckoutTempAgg;
|
||||
using Company.Domain.PersonnelCodeAgg;
|
||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||
|
||||
namespace CompanyManagment.Application
|
||||
{
|
||||
@@ -33,9 +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)
|
||||
IRollCallMandatoryRepository rollCallMandatoryRepository, IContractRepository contractRepository, IWorkshopRepository workshopRepository, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, ICheckoutRepository checkoutRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository)
|
||||
{
|
||||
_customizeCheckoutRepository = customizeCheckoutRepository;
|
||||
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
|
||||
@@ -46,6 +54,9 @@ namespace CompanyManagment.Application
|
||||
_workshopRepository = workshopRepository;
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
_personnelCodeRepository = personnelCodeRepository;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
_checkoutRepository = checkoutRepository;
|
||||
_customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
|
||||
}
|
||||
|
||||
public List<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
@@ -86,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 =>
|
||||
@@ -110,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();
|
||||
@@ -143,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();
|
||||
@@ -166,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);
|
||||
@@ -215,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;
|
||||
@@ -258,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);
|
||||
|
||||
@@ -270,8 +290,8 @@ namespace CompanyManagment.Application
|
||||
|
||||
var statusesWithActiveLeftWorks = statuses
|
||||
.Where(status => workshopLeftWorksInMonth.Any(leftWork => leftWork.EmployeeId == status.EmployeeId &&
|
||||
leftWork.StartWorkDateGr.Date <= status.StartDateGr.Date &&
|
||||
leftWork.LeftWorkDateGr.Date >= status.EndDateGr.Date)).ToList();
|
||||
leftWork.StartWorkDateGr.Date <= status.EndDateGr.Date &&
|
||||
leftWork.LeftWorkDateGr.Date >= status.StartDateGr.Date)).ToList();
|
||||
|
||||
|
||||
|
||||
@@ -299,8 +319,8 @@ namespace CompanyManagment.Application
|
||||
|
||||
if (workshopId == 170)
|
||||
{
|
||||
List<long> employeesIds = [ 45084, 7980, 5976,45214,45215];
|
||||
foreach (var employeesId in employeesIds)
|
||||
var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(117).Select(x => x.EmployeeId).ToList();
|
||||
foreach (var employeesId in exceptionEmployeeIds)
|
||||
{
|
||||
|
||||
var status = new RollCallEmployeeStatusViewModel()
|
||||
@@ -331,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,
|
||||
@@ -350,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.ContractAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg.ValueObjects;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
@@ -21,6 +19,7 @@ using Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
|
||||
using Company.Domain.PersonnelCodeAgg;
|
||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||
|
||||
namespace CompanyManagment.Application
|
||||
{
|
||||
@@ -35,8 +34,10 @@ namespace CompanyManagment.Application
|
||||
private readonly IContractRepository _contractRepository;
|
||||
private readonly IPersonnelCodeRepository _personnelCodeRepository;
|
||||
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
|
||||
private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository;
|
||||
|
||||
public CustomizeCheckoutTempApplication(IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, ILeftWorkRepository leftWorkRepository, IEmployeeRepository employeeRepository, IRollCallMandatoryRepository rollCallMandatoryRepository, IContractRepository contractRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IWorkshopRepository workshopRepository, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, IPersonnelCodeRepository personnelCodeRepository)
|
||||
|
||||
public CustomizeCheckoutTempApplication(IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, ILeftWorkRepository leftWorkRepository, IEmployeeRepository employeeRepository, IRollCallMandatoryRepository rollCallMandatoryRepository, IContractRepository contractRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IWorkshopRepository workshopRepository, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository)
|
||||
{
|
||||
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
@@ -47,6 +48,7 @@ namespace CompanyManagment.Application
|
||||
_workshopRepository = workshopRepository;
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
_personnelCodeRepository = personnelCodeRepository;
|
||||
_customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
|
||||
}
|
||||
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
@@ -72,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();
|
||||
@@ -95,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();
|
||||
@@ -125,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);
|
||||
|
||||
@@ -152,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);
|
||||
@@ -247,8 +249,8 @@ namespace CompanyManagment.Application
|
||||
|
||||
if (workshopId == 170)
|
||||
{
|
||||
List<long> employeesIds = [45084, 7980, 5976, 45214,45215];
|
||||
foreach (var employeesId in employeesIds)
|
||||
var exceptionEmployeeIds = _customizeWorkshopGroupSettingsRepository.GetEmployeeSettingsByGroupSettingsId(117).Select(x => x.EmployeeId).ToList();
|
||||
foreach (var employeesId in exceptionEmployeeIds)
|
||||
{
|
||||
|
||||
var status = new RollCallEmployeeStatusViewModel()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ using Company.Domain.RollCallEmployeeAgg;
|
||||
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using Company.Domain.EmployeeAuthorizeTempAgg;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -49,7 +50,6 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
||||
private readonly ICustomizeWorkshopSettingsApplication _customizeWorkshopSettingsApplication;
|
||||
private readonly IEmployeeDocumentsApplication _employeeDocumentsApplication;
|
||||
private readonly IEmployeeDocumentsRepository _employeeDocumentsRepository;
|
||||
private readonly IEmployeeBankInformationApplication _employeeBankInformationApplication;
|
||||
private readonly ILeftWorkTempRepository _leftWorkTempRepository;
|
||||
private readonly IUidService _uidService;
|
||||
@@ -58,8 +58,9 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
private readonly IPersonnelCodeRepository _personnelCodeRepository;
|
||||
private readonly IEmployeeClientTempRepository _employeeClientTempRepository;
|
||||
private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository;
|
||||
private readonly IEmployeeAuthorizeTempRepository _employeeAuthorizeTempRepository;
|
||||
|
||||
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IEmployeeDocumentsRepository employeeDocumentsRepository, IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, ILeftWorkRepository leftWorkRepository) : base(context)
|
||||
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository, IWebHostEnvironment webHostEnvironment, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, ICustomizeWorkshopSettingsApplication customizeWorkshopSettingsApplication, IEmployeeDocumentsApplication employeeDocumentsApplication, IEmployeeDocumentsRepository employeeDocumentsRepository, IEmployeeBankInformationApplication employeeBankInformationApplication, ILeftWorkTempRepository leftWorkTempRepository, IUidService uidService, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, IPersonnelCodeRepository personnelCodeRepository, IEmployeeClientTempRepository employeeClientTempRepository, ICustomizeWorkshopGroupSettingsRepository customizeWorkshopGroupSettingsRepository, ILeftWorkRepository leftWorkRepository, IEmployeeAuthorizeTempRepository employeeAuthorizeTempRepository) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_WorkShopRepository = workShopRepository;
|
||||
@@ -68,15 +69,14 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication;
|
||||
_employeeDocumentsApplication = employeeDocumentsApplication;
|
||||
_employeeDocumentsRepository = employeeDocumentsRepository;
|
||||
_employeeBankInformationApplication = employeeBankInformationApplication;
|
||||
_leftWorkTempRepository = leftWorkTempRepository;
|
||||
_uidService = uidService;
|
||||
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
|
||||
_personnelCodeRepository = personnelCodeRepository;
|
||||
_employeeClientTempRepository = employeeClientTempRepository;
|
||||
_customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
_employeeAuthorizeTempRepository = employeeAuthorizeTempRepository;
|
||||
_EmployeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
@@ -201,10 +201,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
var dateOfBirth = command.DateOfBirth != null ? command.DateOfBirth.ToGeorgianDateTime() : initial.ToGeorgianDateTime();
|
||||
var dateOfIssue = command.DateOfIssue != null ? command.DateOfIssue.ToGeorgianDateTime() : initial.ToGeorgianDateTime();
|
||||
|
||||
|
||||
|
||||
var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth,
|
||||
dateOfIssue,
|
||||
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,
|
||||
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.IdNumberSerial, command.IdNumberSeri,
|
||||
command.Phone, command.Address,
|
||||
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
|
||||
command.FieldOfStudy, command.BankCardNumber,
|
||||
@@ -212,7 +212,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
command.InsuranceHistoryByMonth, command.NumberOfChildren, command.OfficePhone, command.MclsUserName, command.MclsPassword, command.EserviceUserName, command.EservicePassword,
|
||||
command.TaxOfficeUserName, command.TaxOfficepassword, command.SanaUserName, command.SanaPassword);
|
||||
|
||||
|
||||
if (command.IsAuthorized)
|
||||
{
|
||||
employeeData.Authorized();
|
||||
}
|
||||
_EmployeeRepository.Create(employeeData);
|
||||
_EmployeeRepository.SaveChanges();
|
||||
|
||||
@@ -1248,10 +1251,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber;
|
||||
|
||||
var newEmployee = new Employee(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, apiBirthDate,
|
||||
dateOfIssue, null, identityInfo.NationalId, idNumber, gender, "ایرانی");
|
||||
dateOfIssue, null, identityInfo.NationalId, idNumber, gender, "ایرانی", identityInfo.ShenasnameSerial, identityInfo.ShenasnameSeri);
|
||||
newEmployee.Authorized();
|
||||
await _EmployeeRepository.CreateAsync(newEmployee);
|
||||
await _context.SaveChangesAsync();
|
||||
await _EmployeeRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel()
|
||||
{
|
||||
@@ -1484,15 +1487,25 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
{
|
||||
employee.Edit(command.FName, command.LName, command.FatherName, command.BirthDate.ToGeorgianDateTime(),
|
||||
employee.DateOfIssue, employee.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender,
|
||||
command.Nationality,
|
||||
employee.Phone, employee.Address, employee.State, employee.City, employee.MaritalStatus,
|
||||
employee.MilitaryService,
|
||||
command.Nationality, employee.Phone, employee.Address, employee.State, employee.City,
|
||||
command.MaritalStatus, command.MilitaryService,
|
||||
employee.LevelOfEducation, employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch,
|
||||
employee.InsuranceCode, employee.InsuranceHistoryByYear, employee.InsuranceHistoryByMonth,
|
||||
employee.NumberOfChildren, employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
|
||||
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
|
||||
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
employee.EditAuthorizeEmployee(employee.DateOfIssue, employee.PlaceOfIssue,
|
||||
employee.Phone, employee.Address, employee.State, employee.City, command.MaritalStatus,
|
||||
command.MilitaryService, employee.LevelOfEducation, employee.FieldOfStudy,
|
||||
employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode,
|
||||
employee.InsuranceHistoryByYear, employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
|
||||
employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
|
||||
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
|
||||
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
|
||||
}
|
||||
await _EmployeeRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded();
|
||||
@@ -1503,5 +1516,105 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
return await _EmployeeRepository.WorkedEmployeesInWorkshopSelectList(workshopId);
|
||||
}
|
||||
|
||||
public async Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate)
|
||||
{
|
||||
var op = new OperationResult<EmployeeDataFromApiViewModel>();
|
||||
var birthDateGr = birthDate.ToGeorgianDateTime();
|
||||
|
||||
if (_EmployeeRepository.Exists(x => x.NationalCode == nationalCode))
|
||||
{
|
||||
var employee = _EmployeeRepository.GetByNationalCode(nationalCode);
|
||||
|
||||
if (employee.IsAuthorized == false)
|
||||
{
|
||||
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
|
||||
if (apiResult.ResponseContext.Status.Code != 0)
|
||||
{
|
||||
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
|
||||
}
|
||||
var basicInfo = apiResult.BasicInformation;
|
||||
var identityInfo = apiResult.IdentificationInformation;
|
||||
|
||||
var gender = basicInfo.GenderEnum switch
|
||||
{
|
||||
Gender.Female => "زن",
|
||||
Gender.Male => "مرد",
|
||||
_ => throw new AggregateException()
|
||||
};
|
||||
|
||||
var idNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber;
|
||||
employee.Edit(basicInfo.FirstName, basicInfo.LastName, basicInfo.FatherName, birthDateGr,
|
||||
employee.DateOfIssue, employee.PlaceOfIssue, identityInfo.NationalId, idNumber,
|
||||
gender, "ایرانی", employee.Phone, employee.Address, employee.State, employee.City,
|
||||
employee.MaritalStatus, employee.MilitaryService, employee.LevelOfEducation,
|
||||
employee.FieldOfStudy, employee.BankCardNumber, employee.BankBranch, employee.InsuranceCode, employee.InsuranceHistoryByYear,
|
||||
employee.InsuranceHistoryByMonth, employee.NumberOfChildren,
|
||||
employee.OfficePhone, employee.MclsUserName, employee.MclsPassword,
|
||||
employee.EserviceUserName, employee.EservicePassword, employee.TaxOfficeUserName,
|
||||
employee.TaxOfficepassword, employee.SanaUserName, employee.SanaPassword);
|
||||
|
||||
employee.Authorized();
|
||||
await _EmployeeRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
|
||||
}
|
||||
else
|
||||
{
|
||||
EmployeeDataFromApiViewModel data;
|
||||
if (_employeeAuthorizeTempRepository.Exists(x => x.NationalCode == nationalCode))
|
||||
{
|
||||
var employeeAuthorizeTemp = await _employeeAuthorizeTempRepository.GetByNationalCode(nationalCode);
|
||||
if (employeeAuthorizeTemp.BirthDate.ToFarsi() != birthDate)
|
||||
{
|
||||
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
|
||||
}
|
||||
|
||||
data = new EmployeeDataFromApiViewModel()
|
||||
{
|
||||
BirthDate = employeeAuthorizeTemp.BirthDate.ToFarsi(),
|
||||
NationalCode = employeeAuthorizeTemp.NationalCode,
|
||||
IdNumber = employeeAuthorizeTemp.IdNumber,
|
||||
FName = employeeAuthorizeTemp.FName,
|
||||
FatherName = employeeAuthorizeTemp.FatherName,
|
||||
Gender = employeeAuthorizeTemp.Gender,
|
||||
LName = employeeAuthorizeTemp.LName,
|
||||
};
|
||||
return op.Succcedded(data);
|
||||
}
|
||||
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
|
||||
if (apiResult.ResponseContext.Status.Code != 0)
|
||||
{
|
||||
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
|
||||
}
|
||||
var basicInfo = apiResult.BasicInformation;
|
||||
var identityInfo = apiResult.IdentificationInformation;
|
||||
|
||||
data = new EmployeeDataFromApiViewModel()
|
||||
{
|
||||
BirthDate = identityInfo.BirthDate,
|
||||
NationalCode = identityInfo.NationalId,
|
||||
IdNumber = identityInfo.ShenasnamehNumber == "0" ? identityInfo.NationalId : identityInfo.ShenasnamehNumber,
|
||||
FatherName = basicInfo.FatherName,
|
||||
FName = basicInfo.FirstName,
|
||||
Gender = basicInfo.GenderEnum,
|
||||
LName = basicInfo.LastName,
|
||||
IdNumberSeri = identityInfo.ShenasnameSeri,
|
||||
IdNumberSerial = identityInfo.ShenasnameSerial
|
||||
};
|
||||
|
||||
var newAuthorizeTemp = new EmployeeAuthorizeTemp(data.Gender, data.FName, data.LName, data.FatherName, birthDateGr, data.NationalCode, data.IdNumber, data.IdNumberSerial, data.IdNumberSeri);
|
||||
await _employeeAuthorizeTempRepository.CreateAsync(newAuthorizeTemp);
|
||||
await _employeeAuthorizeTempRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using _0_Framework.Application;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
@@ -29,4 +31,10 @@ public class EmployeeClientTempApplication : IEmployeeClientTempApplication
|
||||
{
|
||||
return _employeeClientTempRepository.GetDetails(employeeId, workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId)
|
||||
{
|
||||
return await _employeeClientTempRepository.GetByEmployeeId(employeeId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType,roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == employeeId))
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace CompanyManagment.Application
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaOpResult.SendId, entity.id, item.Label, uploaderId, uploaderType);
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaOpResult.SendId, entity.id, item.Label, uploaderId, uploaderType,roleId);
|
||||
newEntities.Add(newEntity);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace CompanyManagment.Application
|
||||
public OperationResult DeleteUnsubmittedItems(long workshopId, long employeeId)
|
||||
{
|
||||
OperationResult op = new();
|
||||
(_, UserType userType) = _authHelper.GetUserTypeWithId();
|
||||
(_, UserType userType,_) = _authHelper.GetUserTypeWithId();
|
||||
var entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId);
|
||||
var items =
|
||||
entity.EmployeeDocumentItemCollection.Where(x =>
|
||||
@@ -244,7 +244,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType, roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == command.EmployeeId))
|
||||
return op.Failed("پرسنل یافت نشد");
|
||||
@@ -289,7 +289,7 @@ namespace CompanyManagment.Application
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(command.WorkshopId, command.EmployeeId, mediaOpResult.SendId, entity.id, command.Label, uploaderId, uploaderType);
|
||||
var newEntity = new EmployeeDocumentItem(command.WorkshopId, command.EmployeeId, mediaOpResult.SendId, entity.id, command.Label, uploaderId, uploaderType, roleId);
|
||||
|
||||
_employeeDocumentItemRepository.Create(newEntity);
|
||||
_employeeDocumentItemRepository.SaveChanges();
|
||||
@@ -311,7 +311,7 @@ namespace CompanyManagment.Application
|
||||
.ToList();
|
||||
|
||||
|
||||
var (userId, userType) = _authHelper.GetUserTypeWithId();
|
||||
var (userId, userType,_) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
var unsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted &&
|
||||
x.UploaderType == UserType.Client).ToList();
|
||||
@@ -356,7 +356,7 @@ namespace CompanyManagment.Application
|
||||
if (!HasRequiredDocuments(notRejectedDocs, entity.Gender))
|
||||
return op.Failed("مدارک الزامی بارگذاری نشده اند");
|
||||
|
||||
var (userId, userType) = _authHelper.GetUserTypeWithId();
|
||||
var (userId, userType, roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
var unsubmittedDocs = notRejectedDocs.Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted).ToList();
|
||||
|
||||
@@ -386,10 +386,9 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType,roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == employeeId))
|
||||
|
||||
return op.Failed("پرسنل یافت نشد");
|
||||
|
||||
|
||||
@@ -430,11 +429,12 @@ namespace CompanyManagment.Application
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaOpResult.SendId, entity.id, item.Label, uploaderId, uploaderType, DocumentStatus.SubmittedByClient);
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaOpResult.SendId, entity.id, item.Label, uploaderId, uploaderType, roleId,DocumentStatus.SubmittedByClient);
|
||||
newEntities.Add(newEntity);
|
||||
}
|
||||
|
||||
var currentItems = entity.EmployeeDocumentItemCollection.GroupBy(x => x.DocumentLabel)
|
||||
.Where(x => command.Any(a => a.Label == x.Key))
|
||||
.Select(x => x.MaxBy(y => y.CreationDate));
|
||||
|
||||
//This can bite!
|
||||
@@ -660,6 +660,12 @@ namespace CompanyManagment.Application
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentForClient(long workshopId, long accountId)
|
||||
{
|
||||
return _employeeDocumentsRepository.GetClientRejectedDocumentForClient(workshopId, accountId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Admin Only Methods
|
||||
@@ -670,7 +676,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType, roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == employeeId))
|
||||
@@ -725,7 +731,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType,roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == employeeId))
|
||||
@@ -778,7 +784,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType, roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
//ToDo: add check for leftwork
|
||||
if (!_employeeRepository.Exists(x => x.id == command.EmployeeId))
|
||||
@@ -834,7 +840,7 @@ namespace CompanyManagment.Application
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(command.WorkshopId, command.EmployeeId, mediaOpResult.SendId, entity.id, command.Label, uploaderId, uploaderType);
|
||||
var newEntity = new EmployeeDocumentItem(command.WorkshopId, command.EmployeeId, mediaOpResult.SendId, entity.id, command.Label, uploaderId, uploaderType, roleId);
|
||||
|
||||
_employeeDocumentItemRepository.Create(newEntity);
|
||||
_employeeDocumentItemRepository.SaveChanges();
|
||||
@@ -856,7 +862,7 @@ namespace CompanyManagment.Application
|
||||
//if (!HasRequiredDocuments(notRejectedDocs, entity.Gender))
|
||||
// return op.Failed("مدارک الزامی بارگذاری نشده اند");
|
||||
|
||||
var (userId, operatorType) = _authHelper.GetUserTypeWithId();
|
||||
var (userId, operatorType, _) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
var adminUnsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.SubmittedByClient ||
|
||||
(x.DocumentStatus == DocumentStatus.Unsubmitted && x.UploaderType == UserType.Admin)).ToList();
|
||||
@@ -895,7 +901,7 @@ namespace CompanyManagment.Application
|
||||
//if (!HasRequiredDocuments(notRejectedDocs, entity.Gender))
|
||||
// return op.Failed("مدارک الزامی بارگذاری نشده اند");
|
||||
|
||||
var (userId, operatorType) = _authHelper.GetUserTypeWithId();
|
||||
var (userId, operatorType, _) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
var adminUnsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.SubmittedByClient ||
|
||||
(x.DocumentStatus == DocumentStatus.Unsubmitted && x.UploaderType == UserType.Admin)).ToList();
|
||||
@@ -1131,7 +1137,7 @@ namespace CompanyManagment.Application
|
||||
OperationResult op = new();
|
||||
var entity = _employeeDocumentItemRepository.Get(documentItemId);
|
||||
|
||||
(long operatorId, _) = _authHelper.GetUserTypeWithId();
|
||||
(long operatorId, _,_) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
@@ -1165,6 +1171,45 @@ namespace CompanyManagment.Application
|
||||
return await _employeeDocumentsRepository.GetAdminWorkFlowCountForNewEmployees(workshopIds);
|
||||
}
|
||||
|
||||
public async Task<ICollection<WorkshopWithEmployeeDocumentsViewModel>> GetWorkshopDocumentCreatedEmployeeForAdmin(List<long> workshops, long roleId)
|
||||
{
|
||||
return await _employeeDocumentsRepository.GetWorkshopDocumentCreatedEmployeeForAdmin(workshops, roleId);
|
||||
}
|
||||
|
||||
public async Task<ICollection<WorkshopWithEmployeeDocumentsViewModel>> GetWorkshopDocumentRejectedForAdmin(List<long> workshops, long roleId)
|
||||
{
|
||||
return await _employeeDocumentsRepository.GetWorkshopDocumentRejectedForAdmin(workshops, roleId);
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeDocumentsViewModel>> GetRejectedItemsByWorkshopIdAndRoleForAdminWorkFlow(long workshopId, long roleId)
|
||||
{
|
||||
return await _employeeDocumentsRepository.GetRejectedItemsByWorkshopIdAndRoleForAdminWorkFlow(workshopId,
|
||||
roleId);
|
||||
}
|
||||
|
||||
public Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetCreatedEmployeesWorkshopDocumentForAdmin(
|
||||
List<long> workshops, long roleId)
|
||||
{
|
||||
return _employeeDocumentsRepository.GetCreatedEmployeesWorkshopDocumentForAdmin(workshops, roleId);
|
||||
}
|
||||
|
||||
public Task<List<EmployeeDocumentsViewModel>> GetCreatedEmployeesDocumentByWorkshopIdForAdmin(long workshopId)
|
||||
{
|
||||
return _employeeDocumentsRepository.GetCreatedEmployeesDocumentByWorkshopIdForAdmin(workshopId);
|
||||
}
|
||||
|
||||
public Task<List<WorkshopWithEmployeeDocumentsViewModel>> GetClientRejectedDocumentWorkshopsForAdmin(
|
||||
List<long> workshops, long roleId)
|
||||
{
|
||||
return _employeeDocumentsRepository.GetClientRejectedDocumentWorkshopsForAdmin(workshops,roleId);
|
||||
}
|
||||
|
||||
public Task<List<EmployeeDocumentsViewModel>> GetClientRejectedDocumentByWorkshopIdForAdmin(long workshopId)
|
||||
{
|
||||
return _employeeDocumentsRepository.GetClientRejectedDocumentByWorkshopIdForAdmin(workshopId);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Checker Only Methods
|
||||
@@ -1189,7 +1234,7 @@ namespace CompanyManagment.Application
|
||||
return op.Failed("رکورد مورد نظر یافت نشد");
|
||||
}
|
||||
|
||||
(long operatorId, UserType userType) = _authHelper.GetUserTypeWithId();
|
||||
(long operatorId, UserType userType,long roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if ((item.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient) == false)
|
||||
return op.Failed("امکان بررسی رکورد مورد نظر وجود ندارد");
|
||||
@@ -1390,7 +1435,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId();
|
||||
var (uploaderId, uploaderType,roleId) = _authHelper.GetUserTypeWithId();
|
||||
|
||||
if (!_employeeRepository.Exists(x => x.id == employeeId))
|
||||
|
||||
@@ -1414,27 +1459,42 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
var opCreate = Create(new CreateEmployeeDocuments()
|
||||
{ EmployeeId = employeeId, WorkshopId = workshopId });
|
||||
if (opCreate.IsSuccedded == false) return opCreate;
|
||||
entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopId(employeeId, workshopId);
|
||||
|
||||
if (opCreate.IsSuccedded == false)
|
||||
return opCreate;
|
||||
|
||||
entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId);
|
||||
}
|
||||
|
||||
List<EmployeeDocumentItem> newEntities = new();
|
||||
foreach (var item in command)
|
||||
{
|
||||
DeleteMultipleUnsubmittedDocumentsByLabel(entity, item.Label, uploaderType);
|
||||
long mediaId = 0;
|
||||
if (item.WithoutPicture)
|
||||
{
|
||||
var employeeDocumentItem =
|
||||
entity.EmployeeDocumentItemCollection.First(x => x.DocumentLabel == item.Label);
|
||||
mediaId = employeeDocumentItem.MediaId;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteMultipleUnsubmittedDocumentsByLabel(entity, item.Label, uploaderType);
|
||||
|
||||
var mediaOpResult = UploadDocumentItemFile(item.PictureFile, item.Label.ToString(),
|
||||
$"temp/{workshopId}/{employeeId}");
|
||||
var mediaOpResult = UploadDocumentItemFile(item.PictureFile, item.Label.ToString(),
|
||||
$"temp/{workshopId}/{employeeId}");
|
||||
|
||||
if (mediaOpResult.IsSuccedded == false)
|
||||
return mediaOpResult;
|
||||
if (mediaOpResult.IsSuccedded == false)
|
||||
return mediaOpResult;
|
||||
|
||||
|
||||
//if the mediaId is already in use in our table return failed
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
//if the mediaId is already in use in our table return failed
|
||||
if (_employeeDocumentItemRepository.Exists(x => x.MediaId == mediaOpResult.SendId))
|
||||
return op.Failed("امکان ثبت رکورد تکراری وجود ندارد");
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaOpResult.SendId, entity.id, item.Label, uploaderId, uploaderType, DocumentStatus.SubmittedByAdmin);
|
||||
mediaId = mediaOpResult.SendId;
|
||||
}
|
||||
|
||||
var newEntity = new EmployeeDocumentItem(workshopId, employeeId, mediaId, entity.id, item.Label, uploaderId, uploaderType,roleId ,DocumentStatus.SubmittedByAdmin);
|
||||
newEntities.Add(newEntity);
|
||||
}
|
||||
|
||||
@@ -1459,6 +1519,24 @@ namespace CompanyManagment.Application
|
||||
return op.Succcedded(entity.id);
|
||||
}
|
||||
|
||||
public EmployeeDocumentItemViewModel GetOneDocumentItemDetailsForAdmin(long employeeId, long workshopId,long documentItemId)
|
||||
{
|
||||
var documentItem = _employeeDocumentItemRepository.GetWithEmployeeDocumentsByItemId(documentItemId);
|
||||
var viewModel = new EmployeeDocumentItemViewModel()
|
||||
{
|
||||
CreationDateTime = documentItem.CreationDate,
|
||||
DocumentItemLabel = documentItem.DocumentLabel,
|
||||
EmployeeDocumentsId = documentItem.EmployeeDocumentId,
|
||||
Gender = documentItem.EmployeeDocuments.Gender,
|
||||
Id = documentItem.id,
|
||||
Status = documentItem.DocumentStatus,
|
||||
MediaId = documentItem.MediaId,
|
||||
RejectionMessage = documentItem.RejectionReason,
|
||||
UploaderType = documentItem.UploaderType
|
||||
};
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1785,8 +1863,9 @@ namespace CompanyManagment.Application
|
||||
StatusString = item.DocumentStatus.ToString().ToLower(),
|
||||
PicturePath = medias.FirstOrDefault(x => x.Id == item.MediaId)?.Path ?? "",
|
||||
RejectionMessage = item.RejectionReason,
|
||||
UploaderType = item.UploaderType
|
||||
};
|
||||
UploaderType = item.UploaderType,
|
||||
MediaId = medias.FirstOrDefault(x => x.Id == item.MediaId)?.Id ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class FinancialTransactionApplication : IFinancialTransactionApplication
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var now = DateTime.Now;
|
||||
var check = _financialTransactionRepository.Exists(x => x.CreationDate.Date == now.Date && x.CreationDate.Hour == now.Hour && x.CreationDate.Minute == now.Minute &&
|
||||
var check = _financialTransactionRepository.Exists(x => x.CreationDate.Date == now.Date && x.CreationDate.Hour == now.Hour && x.CreationDate.Minute == now.Minute && x.CreationDate.Second == now.Second &&
|
||||
x.FinancialStatementId == command.FinancialStatementId
|
||||
&& x.Creditor == command.Creditor &&
|
||||
x.Deptor == command.Deptor &&
|
||||
@@ -32,9 +32,14 @@ public class FinancialTransactionApplication : IFinancialTransactionApplication
|
||||
command.TypeOfTransaction, command.DescriptionOption, command.Deptor, command.Creditor, 0);
|
||||
_financialTransactionRepository.Create(transaction);
|
||||
_financialTransactionRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
else
|
||||
{
|
||||
return op.Failed("تکراری است");
|
||||
}
|
||||
|
||||
return op.Succcedded();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ public class InsuranceJobApplication: IInsuranceJobApplication
|
||||
if (_insuranceJobRepositpry.Exists(x => x.InsuranceJobTitle == command.InsuranceJobTitle && x.id!=command.Id))
|
||||
return opration.Failed("عنوان صنف و درجه تکراری است");
|
||||
|
||||
if (_insuranceJobRepositpry.Exists(x => x.EconomicCode == command.EconomicCode && x.id != command.Id))
|
||||
return opration.Failed("کد اقتصادی تکراری است");
|
||||
//if (_insuranceJobRepositpry.Exists(x => x.EconomicCode == command.EconomicCode && x.id != command.Id))
|
||||
// return opration.Failed("کد اقتصادی تکراری است");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1633,6 +1633,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
dateSaleryviewModel.StartDateGr = startDateGr;
|
||||
dateSaleryviewModel.EndDateGr = endDateGr;
|
||||
var _dateSalary = _dateSalaryRepository.GetDateSalaryViewModel(dateSaleryviewModel);
|
||||
// && _dateSalary.Id >0
|
||||
if (_dateSalary != null)
|
||||
{
|
||||
var dateSaleryItemviewModel = new DateSalaryItemSearchModel();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
@@ -57,6 +58,11 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
{
|
||||
#region Validation
|
||||
|
||||
if (_leftWorkTempRepository.Exists(x=>x.WorkshopId == command.WorkshopId && x.EmployeeId == employeeId))
|
||||
{
|
||||
return op.Failed("برای پرسنل وارد شده قبلا درخواست ترک کار ثبت کرده اید");
|
||||
}
|
||||
|
||||
if (command.LeftWorkTime.TryToGeorgianDateTime(out var leftWorkDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
@@ -233,6 +239,18 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<List<LeftWorkTempViewModel>> GetLeftWorkTempsByEmployeeId(long employeeId)
|
||||
{
|
||||
return await _leftWorkTempRepository.GetLeftWorkTempsByEmployeeId(employeeId);
|
||||
}
|
||||
|
||||
public List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId)
|
||||
{
|
||||
return _leftWorkTempRepository.GetLeftWorksByWorkshopId(workshopId);
|
||||
|
||||
}
|
||||
|
||||
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
|
||||
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,7 @@ public class ProceedingSessionApplication : IProceedingSessionApplication
|
||||
ArchiveNo = searchModel.File.ArchiveNo.ToString(),
|
||||
FileClass = searchModel.File.FileClass,
|
||||
UserId_RequesterOrSummoned = searchModel.UserId_RequesterOrSummoned,
|
||||
Status = 0
|
||||
});
|
||||
|
||||
if (searchModel.IsSearched)
|
||||
@@ -230,6 +231,10 @@ public class ProceedingSessionApplication : IProceedingSessionApplication
|
||||
|
||||
private List<File_Board_PS> GetFile_Board_PSList(List<EditProceedingSession> list, List<FileViewModel> files, ProceedingSessionSearchModel searchModel)
|
||||
{
|
||||
if (list.Any(x=>x.Id == 1516))
|
||||
{
|
||||
|
||||
}
|
||||
var file_PSList = new List<File_Board_PS>();
|
||||
|
||||
foreach (var item in list)
|
||||
@@ -248,7 +253,9 @@ public class ProceedingSessionApplication : IProceedingSessionApplication
|
||||
continue;
|
||||
}
|
||||
|
||||
var file = _fileRepository.Search(new FileSearchModel { Id = board.File_Id, Status = 0 }).FirstOrDefault();
|
||||
var filelist = _fileRepository.Search(new FileSearchModel { Id = board.File_Id, Status = 0 }).ToList();
|
||||
|
||||
var file = filelist.FirstOrDefault();
|
||||
|
||||
file = _fileApplication.GetFileDetails(file);
|
||||
|
||||
|
||||
@@ -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,33 +106,88 @@ 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("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی رسمی صادر شده است پاداشی دهید");
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
var (userId, userType) = _authHelper.GetUserTypeWithId();
|
||||
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
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||
using Company.Domain.CustomizeWorkshopSettingsAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
@@ -24,7 +25,6 @@ namespace CompanyManagment.Application;
|
||||
public class RollCallApplication : IRollCallApplication
|
||||
{
|
||||
private readonly IRollCallRepository _rollCallRepository;
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private readonly ILeaveRepository _leaveRepository;
|
||||
@@ -33,11 +33,11 @@ public class RollCallApplication : IRollCallApplication
|
||||
private readonly IRollCallDomainService _rollCallDomainService;
|
||||
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
|
||||
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
|
||||
public RollCallApplication(IRollCallRepository rollCallRepository, IEmployeeApplication employeeApplication, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository)
|
||||
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository)
|
||||
{
|
||||
_rollCallRepository = rollCallRepository;
|
||||
_employeeApplication = employeeApplication;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
_employeeRepository = employeeRepository;
|
||||
_leaveRepository = leaveRepository;
|
||||
@@ -46,7 +46,8 @@ public class RollCallApplication : IRollCallApplication
|
||||
_rollCallDomainService = rollCallDomainService;
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
|
||||
}
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateRollCall command)
|
||||
{
|
||||
@@ -55,7 +56,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
var yearFa = Convert.ToInt32(startDateFa.Substring(0, 4));
|
||||
var monthFa = Convert.ToInt32(startDateFa.Substring(5, 2));
|
||||
var employeeName = _employeeApplication.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
var employeeName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
|
||||
var create = new RollCall(command.WorkshopId, command.EmployeeId, employeeName, command.StartDate.Value, null,
|
||||
yearFa, monthFa, _rollCallDomainService);
|
||||
_rollCallRepository.Create(create);
|
||||
@@ -336,15 +337,19 @@ public class RollCallApplication : IRollCallApplication
|
||||
public OperationResult ManualEdit(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var now = DateTime.Now;
|
||||
|
||||
DateTime date = command.DateFa.ToGeorgianDateTime();
|
||||
if (date == Tools.GetUndefinedDateTime())
|
||||
return operation.Failed("فرمت تاریخ وارد شده صحیح نمی باشد");
|
||||
|
||||
if (date >= DateTime.Now.Date)
|
||||
{
|
||||
return operation.Failed("امکان اضافه کردن حضور غیاب برای روز جاری و روز های آینده وجود ندارد");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if (date >= DateTime.Now.Date)
|
||||
//{
|
||||
// return operation.Failed("امکان اضافه کردن حضور غیاب برای روز جاری و روز های آینده وجود ندارد");
|
||||
//}
|
||||
|
||||
var twoDaysEarlier = date.AddDays(-2).Date;
|
||||
var twoDaysLater = date.AddDays(2).Date >= DateTime.Today
|
||||
@@ -407,8 +412,8 @@ public class RollCallApplication : IRollCallApplication
|
||||
if (startDateTime >= endDateTime)
|
||||
return operation.Failed("زمان ورود نمی تواند بعد یا مساوی زمان خروج باشد");
|
||||
|
||||
if (endDateTime.Date >= DateTime.Today)
|
||||
return operation.Failed("نمی توانید برای روز جاری یا روز های آینده حضور غیاب ثبت کنید");
|
||||
//if (endDateTime.Date >= DateTime.Today)
|
||||
// return operation.Failed("نمی توانید برای روز جاری یا روز های آینده حضور غیاب ثبت کنید");
|
||||
|
||||
var rollCall = new EditRollCall
|
||||
{
|
||||
@@ -420,7 +425,10 @@ public class RollCallApplication : IRollCallApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (newRollCallDates.Any(x => x.StartDate >= now || x.EndDate >= now))
|
||||
{
|
||||
return operation.Failed("حضورغیاب وارد شده نمیتواند در آینده باشد");
|
||||
}
|
||||
|
||||
if (newRollCallDates.Any(x => newRollCallDates.Any(y => x != y && x.EndDate >= y.StartDate && x.StartDate <= y.EndDate)))
|
||||
return operation.Failed("بازه های وارد شده با هم تداخل دارند");
|
||||
@@ -447,7 +455,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
{
|
||||
x.ShiftDate =
|
||||
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
||||
x.StartDate!.Value,x.EndDate!.Value);
|
||||
x.StartDate!.Value,x.EndDate.Value);
|
||||
});
|
||||
|
||||
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
||||
@@ -455,14 +463,13 @@ public class RollCallApplication : IRollCallApplication
|
||||
return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید");
|
||||
}
|
||||
|
||||
|
||||
if (new TimeSpan(newRollCallDates.Sum(x => (x.EndDate.Value - x.StartDate.Value).Ticks)) > TimeSpan.FromHours(26))
|
||||
{
|
||||
return operation.Failed("بازه حضور پرسنل نمی تواند بیشتر از 26 ساعت باشد");
|
||||
}
|
||||
if (new TimeSpan(newRollCallDates.Sum(x => (x.EndDate.Value - x.StartDate.Value).Ticks)) > TimeSpan.FromHours(26))
|
||||
{
|
||||
return operation.Failed("بازه حضور پرسنل نمی تواند بیشتر از 26 ساعت باشد");
|
||||
}
|
||||
|
||||
|
||||
if (newRollCallDates.Any(x => employeeRollCalls.Any(y =>
|
||||
if (newRollCallDates.Any(x => employeeRollCalls.Any(y =>
|
||||
y.StartDate.Value.Date != command.DateFa.ToGeorgianDateTime().Date &&
|
||||
x.EndDate >= y.StartDate.Value && x.StartDate <= y.EndDate.Value)))
|
||||
return operation.Failed("بازه های وارد شده با حضور غیاب های مربوط به روز های قبل و بعد تداخل زمانی دارد");
|
||||
@@ -496,26 +503,27 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
_rollCallRepository.AddRange(rollCallsAsEntityModels);
|
||||
_rollCallRepository.SaveChanges();
|
||||
|
||||
foreach (var rollCallsAsEntityModel in rollCallsAsEntityModels)
|
||||
{
|
||||
rollCallsAsEntityModel.Edit(rollCallsAsEntityModel.StartDate.Value, rollCallsAsEntityModel.EndDate.Value, _rollCallDomainService);
|
||||
}
|
||||
_rollCallRepository.SaveChanges();
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
public OperationResult ManualEditForUndefined(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var now = DateTime.Now;
|
||||
|
||||
DateTime date = command.DateFa.ToGeorgianDateTime();
|
||||
if (date == Tools.GetUndefinedDateTime())
|
||||
return operation.Failed("فرمت تاریخ وارد شده صحیح نمی باشد");
|
||||
|
||||
if (date >= DateTime.Now.Date)
|
||||
{
|
||||
return operation.Failed("امکان اضافه کردن حضور غیاب برای روز جاری و روز های آینده وجود ندارد");
|
||||
}
|
||||
//if (date >= DateTime.Now.Date)
|
||||
//{
|
||||
// return operation.Failed("امکان اضافه کردن حضور غیاب برای روز جاری و روز های آینده وجود ندارد");
|
||||
//}
|
||||
|
||||
var twoDaysEarlier = date.AddDays(-2).Date;
|
||||
var twoDaysLater = date.AddDays(2).Date >= DateTime.Today
|
||||
@@ -578,8 +586,8 @@ public class RollCallApplication : IRollCallApplication
|
||||
if (startDateTime >= endDateTime)
|
||||
return operation.Failed("زمان ورود نمی تواند بعد یا مساوی زمان خروج باشد");
|
||||
|
||||
if (endDateTime.Date >= DateTime.Today)
|
||||
return operation.Failed("نمی توانید برای روز جاری یا روز های آینده حضور غیاب ثبت کنید");
|
||||
//if (endDateTime.Date >= DateTime.Today)
|
||||
// return operation.Failed("نمی توانید برای روز جاری یا روز های آینده حضور غیاب ثبت کنید");
|
||||
|
||||
var rollCall = new EditRollCall
|
||||
{
|
||||
@@ -594,6 +602,12 @@ public class RollCallApplication : IRollCallApplication
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
if (newRollCallDates.Any(x => x.StartDate >= now || x.EndDate >= now))
|
||||
{
|
||||
return operation.Failed("حضورغیاب وارد شده نمیتواند در آینده باشد");
|
||||
}
|
||||
|
||||
if (newRollCallDates.Any(x => newRollCallDates.Any(y => x != y && x.EndDate >= y.StartDate && x.StartDate <= y.EndDate)))
|
||||
return operation.Failed("بازه های وارد شده با هم تداخل دارند");
|
||||
|
||||
@@ -618,7 +632,7 @@ public class RollCallApplication : IRollCallApplication
|
||||
{
|
||||
x.ShiftDate =
|
||||
_rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId,
|
||||
x.StartDate!.Value,x.EndDate!.Value);
|
||||
x.StartDate!.Value,x.EndDate.Value);
|
||||
});
|
||||
if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date))
|
||||
{
|
||||
@@ -626,10 +640,10 @@ public class RollCallApplication : IRollCallApplication
|
||||
}
|
||||
if (new TimeSpan(newRollCallDates.Sum(x => (x.EndDate.Value - x.StartDate.Value).Ticks)) > TimeSpan.FromHours(26))
|
||||
{
|
||||
return operation.Failed("بازه حضور پرسنل نمی تواند بیشتر از 26 ساعت باشد");
|
||||
return operation.Failed("بازه حضور پرسنل نمی تواند بیشتر از 26 ساعت باشد");
|
||||
}
|
||||
|
||||
if (newRollCallDates.Any(x => employeeRollCalls.Any(y =>
|
||||
if (newRollCallDates.Any(x => employeeRollCalls.Any(y =>
|
||||
y.StartDate.Value.Date != command.DateFa.ToGeorgianDateTime().Date &&
|
||||
x.EndDate >= y.StartDate.Value && x.StartDate <= y.EndDate.Value)))
|
||||
return operation.Failed("بازه های وارد شده با حضور غیاب های مربوط به روز های قبل و بعد تداخل زمانی دارد");
|
||||
@@ -717,8 +731,11 @@ public class RollCallApplication : IRollCallApplication
|
||||
|
||||
if (rollCalls == null)
|
||||
return operation.Failed("چنین آیتمی یافت نشد");
|
||||
foreach (var item in rollCalls)
|
||||
foreach (var item in rollCalls)
|
||||
{
|
||||
item.Edit(item.StartDate.Value,item.EndDate.Value,_rollCallDomainService);
|
||||
item.SetModifyType(RollCallModifyType.EditByEmployer);
|
||||
}
|
||||
|
||||
_rollCallRepository.SaveChanges();
|
||||
|
||||
@@ -756,4 +773,56 @@ public class RollCallApplication : IRollCallApplication
|
||||
{
|
||||
return _rollCallRepository.CheckRepeat(employeeId, workshopId);
|
||||
}
|
||||
|
||||
public OperationResult RecalculateValues(long workshopId, List<ReCalculateRollCallValues> commands)
|
||||
{
|
||||
var operationResult = new OperationResult();
|
||||
try
|
||||
{
|
||||
List<DateTime> fromDates = commands.Select(x => x.FromDate.ToGeorgianDateTime()).ToList();
|
||||
var employeeIds = commands.Select(x => x.EmployeeId).ToList();
|
||||
if (_checkoutRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractStart)))
|
||||
{
|
||||
return operationResult.Failed("پرسنل بعد از تاریخ وارد شده دارای فیش رسمی است");
|
||||
}
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractStart)))
|
||||
{
|
||||
return operationResult.Failed("پرسنل بعد از تاریخ وارد شده دارای فیش غیررسمی نهایی است");
|
||||
}
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractStart)))
|
||||
{
|
||||
return operationResult.Failed("پرسنل بعد از تاریخ وارد شده دارای فیش غیررسمی موقت است");
|
||||
}
|
||||
|
||||
var oldestDate = commands.MinBy(x => x.FromDate).FromDate.ToGeorgianDateTime();
|
||||
|
||||
var allRollCalls = _rollCallRepository
|
||||
.GetRollCallsUntilNowWithWorkshopIdEmployeeIds(workshopId, commands.Select(x => x.EmployeeId).ToList(),
|
||||
oldestDate).GetAwaiter().GetResult();
|
||||
|
||||
|
||||
foreach (var command in commands)
|
||||
{
|
||||
var rollCalls = allRollCalls
|
||||
.Where(x => x.EmployeeId == command.EmployeeId && x.ShiftDate >= command.FromDate.ToGeorgianDateTime()).ToList();
|
||||
|
||||
foreach (var rollCall in rollCalls)
|
||||
{
|
||||
rollCall.ClearTimeDiff();
|
||||
_rollCallRepository.SaveChanges();
|
||||
rollCall.SetEndDateTime(rollCall.EndDate!.Value, _rollCallDomainService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return operationResult.Succcedded();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return operationResult.Failed(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -90,15 +90,28 @@ namespace CompanyManagment.Application
|
||||
|
||||
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
//موقت
|
||||
// دادمهرگستر 11 *
|
||||
//585 کاشی گالری سرامیس (بابک ابراهیمی ) *
|
||||
//آموزشگاه ملل 604 *
|
||||
//کاریابی ملل 605 *
|
||||
//368 پیتزا امیر آماده سازی
|
||||
//367 پیتزا امیر رستوران
|
||||
//286 مرکز توان بخشی رسالت *
|
||||
bool skipRollCallByWorkshopId = workshopId is 11 or 585 or 604 or 605 or 368 or 367 or 286;
|
||||
//موقت
|
||||
// دادمهرگستر 11 *
|
||||
//585 کاشی گالری سرامیس (بابک ابراهیمی )
|
||||
//آموزشگاه ملل 604 *
|
||||
//کاریابی ملل 605 *
|
||||
//368 پیتزا امیر آماده سازی
|
||||
//367 پیتزا امیر رستوران
|
||||
//286 مرکز توان بخشی رسالت *
|
||||
//610 بیمارستان پارس - رازقی طعام
|
||||
DateTime start1404 = new DateTime(2025, 03, 21);
|
||||
bool skipRollCallByWorkshopId = false;
|
||||
if (contractStart < start1404)
|
||||
{
|
||||
skipRollCallByWorkshopId = workshopId is 11 or 585 or 604 or 605 or 368 or 367 or 286;
|
||||
}
|
||||
else
|
||||
{
|
||||
skipRollCallByWorkshopId = workshopId is 368 or 367 or 585 or 610;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//#if DEBUG
|
||||
// skipRollCallByWorkshopId = workshopId is 11 or 585 or 604 or 605 or 368 or 367;
|
||||
@@ -111,7 +124,10 @@ namespace CompanyManagment.Application
|
||||
bool skipRollCallByEmployeeId = employeeId is 42550;
|
||||
if (skipRollCallByEmployeeId)
|
||||
return false;
|
||||
|
||||
|
||||
//9211 محسا تازه
|
||||
if (employeeId == 9211 && contractStart >= start1404)
|
||||
return false;
|
||||
|
||||
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -24,4 +25,10 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication
|
||||
{
|
||||
return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking);
|
||||
}
|
||||
|
||||
public async Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd,
|
||||
string shiftwork)
|
||||
{
|
||||
return await _rollCallMandatoryRepository.RotatingShiftReport(workshopId, employeeId, contractStart, contractEnd, shiftwork);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -23,6 +23,7 @@ using Company.Domain.DateSalaryAgg;
|
||||
using Company.Domain.DateSalaryItemAgg;
|
||||
using Company.Domain.EmployeeAccountAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.EmployeeAuthorizeTempAgg;
|
||||
using Company.Domain.EmployeeBankInformationAgg;
|
||||
using Company.Domain.EmployeeChildrenAgg;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
@@ -174,6 +175,7 @@ public class CompanyContext : DbContext
|
||||
public DbSet<EmployeeClientTemp> EmployeeClientTemps { get; set; }
|
||||
public DbSet<LeftWorkTemp> LeftWorkTemps { get; set; }
|
||||
|
||||
public DbSet<EmployeeAuthorizeTemp> EmployeeAuthorizeTemps { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Company.Domain.EmployeeAuthorizeTempAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping;
|
||||
|
||||
public class EmployeeAuthorizeTempMapping:IEntityTypeConfiguration<EmployeeAuthorizeTemp>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<EmployeeAuthorizeTemp> builder)
|
||||
{
|
||||
builder.ToTable("EmployeeAuthorizeTemps");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.NationalCode).HasMaxLength(15);
|
||||
builder.Property(x => x.IdNumber).HasMaxLength(15);
|
||||
builder.Property(x => x.FName).HasMaxLength(100);
|
||||
builder.Property(x => x.LName).HasMaxLength(100);
|
||||
builder.Property(x => x.FatherName).HasMaxLength(100);
|
||||
builder.Property(x => x.Gender).HasConversion<string>().HasMaxLength(15);
|
||||
|
||||
builder.Property(x => x.IdNumberSerial).HasMaxLength(25);
|
||||
builder.Property(x => x.IdNumberSeri).HasMaxLength(25);
|
||||
|
||||
builder.HasIndex(x => x.NationalCode).IsUnique();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -80,9 +80,17 @@ public class EmployeeMapping : IEntityTypeConfiguration<Employee>
|
||||
.HasForeignKey(x => x.EmployeeId);
|
||||
|
||||
builder.HasMany(x => x.EmployeeBankInformationList).WithOne(x => x.Employee)
|
||||
.HasForeignKey(x => x.EmployeeId);
|
||||
.HasForeignKey(x => x.EmployeeId);
|
||||
|
||||
builder.Ignore(x => x.FullName);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
builder.Property(x => x.IdNumberSerial).HasMaxLength(25);
|
||||
builder.Property(x => x.IdNumberSeri).HasMaxLength(25);
|
||||
|
||||
builder.Ignore(x => x.FullName);
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
|
||||
builder.Property(x => x.Signature).HasMaxLength(1);
|
||||
builder.Property(x => x.OfficialCompany).HasMaxLength(12);
|
||||
builder.Property(x => x.TypeOfContract).HasMaxLength(30);
|
||||
builder.Property(x => x.HasValueAddedTax).HasMaxLength(10);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ partial class WorkshopMapping : IEntityTypeConfiguration<Workshop>
|
||||
|
||||
builder.HasMany(x => x.RollCallServicesList)
|
||||
.WithOne(x => x.Workshop)
|
||||
.HasForeignKey(x => x.AccountId);
|
||||
.HasForeignKey(x => x.WorkshopId);
|
||||
|
||||
builder.HasMany(x => x.TaxLeftWorkCategoryList)
|
||||
.WithOne(x => x.Workshop)
|
||||
|
||||
9407
CompanyManagment.EFCore/Migrations/20250426185835_institutioncontractChanges.Designer.cs
generated
Normal file
9407
CompanyManagment.EFCore/Migrations/20250426185835_institutioncontractChanges.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class institutioncontractChanges : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "HasValueAddedTax",
|
||||
table: "InstitutionContracts",
|
||||
type: "nvarchar(10)",
|
||||
maxLength: 10,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(max)",
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "HasValueAddedTax",
|
||||
table: "InstitutionContracts",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(10)",
|
||||
oldMaxLength: 10,
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
9471
CompanyManagment.EFCore/Migrations/20250501111715_add employeeAuthorizeTemp and add serialNumber.Designer.cs
generated
Normal file
9471
CompanyManagment.EFCore/Migrations/20250501111715_add employeeAuthorizeTemp and add serialNumber.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addemployeeAuthorizeTempandaddserialNumber : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "IdNumberSeri",
|
||||
table: "Employees",
|
||||
type: "nvarchar(25)",
|
||||
maxLength: 25,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "IdNumberSerial",
|
||||
table: "Employees",
|
||||
type: "nvarchar(25)",
|
||||
maxLength: 25,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmployeeAuthorizeTemps",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Gender = table.Column<string>(type: "nvarchar(15)", maxLength: 15, nullable: false),
|
||||
FName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
LName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
FatherName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||
BirthDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
NationalCode = table.Column<string>(type: "nvarchar(15)", maxLength: 15, nullable: true),
|
||||
IdNumber = table.Column<string>(type: "nvarchar(15)", maxLength: 15, nullable: true),
|
||||
IdNumberSerial = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: true),
|
||||
IdNumberSeri = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: true),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmployeeAuthorizeTemps", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmployeeAuthorizeTemps_NationalCode",
|
||||
table: "EmployeeAuthorizeTemps",
|
||||
column: "NationalCode",
|
||||
unique: true,
|
||||
filter: "[NationalCode] IS NOT NULL");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmployeeAuthorizeTemps");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdNumberSeri",
|
||||
table: "Employees");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdNumberSerial",
|
||||
table: "Employees");
|
||||
}
|
||||
}
|
||||
}
|
||||
9407
CompanyManagment.EFCore/Migrations/20250503140454_changeRollCallServiceRelation.Designer.cs
generated
Normal file
9407
CompanyManagment.EFCore/Migrations/20250503140454_changeRollCallServiceRelation.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class changeRollCallServiceRelation : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RollCallServices_Workshops_AccountId",
|
||||
table: "RollCallServices");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_RollCallServices_AccountId",
|
||||
table: "RollCallServices");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RollCallServices_WorkshopId",
|
||||
table: "RollCallServices",
|
||||
column: "WorkshopId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RollCallServices_Workshops_WorkshopId",
|
||||
table: "RollCallServices",
|
||||
column: "WorkshopId",
|
||||
principalTable: "Workshops",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_RollCallServices_Workshops_WorkshopId",
|
||||
table: "RollCallServices");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_RollCallServices_WorkshopId",
|
||||
table: "RollCallServices");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RollCallServices_AccountId",
|
||||
table: "RollCallServices",
|
||||
column: "AccountId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_RollCallServices_Workshops_AccountId",
|
||||
table: "RollCallServices",
|
||||
column: "AccountId",
|
||||
principalTable: "Workshops",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
9474
CompanyManagment.EFCore/Migrations/20250505140611_add uploaderRoleId to EmployeeDocumentItems.Designer.cs
generated
Normal file
9474
CompanyManagment.EFCore/Migrations/20250505140611_add uploaderRoleId to EmployeeDocumentItems.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class adduploaderRoleIdtoEmployeeDocumentItems : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "UploaderRoleId",
|
||||
table: "EmployeeDocumentItems",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UploaderRoleId",
|
||||
table: "EmployeeDocumentItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1495,6 +1495,14 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<string>("IdNumberSeri")
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("IdNumberSerial")
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("InsuranceCode")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
@@ -1591,6 +1599,62 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("Employees", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.EmployeeAuthorizeTempAgg.EmployeeAuthorizeTemp", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<DateTime>("BirthDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("FatherName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.IsRequired()
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b.Property<string>("IdNumber")
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b.Property<string>("IdNumberSeri")
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("IdNumberSerial")
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("LName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("NationalCode")
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("NationalCode")
|
||||
.IsUnique()
|
||||
.HasFilter("[NationalCode] IS NOT NULL");
|
||||
|
||||
b.ToTable("EmployeeAuthorizeTemps", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.EmployeeBankInformationAgg.EmployeeBankInformation", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -1779,6 +1843,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<long>("UploaderId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("UploaderRoleId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("UploaderType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
@@ -2797,7 +2864,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("HasValueAddedTax")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.Property<string>("IsActiveString")
|
||||
.HasMaxLength(5)
|
||||
@@ -4636,7 +4704,7 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("AccountId");
|
||||
b.HasIndex("WorkshopId");
|
||||
|
||||
b.ToTable("RollCallServices", (string)null);
|
||||
});
|
||||
@@ -4652,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");
|
||||
|
||||
@@ -6221,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)");
|
||||
@@ -6260,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)
|
||||
@@ -6307,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");
|
||||
|
||||
@@ -6346,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");
|
||||
|
||||
@@ -6496,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)");
|
||||
@@ -6535,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)
|
||||
@@ -6582,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");
|
||||
|
||||
@@ -6621,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");
|
||||
|
||||
@@ -8902,7 +9017,7 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
b.HasOne("Company.Domain.WorkshopAgg.Workshop", "Workshop")
|
||||
.WithMany("RollCallServicesList")
|
||||
.HasForeignKey("AccountId")
|
||||
.HasForeignKey("WorkshopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
|
||||
@@ -28,10 +28,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly IContractApplication _contractApplication;
|
||||
private readonly IWorkingHoursApplication _workingHoursApplication;
|
||||
|
||||
private readonly IWorkingHoursTempApplication _workingHoursTempApplication;
|
||||
|
||||
private readonly IAuthHelper _authHelper;
|
||||
@@ -39,14 +36,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
private readonly ILeftWorkRepository _leftWorkRepository;
|
||||
private readonly IRollCallRepository _rollCallRepository;
|
||||
|
||||
public CheckoutRepository(IEmployeeApplication employeeApplication, IWorkshopApplication workshopApplication,
|
||||
IContractApplication contractApplication, IWorkingHoursApplication workingHoursApplication,
|
||||
IAuthHelper authHelper, CompanyContext context, IConfiguration configuration, ILeftWorkRepository leftWorkRepository, IWorkingHoursTempApplication workingHoursTempApplication, IRollCallRepository rollCallRepository) : base(context)
|
||||
public CheckoutRepository(IAuthHelper authHelper, CompanyContext context, IConfiguration configuration, ILeftWorkRepository leftWorkRepository, IWorkingHoursTempApplication workingHoursTempApplication, IRollCallRepository rollCallRepository) : base(context)
|
||||
{
|
||||
_employeeApplication = employeeApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
_contractApplication = contractApplication;
|
||||
_workingHoursApplication = workingHoursApplication;
|
||||
|
||||
_authHelper = authHelper;
|
||||
_context = context;
|
||||
_configuration = configuration;
|
||||
@@ -90,7 +82,16 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment,
|
||||
RewardPay = x.RewardPay,
|
||||
})
|
||||
HasRollCall = x.HasRollCall,
|
||||
EmployeeId = x.EmployeeId,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ContractId = x.ContractId,
|
||||
ContractStartGr = x.ContractStart,
|
||||
ContractEndGr = x.ContractEnd,
|
||||
ContractStart = x.ContractStart.ToFarsi(),
|
||||
ContractEnd = x.ContractEnd.ToFarsi()
|
||||
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
.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,293 +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.Where(x => customizeCheckoutIds.Contains(x.id));
|
||||
//var pc = new PersianCalendar();
|
||||
//var year = pc.GetYear(monthStart);
|
||||
//var month = pc.GetMonth(monthStart);
|
||||
|
||||
IQueryable<Workshop> workshopsQuery = _companyContext.Workshops.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.id));
|
||||
IQueryable<CustomizeCheckoutTemp> customizeCheckoutsQuery = _companyContext.CustomizeCheckoutTemps.AsSplitQuery()
|
||||
.Where(x => customizeCheckoutIds.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<Workshop> workshopsQuery = _companyContext.Workshops.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.id));
|
||||
|
||||
IQueryable<PersonnelCodeDomain> personnelCodesQuery = _companyContext.PersonnelCodeSet
|
||||
.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId));
|
||||
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<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<PersonnelCodeDomain> personnelCodesQuery = _companyContext.PersonnelCodeSet
|
||||
.Where(x => customizeCheckoutsQuery.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId));
|
||||
|
||||
//IQueryable<Employee> employeesQuery = _companyContext.Employees.Where(x => customizeCheckoutsQuery.Any(y => y.EmployeeId == x.id));
|
||||
//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));
|
||||
|
||||
|
||||
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(),
|
||||
@@ -370,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);
|
||||
@@ -479,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings.ValueObjectsViewModel;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
@@ -174,4 +177,65 @@ public class CustomizeWorkshopEmployeeSettingsRepository(CompanyContext companyC
|
||||
if (entity != null)
|
||||
Remove(entity);
|
||||
}
|
||||
|
||||
public bool CheckEmployeeShiftHasChanged(EditCustomizeEmployeeSettings command)
|
||||
{
|
||||
var employeeSettings = _companyContext.CustomizeWorkshopEmployeeSettings.Find(command.Id);
|
||||
if (employeeSettings == null)
|
||||
{
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
if (command.WorkshopShiftStatus != employeeSettings.WorkshopShiftStatus)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (employeeSettings.WorkshopShiftStatus)
|
||||
{
|
||||
case WorkshopShiftStatus.Irregular:
|
||||
if (command.IrregularShift != employeeSettings.IrregularShift)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case WorkshopShiftStatus.Rotating:
|
||||
var rotatingShift = command.CustomizeRotatingShifts
|
||||
.Select(x => new CustomizeRotatingShift(TimeOnly.Parse(x.StartTime), TimeOnly.Parse(x.EndTime)))
|
||||
.ToList();
|
||||
|
||||
if (!rotatingShift.All(x => employeeSettings.CustomizeRotatingShifts.Any(x.Equals)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case WorkshopShiftStatus.Regular:
|
||||
var employeesShifts =
|
||||
command.ShiftViewModel.Select(x =>
|
||||
{
|
||||
var placement = x.Placement switch
|
||||
{
|
||||
ShiftPlacement.First => "اول",
|
||||
ShiftPlacement.Second => "دوم",
|
||||
ShiftPlacement.Third => "سوم"
|
||||
};
|
||||
if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
|
||||
throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
|
||||
if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
|
||||
throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
|
||||
|
||||
|
||||
return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
|
||||
|
||||
}).ToList();
|
||||
if (!employeesShifts.All(x => employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.Any(x.Equals)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -123,15 +123,18 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
|
||||
public bool HasAnyEmployeeWithoutGroup(long workshopId)
|
||||
{
|
||||
var dateNow = DateTime.Now.Date;
|
||||
var leftWork = _companyContext.LeftWorkList.Where(x =>
|
||||
x.WorkshopId == workshopId && x.StartWorkDate <= dateNow && x.LeftWorkDate >= dateNow);
|
||||
|
||||
var rollCallEmployeesWithoutCWS = _companyContext.RollCallEmployees
|
||||
var rollCallEmployeesWithoutCWS = _companyContext.RollCallEmployees
|
||||
.Include(x =>
|
||||
x.EmployeesStatus)
|
||||
.Where(
|
||||
x =>
|
||||
x.WorkshopId == workshopId &&
|
||||
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
|
||||
x.HasUploadedImage == "true")
|
||||
x.HasUploadedImage == "true"&&
|
||||
leftWork.Any(l => l.EmployeeId == x.EmployeeId && l.WorkshopId == x.WorkshopId))
|
||||
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
|
||||
.AsSplitQuery()
|
||||
.Include(x => x.CustomizeWorkshopGroupSettings)
|
||||
|
||||
@@ -92,6 +92,7 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
return new CustomizeWorkshopSettingsViewModel()
|
||||
{
|
||||
Id = entity.id,
|
||||
Offset = entity.EndTimeOffSet,
|
||||
GroupSettings = entity.CustomizeWorkshopGroupSettingsCollection.Where(x => !x.MainGroup).Select(x =>
|
||||
new CustomizeWorkshopGroupSettingsViewModel()
|
||||
{
|
||||
@@ -106,7 +107,7 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
EmployeeId = y.EmployeeId,
|
||||
IsSettingChanged = y.IsSettingChanged,
|
||||
IsShiftChanged = y.IsShiftChanged,
|
||||
Name = $"{employee.FName} {employee.LName}",
|
||||
Name = $"{employee?.FName} {employee?.LName}",
|
||||
RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
|
||||
new CustomizeWorkshopShiftViewModel()
|
||||
{
|
||||
@@ -115,7 +116,14 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
Salary = y.Salary,
|
||||
|
||||
CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
LeavePermittedDays = y.LeavePermittedDays,
|
||||
IrregularShift = y.IrregularShift,
|
||||
WorkshopShiftStatus = y.WorkshopShiftStatus
|
||||
};
|
||||
}).ToList(),
|
||||
Salary = x.Salary,
|
||||
@@ -127,7 +135,16 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
|
||||
}).ToList(),
|
||||
MainGroup = x.MainGroup
|
||||
MainGroup = x.MainGroup,
|
||||
WorkshopShiftStatus = x.WorkshopShiftStatus,
|
||||
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
IrregularShift = x.IrregularShift
|
||||
|
||||
|
||||
|
||||
}).ToList(),
|
||||
};
|
||||
|
||||
@@ -77,6 +77,7 @@ public class DateSalaryRepository : RepositoryBase<long, DateSalary>, IDateSalar
|
||||
var dateSalary = new DateSalary(command.StartDateFa, command.EndDateFa);
|
||||
Create(dateSalary);
|
||||
SaveChanges();
|
||||
command.DateSalaryItems = command.DateSalaryItems.Where(x => x.Salary > 0).ToList();
|
||||
foreach (var item in command.DateSalaryItems)
|
||||
{
|
||||
|
||||
@@ -104,7 +105,7 @@ public class DateSalaryRepository : RepositoryBase<long, DateSalary>, IDateSalar
|
||||
var dateSalary = Get(command.Id);
|
||||
dateSalary.Edit(command.StartDateFa, command.EndDateFa);
|
||||
SaveChanges();
|
||||
|
||||
command.DateSalaryItems = command.DateSalaryItems.Where(x => x.Salary > 0).ToList();
|
||||
foreach (var item in command.DateSalaryItems)
|
||||
{
|
||||
if (item.Id == 0)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user