change
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -359,5 +359,6 @@ MigrationBackup/
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
# # Fody - auto-generated XML schema
|
||||
# FodyWeavers.xsd
|
||||
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
public enum Gender
|
||||
{
|
||||
Male,
|
||||
Female
|
||||
Female,
|
||||
None
|
||||
}
|
||||
@@ -37,10 +37,12 @@
|
||||
/// </summary>
|
||||
public const int PersonnelStatusIndividualReportPermissionCode = 10205;
|
||||
|
||||
/// <summary>
|
||||
/// لیست کل پرسنل
|
||||
/// </summary>
|
||||
public const int PersonnelListPermissionCode = 10206;
|
||||
|
||||
//کد 10206 به بخش عملیات پرسنل منتقل شد و رزرو می باشد
|
||||
///// <summary>
|
||||
///// لیست کل پرسنل
|
||||
///// </summary>
|
||||
//public const int PersonnelListPermissionCode = 10206;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -72,11 +74,22 @@
|
||||
/// </summary>
|
||||
public const int PaymentToEmployeePermissionCode = 10304;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// عملیات حساب بانکی پرسنل
|
||||
/// </summary>
|
||||
public const int EmployeeBankInformationPermissionCode = 10309;
|
||||
|
||||
/// <summary>
|
||||
/// عملیات افزودن پرسنل
|
||||
/// </summary>
|
||||
public const int AddEmployeePermissionCode = 10310;
|
||||
|
||||
/// <summary>
|
||||
/// عملیات افزودن پرسنل
|
||||
/// </summary>
|
||||
public const int LeftWorkEmployeePermissionCode = 10311;
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد وام
|
||||
/// </summary>
|
||||
@@ -190,6 +203,12 @@
|
||||
public const int DeleteFinePermissionCode = 1030804;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// لیست کل پرسنل
|
||||
/// </summary>
|
||||
public const int PersonnelListPermissionCode = 10206;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -562,13 +581,7 @@
|
||||
Code = PersonnelStatusIndividualReportPermissionCode,
|
||||
ParentId = WorkshopOperationsPermissionCode
|
||||
};
|
||||
public static SubAccountPermissionDto PersonnelListPermission { get; } = new()
|
||||
{
|
||||
Id = PersonnelListPermissionCode,
|
||||
Name = "لیست کل پرسنل",
|
||||
Code = PersonnelListPermissionCode,
|
||||
ParentId = WorkshopOperationsPermissionCode
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region عملیات پرسنل, ParentId = PersonnelOperationsPermissionCode
|
||||
@@ -613,12 +626,35 @@
|
||||
ParentId = PersonnelOperationsPermissionCode
|
||||
};
|
||||
|
||||
#endregion
|
||||
public static SubAccountPermissionDto AddEmployeeInformationPermission { get; } = new()
|
||||
{
|
||||
Id = AddEmployeePermissionCode,
|
||||
Name = "عملیات افزودن پرسنل",
|
||||
Code = AddEmployeePermissionCode,
|
||||
ParentId = PersonnelOperationsPermissionCode
|
||||
};
|
||||
|
||||
#region فیش حقوقی غیر رسمی,ParentId = CustomizeCheckoutOperationsPermissionCode
|
||||
public static SubAccountPermissionDto LeftWorkEmployeeInformationPermission { get; } = new()
|
||||
{
|
||||
Id = LeftWorkEmployeePermissionCode,
|
||||
Name = "عملیات ترک کار پرسنل",
|
||||
Code = LeftWorkEmployeePermissionCode,
|
||||
ParentId = PersonnelOperationsPermissionCode
|
||||
};
|
||||
|
||||
public static SubAccountPermissionDto PersonnelListPermission { get; } = new()
|
||||
{
|
||||
Id = PersonnelListPermissionCode,
|
||||
Name = "لیست کل پرسنل",
|
||||
Code = PersonnelListPermissionCode,
|
||||
ParentId = PersonnelOperationsPermissionCode
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region فیش حقوقی غیر رسمی,ParentId = CustomizeCheckoutOperationsPermissionCode
|
||||
|
||||
|
||||
public static SubAccountPermissionDto CustomizeCheckoutSetGroupAndSalaryPermission { get; } = new()
|
||||
public static SubAccountPermissionDto CustomizeCheckoutSetGroupAndSalaryPermission { get; } = new()
|
||||
{
|
||||
Id = CustomizeCheckoutSetGroupAndSalaryPermissionCode,
|
||||
Name = "تنظیم گروه بندی و حقوق پرسنل",
|
||||
|
||||
@@ -19,6 +19,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace _0_Framework.Application;
|
||||
@@ -32,6 +33,15 @@ public static class Tools
|
||||
public static string[] DayNames = { "شنبه", "یکشنبه", "دو شنبه", "سه شنبه", "چهار شنبه", "پنج شنبه", "جمعه" };
|
||||
public static string[] DayNamesG = { "یکشنبه", "دو شنبه", "سه شنبه", "چهار شنبه", "پنج شنبه", "جمعه", "شنبه" };
|
||||
|
||||
|
||||
public static bool IsMobileValid(this string mobileNo)
|
||||
{
|
||||
if (mobileNo.Length < 11)
|
||||
return false;
|
||||
return Regex.IsMatch(mobileNo, "^((09))(\\d{9})$");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت روزهای کارکرد پرسنل در لیست بیمه ماه مشخص شده
|
||||
/// با کمک شروع بکار و ترک کار
|
||||
@@ -778,8 +788,8 @@ public static class Tools
|
||||
{
|
||||
case "0000000000":
|
||||
case "1111111111":
|
||||
case "22222222222":
|
||||
case "33333333333":
|
||||
case "2222222222":
|
||||
case "3333333333":
|
||||
case "4444444444":
|
||||
case "5555555555":
|
||||
case "6666666666":
|
||||
@@ -1377,15 +1387,41 @@ public static class Tools
|
||||
var pc = new PersianCalendar();
|
||||
return ($"{pc.GetYear(date)}/{pc.GetMonth(date):00}/01").ToGeorgianDateTime();
|
||||
}
|
||||
#region Mahan
|
||||
/// <summary>
|
||||
/// این متد سعی میکند رشته را به تاریخ برگرداند و یک بول و دیت تایم برمیگرداند
|
||||
/// </summary>
|
||||
/// <param name="persianDate">تاریخ شمسی</param>
|
||||
/// <param name="georgianDateTime">تاریخ</param>
|
||||
/// <returns></returns>
|
||||
public static bool TryToGeorgianDateTime(this string persianDate, out DateTime georgianDateTime)
|
||||
#region Mahan
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// این متد حروف عربی را به فارسی در میاورد. مثال: علي را به علی تبدیل میکند
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToPersian(this string text)
|
||||
{
|
||||
var res = "";
|
||||
foreach (var @char in text)
|
||||
{
|
||||
|
||||
if (@char == char.Parse("ي"))
|
||||
res += "ی";
|
||||
else
|
||||
res += @char;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// این متد سعی میکند رشته را به تاریخ برگرداند و یک بول و دیت تایم برمیگرداند
|
||||
/// </summary>
|
||||
/// <param name="persianDate">تاریخ شمسی</param>
|
||||
/// <param name="georgianDateTime">تاریخ</param>
|
||||
/// <returns></returns>
|
||||
public static bool TryToGeorgianDateTime(this string persianDate, out DateTime georgianDateTime)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(persianDate))
|
||||
{
|
||||
georgianDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
|
||||
return false;
|
||||
}
|
||||
persianDate = persianDate.ToEnglishNumber();
|
||||
try
|
||||
{
|
||||
|
||||
@@ -32,11 +32,24 @@ 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);
|
||||
if(!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
return responseResult;
|
||||
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();
|
||||
|
||||
|
||||
return responseResult;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +63,19 @@ 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 requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace _0_Framework.Excel.Checkout;
|
||||
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
public class CustomizeCheckoutExcelGenerator
|
||||
{
|
||||
public static byte[] GenerateCheckoutTempExcelInfo(List<CustomizeCheckoutTempExcelViewModel> data, List<string> selectedParameters)
|
||||
{
|
||||
OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
using var package = new ExcelPackage();
|
||||
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
|
||||
|
||||
|
||||
// Define headers
|
||||
Dictionary<string, string> headers = new Dictionary<string, string>
|
||||
{
|
||||
{ "Month", "ماه" },
|
||||
{ "Year", "سال" },
|
||||
{ "EmployeeFullName", "نام و نام خانوادگی" },
|
||||
{ "PersonnelCodeString", "شماره پرسنلی" },
|
||||
{ "NationalCode", "کدملی" },
|
||||
{ "SumOfWorkingDays", "روز کارکرد" },
|
||||
{ "MonthlySalary", "حقوق ماهانه" },
|
||||
{ "BaseYearsPay", "سنوات" },
|
||||
{ "MarriedAllowance", "حق تاهل" },
|
||||
{ "OvertimePay", "اضافه کاری" },
|
||||
{ "NightworkPay", "شب کاری" },
|
||||
{ "FridayPay", "جمعه کاری" },
|
||||
{ "MissionPay", "مأموریت" },
|
||||
{ "ShiftPay", "نوبت کاری" },
|
||||
{ "FamilyAllowance", "حق فرزند" },
|
||||
{ "BonusesPay", "پاداش" },
|
||||
{ "LeavePay", "مزد مرخصی" },
|
||||
{ "RewardPay", "پاداش" },
|
||||
{ "FineDeduction", "جریمه" },
|
||||
{ "InsuranceDeduction", "حق بیمه" },
|
||||
{ "TaxDeducation", "مالیات" },
|
||||
{ "InstallmentDeduction", "قسط وام" },
|
||||
{ "SalaryAidDeduction", "مساعده" },
|
||||
{ "AbsenceDeduction", "غیبت" },
|
||||
{ "EarlyExitDeduction", "تعجیل در خروج" },
|
||||
{ "LateToWorkDeduction", "تاخیر در ورود" },
|
||||
{ "TotalClaims", "جمع مطالبات" },
|
||||
{ "TotalDeductions", "جمع کسورات" },
|
||||
{ "TotalPayment", "مبلغ قابل پرداخت" },
|
||||
{ "CardNumber", "شماره کارت" },
|
||||
{ "ShebaNumber", "شماره شبا" },
|
||||
{ "BankAccountNumber", "شماره حساب" },
|
||||
|
||||
};
|
||||
Dictionary<string, string> filteredHeaders;
|
||||
if (!selectedParameters.Any())
|
||||
{
|
||||
filteredHeaders = headers;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Filter headers based on selected parameters
|
||||
filteredHeaders = headers.Where(h => selectedParameters.Contains(h.Key)).ToDictionary();
|
||||
}
|
||||
var indexCell = worksheet.Cells[1, 1];
|
||||
indexCell.Value = "ردیف";
|
||||
ApplyHeaderStyle(indexCell);
|
||||
// Add headers to worksheet
|
||||
for (int i = 0; i < filteredHeaders.Count; i++)
|
||||
{
|
||||
worksheet.Cells[1, i + 2].Value = filteredHeaders.ElementAt(i).Value;
|
||||
ApplyHeaderStyle(worksheet.Cells[1, i + 2]);
|
||||
}
|
||||
|
||||
var dataRow = 2;
|
||||
int totalPaymentColumnIndex = -1;
|
||||
foreach (var item in data)
|
||||
{
|
||||
var column = 2;
|
||||
foreach (var header in filteredHeaders)
|
||||
{
|
||||
var property = item.GetType().GetProperty(header.Key);
|
||||
var value = property.GetValue(item, null)?.ToString();
|
||||
|
||||
// Check if the property requires MoneyToDouble()
|
||||
if (RequiresMoneyToDouble(property.Name))
|
||||
{
|
||||
worksheet.Cells[dataRow, column].Value = MoneyToDouble(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
worksheet.Cells[dataRow, column].Value = value;
|
||||
}
|
||||
|
||||
ApplyGeneralDataStyle(worksheet.Cells[dataRow, column]);
|
||||
ApplySpecificStyle(worksheet.Cells[dataRow, column], column); // Apply specific styles
|
||||
if (header.Key == "TotalPayment")
|
||||
{
|
||||
totalPaymentColumnIndex = column;
|
||||
}
|
||||
column++;
|
||||
}
|
||||
var rowCounter = worksheet.Cells[dataRow, 1];
|
||||
rowCounter.Value = dataRow - 1;
|
||||
ApplyGeneralDataStyle(rowCounter);
|
||||
ApplySpecificStyle(rowCounter, 1);
|
||||
|
||||
dataRow++;
|
||||
}
|
||||
|
||||
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
worksheet.PrinterSettings.PaperSize = ePaperSize.A4;
|
||||
worksheet.PrinterSettings.Orientation = eOrientation.Landscape;
|
||||
worksheet.PrinterSettings.FitToPage = true;
|
||||
worksheet.PrinterSettings.FitToWidth = 1;
|
||||
worksheet.PrinterSettings.FitToHeight = 0;
|
||||
worksheet.PrinterSettings.Scale = 85;
|
||||
worksheet.View.RightToLeft = true;
|
||||
|
||||
if (totalPaymentColumnIndex != -1)
|
||||
{
|
||||
ApplyConditionalFormatting(worksheet, dataRow, totalPaymentColumnIndex);
|
||||
}
|
||||
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
|
||||
// Method to check if a property requires MoneyToDouble()
|
||||
private static bool RequiresMoneyToDouble(string propertyName)
|
||||
{
|
||||
var propertiesRequiringConversion = new HashSet<string>
|
||||
{
|
||||
"MonthlySalary", "RewardPay", "FridayPay", "OvertimePay", "ShiftPay", "NightWorkPay",
|
||||
"MarriedAllowance", "FamilyAllowance", "BonusesPay", "BaseYearsPay", "LeavePay",
|
||||
"AbsenceDeduction", "LateToWorkDeduction", "EarlyExitDeduction", "SalaryAidDeduction",
|
||||
"InstallmentDeduction", "FineDeduction", "InsuranceDeduction", "TaxDeduction",
|
||||
"TotalClaims", "TotalDeductions", "TotalPayment"
|
||||
};
|
||||
return propertiesRequiringConversion.Contains(propertyName);
|
||||
}
|
||||
|
||||
// Placeholder for the MoneyToDouble() method
|
||||
private static double MoneyToDouble(string value)
|
||||
{
|
||||
Console.WriteLine(value);
|
||||
var min = value.Length>1? value.Substring(0, 2): "";
|
||||
var test = min == "\u200e\u2212" ? value.MoneyToDouble() * -1 : value.MoneyToDouble();
|
||||
|
||||
Console.WriteLine(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private static void ApplyHeaderStyle(ExcelRange cell)
|
||||
{
|
||||
cell.Style.Font.Bold = true;
|
||||
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
|
||||
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
}
|
||||
|
||||
private static void ApplyGeneralDataStyle(ExcelRange cell)
|
||||
{
|
||||
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
}
|
||||
|
||||
private static void ApplySpecificStyle(ExcelRange cell, int columnIndex)
|
||||
{
|
||||
switch (columnIndex)
|
||||
{
|
||||
case int n when (n >= 1 && n <= 8):
|
||||
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightYellow);
|
||||
break;
|
||||
case int n when (n >= 9 && n <= 19):
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 208, 248, 208);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case int n when (n >= 20 && n <= 27):
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 246, 176, 176);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case 28:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 169, 208, 142);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case 29:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 241, 143, 143);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case 30:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 168, 186, 254);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case >= 31 and <= 33:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightYellow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyConditionalFormatting(ExcelWorksheet worksheet, int dataRow, int totalPaymentColumnIndex)
|
||||
{
|
||||
for (int rowIndex = 2; rowIndex < dataRow; rowIndex++)
|
||||
{
|
||||
var totalPaymentValue = worksheet.Cells[rowIndex, totalPaymentColumnIndex].Value;
|
||||
if (totalPaymentValue != null && double.TryParse(totalPaymentValue.ToString(), out double payment))
|
||||
{
|
||||
if (payment < 0)
|
||||
{
|
||||
var rowRange = worksheet.Cells[rowIndex, 1, rowIndex, worksheet.Dimension.End.Column];
|
||||
rowRange.Style.Fill.PatternType = ExcelFillStyle.Solid; rowRange.Style.Fill.BackgroundColor.SetColor(Color.Red);
|
||||
foreach (var cell in rowRange)
|
||||
{
|
||||
cell.Style.Font.Color.SetColor(Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.empolyerAgg;
|
||||
using Company.Domain.RepresentativeAgg;
|
||||
@@ -42,8 +43,44 @@ public class PersonalContractingParty : EntityBase
|
||||
|
||||
public string IsActiveString { get; private set; }
|
||||
public string IsBlock { get; private set; }
|
||||
|
||||
public int BlockTimes {get; private set; }
|
||||
|
||||
#region NewProps
|
||||
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پدر
|
||||
/// </summary>
|
||||
public string FatherName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ تولد
|
||||
/// </summary>
|
||||
public DateTime? DateOfBirth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا از طریق ای پی ای احراز هویت شده است
|
||||
/// </summary>
|
||||
public bool IsAuthenticated { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// جنسیت
|
||||
/// </summary>
|
||||
public Gender Gender { get; private set; }
|
||||
#endregion
|
||||
|
||||
|
||||
public List<Employer> Employers { get; private set; }
|
||||
public Representative Representative { get; set; }
|
||||
|
||||
@@ -159,5 +196,21 @@ public class PersonalContractingParty : EntityBase
|
||||
this.IsActiveString = "false";
|
||||
}
|
||||
|
||||
|
||||
public void Authenticated()
|
||||
{
|
||||
IsAuthenticated = true;
|
||||
}
|
||||
|
||||
public void Authentication(string fName, string lName, string fatherName,string idNumber, string idNumberSeri, string idNumberSerial, string dateOfBirth, Gender gender)
|
||||
{
|
||||
this.FName = fName;
|
||||
this.LName = lName;
|
||||
this.FatherName = fatherName;
|
||||
this.IdNumberSeri = idNumberSeri;
|
||||
this.IdNumberSerial = idNumberSerial;
|
||||
this.DateOfBirth = !string.IsNullOrWhiteSpace(dateOfBirth) ? dateOfBirth.ToGeorgianDateTime() : null;
|
||||
this.IdNumber = idNumber;
|
||||
this.Gender = gender;
|
||||
this.IsAuthenticated = true;
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,6 @@ public interface ICustomizeWorkshopEmployeeSettingsRepository : IRepository<long
|
||||
List<CustomizeWorkshopEmployeeSettings> GetBy(long groupId);
|
||||
List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsByWorkshopId(long workshopId);
|
||||
List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingNotInMainGroup(long entityWorkshopId);
|
||||
void RemoveByWorkshopIdAndEmployeeId(long workshopId, long employeeId);
|
||||
|
||||
}
|
||||
@@ -21,11 +21,13 @@ 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 phone, string address, string state, string city,
|
||||
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)
|
||||
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)
|
||||
{
|
||||
FName = fName;
|
||||
LName = lName;
|
||||
@@ -135,7 +137,16 @@ public class Employee : EntityBase
|
||||
#region Pooya
|
||||
public List<EmployeeDocuments> EmployeeDocuments { get; set; }
|
||||
public EmployeeDocumentsAdminSelection EmployeeDocumentsAdminSelection { get; set; }
|
||||
public List<EmployeeBankInformation> EmployeeBankInformationList { get; set; }
|
||||
public List<EmployeeBankInformation> EmployeeBankInformationList { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
/// <summary>
|
||||
/// آیا پرسنل احراز هویت شده است
|
||||
/// </summary>
|
||||
public bool IsAuthorized { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
//public List<Checkout> Checkouts { get; set; }
|
||||
@@ -211,4 +222,17 @@ public class Employee : EntityBase
|
||||
this.IsActive = false;
|
||||
this.IsActiveString = "false";
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
public void EditFromEmployeeClientTemp(string maritalStatus)
|
||||
{
|
||||
MaritalStatus = maritalStatus;
|
||||
}
|
||||
|
||||
public void Authorized()
|
||||
{
|
||||
IsAuthorized = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.EmployeeInsuranceRecordAgg;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||
|
||||
namespace Company.Domain.EmployeeAgg;
|
||||
@@ -47,6 +48,14 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
Employee GetByNationalCode(string nationalCode);
|
||||
List<EmployeeViewModel> GetBy(List<long> employeeIds);
|
||||
|
||||
Employee GetByNationalCodeIgnoreQueryFilter(string nationalCode);
|
||||
Task<ICollection<ClientStartedWorkEmployeesDto>> GetClientEmployeesStartWork(long workshopId);
|
||||
Task<ICollection<ClientLeftWorkWorkEmployeesDto>> GetEmployeesForLeftWorkTemp(long workshopId);
|
||||
|
||||
Employee GetIgnoreQueryFilter(long id);
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
@@ -54,7 +63,14 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
List<EmployeeViewModel> GetWorkingEmployeesByWorkshopIdsAndNationalCodeAndDate(List<long> workshopIds, string nationalCode, DateTime date);
|
||||
List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId);
|
||||
|
||||
List<EmployeeViewModel> GetWorkedEmployeesByWorkshopIdsAndNationalCodeAndDate(List<long> workshopIds,
|
||||
string nationalCode, DateTime date);
|
||||
|
||||
List<(long Id, string Name)> SimpleGetRangeByIds(IEnumerable<long> newEmployeeIds);
|
||||
Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId,
|
||||
long workshopId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
31
Company.Domain/EmployeeClientTempAgg/EmployeeClientTemp.cs
Normal file
31
Company.Domain/EmployeeClientTempAgg/EmployeeClientTemp.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
|
||||
namespace Company.Domain.EmployeeClientTempAgg;
|
||||
|
||||
public class EmployeeClientTemp : EntityBase
|
||||
{
|
||||
public EmployeeClientTemp(long workshopId, DateTime startWorkDate, long employeeId, string maritalStatus,
|
||||
string employeeFullName)
|
||||
{
|
||||
StartWorkDate = startWorkDate;
|
||||
WorkshopId = workshopId;
|
||||
EmployeeId = employeeId;
|
||||
MaritalStatus = maritalStatus;
|
||||
EmployeeFullName = employeeFullName;
|
||||
}
|
||||
|
||||
public string EmployeeFullName { get; private set; }
|
||||
public long WorkshopId { get; private set; }
|
||||
public long EmployeeId { get; private set; }
|
||||
public DateTime StartWorkDate { get; private set; }
|
||||
|
||||
public string MaritalStatus { get; private set; }
|
||||
|
||||
public void Edit(string maritalStatus)
|
||||
{
|
||||
|
||||
MaritalStatus = maritalStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
namespace Company.Domain.EmployeeClientTempAgg;
|
||||
|
||||
public interface IEmployeeClientTempRepository : IRepository<long, EmployeeClientTemp>
|
||||
{
|
||||
EmployeeClientTemp GetByEmployeeIdAndWorkshopId(long employeeId, long commandWorkshopId);
|
||||
EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId);
|
||||
void Remove(EmployeeClientTemp entity);
|
||||
}
|
||||
@@ -54,11 +54,12 @@ namespace Company.Domain.EmployeeDocumentsAgg
|
||||
|
||||
var currentItems = EmployeeDocumentItemCollection.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted)
|
||||
.GroupBy(x => x.DocumentLabel).Select(x => x.OrderByDescending(y => y.CreationDate).First());
|
||||
var currentItemsFiltered = currentItems.Where(x => x.DocumentStatus == DocumentStatus.Confirmed || x.DocumentStatus == DocumentStatus.SubmittedByAdmin)
|
||||
.Select(x => new{x.DocumentStatus,x.DocumentLabel}).ToList();
|
||||
var currentItemsFiltered = currentItems.Where(x => x.DocumentStatus is DocumentStatus.Confirmed or DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient)
|
||||
.Select(x => new { x.DocumentStatus, x.DocumentLabel }).ToList();
|
||||
|
||||
|
||||
// ReSharper disable once SimplifyLinqExpressionUseAll
|
||||
if (!currentItemsFiltered.Any(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin))
|
||||
if (!currentItemsFiltered.Any(x => x.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient))
|
||||
IsSentToChecker = false;
|
||||
|
||||
else
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace Company.Domain.EmployeeDocumentsAgg
|
||||
|
||||
List<WorkshopWithEmployeeDocumentsViewModel> GetWorkshopsWithDocumentsAwaitingReviewForAdminWorkFlow(List<long> workshops);
|
||||
List<EmployeeDocumentsViewModel> GetByWorkshopIdWithItemsForAdminWorkFlow(long workshopId);
|
||||
int GetCheckerWorkFlowCount();
|
||||
//int GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds);
|
||||
int GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds);
|
||||
Task<int> GetCheckerWorkFlowCount();
|
||||
Task<int> GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds);
|
||||
Task<int> GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds);
|
||||
List<EmployeeDocumentsViewModel> GetDocumentsAwaitingReviewByWorkshopIdForCheckerWorkFlow(long workshopId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public interface ILeftWorkRepository : IRepository<long, LeftWork>
|
||||
/// <returns>یک کلاس از جنس اطلاعات ترک کار</returns>
|
||||
LeftWorkViewModel GetByDateAndWorkshopIdAndEmployeeId(long workshopId, long employeeId, DateTime dateTime);
|
||||
List<long> GetAllEmployeeIdsInWorkshop(long workshopId);
|
||||
LeftWork GetLastLeftWorkByEmployeeIdAndWorkshopId(long workshopId, long employeeId);
|
||||
|
||||
|
||||
#endregion
|
||||
List<LeftWorkViewModel> GetLeftPersonelByWorkshopId(List<long> workshopIds);
|
||||
@@ -40,7 +42,7 @@ public interface ILeftWorkRepository : IRepository<long, LeftWork>
|
||||
bool IsEmployeeWorkingInDates(long employeeId, long workshopId, List<(DateTime, DateTime)> dates);
|
||||
List<LeftWorkViewModel> GetByWorkshopIdInDates(long workshopId, DateTime startDateGr, DateTime endDateGr);
|
||||
LeftWorkViewModel GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start, DateTime end);
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId);
|
||||
}
|
||||
17
Company.Domain/LeftWorkTempAgg/ILeftWorkTempRepository.cs
Normal file
17
Company.Domain/LeftWorkTempAgg/ILeftWorkTempRepository.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
namespace Company.Domain.LeftWorkTempAgg;
|
||||
|
||||
public interface ILeftWorkTempRepository:IRepository<long,LeftWorkTemp>
|
||||
{
|
||||
/// <summary>
|
||||
/// گرفتن اطلاعات برای مودال جزئیات شروع به کار موقت یا ترک کار موقت
|
||||
/// </summary>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId);
|
||||
void Remove(LeftWorkTemp entity);
|
||||
}
|
||||
65
Company.Domain/LeftWorkTempAgg/LeftWorkTemp.cs
Normal file
65
Company.Domain/LeftWorkTempAgg/LeftWorkTemp.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
namespace Company.Domain.LeftWorkTempAgg;
|
||||
|
||||
public class LeftWorkTemp:EntityBase
|
||||
{
|
||||
private LeftWorkTemp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// برای ایجاد ترک کار موقت
|
||||
/// </summary>
|
||||
/// <param name="leftWorkId"></param>
|
||||
/// <param name="startWorkDate"></param>
|
||||
/// <param name="leftWork"></param>
|
||||
/// <param name="lastDayStanding"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <param name="jobId"></param>
|
||||
public static LeftWorkTemp CreateLeftWork(long leftWorkId, DateTime startWorkDate, DateTime leftWork, DateTime lastDayStanding, long workshopId, long employeeId,long jobId)
|
||||
{
|
||||
var leftWorkTemp = new LeftWorkTemp
|
||||
{
|
||||
LeftWorkId = leftWorkId,
|
||||
LeftWork = leftWork,
|
||||
LastDayStanding = lastDayStanding,
|
||||
WorkshopId = workshopId,
|
||||
EmployeeId = employeeId,
|
||||
StartWork = startWorkDate,
|
||||
LeftWorkType = LeftWorkTempType.LeftWork,
|
||||
JobId = jobId
|
||||
};
|
||||
|
||||
return leftWorkTemp;
|
||||
}
|
||||
|
||||
|
||||
public static LeftWorkTemp CreateStartWork(long workshopId, long employeeId, DateTime startDate,long jobId)
|
||||
{
|
||||
var leftWorkTemp = new LeftWorkTemp
|
||||
{
|
||||
StartWork = startDate,
|
||||
WorkshopId = workshopId,
|
||||
EmployeeId = employeeId,
|
||||
JobId = jobId,
|
||||
LeftWorkType = LeftWorkTempType.StartWork
|
||||
};
|
||||
return leftWorkTemp;
|
||||
}
|
||||
|
||||
public long LeftWorkId { get; private set; }
|
||||
public DateTime StartWork { get; private set; }
|
||||
public DateTime LeftWork { get; private set; }
|
||||
public DateTime LastDayStanding { get; private set; }
|
||||
public long WorkshopId { get; private set; }
|
||||
public long EmployeeId { get; private set; }
|
||||
public long JobId { get; private set; }
|
||||
public LeftWorkTempType LeftWorkType { get; private set; }
|
||||
}
|
||||
|
||||
@@ -18,4 +18,11 @@ public interface IPersonnelCodeRepository : IRepository<long, PersonnelCodeDomai
|
||||
|
||||
long GetPSCodeByWorkshopIdAndEmployeeId(long workshopId, long employeeId);
|
||||
long GetEmployeeIdByPersonelCode(long personleCode, long workshopId);
|
||||
|
||||
#region Mahan
|
||||
|
||||
long GetLastPersonnelCodeByWorkshop(long workshopId);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -209,7 +209,8 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
var shiftDetails = GetEmployeeShiftDetails(employeeId, workshopId);
|
||||
|
||||
|
||||
List<RollCall> rollCalls = GetRollCallsInShiftDate(rollCall.ShiftDate,employeeId, workshopId).GetAwaiter().GetResult();
|
||||
List<RollCall> rollCalls = GetRollCallsInShiftDate(rollCall.ShiftDate, employeeId, workshopId).GetAwaiter().GetResult();
|
||||
|
||||
var deletedRollCall = rollCalls.FirstOrDefault(x => x.id == rollCall.id);
|
||||
|
||||
rollCalls.Remove(deletedRollCall);
|
||||
@@ -255,7 +256,7 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
var lateEntryRollCall = rollCallsInShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate > employeeShift.start);
|
||||
|
||||
|
||||
|
||||
|
||||
var previousShift = employeeShifts.OrderByDescending(x => x.start)
|
||||
.FirstOrDefault(x => x.end < employeeShift.start);
|
||||
@@ -298,6 +299,8 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
var lateExitRollCall = rollCallsInShift.OrderBy(x => x.EndDate).FirstOrDefault(x => x.EndDate > employeeShift.end);
|
||||
|
||||
|
||||
|
||||
// تعجیل در خروج - زود رفتن
|
||||
var nextShift = employeeShifts.OrderBy(x => x.start)
|
||||
.FirstOrDefault(x => x.start > employeeShift.end);
|
||||
@@ -371,8 +374,7 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
|
||||
var lateEntryRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.StartDate).FirstOrDefault(x => x.StartDate > shift.start);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (earlyEntryRollCallRotating != null)
|
||||
{
|
||||
@@ -403,6 +405,7 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
var lateExitRollCallRotating = rollCallsInRotatingShift.OrderBy(x => x.EndDate).FirstOrDefault(x => x.EndDate > shift.end);
|
||||
|
||||
|
||||
|
||||
|
||||
if (earlyExitRollCallRotating != null && (rollCallsInRotatingShift.Any(x =>
|
||||
x.StartDate < rotatingShiftEnd && x.StartDate > earlyExitRollCallRotating.EndDate) == false))
|
||||
@@ -434,7 +437,7 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
_rollCallRepository.SaveChanges();
|
||||
}
|
||||
|
||||
private async Task<List<RollCall>> GetRollCallsInShiftDate(DateTime rollCallShiftDate,long employeeId,long workshopId)
|
||||
private async Task<List<RollCall>> GetRollCallsInShiftDate(DateTime rollCallShiftDate, long employeeId, long workshopId)
|
||||
{
|
||||
return await _rollCallRepository.GetRollCallsInShiftDate(rollCallShiftDate, employeeId, workshopId);
|
||||
}
|
||||
|
||||
@@ -515,8 +515,21 @@ namespace Company.Domain.RollCallAgg
|
||||
|
||||
FridayWorkTimeSpan = CalculateFridayWorkDuration(StartDate.Value, EndDate.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// جیزه
|
||||
/// </summary>
|
||||
public void ClearTimeDiff()
|
||||
{
|
||||
LateExitDuration = TimeSpan.Zero;
|
||||
EarlyExitDuration = TimeSpan.Zero;
|
||||
LateEntryDuration = TimeSpan.Zero;
|
||||
EarlyEntryDuration = TimeSpan.Zero;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum RollCallModifyType
|
||||
{
|
||||
None,
|
||||
|
||||
@@ -28,6 +28,8 @@ public interface IRollCallEmployeeRepository : IRepository<long, RollCallEmploye
|
||||
|
||||
bool HasEmployees(long workshopId);
|
||||
(int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId);
|
||||
RollCallEmployee GetBy(long employeeId, long workshopId);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -17,4 +17,5 @@ public interface IRollCallServiceRepository : IRepository<long, RollCallService>
|
||||
List<RollCallServiceViewModel> GetAllServiceByAccountId(long accountId);
|
||||
|
||||
|
||||
bool IsExistActiveServiceByWorkshopId(long workshopId);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
|
||||
namespace Company.Domain.TemporaryClientRegistrationAgg;
|
||||
|
||||
public class ContractingPartyTemp : EntityBase
|
||||
{
|
||||
public ContractingPartyTemp(string fName, string lName, string nationalCode, string idNumber, string phone, string fatherName, string state, string city, string address, string idNumberSeri, string idNumberSerial, Gender gender, DateTime dateOfBirth)
|
||||
{
|
||||
FName = fName;
|
||||
LName = lName;
|
||||
NationalCode = nationalCode;
|
||||
IdNumber = idNumber;
|
||||
Phone = phone;
|
||||
FatherName = fatherName;
|
||||
State = state;
|
||||
City = city;
|
||||
Address = address;
|
||||
IdNumberSeri = idNumberSeri;
|
||||
IdNumberSerial = idNumberSerial;
|
||||
Gender = gender;
|
||||
DateOfBirth = dateOfBirth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نام
|
||||
/// </summary>
|
||||
public string FName { get; private set; }
|
||||
/// <summary>
|
||||
/// نام خانوادگی
|
||||
/// </summary>
|
||||
public string LName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پدر
|
||||
/// </summary>
|
||||
public string FatherName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// جنسیت
|
||||
/// </summary>
|
||||
public Gender Gender { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///تاریخ تولد
|
||||
/// </summary>
|
||||
public DateTime DateOfBirth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; private set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// شماره همراه
|
||||
/// </summary>
|
||||
public string Phone { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// استان
|
||||
/// </summary>
|
||||
public string State { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// شهر
|
||||
/// </summary>
|
||||
public string City { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// نشانی
|
||||
/// </summary>
|
||||
public string Address { get; private set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
|
||||
namespace Company.Domain.TemporaryClientRegistrationAgg;
|
||||
|
||||
public interface IContractingPartyTempRepository :IRepository<long, ContractingPartyTemp>
|
||||
{
|
||||
/// <summary>
|
||||
/// چک میکند که آیا طرف حساب با این کد ملی قبلا ایجاد شده است یا خبر
|
||||
/// اگر ایجاد شده احراز هویت نشده احراز هویت میشود
|
||||
/// </summary>
|
||||
/// <param name="nationalCode"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> CheckExistOrAuthenticated(string nationalCode, string dateOfBirth);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات طرف حساب موقت با کد ملی
|
||||
/// </summary>
|
||||
/// <param name="nationalCode"></param>
|
||||
/// <returns></returns>
|
||||
ContractingPartyTempViewModel GetByNationalCode(string nationalCode);
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
|
||||
namespace Company.Domain.WorkshopAgg;
|
||||
|
||||
@@ -59,18 +61,23 @@ public interface IWorkshopRepository : IRepository<long, Workshop>
|
||||
List<PrintListWorkshop> PrintWorkshopList(WorkshopSearchModel searchModel);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
PersonalContractingPartyViewModel GetPersonalContractingPartyByWorkshopId(long workshopId);
|
||||
List<WorkshopViewModel> GetWorkshopsByClientAccountId(long clientAccountId);
|
||||
Task<List<WorkshopWithStartedEmployeesDto>> GetWorkshopsForEmployeeStartWork(long accountId);
|
||||
Task<int> GetWorkshopsForEmployeeStartWorkCount(long accountId);
|
||||
Task<List<WorkshopWithLeftWorkTempEmployeesDto>> GetWorkshopsForLeftWorkTemp(long accountId);
|
||||
Task<int> GetWorkshopsForLeftWorkTempCount(long accountId);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Insurance
|
||||
/// <summary>
|
||||
/// لیست انتخاب کارگاه در مودال ایجاد بیمه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<WorkshopViewModel> GetWorkshopSelectListInsuransce();
|
||||
#region Insurance
|
||||
/// <summary>
|
||||
/// لیست انتخاب کارگاه در مودال ایجاد بیمه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<WorkshopViewModel> GetWorkshopSelectListInsuransce();
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
@@ -87,4 +94,13 @@ public interface IWorkshopRepository : IRepository<long, Workshop>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
OperationResult EditAccountLeftWorkAndWorkshopAccounts(List<long> accountIds, long workshopId);
|
||||
|
||||
|
||||
#region Pooya
|
||||
|
||||
List<PersonnelInfoViewModel> GetPersonnelInfoRemastered(long searchModelWorkshopId);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
using System.Drawing;
|
||||
using _0_Framework.Application;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
|
||||
namespace CompanyManagement.Infrastructure.Excel.Checkout;
|
||||
|
||||
public class CustomizeCheckoutExcelGenerator
|
||||
{
|
||||
|
||||
public static Dictionary<string, string> Header { get; set; } = new() {
|
||||
{ "Month", "ماه" },
|
||||
{ "Year", "سال" },
|
||||
{ "EmployeeFullName", "نام و نام خانوادگی" },
|
||||
{ "PersonnelCodeString", "شماره پرسنلی" },
|
||||
{ "NationalCode", "کدملی" },
|
||||
{ "SumOfWorkingDays", "روز کارکرد" },
|
||||
{ "MonthlySalary", "حقوق ماهانه" },
|
||||
{ "BaseYearsPay", "سنوات" },
|
||||
{ "MarriedAllowance", "حق تاهل" },
|
||||
{ "OvertimePay", "اضافه کاری" },
|
||||
{ "NightworkPay", "شب کاری" },
|
||||
{ "FridayPay", "جمعه کاری" },
|
||||
{ "MissionPay", "مأموریت" },
|
||||
{ "ShiftPay", "نوبت کاری" },
|
||||
{ "FamilyAllowance", "حق فرزند" },
|
||||
{ "BonusesPay", "پاداش" },
|
||||
{ "LeavePay", "مزد مرخصی" },
|
||||
{ "RewardPay", "پاداش" },
|
||||
{ "FineDeduction", "جریمه" },
|
||||
{ "InsuranceDeduction", "حق بیمه" },
|
||||
{ "TaxDeducation", "مالیات" },
|
||||
{ "InstallmentDeduction", "قسط وام" },
|
||||
{ "SalaryAidDeduction", "مساعده" },
|
||||
{ "AbsenceDeduction", "غیبت" },
|
||||
{ "EarlyExitDeduction", "تعجیل در خروج" },
|
||||
{ "LateToWorkDeduction", "تاخیر در ورود" },
|
||||
{ "TotalClaims", "جمع مطالبات" },
|
||||
{ "TotalDeductions", "جمع کسورات" },
|
||||
{ "TotalPayment", "مبلغ قابل پرداخت" },
|
||||
{ "CardNumber", "شماره کارت" },
|
||||
{ "ShebaNumber", "شماره شبا" },
|
||||
{ "BankAccountNumber", "شماره حساب" },
|
||||
{ "BankName", "نام بانک" },
|
||||
|
||||
};
|
||||
public static byte[] GenerateCheckoutTempExcelInfo(List<CustomizeCheckoutTempExcelViewModel> data, List<string> selectedParameters)
|
||||
{
|
||||
OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
using var package = new ExcelPackage();
|
||||
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
|
||||
|
||||
|
||||
// Define headers
|
||||
|
||||
Dictionary<string, string> filteredHeaders;
|
||||
if (!selectedParameters.Any())
|
||||
{
|
||||
filteredHeaders = Header;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Filter headers based on selected parameters
|
||||
filteredHeaders = Header.Where(h => selectedParameters.Contains(h.Key)).ToDictionary();
|
||||
}
|
||||
var indexCell = worksheet.Cells[1, 1];
|
||||
indexCell.Value = "ردیف";
|
||||
ApplyHeaderStyle(indexCell);
|
||||
// Add headers to worksheet
|
||||
for (int i = 0; i < filteredHeaders.Count; i++)
|
||||
{
|
||||
worksheet.Cells[1, i + 2].Value = filteredHeaders.ElementAt(i).Value;
|
||||
ApplyHeaderStyle(worksheet.Cells[1, i + 2]);
|
||||
}
|
||||
|
||||
var dataRow = 2;
|
||||
int totalPaymentColumnIndex = -1;
|
||||
foreach (var item in data)
|
||||
{
|
||||
var column = 2;
|
||||
foreach (var header in filteredHeaders)
|
||||
{
|
||||
var property = item.GetType().GetProperty(header.Key);
|
||||
var value = property.GetValue(item, null)?.ToString();
|
||||
|
||||
// Check if the property requires MoneyToDouble()
|
||||
if (RequiresMoneyToDouble(property.Name))
|
||||
{
|
||||
worksheet.Cells[dataRow, column].Value = MoneyToDouble(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
worksheet.Cells[dataRow, column].Value = value;
|
||||
}
|
||||
|
||||
ApplyGeneralDataStyle(worksheet.Cells[dataRow, column]);
|
||||
ApplySpecificStyle(worksheet.Cells[dataRow, column], column, worksheet); // Apply specific styles
|
||||
if (header.Key == "TotalPayment")
|
||||
{
|
||||
totalPaymentColumnIndex = column;
|
||||
}
|
||||
column++;
|
||||
}
|
||||
var rowCounter = worksheet.Cells[dataRow, 1];
|
||||
rowCounter.Value = dataRow - 1;
|
||||
ApplyGeneralDataStyle(rowCounter);
|
||||
ApplySpecificStyle(rowCounter, 1, worksheet);
|
||||
|
||||
dataRow++;
|
||||
}
|
||||
|
||||
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
worksheet.PrinterSettings.PaperSize = ePaperSize.A4;
|
||||
worksheet.PrinterSettings.Orientation = eOrientation.Landscape;
|
||||
worksheet.PrinterSettings.FitToPage = true;
|
||||
worksheet.PrinterSettings.FitToWidth = 1;
|
||||
worksheet.PrinterSettings.FitToHeight = 0;
|
||||
worksheet.PrinterSettings.Scale = 85;
|
||||
worksheet.View.RightToLeft = true;
|
||||
|
||||
if (totalPaymentColumnIndex != -1)
|
||||
{
|
||||
ApplyConditionalFormatting(worksheet, dataRow, totalPaymentColumnIndex);
|
||||
}
|
||||
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
|
||||
// Method to check if a property requires MoneyToDouble()
|
||||
private static bool RequiresMoneyToDouble(string propertyName)
|
||||
{
|
||||
var propertiesRequiringConversion = new HashSet<string>
|
||||
{
|
||||
"MonthlySalary", "RewardPay", "FridayPay", "OvertimePay", "ShiftPay", "NightWorkPay",
|
||||
"MarriedAllowance", "FamilyAllowance", "BonusesPay", "BaseYearsPay", "LeavePay",
|
||||
"AbsenceDeduction", "LateToWorkDeduction", "EarlyExitDeduction", "SalaryAidDeduction",
|
||||
"InstallmentDeduction", "FineDeduction", "InsuranceDeduction", "TaxDeduction",
|
||||
"TotalClaims", "TotalDeductions", "TotalPayment"
|
||||
};
|
||||
return propertiesRequiringConversion.Contains(propertyName);
|
||||
}
|
||||
|
||||
// Placeholder for the MoneyToDouble() method
|
||||
private static double MoneyToDouble(string value)
|
||||
{
|
||||
Console.WriteLine(value);
|
||||
var min = value.Length > 1 ? value.Substring(0, 2) : "";
|
||||
var test = min == "\u200e\u2212" ? value.MoneyToDouble() * -1 : value.MoneyToDouble();
|
||||
|
||||
Console.WriteLine(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private static void ApplyHeaderStyle(ExcelRange cell)
|
||||
{
|
||||
cell.Style.Font.Bold = true;
|
||||
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
|
||||
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
}
|
||||
|
||||
private static void ApplyGeneralDataStyle(ExcelRange cell)
|
||||
{
|
||||
cell.Style.Border.BorderAround(ExcelBorderStyle.Thin);
|
||||
cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
|
||||
}
|
||||
|
||||
private static void ApplySpecificStyle(ExcelRange cell, int columnIndex, ExcelWorksheet worksheet)
|
||||
{
|
||||
var headerCell = worksheet.Cells[1, columnIndex].Value.ToString();
|
||||
|
||||
var index = Header.Values.ToList().IndexOf(headerCell);
|
||||
index += 2;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case int n when (n >= 1 && n <= 8):
|
||||
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightYellow);
|
||||
break;
|
||||
case int n when (n >= 9 && n <= 19):
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 208, 248, 208);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case int n when (n >= 20 && n <= 27):
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 246, 176, 176);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case 28:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 169, 208, 142);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case 29:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 241, 143, 143);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case 30:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(1, 168, 186, 254);
|
||||
cell.Style.Numberformat.Format = "#,##0";
|
||||
break;
|
||||
case >= 31 and <= 34:
|
||||
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightYellow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyConditionalFormatting(ExcelWorksheet worksheet, int dataRow, int totalPaymentColumnIndex)
|
||||
{
|
||||
for (int rowIndex = 2; rowIndex < dataRow; rowIndex++)
|
||||
{
|
||||
var totalPaymentValue = worksheet.Cells[rowIndex, totalPaymentColumnIndex].Value;
|
||||
if (totalPaymentValue != null && double.TryParse(totalPaymentValue.ToString(), out double payment))
|
||||
{
|
||||
if (payment < 0)
|
||||
{
|
||||
var rowRange = worksheet.Cells[rowIndex, 1, rowIndex, worksheet.Dimension.End.Column];
|
||||
rowRange.Style.Fill.PatternType = ExcelFillStyle.Solid; rowRange.Style.Fill.BackgroundColor.SetColor(Color.Red);
|
||||
foreach (var cell in rowRange)
|
||||
{
|
||||
cell.Style.Font.Color.SetColor(Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace _0_Framework.Excel.Checkout;
|
||||
namespace CompanyManagement.Infrastructure.Excel.Checkout;
|
||||
|
||||
public class CustomizeCheckoutTempExcelViewModel
|
||||
{
|
||||
@@ -52,5 +50,7 @@ public class CustomizeCheckoutTempExcelViewModel
|
||||
public string CardNumber { get; set; }
|
||||
public string ShebaNumber { get; set; }
|
||||
|
||||
public string BankName { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
using System.Linq;
|
||||
using OfficeOpenXml.Table.PivotTable;
|
||||
|
||||
namespace _0_Framework.Excel.EmployeeBankInfo;
|
||||
namespace CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
|
||||
|
||||
public class EmployeeBankInfoExcelGenerator
|
||||
{
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace _0_Framework.Excel.EmployeeBankInfo;
|
||||
namespace CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
|
||||
|
||||
public class EmployeeBankInfoExcelViewModel
|
||||
{
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace _0_Framework.Excel.RollCall;
|
||||
namespace CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace _0_Framework.Excel.RollCall;
|
||||
namespace CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
|
||||
public class CaseHistoryRollCallForOneDayViewModel
|
||||
{
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using _0_Framework.Excel;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Drawing;
|
||||
|
||||
namespace _0_Framework.Excel.RollCall;
|
||||
namespace CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
|
||||
public class RollCallExcelGenerator : ExcelGenerator
|
||||
{
|
||||
@@ -14,6 +14,8 @@ public class SearchCustomizeCheckout
|
||||
public string SearchEndFa { get; set; }
|
||||
|
||||
public long EmployeeId { get; set; }
|
||||
public long BankId { get; set; }
|
||||
|
||||
public CustomizeCheckoutOrderByEnum OrderBy { get; set; } = CustomizeCheckoutOrderByEnum.ContractStartDesc;
|
||||
public int PageIndex { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
using CompanyManagment.App.Contracts.EmployeeBankInformation;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public class CreateEmployeeByClient
|
||||
{
|
||||
public string NationalCode { get; set; }
|
||||
public string Nationality { get; set; }
|
||||
public string Gender { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string MaritalStatus { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string StartLeftWork { get; set; }
|
||||
public RollCallUploadEmployeePicture RollCallUploadEmployeePicture { get; set; }
|
||||
public EditCustomizeEmployeeSettings CreateCustomizeEmployeeSettings { get; set; }
|
||||
public ICollection<CreateEmployeeInformation> EmployeeBankInfos { get; set; }
|
||||
public bool HasBankInformation { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
public long JobId { get; set; }
|
||||
public List<AddEmployeeDocumentItem> EmployeeDocumentItems { get; set; }
|
||||
public bool HasEmployeeDocument { get; set; }
|
||||
public bool HasRollCallService { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public record RollCallUploadEmployeePicture
|
||||
{
|
||||
public string Picture1 { get; set; }
|
||||
public string Picture2 { get; set; }
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string IsActiveString { get; set; }
|
||||
public string HasUploadedImage { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public class ClientLeftWorkWorkEmployeesDto
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
|
||||
public string LeftWorkDateTime { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// پرسنل هایی که درسمت ادمین شروع به کار کرده اند
|
||||
/// </summary>
|
||||
public class ClientStartedWorkEmployeesDto
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// آیا آپلود مدارک اصلی رو انجام داده یا نه
|
||||
/// </summary>
|
||||
public bool HasCompleteEmployeeDocument { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public class EditEmployeeInEmployeeDocument
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string FName { get; set; } = string.Empty;
|
||||
public string LName { get; set; } = string.Empty;
|
||||
public string NationalCode { get; set; } = string.Empty;
|
||||
public string IdNumber { get; set; } = string.Empty;
|
||||
public string FatherName { get; set; } = string.Empty;
|
||||
public string BirthDate { get; set; } = string.Empty;
|
||||
public string MaritalStatus { get; set; } = string.Empty;
|
||||
public string MilitaryService { get; set; } = string.Empty;
|
||||
public string Nationality { get; set; } = string.Empty;
|
||||
public string Gender { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public record EmployeeByNationalCodeInWorkshopViewModel
|
||||
{
|
||||
public string EmployeeFName { get; set; }
|
||||
public string EmployeeLName { get; set; }
|
||||
public string Nationality { get; set; }
|
||||
public string Gender { get; set; }
|
||||
public string MaritalStatus { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public string Picture1 { get; set; }
|
||||
public string Picture2 { get; set; }
|
||||
public long PersonnelCode { get; set; }
|
||||
public List<EmployeeByNationalCodeEmployeeBankInfoViewModel> EmployeeBankInfos { get; set; }
|
||||
public EmployeeByNationalCodeEmployeeDocumentViewModel EmployeeDocument { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class EmployeeByNationalCodeEmployeeDocumentViewModel
|
||||
{
|
||||
//عکس پرسنل
|
||||
public EmployeeDocumentItemViewModel EmployeePicture { get; set; }
|
||||
|
||||
//شناسنامه
|
||||
public EmployeeDocumentItemViewModel IdCardPage1 { get; set; }
|
||||
public EmployeeDocumentItemViewModel IdCardPage2 { get; set; }
|
||||
public EmployeeDocumentItemViewModel IdCardPage3 { get; set; }
|
||||
public EmployeeDocumentItemViewModel IdCardPage4 { get; set; }
|
||||
|
||||
//کارت ملی
|
||||
public EmployeeDocumentItemViewModel NationalCardFront { get; set; }
|
||||
|
||||
public EmployeeDocumentItemViewModel NationalCardRear { get; set; }
|
||||
//مدرک تحصیلی
|
||||
public EmployeeDocumentItemViewModel EducationalDegree { get; set; }
|
||||
|
||||
//کارت پایان خدمت
|
||||
public EmployeeDocumentItemViewModel MilitaryServiceCard { get; set; }
|
||||
}
|
||||
|
||||
public class EmployeeByNationalCodeEmployeeBankInfoViewModel
|
||||
{
|
||||
public string BankName { get; set; }
|
||||
public string BankLogoPath { get; set; }
|
||||
public string CardNumber { get; set; }
|
||||
public string ShebaNumber { get; set; }
|
||||
public string BankAccountNumber { get; set; }
|
||||
public bool IsDefault { get; set; }
|
||||
public long BankId { get; set; }
|
||||
public long BankLogoMediaId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
|
||||
public class GetEditEmployeeInEmployeeDocumentViewModel
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
public string FName { get; set; } = string.Empty;
|
||||
public string LName { get; set; } = string.Empty;
|
||||
public string NationalCode { get; set; } = string.Empty;
|
||||
public string IdNumber { get; set; } = string.Empty;
|
||||
public string FatherName { get; set; } = string.Empty;
|
||||
public string BirthDate { get; set; } = string.Empty;
|
||||
public string MaritalStatus { get; set; } = string.Empty;
|
||||
public string MilitaryService { get; set; } = string.Empty;
|
||||
public string Nationality { get; set; } = string.Empty;
|
||||
public string Gender { get; set; } = string.Empty;
|
||||
public bool IsAuthorized { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee;
|
||||
@@ -44,6 +45,33 @@ public interface IEmployeeApplication
|
||||
List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId);
|
||||
|
||||
|
||||
EmployeeViewModel GetEmployeeByNationalCodeIfHasLeftWork(string nationalCode, List<long> workshopIds);
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
OperationResult CreateEmployeeByClient(CreateEmployeeByClient command);
|
||||
|
||||
/// <summary>
|
||||
/// اطلاعات پرسنل با کد ملی در کارگاه. اگر در کارگاه کار نکرده باشه وجود نداشته باشه اطلاعات خالی داده میشه
|
||||
/// </summary>
|
||||
/// <param name="nationalCode"></param>
|
||||
/// <param name="birthDate"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>>
|
||||
ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode,
|
||||
string birthDate, long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// پرسنل هایی که در کارگاهی از سمت ادمین شروع به کار کرده اند
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ICollection<ClientStartedWorkEmployeesDto>> GetClientEmployeesStartWork(long workshopId);
|
||||
Task<ICollection<ClientLeftWorkWorkEmployeesDto>> GetEmployeesForLeftWorkTemp(long workshopId);
|
||||
Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId,
|
||||
long workshopId);
|
||||
Task<OperationResult> EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command);
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
public class CreateEmployeeClientTemp
|
||||
{
|
||||
public string FName { get; set; }
|
||||
public string LName { get; set; }
|
||||
public string NationalCode { get; set; }
|
||||
public string Nationality { get; set; }
|
||||
public string MaritalStatus { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public DateTime StartWorkTime { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using _0_Framework_b.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
public interface IEmployeeClientTempApplication
|
||||
{
|
||||
OperationResult Create(CreateEmployeeClientTemp command);
|
||||
|
||||
EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId);
|
||||
|
||||
}
|
||||
|
||||
public class EmployeeClientTempGetDetailsViewModel
|
||||
{
|
||||
public long WorkshopId { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public string StartWorkDate { get; set; }
|
||||
public string FName { get; set; }
|
||||
public string LName { get; set; }
|
||||
|
||||
public string FullName => $"{FName} {LName}";
|
||||
public string NationalCode { get; set; }
|
||||
public string Nationality { get; set; }
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace CompanyManagment.App.Contracts.EmployeeDocuments
|
||||
|
||||
OperationResult AddEmployeeDocumentItemForAdmin(AddEmployeeDocumentItem command);
|
||||
|
||||
OperationResult AddRangeEmployeeDocumentItems(long workshopId, long employeeId,
|
||||
OperationResult AddRangeEmployeeDocumentItemsByClient(long workshopId, long employeeId,
|
||||
List<AddEmployeeDocumentItem> command);
|
||||
|
||||
/// <summary>
|
||||
@@ -49,10 +49,16 @@ namespace CompanyManagment.App.Contracts.EmployeeDocuments
|
||||
List<EmployeeDocumentsViewModel> GetByWorkshopIdWithItemsForAdminWorkFlow(long workshopId);
|
||||
|
||||
List<EmployeeDocumentsViewModel> GetDocumentsAwaitingReviewByWorkshopIdForCheckerWorkFlow(long workshopId);
|
||||
int GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds);
|
||||
//int GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds);
|
||||
Task<int> GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds);
|
||||
Task<int> GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds);
|
||||
OperationResult RemoveByAdmin(long documentItemId);
|
||||
int GetCheckerWorkFlowCount();
|
||||
Task<int> GetCheckerWorkFlowCount();
|
||||
|
||||
/// <summary>
|
||||
/// برای افزودن یکباره مدارک در افزودن پرسنل توسط ادمین
|
||||
/// </summary>
|
||||
OperationResult AddRangeEmployeeDocumentItemsByAdmin(long workshopId, long employeeId,
|
||||
List<AddEmployeeDocumentItem> command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
public class CreateLeftWorkTemp
|
||||
{
|
||||
public List<long> EmployeeIds { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string LeftWorkTime { get; set; }
|
||||
public string LastDayStanding { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
public class CreateLeftWorkTempSingleViewModel
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public List<long> EmployeeIds { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
public interface ILeftWorkTempApplication
|
||||
{
|
||||
Task<OperationResult> Create(CreateLeftWorkTemp command);
|
||||
|
||||
/// <summary>
|
||||
/// گرفتن اطلاعات برای مودال جزئیات شروع به کار موقت یا ترک کار موقت
|
||||
/// </summary>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId,long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// تایید شروع به کار موقت
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> AcceptStartWork(AcceptStartWorkTemp command);
|
||||
|
||||
/// <summary>
|
||||
/// تایید ترک کار موقت
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> AcceptLeftWork(AcceptLeftWorkTemp command);
|
||||
}
|
||||
|
||||
public class AcceptLeftWorkTemp
|
||||
{
|
||||
public long LeftWorkTempId { get; set; }
|
||||
public string LeftWorkTime { get; set; }
|
||||
public string LastDayStanding { get; set; }
|
||||
}
|
||||
|
||||
public class AcceptStartWorkTemp
|
||||
{
|
||||
public long LeftWorkTempId { get; set; }
|
||||
public string StartDateTime { get; set; }
|
||||
public long JobId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class GetStartWorkTempDetails
|
||||
{
|
||||
public LeftWorkTempDetailsViewModel LeftWorkTemp { get; set; }
|
||||
public List<LeftWorkTempDetailsViewModel> PreviousLeftWorks { get; set; }
|
||||
public long JobId { get; set; }
|
||||
public string JobName { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string WorkshopFullName { get; set; }
|
||||
public string EmployeeFullName { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public long PersonnelCode { get; set; }
|
||||
}
|
||||
|
||||
public class LeftWorkTempDetailsViewModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string StartWork { get; set; }
|
||||
public string LeftWork { get; set; }
|
||||
public string LastDayStanding { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
public enum LeftWorkTempType
|
||||
{
|
||||
/// <summary>
|
||||
/// شروع به کار کرده
|
||||
/// </summary>
|
||||
StartWork,
|
||||
|
||||
/// <summary>
|
||||
/// ترک کار کرده
|
||||
/// </summary>
|
||||
LeftWork
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public class PersonalContractingPartyViewModel
|
||||
public string IsActiveString { get; set; }
|
||||
public string IsBlock { get; set; }
|
||||
public int BlockTimes { get; set; }
|
||||
public bool IsAuthenticated { get; set; }
|
||||
public List<EmployerViewModel> EmployerList { get; set; }
|
||||
|
||||
}
|
||||
@@ -16,5 +16,7 @@ public interface IPersonnelCodeApplication
|
||||
List<PersonnelCodeViewModel> Search(PersonnelCodeSearchModel searchModel);
|
||||
PersonnelCodeViewModel GetPersonnelCodeViewModel(PersonnelCodeSearchModel searchModel);
|
||||
long GetEmployeeIdByPersonelCode(long personleCode, long workshopId);
|
||||
long GetLastPersonnelCodeByWorkshop(long workshopId);
|
||||
|
||||
|
||||
}
|
||||
@@ -15,8 +15,7 @@ public class RollCallEmployeeViewModel : EditRollCallEmployee
|
||||
public string PersonName { get; set; }
|
||||
public bool ContractPerson { get; set; }
|
||||
public bool InsurancePerson { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
public bool ContractLeft { get; set; }
|
||||
public bool InsurancetLeft { get; set; }
|
||||
public bool Black { get; set; }
|
||||
@@ -35,4 +34,5 @@ public class RollCallEmployeeViewModel : EditRollCallEmployee
|
||||
public string EmployeeLName { get; set; }
|
||||
public string EmployeeFName { get; set; }
|
||||
public long RollCallEmployeeId { get; set; }
|
||||
public bool CreatedByClient { get; set; }
|
||||
}
|
||||
@@ -19,4 +19,5 @@ public interface IRollCallServiceApplication
|
||||
List<RollCallServiceViewModel> GetActiveServiceByAccountId(long accountId);
|
||||
List<RollCallServiceViewModel> GetAllServiceByAccountId(long accountId);
|
||||
|
||||
bool IsExistActiveServiceByWorkshopId(long workshopId);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
|
||||
public class ContractingPartyTempViewModel : CreateContractingPartyTemp
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// تاریخ تولد شمسی
|
||||
/// </summary>
|
||||
public string DateOfBirthFa { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using _0_Framework.Application;
|
||||
using System;
|
||||
using System.Drawing.Interop;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
|
||||
|
||||
|
||||
public class CreateContractingPartyTemp
|
||||
{
|
||||
/// <summary>
|
||||
/// نام
|
||||
/// </summary>
|
||||
public string FName { get; set; }
|
||||
/// <summary>
|
||||
/// نام خانوادگی
|
||||
/// </summary>
|
||||
public string LName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پدر
|
||||
/// </summary>
|
||||
public string FatherName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// جنسیت
|
||||
/// </summary>
|
||||
public Gender Gender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///تاریخ تولد
|
||||
/// </summary>
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سری شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSeri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سریال شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumberSerial { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// شماره همراه
|
||||
/// </summary>
|
||||
public string Phone { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// استان
|
||||
/// </summary>
|
||||
public string State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شهر
|
||||
/// </summary>
|
||||
public string City { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نشانی
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
|
||||
public interface ITemporaryClientRegistrationApplication
|
||||
{
|
||||
Task<OperationResult<ContractingPartyTempViewModel>> CreateContractingPartyTemp(string nationalCode, string dateOfBirth, string mobile);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace CompanyManagment.App.Contracts.Workshop;
|
||||
|
||||
public class WorkshopWithLeftWorkTempEmployeesDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آیدی کارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کارگاه
|
||||
/// </summary>
|
||||
public string WorkshopName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// نام کارفرما
|
||||
/// </summary>
|
||||
public string EmployerName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد پرسنل ترک کار کرده
|
||||
/// </summary>
|
||||
public int LeftWorkEmployees { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
|
||||
/// <summary>
|
||||
/// کارگاه هایی که از کلاینت، پرسنلی را شروع به کار زدند
|
||||
/// </summary>
|
||||
public class WorkshopWithStartedEmployeesDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آیدی کارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کارگاه
|
||||
/// </summary>
|
||||
public string WorkshopName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// نام کارفرما
|
||||
/// </summary>
|
||||
public string EmployerName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد پرسنل اضافه شده
|
||||
/// </summary>
|
||||
public int AddedEmployeesCount { get; set; }
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Workshop;
|
||||
|
||||
@@ -54,6 +56,11 @@ public interface IWorkshopApplication
|
||||
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
|
||||
List<PersonnelInfoViewModel> GetPersonnelInfoRemastered(PersonnelInfoSearchModel searchModel);
|
||||
#endregion
|
||||
|
||||
#region Vafa
|
||||
|
||||
List<PrintListWorkshop> PrintWorkshopList(WorkshopSearchModel searchModel);
|
||||
@@ -70,5 +77,14 @@ public interface IWorkshopApplication
|
||||
/// <returns></returns>
|
||||
List<WorkshopViewModel> GetWorkshopSelectListInsuransce();
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
Task<List<WorkshopWithStartedEmployeesDto>> GetWorkshopsForEmployeeStartWork(long accountId);
|
||||
Task<int> GetWorkshopsForEmployeeStartWorkCount(long accountId);
|
||||
|
||||
Task<List<WorkshopWithLeftWorkTempEmployeesDto>> GetWorkshopsForLeftWorkTemp(long accountId);
|
||||
Task<int> GetWorkshopsForLeftWorkTempCount(long accountId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -43,4 +43,6 @@ public class PersonnelInfoViewModel
|
||||
public bool Black { get; set; }
|
||||
public DateTime StartWork { get; set; }
|
||||
public DateTime LeftWork { get; set; }
|
||||
public bool CreatedByClient { get; set; }
|
||||
public bool LefWorkTemp { get; set; }
|
||||
}
|
||||
@@ -340,6 +340,17 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
|
||||
return createDefaultEmployee;
|
||||
}
|
||||
|
||||
if (_customizeWorkshopEmployeeSettingsRepository.Exists(x =>
|
||||
x.WorkshopId == command.WorkshopId && command.EmployeeIds.First()== x.EmployeeId &&
|
||||
x.CustomizeWorkshopGroupSettingId == command.GroupId))
|
||||
{
|
||||
var employeeSettings = _customizeWorkshopEmployeeSettingsRepository
|
||||
.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(command.WorkshopId,command.EmployeeIds.First());
|
||||
|
||||
_customizeWorkshopEmployeeSettingsRepository.Remove(employeeSettings.id);
|
||||
_customizeWorkshopEmployeeSettingsRepository.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
List<CustomizeWorkshopEmployeeSettingsShift> shiftCollection = new List<CustomizeWorkshopEmployeeSettingsShift>();
|
||||
List<CustomizeRotatingShift> rotatingShift = [];
|
||||
@@ -396,7 +407,12 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
|
||||
|
||||
if (previousEnd != new DateTime())
|
||||
{
|
||||
if (newShift.start <= previousEnd)
|
||||
if (newShift.start == previousEnd)
|
||||
{
|
||||
return op.Failed("در شیفت منظم پایان شیفت نمیتواند با شروع شیفت بعدی برابر باشد");
|
||||
}
|
||||
|
||||
if (newShift.start <= previousEnd)
|
||||
{
|
||||
newShift.start = newShift.start.AddDays(1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
@@ -10,6 +11,24 @@ using Company.Domain.EmployeeInsuranceRecordAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Company.Domain.PersonnelCodeAgg;
|
||||
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
|
||||
using CompanyManagment.App.Contracts.EmployeeBankInformation;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.IO;
|
||||
using System.Transactions;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using _0_Framework.Application.UID;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg;
|
||||
using Company.Domain.EmployeeDocumentsAgg;
|
||||
using Company.Domain.RollCallEmployeeAgg;
|
||||
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -25,11 +44,39 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
public bool StatCity = true;
|
||||
public bool city = true;
|
||||
public bool address = true;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
|
||||
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;
|
||||
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
|
||||
private readonly ILeftWorkRepository _leftWorkRepository;
|
||||
private readonly IPersonnelCodeRepository _personnelCodeRepository;
|
||||
private readonly IEmployeeClientTempRepository _employeeClientTempRepository;
|
||||
private readonly ICustomizeWorkshopGroupSettingsRepository _customizeWorkshopGroupSettingsRepository;
|
||||
|
||||
public EmployeeAplication(IEmployeeRepository employeeRepository, CompanyContext context, IWorkshopRepository workShopRepository) : 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) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_WorkShopRepository = workShopRepository;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
_customizeWorkshopSettingsApplication = customizeWorkshopSettingsApplication;
|
||||
_employeeDocumentsApplication = employeeDocumentsApplication;
|
||||
_employeeDocumentsRepository = employeeDocumentsRepository;
|
||||
_employeeBankInformationApplication = employeeBankInformationApplication;
|
||||
_leftWorkTempRepository = leftWorkTempRepository;
|
||||
_uidService = uidService;
|
||||
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
|
||||
_personnelCodeRepository = personnelCodeRepository;
|
||||
_employeeClientTempRepository = employeeClientTempRepository;
|
||||
_customizeWorkshopGroupSettingsRepository = customizeWorkshopGroupSettingsRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
_EmployeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
@@ -861,6 +908,13 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
return workshopEmployeesWithLeftWork.FirstOrDefault();
|
||||
}
|
||||
|
||||
public EmployeeViewModel GetEmployeeByNationalCodeIfHasLeftWork(string nationalCode, List<long> workshopIds)
|
||||
{
|
||||
if (nationalCode.NationalCodeValid() != "valid")
|
||||
return new();
|
||||
var workshopEmployeesWithLeftWork = _EmployeeRepository.GetWorkedEmployeesByWorkshopIdsAndNationalCodeAndDate(workshopIds, nationalCode, DateTime.Now.Date);
|
||||
return workshopEmployeesWithLeftWork.FirstOrDefault();
|
||||
}
|
||||
public List<EmployeeViewModel> GetWorkingEmployeesByWorkshopId(long workshopId)
|
||||
{
|
||||
return _EmployeeRepository.GetWorkingEmployeesByWorkshopId(workshopId);
|
||||
@@ -902,4 +956,547 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
public OperationResult CreateEmployeeByClient(CreateEmployeeByClient command)
|
||||
{
|
||||
OperationResult op = new();
|
||||
|
||||
if (command.Gender != "مرد" && command.Gender != "زن")
|
||||
return op.Failed("جنسیت را انتخاب کنید");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.FirstName) || string.IsNullOrWhiteSpace(command.LastName))
|
||||
return op.Failed("نام نمی تواند خالی باشد");
|
||||
|
||||
if (command.MaritalStatus != "مجرد" && command.MaritalStatus != "متاهل")
|
||||
return op.Failed("وضعیت تاهل نمی تواند خالی باشد");
|
||||
|
||||
bool isNationalCardValid = command.NationalCode?.NationalCodeValid() == "valid";
|
||||
if (isNationalCardValid == false)
|
||||
return op.Failed("کد ملی وارد شده معتبر نمی باشد");
|
||||
|
||||
if (command.Nationality != "ایرانی")
|
||||
return op.Failed("خطای سیستمی");
|
||||
|
||||
if (!_WorkShopRepository.Exists(x => x.id == command.WorkshopId))
|
||||
{
|
||||
return op.Failed("کارگاه نامعتبر است");
|
||||
}
|
||||
|
||||
using var transaction = new TransactionScope();
|
||||
|
||||
//if (_EmployeeRepository.ExistsIgnoreQueryFilter(x => x.NationalCode == command.NationalCode && x.EmployeeType == EmployeeType.CreatedByClient))
|
||||
//{
|
||||
// return op.Failed("این پرسنل قبلا افزوده شده است و در انتظار تایید میباشد");
|
||||
//}
|
||||
|
||||
var employee = _EmployeeRepository.GetByNationalCodeIgnoreQueryFilter(command.NationalCode);
|
||||
var workshop = _WorkShopRepository.GetDetails(command.WorkshopId);
|
||||
if (employee == null)
|
||||
{
|
||||
return op.Failed("خطای سیستمی. لطفا دوباره تلاش کنید . درصورت تکرار این مشکل با تیم پشتیبان تماس بگیرید");
|
||||
}
|
||||
|
||||
if (_leftWorkTempRepository.Exists(x =>
|
||||
x.EmployeeId == employee.id && x.WorkshopId == command.WorkshopId && x.LeftWorkType == LeftWorkTempType.StartWork))
|
||||
{
|
||||
return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد");
|
||||
}
|
||||
|
||||
var startLeftWork = command.StartLeftWork.ToGeorgianDateTime();
|
||||
|
||||
var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(command.WorkshopId, employee.id);
|
||||
PersonnelCodeDomain personnelCode = null;
|
||||
if (leftWorkViewModel != null)
|
||||
{
|
||||
if (leftWorkViewModel.HasLeft == false && leftWorkViewModel.LeftWorkDate > DateTime.Now)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید پرسنلی که در کارگاه شما در حال کار است را ایجاد کنید");
|
||||
}
|
||||
|
||||
if (leftWorkViewModel.LeftWorkDate > startLeftWork)
|
||||
{
|
||||
return op.Failed("شما نمیتوانید قبل از بازه ترک کار قبلی پرسنل شروع به کاری ثبت کنید");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var lastPersonnelCodeByWorkshop = _personnelCodeRepository.GetLastPersonnelCodeByWorkshop(command.WorkshopId);
|
||||
|
||||
personnelCode = new PersonnelCodeDomain(command.WorkshopId,
|
||||
employee.id, lastPersonnelCodeByWorkshop + 1);
|
||||
}
|
||||
|
||||
var leftWorkTemp = LeftWorkTemp.CreateStartWork(command.WorkshopId, employee.id, startLeftWork, command.JobId);
|
||||
_leftWorkTempRepository.Create(leftWorkTemp);
|
||||
_leftWorkTempRepository.SaveChanges();
|
||||
|
||||
|
||||
if (personnelCode != null)
|
||||
{
|
||||
_personnelCodeRepository.Create(personnelCode);
|
||||
_personnelCodeRepository.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.RollCallUploadEmployeePicture?.Picture1) == false &&
|
||||
string.IsNullOrWhiteSpace(command.RollCallUploadEmployeePicture?.Picture2) == false)
|
||||
{
|
||||
var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{command.WorkshopId}\\{employee.id}";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
var filePath1 = Path.Combine(directoryPath) + $@"\1.jpg";
|
||||
|
||||
CreateImageFromBase64(command.RollCallUploadEmployeePicture.Picture1, filePath1);
|
||||
|
||||
|
||||
var filePath2 = Path.Combine(directoryPath) + $@"\2.jpg";
|
||||
|
||||
CreateImageFromBase64(command.RollCallUploadEmployeePicture.Picture2, filePath2);
|
||||
|
||||
|
||||
|
||||
var rollCallEmployee =
|
||||
_rollCallEmployeeRepository.GetBy(employee.id, command.WorkshopId);
|
||||
|
||||
if (rollCallEmployee == null)
|
||||
{
|
||||
if (_employeeClientTempRepository.Exists(x =>
|
||||
x.EmployeeId == employee.id && x.WorkshopId == command.WorkshopId))
|
||||
{
|
||||
//var employeeTemp =
|
||||
// _employeeClientTempRepository.GetByEmployeeIdAndWorkshopId(employee.id, command.WorkshopId);
|
||||
|
||||
rollCallEmployee = new RollCallEmployee(command.WorkshopId, employee.id, employee.FName,
|
||||
employee.LName);
|
||||
}
|
||||
else
|
||||
{
|
||||
rollCallEmployee =
|
||||
new RollCallEmployee(command.WorkshopId, employee.id, employee.FName, employee.LName);
|
||||
}
|
||||
|
||||
rollCallEmployee.HasImage();
|
||||
_rollCallEmployeeRepository.Create(rollCallEmployee);
|
||||
_rollCallEmployeeRepository.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (command.CreateCustomizeEmployeeSettings.GroupId > 0)
|
||||
{
|
||||
if (_customizeWorkshopEmployeeSettingsRepository
|
||||
.Exists(x => x.WorkshopId == workshop.Id && x.EmployeeId == employee.id))
|
||||
{
|
||||
_customizeWorkshopEmployeeSettingsRepository.RemoveByWorkshopIdAndEmployeeId(workshop.Id, employee.id);
|
||||
}
|
||||
|
||||
command.CreateCustomizeEmployeeSettings.EmployeeIds = [employee.id];
|
||||
command.CreateCustomizeEmployeeSettings.WorkshopId = command.WorkshopId;
|
||||
var resultCreateEmployeeSettings =
|
||||
_customizeWorkshopSettingsApplication.CreateEmployeesSettingsAndSetChanges(
|
||||
command.CreateCustomizeEmployeeSettings);
|
||||
if (resultCreateEmployeeSettings.IsSuccedded == false)
|
||||
{
|
||||
return resultCreateEmployeeSettings;
|
||||
}
|
||||
|
||||
var rollCallEmployeeStatusResult = _rollCallEmployeeStatusApplication.Create(
|
||||
new CreateRollCallEmployeeStatus() { RollCallEmployeeId = rollCallEmployee.id });
|
||||
|
||||
if (rollCallEmployeeStatusResult.IsSuccedded == false)
|
||||
{
|
||||
return rollCallEmployeeStatusResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.CreateCustomizeEmployeeSettings.GroupId > 0)
|
||||
{
|
||||
if (_customizeWorkshopEmployeeSettingsRepository
|
||||
.Exists(x => x.WorkshopId == workshop.Id && x.EmployeeId == employee.id))
|
||||
{
|
||||
_customizeWorkshopEmployeeSettingsRepository.RemoveByWorkshopIdAndEmployeeId(workshop.Id, employee.id);
|
||||
}
|
||||
|
||||
command.CreateCustomizeEmployeeSettings.EmployeeIds = [employee.id];
|
||||
command.CreateCustomizeEmployeeSettings.WorkshopId = command.WorkshopId;
|
||||
var resultCreateEmployeeSettings =
|
||||
_customizeWorkshopSettingsApplication.CreateEmployeesSettingsAndSetChanges(
|
||||
command.CreateCustomizeEmployeeSettings);
|
||||
if (resultCreateEmployeeSettings.IsSuccedded == false)
|
||||
{
|
||||
return resultCreateEmployeeSettings;
|
||||
}
|
||||
|
||||
|
||||
var rollCallEmployee =
|
||||
_rollCallEmployeeRepository.GetBy(employee.id, command.WorkshopId);
|
||||
|
||||
if (rollCallEmployee == null)
|
||||
{
|
||||
if (_employeeClientTempRepository.Exists(x =>
|
||||
x.EmployeeId == employee.id && x.WorkshopId == command.WorkshopId))
|
||||
{
|
||||
|
||||
rollCallEmployee = new RollCallEmployee(command.WorkshopId, employee.id, employee.FName,
|
||||
employee.LName);
|
||||
}
|
||||
else
|
||||
{
|
||||
rollCallEmployee =
|
||||
new RollCallEmployee(command.WorkshopId, employee.id, employee.FName, employee.LName);
|
||||
}
|
||||
_rollCallEmployeeRepository.Create(rollCallEmployee);
|
||||
_rollCallEmployeeRepository.SaveChanges();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
command.EmployeeDocumentItems = command.EmployeeDocumentItems ?? [];
|
||||
|
||||
var employeeDocumentResult = _employeeDocumentsApplication.AddRangeEmployeeDocumentItemsByClient(command.WorkshopId,
|
||||
employee.id, command.EmployeeDocumentItems);
|
||||
|
||||
if (employeeDocumentResult.IsSuccedded == false)
|
||||
{
|
||||
return employeeDocumentResult;
|
||||
}
|
||||
|
||||
|
||||
var employeeTemp = new EmployeeClientTemp(command.WorkshopId, startLeftWork, employee.id,
|
||||
command.MaritalStatus, employee.FullName);
|
||||
|
||||
_employeeClientTempRepository.Create(employeeTemp);
|
||||
_employeeClientTempRepository.SaveChanges();
|
||||
|
||||
if (command.HasBankInformation)
|
||||
{
|
||||
|
||||
var employeeBankInfos = command.EmployeeBankInfos.Select(x => new CreateEmployeeInformation
|
||||
{
|
||||
WorkshopId = command.WorkshopId,
|
||||
BankAccountNumber = x.BankAccountNumber,
|
||||
BankId = x.BankId,
|
||||
CardNumber = x.CardNumber,
|
||||
EmployeeId = employee.id,
|
||||
EmployeeName = employee.FullName,
|
||||
ShebaNumber = x.ShebaNumber
|
||||
}).ToList();
|
||||
|
||||
var employeeBankInformationResult =
|
||||
_employeeBankInformationApplication.GroupCreate(command.WorkshopId, employeeBankInfos);
|
||||
|
||||
if (employeeBankInformationResult.IsSuccedded == false)
|
||||
{
|
||||
return employeeBankInformationResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
transaction.Complete();
|
||||
return op.Succcedded(employee.id);
|
||||
}
|
||||
|
||||
private void CreateImageFromBase64(string picture, string filePath)
|
||||
{
|
||||
var subBase64 = picture.Substring(picture.LastIndexOf(',') + 1);
|
||||
byte[] bytes = Convert.FromBase64String(subBase64);
|
||||
System.IO.File.WriteAllBytes(filePath, bytes);
|
||||
}
|
||||
public async Task<OperationResult<EmployeeByNationalCodeInWorkshopViewModel>>
|
||||
ValidateCreateEmployeeClientByNationalCodeAndWorkshopId(string nationalCode, string birthDate, long workshopId)
|
||||
{
|
||||
var op = new OperationResult<EmployeeByNationalCodeInWorkshopViewModel>();
|
||||
|
||||
if (nationalCode.NationalCodeValid() != "valid")
|
||||
{
|
||||
return op.Failed("کد ملی معتبر نمیباشد");
|
||||
}
|
||||
|
||||
if (birthDate.TryToGeorgianDateTime(out _) == false)
|
||||
{
|
||||
return op.Failed("تاریخ تولد معتبر نمیباشد");
|
||||
}
|
||||
|
||||
var employee = _EmployeeRepository.GetByNationalCodeIgnoreQueryFilter(nationalCode);
|
||||
|
||||
if (employee == null)
|
||||
{
|
||||
var personalInfo = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
if (personalInfo.ResponseContext.Status.Code != 0)
|
||||
{
|
||||
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
|
||||
}
|
||||
|
||||
var basicInfo = personalInfo.BasicInformation;
|
||||
var identityInfo = personalInfo.IdentificationInformation;
|
||||
DateTime apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime();
|
||||
|
||||
var dateOfIssue = new DateTime(1922, 1, 1);
|
||||
|
||||
var gender = basicInfo.GenderEnum switch
|
||||
{
|
||||
Gender.Female => "زن",
|
||||
Gender.Male => "مرد",
|
||||
_ => throw new AggregateException()
|
||||
};
|
||||
|
||||
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, "ایرانی");
|
||||
newEmployee.Authorized();
|
||||
await _EmployeeRepository.CreateAsync(newEmployee);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel()
|
||||
{
|
||||
EmployeeId = newEmployee.id,
|
||||
EmployeeFName = newEmployee.FName,
|
||||
Gender = newEmployee.Gender,
|
||||
Nationality = newEmployee.Nationality,
|
||||
EmployeeLName = newEmployee.LName
|
||||
});
|
||||
}
|
||||
|
||||
if (_leftWorkTempRepository.ExistsIgnoreQueryFilter(x =>
|
||||
x.EmployeeId == employee.id && x.WorkshopId == workshopId && x.LeftWorkType == LeftWorkTempType.StartWork))
|
||||
{
|
||||
return op.Failed("این پرسنل در کارگاه شما قبلا افزوده شده است و در انتظار تایید میباشد");
|
||||
}
|
||||
|
||||
if (employee.IsAuthorized == false)
|
||||
{
|
||||
var personalInfoResponse = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
|
||||
if (personalInfoResponse.ResponseContext.Status.Code == 0)
|
||||
{
|
||||
var basicInfo = personalInfoResponse.BasicInformation;
|
||||
var identityInfo = personalInfoResponse.IdentificationInformation;
|
||||
var apiBirthDate = identityInfo.BirthDate.ToGeorgianDateTime();
|
||||
|
||||
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, apiBirthDate,
|
||||
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();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد");
|
||||
}
|
||||
}
|
||||
else if (employee.DateOfBirth.ToFarsi() != birthDate || employee.NationalCode != nationalCode)
|
||||
{
|
||||
return op.Failed("کد ملی با تاریخ تولد وارد شده مطابقت ندارد");
|
||||
}
|
||||
|
||||
var leftWorkViewModel = _leftWorkRepository.GetLastLeftWorkByEmployeeIdAndWorkshopId(workshopId, employee.id);
|
||||
if (leftWorkViewModel == null)
|
||||
{
|
||||
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel()
|
||||
{
|
||||
EmployeeId = employee.id,
|
||||
EmployeeFName = employee.FName,
|
||||
Gender = employee.Gender,
|
||||
Nationality = employee.Nationality,
|
||||
EmployeeLName = employee.LName
|
||||
}); ;
|
||||
}
|
||||
|
||||
if (leftWorkViewModel.LeftWorkDate >= DateTime.Now || !leftWorkViewModel.HasLeft)
|
||||
return op.Failed("این پرسنل در کارگاه شما در حال کار است");
|
||||
|
||||
var rollCallEmployee = _rollCallEmployeeRepository.GetBy(employee.id, workshopId);
|
||||
|
||||
string picture1 = string.Empty;
|
||||
string picture2 = string.Empty;
|
||||
|
||||
if (rollCallEmployee != null)
|
||||
{
|
||||
var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\Faces\\{workshopId}\\{employee.id}";
|
||||
if (Directory.Exists(directoryPath))
|
||||
{
|
||||
var filePath1 = Path.Combine(directoryPath, @"1.jpg");
|
||||
var filePath2 = Path.Combine(directoryPath, @"2.jpg");
|
||||
|
||||
if (System.IO.File.Exists(filePath1))
|
||||
{
|
||||
byte[] imageBytes1 = await System.IO.File.ReadAllBytesAsync(filePath1);
|
||||
picture1 = Convert.ToBase64String(imageBytes1);
|
||||
}
|
||||
|
||||
if (System.IO.File.Exists(filePath2))
|
||||
{
|
||||
byte[] imageBytes2 = await System.IO.File.ReadAllBytesAsync(filePath2);
|
||||
picture2 = Convert.ToBase64String(imageBytes2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var personnelCode = _personnelCodeRepository.GetPSCodeByWorkshopIdAndEmployeeId(workshopId, employee.id);
|
||||
|
||||
var bankInformationViewModel = _employeeBankInformationApplication.GetByEmployeeId(workshopId, employee.id);
|
||||
|
||||
var employeeDocumentsViewModel = _employeeDocumentsApplication.GetDetailsForClient(employee.id, workshopId);
|
||||
|
||||
|
||||
return op.Succcedded(new EmployeeByNationalCodeInWorkshopViewModel
|
||||
{
|
||||
EmployeeId = employee.id,
|
||||
EmployeeFName = employee.FName,
|
||||
EmployeeLName = employee.LName,
|
||||
Nationality = employee.Nationality,
|
||||
MaritalStatus = employee.MaritalStatus,
|
||||
Gender = employee.Gender,
|
||||
Picture1 = picture1,
|
||||
Picture2 = picture2,
|
||||
PersonnelCode = personnelCode,
|
||||
EmployeeBankInfos = bankInformationViewModel.BankInformation.Select(x => new EmployeeByNationalCodeEmployeeBankInfoViewModel
|
||||
{
|
||||
ShebaNumber = x.ShebaNumber,
|
||||
IsDefault = x.IsDefault,
|
||||
CardNumber = x.CardNumber,
|
||||
BankAccountNumber = x.BankAccountNumber,
|
||||
BankId = x.BankId,
|
||||
BankLogoMediaId = x.BankLogoMediaId,
|
||||
BankLogoPath = x.BankLogoPath,
|
||||
BankName = x.BankName
|
||||
}).ToList(),
|
||||
EmployeeDocument = new EmployeeByNationalCodeEmployeeDocumentViewModel
|
||||
{
|
||||
EducationalDegree = employeeDocumentsViewModel.EducationalDegree,
|
||||
EmployeePicture = employeeDocumentsViewModel.EmployeePicture,
|
||||
IdCardPage1 = employeeDocumentsViewModel.IdCardPage1,
|
||||
IdCardPage2 = employeeDocumentsViewModel.IdCardPage2,
|
||||
IdCardPage3 = employeeDocumentsViewModel.IdCardPage3,
|
||||
IdCardPage4 = employeeDocumentsViewModel.IdCardPage4,
|
||||
MilitaryServiceCard = employeeDocumentsViewModel.MilitaryServiceCard,
|
||||
NationalCardFront = employeeDocumentsViewModel.NationalCardFront,
|
||||
NationalCardRear = employeeDocumentsViewModel.NationalCardRear
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientStartedWorkEmployeesDto>> GetClientEmployeesStartWork(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetClientEmployeesStartWork(workshopId);
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientLeftWorkWorkEmployeesDto>> GetEmployeesForLeftWorkTemp(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetEmployeesForLeftWorkTemp(workshopId);
|
||||
}
|
||||
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(
|
||||
long employeeId,
|
||||
long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetEmployeeEditInEmployeeDocumentWorkFlow(employeeId, workshopId);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
if (command.MaritalStatus is not ("مجرد" or "متاهل"))
|
||||
{
|
||||
return op.Failed("وضعیت تاهل وارد شده نامعتبر میباشد");
|
||||
}
|
||||
|
||||
var employee = _EmployeeRepository.Get(command.EmployeeId);
|
||||
if (employee == null)
|
||||
{
|
||||
return op.Failed("پرسنل مورد نظر یافت نشد");
|
||||
}
|
||||
|
||||
if (!employee.IsAuthorized)
|
||||
{
|
||||
if (command.Gender is not ("مرد" or "زن"))
|
||||
{
|
||||
return op.Failed("جنسیت وارد شده نامعتبر است");
|
||||
}
|
||||
if (command.BirthDate.TryToGeorgianDateTime(out var birthDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ تولد وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (command.Nationality is not ("غیر ایرانی" or "ایرانی"))
|
||||
{
|
||||
return op.Failed("ملیت وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.FName))
|
||||
{
|
||||
return op.Failed("لطفا نام پرسنل را وارد کنید");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.LName))
|
||||
{
|
||||
return op.Failed("لطفا نام خانوادگی پرسنل را وارد کنید");
|
||||
}
|
||||
|
||||
if (command.NationalCode.NationalCodeValid() != "valid")
|
||||
{
|
||||
return op.Failed("کد ملی وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.IdNumber))
|
||||
{
|
||||
return op.Failed("لطفا شماره شناسنامه را وارد کنید");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.FatherName))
|
||||
{
|
||||
return op.Failed("لطفا نام پدر را وارد کنید");
|
||||
}
|
||||
}
|
||||
|
||||
var employeeClientTemp = _employeeClientTempRepository.GetByEmployeeIdAndWorkshopId(command.EmployeeId, command.WorkshopId);
|
||||
|
||||
employeeClientTemp?.Edit(command.MaritalStatus);
|
||||
|
||||
if (!employee.IsAuthorized)
|
||||
{
|
||||
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,
|
||||
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();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using _0_Framework_b.Application;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class EmployeeClientTempApplication : IEmployeeClientTempApplication
|
||||
{
|
||||
private readonly IEmployeeClientTempRepository _employeeClientTempRepository;
|
||||
|
||||
public EmployeeClientTempApplication(IEmployeeClientTempRepository employeeClientTempRepository)
|
||||
{
|
||||
_employeeClientTempRepository = employeeClientTempRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateEmployeeClientTemp command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var fullName = $"{command.FName} {command.LName}";
|
||||
var employeeClientTemp = new EmployeeClientTemp(command.WorkshopId, command.StartWorkTime, command.EmployeeId, command.MaritalStatus, fullName);
|
||||
|
||||
_employeeClientTempRepository.Create(employeeClientTemp);
|
||||
_employeeClientTempRepository.SaveChanges();
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId)
|
||||
{
|
||||
return _employeeClientTempRepository.GetDetails(employeeId, workshopId);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -440,10 +440,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//محاسبه مزایای ماهانه
|
||||
var monthlyBenefits = GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, employee.JobId, employee.EmployeeId,employee.IncludeStatus);
|
||||
|
||||
if (employee.EmployeeId is 7999)// سید عباس خوشکلام سلیمان
|
||||
monthlyBenefits = 80869389;
|
||||
if (employee.EmployeeId is 43787)// شهرام براهیمی سیقلان
|
||||
monthlyBenefits = 54748472;
|
||||
//if (employee.EmployeeId is 7999)// سید عباس خوشکلام سلیمان
|
||||
// monthlyBenefits = 80869389;
|
||||
//if (employee.EmployeeId is 43787)// شهرام براهیمی سیقلان
|
||||
// monthlyBenefits = 54748472;
|
||||
|
||||
|
||||
var marriedAllowanceCompute = MarriedAllowance(employee.MaritalStatus, employee.JobId, employee.IncludeStatus,
|
||||
|
||||
273
CompanyManagment.Application/LeftWorkTempApplication.cs
Normal file
273
CompanyManagment.Application/LeftWorkTempApplication.cs
Normal file
@@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework_b.Application;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.ContractAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.JobAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using Company.Domain.RollCallEmployeeAgg;
|
||||
using Company.Domain.RollCallEmployeeStatusAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using CompanyManagment.App.Contracts.ReportClient;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using OperationResult = _0_Framework.Application.OperationResult;
|
||||
using Tools = _0_Framework.Application.Tools;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
{
|
||||
private readonly ILeftWorkTempRepository _leftWorkTempRepository;
|
||||
private readonly ILeftWorkRepository _leftWorkRepository;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private readonly IJobRepository _jobRepository;
|
||||
private readonly ICheckoutRepository _checkoutRepository;
|
||||
private readonly IContractRepository _contractRepository;
|
||||
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
||||
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
|
||||
|
||||
|
||||
public LeftWorkTempApplication(ILeftWorkTempRepository leftWorkTempRepository, ILeftWorkRepository leftWorkRepository, IWorkshopRepository workshopRepository, IEmployeeRepository employeeRepository, IJobRepository jobRepository, ICheckoutRepository checkoutRepository, IContractRepository contractRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IRollCallEmployeeRepository rollCallEmployeeRepository)
|
||||
{
|
||||
_leftWorkTempRepository = leftWorkTempRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
_employeeRepository = employeeRepository;
|
||||
_jobRepository = jobRepository;
|
||||
_checkoutRepository = checkoutRepository;
|
||||
_contractRepository = contractRepository;
|
||||
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Create(CreateLeftWorkTemp command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
foreach (var employeeId in command.EmployeeIds)
|
||||
{
|
||||
#region Validation
|
||||
|
||||
if (command.LeftWorkTime.TryToGeorgianDateTime(out var leftWorkDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
}
|
||||
if (command.LastDayStanding.TryToGeorgianDateTime(out var lastDayStandingDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var leftWork = await _leftWorkRepository.GetLastLeftWork(employeeId, command.WorkshopId);
|
||||
|
||||
if (lastDayStandingDateGr.AddDays(1).Date != leftWorkDateGr)
|
||||
{
|
||||
return op.Failed("تاریخ آخرین روز کاری با تاریخ ترک کار یک روز اختلاف ندارند");
|
||||
}
|
||||
|
||||
if (leftWork == null)
|
||||
{
|
||||
return op.Failed("شروع به کار پرسنل یافت نشد");
|
||||
}
|
||||
|
||||
if (leftWork.HasLeft)
|
||||
{
|
||||
return op.Failed("پرسنل وارد شده قبلا ترک کار ثبت شده است");
|
||||
}
|
||||
|
||||
if (leftWork.StartWorkDate > lastDayStandingDateGr)
|
||||
{
|
||||
return op.Failed("تاریخ ثبت شده قبل از شروع به کار است");
|
||||
}
|
||||
|
||||
if (leftWork.WorkshopId != command.WorkshopId || leftWork.EmployeeId != employeeId)
|
||||
{
|
||||
return op.Failed("اطلاعات وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if (leftWork.StartWorkDate >= leftWorkDateGr)
|
||||
//{
|
||||
// return op.Failed("ترک کار نمیتواند کوچک تر یا مساوی شروع به کار باشد");
|
||||
//}
|
||||
|
||||
//if (_checkoutRepository.Exists(x => x.EmployeeId == leftWorkTemp.EmployeeId &&
|
||||
// x.WorkshopId == leftWorkTemp.WorkshopId &&
|
||||
// x.ContractStart <= lastDayStandingGr && x.ContractEnd >= lastDayStandingGr))
|
||||
//{
|
||||
// return op.Failed("این پرسنل در تاریخ ترک کار وارد شده دارای فیش حقوقی میباشد. ابتدا فیش حقوقی پرسنل را حذف کنید ");
|
||||
//}
|
||||
|
||||
//if (_contractRepository.Exists(x => x.EmployeeId == leftWorkTemp.EmployeeId &&
|
||||
// x.WorkshopIds == leftWorkTemp.WorkshopId &&
|
||||
// x.ContarctStart <= lastDayStandingGr && x.ContractEnd >= lastDayStandingGr))
|
||||
//{
|
||||
// return op.Failed("این پرسنل در تاریخ ترک کار وارد شده دارای قرارداد میباشد");
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
var leftWorkTemp = LeftWorkTemp.CreateLeftWork(leftWork.id, leftWork.StartWorkDate, leftWorkDateGr, lastDayStandingDateGr,
|
||||
command.WorkshopId, employeeId, leftWork.JobId);
|
||||
|
||||
await _leftWorkTempRepository.CreateAsync(leftWorkTemp);
|
||||
}
|
||||
|
||||
await _leftWorkTempRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId)
|
||||
{
|
||||
return _leftWorkTempRepository.GetStartAndLeftWorkDetails(employeeId, workshopId);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> AcceptStartWork(AcceptStartWorkTemp command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
if (command.StartDateTime.TryToGeorgianDateTime(out var startDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var leftWorkTemp = _leftWorkTempRepository.Get(command.LeftWorkTempId);
|
||||
|
||||
if (leftWorkTemp.LeftWorkType != LeftWorkTempType.StartWork)
|
||||
{
|
||||
return op.Failed("اطلاعات وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (_leftWorkRepository.Exists(x => x.WorkshopId == leftWorkTemp.WorkshopId && x.EmployeeId == leftWorkTemp.EmployeeId && x.LeftWorkDate >= startDateGr))
|
||||
{
|
||||
return op.Failed("شروع به کار وارد شده با ترک کار های قبلی تداخل دارد");
|
||||
}
|
||||
|
||||
|
||||
if (_jobRepository.Exists(x => x.id == command.JobId) == false)
|
||||
{
|
||||
return op.Failed("سمت وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var defaultTime = new DateTime(2121, 03, 21);
|
||||
|
||||
var workshop = _workshopRepository.Get(leftWorkTemp.WorkshopId);
|
||||
var employee = _employeeRepository.Get(leftWorkTemp.EmployeeId);
|
||||
|
||||
var newLeftWork = new LeftWork(defaultTime, startDateGr, leftWorkTemp.WorkshopId, leftWorkTemp.EmployeeId,
|
||||
employee.FullName, workshop.WorkshopFullName, command.JobId, false, false, false, false, "", "");
|
||||
|
||||
await _leftWorkRepository.CreateAsync(newLeftWork);
|
||||
_leftWorkTempRepository.Remove(leftWorkTemp);
|
||||
await _leftWorkRepository.SaveChangesAsync();
|
||||
await _leftWorkTempRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<OperationResult> AcceptLeftWork(AcceptLeftWorkTemp command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
if (command.LeftWorkTime.TryToGeorgianDateTime(out var leftWorkDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ ترک کار وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (command.LastDayStanding.TryToGeorgianDateTime(out var lastDayStandingGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ آخرین روز کاری وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (lastDayStandingGr.AddDays(1).Date != leftWorkDateGr)
|
||||
{
|
||||
return op.Failed("تاریخ آخرین روز کاری با تاریخ ترک کار یک روز اختلاف ندارند");
|
||||
}
|
||||
|
||||
var leftWorkTemp = _leftWorkTempRepository.Get(command.LeftWorkTempId);
|
||||
|
||||
if (leftWorkTemp == null)
|
||||
{
|
||||
return op.Failed("ترک کار وارد شده یافت نشد");
|
||||
}
|
||||
|
||||
|
||||
if (leftWorkTemp.LeftWorkType != LeftWorkTempType.LeftWork)
|
||||
{
|
||||
return op.Failed("اطلاعات وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var leftWork = _leftWorkRepository.Get(leftWorkTemp.LeftWorkId);
|
||||
|
||||
|
||||
if (leftWork == null)
|
||||
return op.Failed("شروع به کار پرسنل یافت نشد");
|
||||
|
||||
if (leftWork.StartWorkDate >= leftWorkDateGr)
|
||||
{
|
||||
return op.Failed("ترک کار نمیتواند کوچک تر یا مساوی شروع به کار باشد");
|
||||
}
|
||||
|
||||
if (_checkoutRepository.Exists(x => x.EmployeeId == leftWorkTemp.EmployeeId &&
|
||||
x.WorkshopId == leftWorkTemp.WorkshopId &&
|
||||
x.ContractStart <= lastDayStandingGr && x.ContractEnd >= lastDayStandingGr))
|
||||
{
|
||||
return op.Failed("این پرسنل در تاریخ ترک کار وارد شده دارای فیش حقوقی میباشد. ابتدا فیش حقوقی پرسنل را حذف کنید ");
|
||||
}
|
||||
|
||||
leftWork.Edit(leftWorkDateGr, leftWork.StartWorkDate, leftWork.WorkshopId, leftWork.EmployeeId, leftWork.JobId,
|
||||
leftWork.IncludeStatus, leftWork.AddBonusesPay, leftWork.AddYearsPay, leftWork.AddLeavePay);
|
||||
|
||||
_leftWorkTempRepository.Remove(leftWorkTemp);
|
||||
await _leftWorkRepository.SaveChangesAsync();
|
||||
await _leftWorkTempRepository.SaveChangesAsync();
|
||||
|
||||
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(leftWork.EmployeeId);
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
|
||||
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
|
||||
{
|
||||
//get last leftworks for employee in all workshops
|
||||
var leftWorks = _leftWorkRepository.search(new LeftWorkSearchModel() { EmployeeId = employeeId }).GroupBy(x => x.WorkshopId).Select(x =>
|
||||
{
|
||||
var leftWork = x.MaxBy(y => y.StartWorkDateGr);
|
||||
return new LeftWorkViewModel()
|
||||
{
|
||||
EmployeeId = employeeId,
|
||||
WorkshopId = x.Key,
|
||||
LeftWorkDateGr = leftWork.LeftWorkDateGr.Date.AddDays(-1),
|
||||
StartWorkDateGr = leftWork.StartWorkDateGr
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
//get rollCallEmployee associated with those leftworks which have a higher end date than leftworkDate
|
||||
var rollCallsEmployee = _rollCallEmployeeRepository.GetByEmployeeIdWithStatuses(employeeId)
|
||||
.Where(x => leftWorks.Any(y => y.WorkshopId == x.WorkshopId)).ToList();
|
||||
|
||||
var joinedList = rollCallsEmployee.Join(leftWorks, x => x.WorkshopId, y => y.WorkshopId, (x, y) => new
|
||||
{
|
||||
x.WorkshopId,
|
||||
x.EmployeeId,
|
||||
y.LeftWorkDateGr,
|
||||
Status = x.Statuses.OrderByDescending(z => z.StartDate).FirstOrDefault(z => z.StartDateGr.Date < y.LeftWorkDateGr && z.EndDateGr.Date > y.LeftWorkDateGr)
|
||||
});
|
||||
|
||||
//shaping up the list to send as parameter to repository
|
||||
var newRollCallRecords = joinedList.Where(x => x.Status != null).Select(x => new AdjustRollCallEmployeesWithEmployeeLeftWork()
|
||||
{
|
||||
LeaveDate = x.LeftWorkDateGr,
|
||||
RollCallStatusId = x.Status.Id
|
||||
}).ToList();
|
||||
if (newRollCallRecords.Count > 0)
|
||||
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates(newRollCallRecords);
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,9 @@ public class PersonnelCodeApplication : IPersonnelCodeApplication
|
||||
{
|
||||
return _personnelCodeRepository.GetEmployeeIdByPersonelCode(personleCode, workshopId);
|
||||
}
|
||||
|
||||
public long GetLastPersonnelCodeByWorkshop(long workshopId)
|
||||
{
|
||||
return _personnelCodeRepository.GetLastPersonnelCodeByWorkshop(workshopId);
|
||||
}
|
||||
}
|
||||
@@ -8,123 +8,143 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Company.Domain.RollCallServiceAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
|
||||
namespace CompanyManagment.Application
|
||||
{
|
||||
public class RollCallEmployeeStatusApplication : IRollCallEmployeeStatusApplication
|
||||
{
|
||||
private readonly IRollCallEmployeeStatusRepository _employeeRollCallStatusRepository;
|
||||
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
||||
private readonly ILeftWorkRepository _leftWorkRepository;
|
||||
private readonly IRollCallServiceRepository _rollCallServiceRepository;
|
||||
public class RollCallEmployeeStatusApplication : IRollCallEmployeeStatusApplication
|
||||
{
|
||||
private readonly IRollCallEmployeeStatusRepository _employeeRollCallStatusRepository;
|
||||
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
|
||||
private readonly ILeftWorkRepository _leftWorkRepository;
|
||||
private readonly IRollCallServiceRepository _rollCallServiceRepository;
|
||||
private readonly ILeftWorkTempRepository _leftWorkTempRepository;
|
||||
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
|
||||
|
||||
|
||||
public RollCallEmployeeStatusApplication(IRollCallEmployeeStatusRepository employeeStatusRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, ILeftWorkRepository leftWorkRepository, IRollCallServiceRepository rollCallServiceRepository)
|
||||
{
|
||||
_employeeRollCallStatusRepository = employeeStatusRepository;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
_rollCallServiceRepository = rollCallServiceRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateRollCallEmployeeStatus cmd)
|
||||
{
|
||||
OperationResult op = new();
|
||||
RollCallEmployee rollCallEmployee = _rollCallEmployeeRepository.Get(cmd.RollCallEmployeeId);
|
||||
if (rollCallEmployee == null)
|
||||
return op.Failed("کارمند مجاز نیست");
|
||||
public RollCallEmployeeStatusApplication(IRollCallEmployeeStatusRepository employeeStatusRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, ILeftWorkRepository leftWorkRepository, IRollCallServiceRepository rollCallServiceRepository, ILeftWorkTempRepository leftWorkTempRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository)
|
||||
{
|
||||
_employeeRollCallStatusRepository = employeeStatusRepository;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
_rollCallServiceRepository = rollCallServiceRepository;
|
||||
_leftWorkTempRepository = leftWorkTempRepository;
|
||||
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
|
||||
}
|
||||
|
||||
if (!_leftWorkRepository.Exists(x => x.EmployeeId == rollCallEmployee.EmployeeId && x.WorkshopId == rollCallEmployee.WorkshopId &&
|
||||
(x.LeftWorkDate.Date > DateTime.Now.Date && x.StartWorkDate.Date <= DateTime.Now.Date) || x.StartWorkDate >= DateTime.Today))
|
||||
return op.Failed("کارمند در کارگاه شروع به کار نکرده است");
|
||||
public OperationResult Create(CreateRollCallEmployeeStatus cmd)
|
||||
{
|
||||
OperationResult op = new();
|
||||
RollCallEmployee rollCallEmployee = _rollCallEmployeeRepository.Get(cmd.RollCallEmployeeId);
|
||||
if (rollCallEmployee == null)
|
||||
return op.Failed("کارمند مجاز نیست");
|
||||
|
||||
if (_employeeRollCallStatusRepository.Exists(y =>
|
||||
rollCallEmployee.id == y.RollCallEmployeeId && y.EndDate.Date > DateTime.Now.Date))
|
||||
return op.Failed("کارمند فعال می باشد");
|
||||
if (!_leftWorkRepository.Exists(x =>
|
||||
x.EmployeeId == rollCallEmployee.EmployeeId && x.WorkshopId == rollCallEmployee.WorkshopId &&
|
||||
x.StartWorkDate <= DateTime.Now && x.LeftWorkDate > DateTime.Now) &&
|
||||
!_leftWorkTempRepository.Exists(x =>
|
||||
x.EmployeeId == rollCallEmployee.EmployeeId && x.WorkshopId == rollCallEmployee.WorkshopId &&
|
||||
x.LeftWorkType == LeftWorkTempType.StartWork))
|
||||
{
|
||||
return op.Failed("کارمند شروع به کار ندارد");
|
||||
}
|
||||
|
||||
if (_employeeRollCallStatusRepository.Exists(y =>
|
||||
rollCallEmployee.id == y.RollCallEmployeeId && y.EndDate.Date == DateTime.Now.Date))
|
||||
{
|
||||
RollCallEmployeeStatus previousStatusInDate = _employeeRollCallStatusRepository.GetByRollCallEmployeeIdAndDate(cmd.RollCallEmployeeId, DateTime.Now.Date);
|
||||
previousStatusInDate.Edit(previousStatusInDate.StartDate, Tools.GetUndefinedDateTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
var pc = new PersianCalendar();
|
||||
var startStatus = DateTime.Today;
|
||||
LeftWork leftWork =
|
||||
_leftWorkRepository.GetLastLeftWork(rollCallEmployee.EmployeeId, rollCallEmployee.WorkshopId).GetAwaiter().GetResult();
|
||||
|
||||
if(leftWork.StartWorkDate>DateTime.Today)
|
||||
startStatus = leftWork.StartWorkDate;
|
||||
if (_employeeRollCallStatusRepository.Exists(y =>
|
||||
rollCallEmployee.id == y.RollCallEmployeeId && y.EndDate.Date > DateTime.Now.Date))
|
||||
return op.Failed("کارمند فعال می باشد");
|
||||
|
||||
//else if(pc.GetMonth(DateTime.Today) == pc.GetMonth(leftWork.StartWorkDate))
|
||||
//{
|
||||
// startStatus = new DateTime(pc.GetYear(leftWork.StartWorkDate), pc.GetMonth(leftWork.StartWorkDate),
|
||||
// 1, pc);
|
||||
//}
|
||||
if (_employeeRollCallStatusRepository.Exists(y =>
|
||||
rollCallEmployee.id == y.RollCallEmployeeId && y.EndDate.Date == DateTime.Now.Date))
|
||||
{
|
||||
RollCallEmployeeStatus previousStatusInDate = _employeeRollCallStatusRepository.GetByRollCallEmployeeIdAndDate(cmd.RollCallEmployeeId, DateTime.Now.Date);
|
||||
previousStatusInDate.Edit(previousStatusInDate.StartDate, Tools.GetUndefinedDateTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
var pc = new PersianCalendar();
|
||||
var startStatus = DateTime.Today;
|
||||
LeftWork leftWork =
|
||||
_leftWorkRepository.GetLastLeftWork(rollCallEmployee.EmployeeId, rollCallEmployee.WorkshopId).GetAwaiter().GetResult();
|
||||
|
||||
RollCallEmployeeStatus newRecord = new(rollCallEmployee.id, startStatus);
|
||||
_employeeRollCallStatusRepository.Create(newRecord);
|
||||
}
|
||||
if (leftWork != null && leftWork.StartWorkDate > DateTime.Today)
|
||||
startStatus = leftWork.StartWorkDate;
|
||||
|
||||
_employeeRollCallStatusRepository.SaveChanges();
|
||||
//else if(pc.GetMonth(DateTime.Today) == pc.GetMonth(leftWork.StartWorkDate))
|
||||
//{
|
||||
// startStatus = new DateTime(pc.GetYear(leftWork.StartWorkDate), pc.GetMonth(leftWork.StartWorkDate),
|
||||
// 1, pc);
|
||||
//}
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
RollCallEmployeeStatus newRecord = new(rollCallEmployee.id, startStatus);
|
||||
_employeeRollCallStatusRepository.Create(newRecord);
|
||||
}
|
||||
|
||||
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
//موقت
|
||||
// دادمهرگستر 11
|
||||
//585 کاشی گالری سرامیس (بابک ابراهیمی )
|
||||
//آموزشگاه ملل 604
|
||||
//کاریابی ملل 605
|
||||
//368 پیتزا امیر آماده سازی
|
||||
//367 پیتزا امیر رستوران
|
||||
//286 مرکز توان بخشی رسالت
|
||||
bool skipRollCall = workshopId is 11 or 585 or 604 or 605 or 368 or 367 or 286;
|
||||
_employeeRollCallStatusRepository.SaveChanges();
|
||||
|
||||
#if DEBUG
|
||||
skipRollCall = workshopId is 11 or 585 or 604 or 605 or 368 or 367;
|
||||
#endif
|
||||
if (skipRollCall)
|
||||
return false;
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
//#if DEBUG
|
||||
// skipRollCallByWorkshopId = workshopId is 11 or 585 or 604 or 605 or 368 or 367;
|
||||
//#endif
|
||||
if (skipRollCallByWorkshopId)
|
||||
return false;
|
||||
|
||||
|
||||
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);
|
||||
// 42550 مصطفی مقدس نژاد فومنی
|
||||
bool skipRollCallByEmployeeId = employeeId is 42550;
|
||||
if (skipRollCallByEmployeeId)
|
||||
return false;
|
||||
|
||||
if (!service.Any(x => x.StartService.Date <= contractStart.Date && x.EndService.Date >= contractEnd.Date))
|
||||
return false;
|
||||
var rollCallEmployee =
|
||||
_rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
|
||||
|
||||
if (rollCallEmployee == null)
|
||||
return false;
|
||||
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);
|
||||
|
||||
return _employeeRollCallStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id &&
|
||||
x.StartDate.Date <= contractStart.Date &&
|
||||
x.EndDate.Date >= contractEnd.Date);
|
||||
}
|
||||
if (!service.Any(x => x.StartService.Date <= contractStart.Date && x.EndService.Date >= contractEnd.Date))
|
||||
return false;
|
||||
var rollCallEmployee =
|
||||
_rollCallEmployeeRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
|
||||
|
||||
public List<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr)
|
||||
{
|
||||
return _employeeRollCallStatusRepository.GetActiveByWorkshopIdInDate(workshopId, startDateGr, endDateGr);
|
||||
}
|
||||
if (rollCallEmployee == null)
|
||||
return false;
|
||||
|
||||
public OperationResult Deactivate(long id)
|
||||
{
|
||||
OperationResult op = new();
|
||||
RollCallEmployeeStatus entity = _employeeRollCallStatusRepository.Get(id);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
if (!entity.EndDate.IsDateUndefined())
|
||||
return op.Failed("کارمند قبلا غیر فعال شده است");
|
||||
entity.Deactivate(DateTime.Now.Date);
|
||||
_employeeRollCallStatusRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
return _employeeRollCallStatusRepository.Exists(x => x.RollCallEmployeeId == rollCallEmployee.Id &&
|
||||
x.StartDate.Date <= contractStart.Date &&
|
||||
x.EndDate.Date >= contractEnd.Date);
|
||||
}
|
||||
|
||||
public List<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr)
|
||||
{
|
||||
return _employeeRollCallStatusRepository.GetActiveByWorkshopIdInDate(workshopId, startDateGr, endDateGr);
|
||||
}
|
||||
|
||||
public OperationResult Deactivate(long id)
|
||||
{
|
||||
OperationResult op = new();
|
||||
RollCallEmployeeStatus entity = _employeeRollCallStatusRepository.Get(id);
|
||||
if (entity == null)
|
||||
return op.Failed(ApplicationMessages.RecordNotFound);
|
||||
if (!entity.EndDate.IsDateUndefined())
|
||||
return op.Failed("کارمند قبلا غیر فعال شده است");
|
||||
entity.Deactivate(DateTime.Now.Date);
|
||||
_employeeRollCallStatusRepository.SaveChanges();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditRollCallEmployeeStatus cmd)
|
||||
{
|
||||
|
||||
@@ -102,4 +102,9 @@ public class RollCallServiceApplication : IRollCallServiceApplication
|
||||
{
|
||||
return _rollCallServiceRepository.GetAllServiceByAccountId(accountId);
|
||||
}
|
||||
|
||||
public bool IsExistActiveServiceByWorkshopId(long workshopId)
|
||||
{
|
||||
return _rollCallServiceRepository.IsExistActiveServiceByWorkshopId(workshopId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.UID;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.TemporaryClientRegistrationAgg;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using PersianTools.Core;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrationApplication
|
||||
{
|
||||
private readonly IContractingPartyTempRepository _contractingPartyTempRepository;
|
||||
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository;
|
||||
private readonly IUidService _uidService;
|
||||
|
||||
public TemporaryClientRegistrationApplication(IContractingPartyTempRepository contractingPartyTempRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IUidService uidService)
|
||||
{
|
||||
_contractingPartyTempRepository = contractingPartyTempRepository;
|
||||
_personalContractingPartyRepository = personalContractingPartyRepository;
|
||||
_uidService = uidService;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<ContractingPartyTempViewModel>> CreateContractingPartyTemp(string nationalCode , string dateOfBirth, string mobile)
|
||||
{
|
||||
var op = new OperationResult<ContractingPartyTempViewModel>();
|
||||
|
||||
#region Validations
|
||||
|
||||
if (string.IsNullOrWhiteSpace(nationalCode) || string.IsNullOrWhiteSpace(dateOfBirth) ||
|
||||
string.IsNullOrWhiteSpace(mobile))
|
||||
return op.Failed("هیچ یک از فیلد ها نمیتواند خالی باشد");
|
||||
|
||||
|
||||
if (nationalCode.NationalCodeValid() != "valid")
|
||||
return op.Failed("کد ملی نا معتبر است");
|
||||
|
||||
if(!dateOfBirth.IsPersianDateValid())
|
||||
return op.Failed("تاریخ تولد نا معتبر است");
|
||||
|
||||
if(!mobile.IsMobileValid())
|
||||
return op.Failed("شماره همراه نا معتبر است");
|
||||
#endregion
|
||||
|
||||
|
||||
var getExistContractingParty = await _contractingPartyTempRepository.CheckExistOrAuthenticated(nationalCode, dateOfBirth);
|
||||
|
||||
//اگر طرف حساب قبلا در دیتابیس وجود داشت
|
||||
if (getExistContractingParty)
|
||||
{
|
||||
return op.Failed("طرف حساب با این مشخصات در سیستم وجود دارد");
|
||||
}
|
||||
//اگر طرف حساب وجود نداشت
|
||||
else
|
||||
{
|
||||
//دریافت اطلاعات طرف حساب موقت که قبلا ایجاد شده
|
||||
var getExistTemp = _contractingPartyTempRepository.GetByNationalCode(nationalCode);
|
||||
|
||||
var dateOfBirthGr = dateOfBirth.ToGeorgianDateTime();
|
||||
|
||||
if (getExistTemp != null)
|
||||
{
|
||||
|
||||
if(getExistTemp.DateOfBirth != dateOfBirthGr)
|
||||
return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
if (getExistTemp.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری ثبت نام نموده اید");
|
||||
return op.Succcedded(getExistTemp);
|
||||
|
||||
}
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if(!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
//دریافت اطلاعات احراز هویت
|
||||
var apiRespons = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
if(apiRespons == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (apiRespons.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiRespons.ResponseContext.Status.Message}");
|
||||
|
||||
var idNumber = apiRespons.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
//ایجاد طرف حساب موقت
|
||||
var createTemp = new ContractingPartyTemp(apiRespons.BasicInformation.FirstName,
|
||||
apiRespons.BasicInformation.LastName, nationalCode, idNumber, mobile,
|
||||
apiRespons.BasicInformation.FatherName, "", "", "",
|
||||
apiRespons.IdentificationInformation.ShenasnameSeri,
|
||||
apiRespons.IdentificationInformation.ShenasnameSerial, apiRespons.BasicInformation.GenderEnum,
|
||||
dateOfBirthGr);
|
||||
await _contractingPartyTempRepository.CreateAsync(createTemp);
|
||||
await _contractingPartyTempRepository.SaveChangesAsync();
|
||||
|
||||
var result = new ContractingPartyTempViewModel();
|
||||
result.Id = createTemp.id;
|
||||
result.FName = createTemp.FName;
|
||||
result.LName = createTemp.LName;
|
||||
result.DateOfBirthFa = dateOfBirth;
|
||||
result.IdNumber = idNumber;
|
||||
|
||||
return op.Succcedded(result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
@@ -15,6 +16,7 @@ using CompanyManagment.App.Contracts.EmployeeChildren;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.RollCallService;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
using CompanyManagment.App.Contracts.WorkshopPlan;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -35,9 +37,9 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository;
|
||||
private readonly IRollCallServiceApplication _rollCallServiceApplication;
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
|
||||
|
||||
public WorkshopAppliction(IWorkshopRepository workshopRepository, ILeftWorkRepository leftWorkRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IWorkshopPlanApplication workshopPlanApplication, IEmployeeApplication employeeApplication, IEmployeeChildrenApplication employeeChildrenApplication, IInstitutionContractRepository institutionContractRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IRollCallServiceApplication rollCallServiceApplication)
|
||||
public WorkshopAppliction(IWorkshopRepository workshopRepository, ILeftWorkRepository leftWorkRepository, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IWorkshopPlanApplication workshopPlanApplication, IEmployeeApplication employeeApplication, IEmployeeChildrenApplication employeeChildrenApplication, IInstitutionContractRepository institutionContractRepository, IPersonalContractingPartyRepository personalContractingPartyRepository, IRollCallServiceApplication rollCallServiceApplication, IPasswordHasher passwordHasher)
|
||||
{
|
||||
_workshopRepository = workshopRepository;
|
||||
_leftWorkRepository = leftWorkRepository;
|
||||
@@ -48,6 +50,7 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_personalContractingPartyRepository = personalContractingPartyRepository;
|
||||
_rollCallServiceApplication = rollCallServiceApplication;
|
||||
_passwordHasher = passwordHasher;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateWorkshop command)
|
||||
@@ -752,6 +755,8 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
return _workshopRepository.PrintWorkshopList(searchModel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AccountViewModel GetClientAccountByWorkshopId(long workshopId)
|
||||
{
|
||||
var contractingParty = _workshopRepository.GetPersonalContractingPartyByWorkshopId(workshopId);
|
||||
@@ -760,19 +765,104 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
|
||||
|
||||
|
||||
//public List<ConnectedPersonnelViewModel> GetConnectedPersonnelsForMain(long workshopId)
|
||||
//{
|
||||
// return _workshopRepository.GetConnectedPersonnelsForMain(workshopId);
|
||||
//}
|
||||
//public List<ConnectedPersonnelViewModel> GetConnectedPersonnelsForMain(long workshopId)
|
||||
//{
|
||||
// return _workshopRepository.GetConnectedPersonnelsForMain(workshopId);
|
||||
//}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Insurance
|
||||
|
||||
public List<WorkshopViewModel> GetWorkshopSelectListInsuransce()
|
||||
#region Pooya
|
||||
public List<PersonnelInfoViewModel> GetPersonnelInfoRemastered(PersonnelInfoSearchModel searchModel)
|
||||
{
|
||||
|
||||
var res = _workshopRepository.GetPersonnelInfoRemastered(searchModel.WorkshopId);
|
||||
res = res.Select(x => new PersonnelInfoViewModel
|
||||
{
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeId = x.EmployeeId,
|
||||
PersonnelCode = x.PersonnelCode,
|
||||
FullName = x.FullName,
|
||||
Name = x.Name,
|
||||
LastName = x.LastName,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
MaritalStatus = x.MaritalStatus,
|
||||
DateOfBirthFa = x.DateOfBirthFa,
|
||||
FatherName = x.FatherName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address,
|
||||
ChildrenList = x.ChildrenList,
|
||||
ContractPerson = x.ContractPerson,
|
||||
InsurancePerson = x.InsurancePerson,
|
||||
ContractLeft = x.ContractLeft,
|
||||
InsuranceLeft = x.InsuranceLeft,
|
||||
Black = ((x.ContractPerson && x.InsurancePerson && x.InsuranceLeft && x.ContractLeft) ||
|
||||
(x.ContractPerson && !x.InsurancePerson && x.ContractLeft) ||
|
||||
(x.InsurancePerson && !x.ContractPerson && x.InsuranceLeft))
|
||||
? true
|
||||
: false,
|
||||
LastStartContractWork = x.LastStartContractWork,
|
||||
LastLeftContractWork = x.LastLeftContractWork,
|
||||
LastStartInsuranceWork = x.LastStartInsuranceWork,
|
||||
LastLeftInsuranceWork = x.LastLeftInsuranceWork,
|
||||
WorkshopHash = _passwordHasher.SlugHasher(x.WorkshopId),
|
||||
EmployeeHash = _passwordHasher.SlugHasher(x.EmployeeId),
|
||||
CreatedByClient = x.CreatedByClient,
|
||||
LefWorkTemp = x.LefWorkTemp,
|
||||
LeftWork = x.LeftWork,
|
||||
PersonnelInfoViewModels = x.PersonnelInfoViewModels,
|
||||
StartWork = x.StartWork
|
||||
}).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.FullName))
|
||||
res = res.Where(x => x.FullName.Contains(searchModel.FullName)).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
||||
res = res.Where(x => x.NationalCode.Contains(searchModel.NationalCode)).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.MaritalStatus))
|
||||
res = res.Where(x => x.MaritalStatus == searchModel.MaritalStatus).ToList();
|
||||
return res;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Insurance
|
||||
|
||||
public List<WorkshopViewModel> GetWorkshopSelectListInsuransce()
|
||||
{
|
||||
return _workshopRepository.GetWorkshopSelectListInsuransce();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
public async Task<List<WorkshopWithStartedEmployeesDto>> GetWorkshopsForEmployeeStartWork(long accountId)
|
||||
{
|
||||
return await _workshopRepository.GetWorkshopsForEmployeeStartWork(accountId);
|
||||
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkshopsForEmployeeStartWorkCount(long accountId)
|
||||
{
|
||||
return await _workshopRepository.GetWorkshopsForEmployeeStartWorkCount(accountId);
|
||||
}
|
||||
|
||||
public async Task<List<WorkshopWithLeftWorkTempEmployeesDto>> GetWorkshopsForLeftWorkTemp(long accountId)
|
||||
{
|
||||
return await _workshopRepository.GetWorkshopsForLeftWorkTemp(accountId);
|
||||
}
|
||||
|
||||
public Task<int> GetWorkshopsForLeftWorkTempCount(long accountId)
|
||||
{
|
||||
return _workshopRepository.GetWorkshopsForLeftWorkTempCount(accountId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ using Company.Domain.EmployeeAccountAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.EmployeeBankInformationAgg;
|
||||
using Company.Domain.EmployeeChildrenAgg;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
using Company.Domain.EmployeeComputeOptionsAgg;
|
||||
using Company.Domain.EmployeeDocumentItemAgg;
|
||||
using Company.Domain.EmployeeDocumentsAgg;
|
||||
@@ -63,6 +64,7 @@ using Company.Domain.JobAgg;
|
||||
using Company.Domain.LeaveAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using Company.Domain.LoanAgg.Entities;
|
||||
using Company.Domain.MandatoryHoursAgg;
|
||||
using Company.Domain.MasterPenaltyTitle;
|
||||
@@ -91,6 +93,7 @@ using Company.Domain.SubtitleAgg;
|
||||
using Company.Domain.TaxJobCategoryAgg;
|
||||
using Company.Domain.TaxLeftWorkCategoryAgg;
|
||||
using Company.Domain.TaxLeftWorkItemAgg;
|
||||
using Company.Domain.TemporaryClientRegistrationAgg;
|
||||
using Company.Domain.TextManagerAgg;
|
||||
using Company.Domain.WorkHistory;
|
||||
using Company.Domain.WorkingHoursAgg;
|
||||
@@ -168,6 +171,9 @@ public class CompanyContext : DbContext
|
||||
|
||||
public DbSet<AndroidApkVersion> AndroidApkVersions { get; set; }
|
||||
|
||||
public DbSet<EmployeeClientTemp> EmployeeClientTemps { get; set; }
|
||||
public DbSet<LeftWorkTemp> LeftWorkTemps { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
@@ -180,10 +186,14 @@ public class CompanyContext : DbContext
|
||||
public DbSet<Bank> Banks { get; set; }
|
||||
public DbSet<EmployeeBankInformation> EmployeeBankInformationSet { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region TemporaryClientRegisteration
|
||||
|
||||
public DbSet<CustomizeCheckout> CustomizeCheckouts { get; set; }
|
||||
public DbSet<ContractingPartyTemp> ContractingPartyTemps { get; set; }
|
||||
|
||||
#endregion
|
||||
public DbSet<CustomizeCheckout> CustomizeCheckouts { get; set; }
|
||||
public DbSet<CustomizeCheckoutTemp> CustomizeCheckoutTemps { get; set; }
|
||||
public DbSet<TaxLeftWorkItem> TaxLeftWorkItems { get; set; }
|
||||
public DbSet<TaxLeftWorkCategory> TaxLeftWorkCategories { get; set; }
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.TemporaryClientRegistrationAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping;
|
||||
|
||||
public class ContractingPartyTempMapping : IEntityTypeConfiguration<ContractingPartyTemp>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ContractingPartyTemp> builder)
|
||||
{
|
||||
builder.ToTable("ContractingPartyTemp");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.FName).HasMaxLength(25).IsRequired();
|
||||
builder.Property(x => x.LName).HasMaxLength(25).IsRequired();
|
||||
builder.Property(x => x.NationalCode).HasMaxLength(10).IsRequired();
|
||||
builder.Property(x => x.IdNumber).HasMaxLength(10).IsRequired(false);
|
||||
builder.Property(x => x.Phone).HasMaxLength(12);
|
||||
builder.Property(x => x.FatherName).HasMaxLength(25);
|
||||
builder.Property(x => x.State).HasMaxLength(35);
|
||||
builder.Property(x => x.City).HasMaxLength(35);
|
||||
builder.Property(x => x.Address).HasMaxLength(500);
|
||||
builder.Property(x => x.IdNumberSeri).HasMaxLength(5);
|
||||
builder.Property(x => x.IdNumberSerial).HasMaxLength(15);
|
||||
builder.Property(x => x.Gender).HasConversion(
|
||||
v => v.ToString(),
|
||||
v => (Gender)Enum.Parse(typeof(Gender), v)).HasMaxLength(6);
|
||||
builder.Property(x => x.DateOfBirth);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
@@ -31,6 +33,18 @@ public class PersonalContractingpartyMapping : IEntityTypeConfiguration<Personal
|
||||
builder.Property(x => x.IsBlock).HasMaxLength(5);
|
||||
builder.Property(x => x.BlockTimes);
|
||||
|
||||
#region NewProp
|
||||
|
||||
builder.Property(x => x.IdNumberSeri).HasMaxLength(5);
|
||||
builder.Property(x => x.IdNumberSerial).HasMaxLength(15);
|
||||
builder.Property(x => x.FatherName).HasMaxLength(20);
|
||||
builder.Property(x => x.DateOfBirth).IsRequired(false);
|
||||
builder.Property(x => x.Gender).HasConversion(
|
||||
v => v.ToString(),
|
||||
v => string.IsNullOrWhiteSpace(v) ? Gender.None : (Gender)Enum.Parse(typeof(Gender), v)).HasMaxLength(6);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8885
CompanyManagment.EFCore/Migrations/20250309154800_add employee by client tables.Designer.cs
generated
Normal file
8885
CompanyManagment.EFCore/Migrations/20250309154800_add employee by client tables.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addemployeebyclienttables : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAuthorized",
|
||||
table: "Employees",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmployeeClientTemps",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
EmployeeFullName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
|
||||
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
|
||||
StartWorkDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
MaritalStatus = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmployeeClientTemps", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeftWorkTemps",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
LeftWorkId = table.Column<long>(type: "bigint", nullable: false),
|
||||
StartWork = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LeftWork = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
LastDayStanding = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
|
||||
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
|
||||
JobId = table.Column<long>(type: "bigint", nullable: false),
|
||||
LeftWorkType = table.Column<int>(type: "int", nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeftWorkTemps", x => x.id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmployeeClientTemps");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeftWorkTemps");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAuthorized",
|
||||
table: "Employees");
|
||||
}
|
||||
}
|
||||
}
|
||||
8829
CompanyManagment.EFCore/Migrations/20250316125105_'addNewPropToContractingParty'.Designer.cs
generated
Normal file
8829
CompanyManagment.EFCore/Migrations/20250316125105_'addNewPropToContractingParty'.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 addNewPropToContractingParty : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DateOfBirth",
|
||||
table: "PersonalContractingParties",
|
||||
type: "datetime2",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FatherName",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(20)",
|
||||
maxLength: 20,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "IdNumberSeri",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(5)",
|
||||
maxLength: 5,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "IdNumberSerial",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(15)",
|
||||
maxLength: 15,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAuthenticated",
|
||||
table: "PersonalContractingParties",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateOfBirth",
|
||||
table: "PersonalContractingParties");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FatherName",
|
||||
table: "PersonalContractingParties");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdNumberSeri",
|
||||
table: "PersonalContractingParties");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IdNumberSerial",
|
||||
table: "PersonalContractingParties");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAuthenticated",
|
||||
table: "PersonalContractingParties");
|
||||
}
|
||||
}
|
||||
}
|
||||
8979
CompanyManagment.EFCore/Migrations/20250318125026_addGenderToPersonalContractingParty.Designer.cs
generated
Normal file
8979
CompanyManagment.EFCore/Migrations/20250318125026_addGenderToPersonalContractingParty.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addGenderToPersonalContractingParty : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Gender",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(6)",
|
||||
maxLength: 6,
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContractingPartyTemp",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FName = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: false),
|
||||
LName = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: false),
|
||||
FatherName = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: true),
|
||||
Gender = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: false),
|
||||
NationalCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
|
||||
DateOfBirth = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
IdNumberSeri = table.Column<string>(type: "nvarchar(5)", maxLength: 5, nullable: true),
|
||||
IdNumberSerial = table.Column<string>(type: "nvarchar(15)", maxLength: 15, nullable: true),
|
||||
IdNumber = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
|
||||
Phone = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: true),
|
||||
State = table.Column<string>(type: "nvarchar(35)", maxLength: 35, nullable: true),
|
||||
City = table.Column<string>(type: "nvarchar(35)", maxLength: 35, nullable: true),
|
||||
Address = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContractingPartyTemp", x => x.id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContractingPartyTemp");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Gender",
|
||||
table: "PersonalContractingParties");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -558,19 +558,42 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateOfBirth")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<string>("FatherName")
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("nvarchar(6)");
|
||||
|
||||
b.Property<string>("IdNumber")
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<string>("IdNumberSeri")
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("nvarchar(5)");
|
||||
|
||||
b.Property<string>("IdNumberSerial")
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b.Property<string>("IsActiveString")
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("nvarchar(5)");
|
||||
|
||||
b.Property<bool>("IsAuthenticated")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("IsBlock")
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("nvarchar(5)");
|
||||
@@ -1469,6 +1492,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.Property<bool>("IsAuthorized")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("LName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
@@ -1619,6 +1645,37 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("EmployeeChildren", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.EmployeeClientTempAgg.EmployeeClientTemp", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("EmployeeFullName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<long>("EmployeeId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("MaritalStatus")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("StartWorkDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("WorkshopId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("EmployeeClientTemps");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.EmployeeComputeOptionsAgg.EmployeeComputeOptions", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -3443,6 +3500,46 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("LeftWorkInsurances", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.LeftWorkTempAgg.LeftWorkTemp", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("EmployeeId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("JobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime>("LastDayStanding")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("LeftWork")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("LeftWorkId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("LeftWorkType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("StartWork")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("WorkshopId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("LeftWorkTemps");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.LoanAgg.Entities.Loan", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -4688,6 +4785,77 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("TaxLeftWorkItem", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.TemporaryClientRegistrationAgg.ContractingPartyTemp", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)");
|
||||
|
||||
b.Property<string>("City")
|
||||
.HasMaxLength(35)
|
||||
.HasColumnType("nvarchar(35)");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("FatherName")
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("nvarchar(6)");
|
||||
|
||||
b.Property<string>("IdNumber")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.Property<string>("IdNumberSeri")
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("nvarchar(5)");
|
||||
|
||||
b.Property<string>("IdNumberSerial")
|
||||
.HasMaxLength(15)
|
||||
.HasColumnType("nvarchar(15)");
|
||||
|
||||
b.Property<string>("LName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(25)
|
||||
.HasColumnType("nvarchar(25)");
|
||||
|
||||
b.Property<string>("NationalCode")
|
||||
.IsRequired()
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("nvarchar(12)");
|
||||
|
||||
b.Property<string>("State")
|
||||
.HasMaxLength(35)
|
||||
.HasColumnType("nvarchar(35)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("ContractingPartyTemp", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.TextManagerAgg.EntityTextManager", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.UID;
|
||||
using _0_Framework.InfraStructure;
|
||||
using AccountMangement.Infrastructure.EFCore.Migrations;
|
||||
using Company.Domain.TemporaryClientRegistrationAgg;
|
||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class ContractingPartyTempRepository : RepositoryBase<long, ContractingPartyTemp>, IContractingPartyTempRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
private readonly IUidService _uidService;
|
||||
public ContractingPartyTempRepository(CompanyContext context, IUidService uidService) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_uidService = uidService;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckExistOrAuthenticated(string nationalCode, string dateOfBirth)
|
||||
{
|
||||
var contractingParty = _context.PersonalContractingParties.FirstOrDefault(x=>x.Nationalcode == nationalCode && x.IsLegal == "false");
|
||||
if (contractingParty == null)
|
||||
return false;
|
||||
|
||||
if (!contractingParty.IsAuthenticated && !string.IsNullOrWhiteSpace(contractingParty.Nationalcode))
|
||||
{
|
||||
|
||||
var dateOfbirth = contractingParty.DateOfBirth.ToFarsi();
|
||||
var apiRespons = await _uidService.GetPersonalInfo(contractingParty.Nationalcode, dateOfbirth);
|
||||
if (apiRespons != null && apiRespons.ResponseContext.Status.Code == 0)
|
||||
{
|
||||
var idNumber = apiRespons.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiRespons.IdentificationInformation.NationalId
|
||||
: apiRespons.IdentificationInformation.ShenasnamehNumber;
|
||||
contractingParty.Authentication(apiRespons.BasicInformation.FirstName, apiRespons.BasicInformation.LastName,apiRespons.BasicInformation.FatherName,idNumber,apiRespons.IdentificationInformation.ShenasnameSeri,apiRespons.IdentificationInformation.ShenasnameSerial, apiRespons.IdentificationInformation.BirthDate,apiRespons.BasicInformation.GenderEnum);
|
||||
_context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ContractingPartyTempViewModel GetByNationalCode(string nationalCode)
|
||||
{
|
||||
return _context.ContractingPartyTemps.Select(x => new ContractingPartyTempViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
DateOfBirth = x.DateOfBirth,
|
||||
IdNumberSeri = x.IdNumberSeri,
|
||||
IdNumberSerial = x.IdNumberSerial,
|
||||
Address = x.Address,
|
||||
City = x.City,
|
||||
FatherName = x.FatherName,
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
Gender = x.Gender,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
Phone = x.Phone,
|
||||
State = x.State,
|
||||
|
||||
|
||||
}).FirstOrDefault(x => x.NationalCode == nationalCode);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -168,9 +168,9 @@ namespace CompanyManagment.EFCore.Repository
|
||||
SalaryAidDateTimeGe = s.SalaryAidDateTime
|
||||
}).ToList(),
|
||||
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{x.LateToWorkValue.Minutes:D2}"
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}"
|
||||
|
||||
}).ToList();
|
||||
}).ToList();
|
||||
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel
|
||||
{
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
@@ -256,135 +256,138 @@ namespace CompanyManagment.EFCore.Repository
|
||||
return _companyContext.CustomizeCheckouts.Where(x => x.WorkshopId==workshopId && ids.Contains(x.id)).AsEnumerable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee)
|
||||
.ThenInclude(x => x.PersonnelCodeList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var query = _companyContext.CustomizeCheckouts.Include(x => x.Employee)
|
||||
.ThenInclude(x => x.PersonnelCodeList).
|
||||
Include(x => x.Employee).ThenInclude(x => x.EmployeeBankInformationList)
|
||||
.AsSplitQuery().Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
#region parameters initialize
|
||||
|
||||
////start of search is the first day of the current month by default and end of search is today
|
||||
//var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date;
|
||||
//var endSearchDate = DateTime.Today;
|
||||
////start of search is the first day of the current month by default and end of search is today
|
||||
//var startSearchDate = DateTime.Now.FindFirstDayOfMonth().ToGeorgianDateTime().Date;
|
||||
//var endSearchDate = DateTime.Today;
|
||||
|
||||
var pc = new PersianCalendar();
|
||||
var currentYear = pc.GetYear(DateTime.Now);
|
||||
var currentMonth = pc.GetMonth(DateTime.Now);
|
||||
var pc = new PersianCalendar();
|
||||
var currentYear = pc.GetYear(DateTime.Now);
|
||||
var currentMonth = pc.GetMonth(DateTime.Now);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) &&
|
||||
searchModel.Year == 0 && searchModel.Month == 0)
|
||||
{
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.SearchStartFa) && !string.IsNullOrWhiteSpace(searchModel.SearchEndFa) &&
|
||||
searchModel.Year == 0 && searchModel.Month == 0)
|
||||
{
|
||||
var queryStartDate = searchModel.SearchStartFa.ToGeorgianDateTime().Date;
|
||||
var queryEndDate = searchModel.SearchEndFa.ToGeorgianDateTime().Date;
|
||||
|
||||
//if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
//query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate);
|
||||
query = query.Where(x => x.ContractEnd.Date >= queryStartDate && x.ContractStart.Date <= queryEndDate);
|
||||
}
|
||||
//if (queryEndDate > queryStartDate && queryEndDate <= DateTime.Today)
|
||||
//{
|
||||
// startSearchDate = queryStartDate;
|
||||
// endSearchDate = queryEndDate;
|
||||
//}
|
||||
//query = query.Where(x => x.ContractEnd.Date >= startSearchDate && x.ContractStart.Date <= endSearchDate);
|
||||
query = query.Where(x => x.ContractEnd.Date >= queryStartDate && x.ContractStart.Date <= queryEndDate);
|
||||
}
|
||||
|
||||
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 12)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
queryEndDate = queryEndDate.Date.AddTicks(-1);
|
||||
if (searchModel.Year > 0 && searchModel.Month > 0 && searchModel.Month < 13)
|
||||
{
|
||||
var queryStartDate = $"{searchModel.Year:0000}/{searchModel.Month:00}/01".ToGeorgianDateTime();
|
||||
queryStartDate.FindFirstDayOfNextMonth(out var queryEndDate);
|
||||
queryEndDate = queryEndDate.Date.AddTicks(-1);
|
||||
|
||||
|
||||
if (queryEndDate >= DateTime.Today)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
//if (queryEndDate >= DateTime.Today)
|
||||
//{
|
||||
// queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
//}
|
||||
|
||||
else if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
if (searchModel.Year == currentYear && searchModel.Month == currentMonth)
|
||||
{
|
||||
queryEndDate = DateTime.Now.AddDays(-1).Date;
|
||||
}
|
||||
|
||||
query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate);
|
||||
}
|
||||
query = query.Where(x => x.ContractEnd <= queryEndDate && x.ContractStart >= queryStartDate);
|
||||
}
|
||||
|
||||
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
////Month Index operations
|
||||
//startSearchDate.AddMonthsFa(-1 * (searchModel.MonthIndex), out startSearchDate);
|
||||
//startSearchDate.FindFirstDayOfNextMonth(out endSearchDate);
|
||||
//endSearchDate = endSearchDate.AddDays(-1);
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
if (searchModel.EmployeeId > 0)
|
||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||
|
||||
|
||||
if (searchModel.BankId > 0)
|
||||
query = query.Where(x => x.Employee.EmployeeBankInformationList.Any(y => y.BankId == searchModel.BankId));
|
||||
|
||||
switch (searchModel.OrderBy)
|
||||
{
|
||||
case CustomizeCheckoutOrderByEnum.ContractStartDesc:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractStart:
|
||||
query = query.OrderBy(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNoDesc:
|
||||
query = query.OrderByDescending(x => x.ContractNo);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNo:
|
||||
query = query.OrderBy(x => x.ContractNo);
|
||||
break;
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
switch (searchModel.OrderBy)
|
||||
{
|
||||
case CustomizeCheckoutOrderByEnum.ContractStartDesc:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractStart:
|
||||
query = query.OrderBy(x => x.ContractStart.Date);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNoDesc:
|
||||
query = query.OrderByDescending(x => x.ContractNo);
|
||||
break;
|
||||
case CustomizeCheckoutOrderByEnum.ContractNo:
|
||||
query = query.OrderBy(x => x.ContractNo);
|
||||
break;
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.ContractStart.Date);
|
||||
break;
|
||||
|
||||
}
|
||||
if (searchModel.Year == 0 || searchModel.Month == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
}
|
||||
if (searchModel.Year == 0 || searchModel.Month == 0)
|
||||
query = query.Skip(searchModel.PageIndex).Take(30);
|
||||
|
||||
return query.Select(x => new CustomizeCheckoutViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractEndFa = x.ContractEnd.ToFarsi(),
|
||||
ContractStartFa = x.ContractStart.ToFarsi(),
|
||||
ContractNo = x.ContractNo,
|
||||
EmployeeFName = x.Employee.FName,
|
||||
EmployeeLName = x.Employee.LName,
|
||||
PersonnelCode = x.Employee.PersonnelCodeList.FirstOrDefault(y => y.WorkshopId == searchModel.WorkshopId).PersonnelCode,
|
||||
Month = pc.GetMonth(x.ContractStart).ToFarsiMonthByIntNumber(),
|
||||
Year = pc.GetYear(x.ContractStart).ToString(),
|
||||
BaseYearsPay = x.BaseYearsPay.ToMoney(),
|
||||
BonusesPay = x.BonusesPay.ToMoney(),
|
||||
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
|
||||
FamilyAllowance = x.FamilyAllowance.ToMoney(),
|
||||
AbsenceDeduction = x.FineAbsenceDeduction.ToMoney(),
|
||||
FineDeduction = x.FineDeduction.ToMoney(),
|
||||
FridayPay = x.FridayPay.ToMoney(),
|
||||
InstallmentDeduction = x.InstallmentDeduction.ToMoney(),
|
||||
InsuranceDeduction = x.InsuranceDeduction.ToMoney(),
|
||||
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
LeavePay = x.LeavePay.ToMoney(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
NightworkPay = x.NightWorkPay.ToMoney(),
|
||||
OvertimePay = x.OverTimePay.ToMoney(),
|
||||
RewardPay = x.RewardPay.ToMoney(),
|
||||
SalaryAidDeduction = x.SalaryAidDeduction.ToMoney(),
|
||||
ShiftPay = x.ShiftPay.ToMoney(),
|
||||
SumOfWorkingDays = x.SumOfWorkingDays.ToString(),
|
||||
TaxDeducation = x.TaxDeduction.ToMoney(),
|
||||
TotalPayment =x.TotalPayment.ToMoney(),
|
||||
TotalPaymentD = x.TotalPayment,
|
||||
TotalLateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
|
||||
|
||||
}).ToList();
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,149 +65,151 @@ namespace CompanyManagment.EFCore.Repository
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
public IEnumerable<CustomizeCheckoutViewModel> Search(SearchCustomizeCheckout searchModel)
|
||||
{
|
||||
|
||||
var query = _companyContext.CustomizeCheckoutTemps.Include(x => x.Employee).ThenInclude(x => x.PersonnelCodeList)
|
||||
.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));
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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,
|
||||
|
||||
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);
|
||||
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();
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
}
|
||||
public List<CustomizeCheckoutViewModel> PrintAll(long workshopId, IEnumerable<long> customizeCheckoutIds)
|
||||
{
|
||||
|
||||
//var pc = new PersianCalendar();
|
||||
@@ -309,7 +311,7 @@ namespace CompanyManagment.EFCore.Repository
|
||||
}).ToList(),
|
||||
|
||||
//LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{x.LateToWorkValue.Minutes:D2}"
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{Convert.ToInt32(x.LateToWorkValue.TotalHours)}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}"
|
||||
LateToWorkValue = x.LateToWorkValue == TimeSpan.Zero ? "-" : $"{(int)x.LateToWorkValue.TotalHours}:{Convert.ToInt32(x.LateToWorkValue.TotalMinutes % 60):00}"
|
||||
|
||||
}).ToList();
|
||||
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel
|
||||
|
||||
@@ -168,4 +168,10 @@ public class CustomizeWorkshopEmployeeSettingsRepository(CompanyContext companyC
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
public void RemoveByWorkshopIdAndEmployeeId(long workshopId, long employeeId)
|
||||
{
|
||||
var entity = _companyContext.CustomizeWorkshopEmployeeSettings.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
if (entity != null)
|
||||
Remove(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class EmployeeClientTempRepository: RepositoryBase<long, EmployeeClientTemp>, IEmployeeClientTempRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
|
||||
public EmployeeClientTempRepository(CompanyContext context): base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public EmployeeClientTemp GetByEmployeeIdAndWorkshopId(long employeeId, long commandWorkshopId)
|
||||
{
|
||||
return _context.EmployeeClientTemps.FirstOrDefault(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == commandWorkshopId);
|
||||
}
|
||||
|
||||
public EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId)
|
||||
{
|
||||
return _context.EmployeeClientTemps
|
||||
.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
||||
.Select(x => new EmployeeClientTempGetDetailsViewModel
|
||||
{
|
||||
EmployeeId = x.EmployeeId,
|
||||
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
||||
WorkshopId = x.WorkshopId
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@@ -394,17 +394,19 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
{
|
||||
var activeEmployees = _companyContext.LeftWorkList
|
||||
.Where(x => workshops.Contains(x.WorkshopId) && x.LeftWorkDate.AddDays(-1) >= DateTime.Now)
|
||||
.Select(x=>new{x.WorkshopId,x.EmployeeId});
|
||||
.Select(x => new { x.WorkshopId, x.EmployeeId });
|
||||
|
||||
var employeeClientTemp = _companyContext.EmployeeClientTemps.Where(x => workshops.Contains(x.WorkshopId));
|
||||
|
||||
var query = _companyContext.EmployeeDocuments
|
||||
.Where(x=> workshops.Contains(x.WorkshopId) &&
|
||||
activeEmployees.Any(y=>y.WorkshopId == x.WorkshopId && y.EmployeeId==x.EmployeeId))
|
||||
.Include(x=>x.Workshop).Include(x => x.EmployeeDocumentItemCollection)
|
||||
.Where(x=> x.IsSentToChecker == false &&
|
||||
(x.EmployeeDocumentItemCollection.Any(y =>
|
||||
y.DocumentStatus == DocumentStatus.SubmittedByClient)) || x.HasRejectedItems)
|
||||
.GroupBy(x=>x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
.Where(x => workshops.Contains(x.WorkshopId) &&
|
||||
(activeEmployees.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId) ||
|
||||
employeeClientTemp.Any(temp => x.EmployeeId == temp.EmployeeId && temp.WorkshopId == x.WorkshopId)) && x.IsConfirmed == false)
|
||||
.Include(x => x.Workshop).Include(x => x.EmployeeDocumentItemCollection)
|
||||
.Where(x => x.IsSentToChecker == false &&
|
||||
(x.EmployeeDocumentItemCollection.Any(y =>
|
||||
y.DocumentStatus == DocumentStatus.SubmittedByClient) || employeeClientTemp.Any(temp => x.EmployeeId == temp.EmployeeId && temp.WorkshopId == x.WorkshopId) || x.HasRejectedItems))
|
||||
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
{
|
||||
WorkshopId = x.Key,
|
||||
WorkshopFullName = x.FirstOrDefault().Workshop.WorkshopName,
|
||||
@@ -414,7 +416,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
|
||||
|
||||
var workshopEmployers = _companyContext.WorkshopEmployers.Include(x => x.Employer)
|
||||
.Where(x => query.Any(y=>y.WorkshopId==x.WorkshopId))
|
||||
.Where(x => query.Any(y => y.WorkshopId == x.WorkshopId))
|
||||
.GroupBy(x => x.WorkshopId).Select(x => x.FirstOrDefault()).ToList();
|
||||
|
||||
|
||||
@@ -422,24 +424,27 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
|
||||
var result = query.ToList();
|
||||
|
||||
|
||||
|
||||
result.ForEach(x =>
|
||||
{
|
||||
var employer = workshopEmployers.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.Employer;
|
||||
x.EmployerName = employer.FullName;
|
||||
|
||||
|
||||
//x.SubmittedItems.ForEach(y=>y.PicturePath= medias.FirstOrDefault(z=>z.id == y.MediaId)?.Path ?? "");
|
||||
});
|
||||
|
||||
return result.Where(x=>x.EmployeesWithoutDocumentCount > 0).OrderByDescending(x => x.EmployeesWithoutDocumentCount).ToList();
|
||||
return result.Where(x => x.EmployeesWithoutDocumentCount > 0).OrderByDescending(x => x.EmployeesWithoutDocumentCount).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ToDo آپلود مدارک و افزودن پرسنل
|
||||
//public List<WorkshopWithEmployeeDocumentsViewModel> GetWorkshopsWithNewEmployeesWithoutDocuments(List<long> workshops)
|
||||
//{
|
||||
// var newEmployees = _companyContext.LeftWorkTemps.Where(x => workshops.Contains(x.WorkshopId))
|
||||
// .Select(x => new { x.WorkshopId, x.EmployeeId });
|
||||
|
||||
|
||||
|
||||
// var query = _companyContext.EmployeeDocuments
|
||||
// .Where(x => workshops.Contains(x.WorkshopId) &&
|
||||
// newEmployees.Any(y => y.WorkshopId == x.WorkshopId && y.EmployeeId == x.EmployeeId))
|
||||
@@ -472,62 +477,88 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
{
|
||||
var activeEmployeesInWorkshop = _companyContext.LeftWorkList
|
||||
.Where(x => workshopId == x.WorkshopId && x.LeftWorkDate.AddDays(-1) >= DateTime.Today)
|
||||
.Include(x=>x.Employee).ThenInclude(x=>x.EmployeeDocuments)
|
||||
.Select(x => new {x.EmployeeId ,FullName= x.Employee.FName +" " +x.Employee.LName,x.Employee.Gender});
|
||||
.Include(x => x.Employee).ThenInclude(x => x.EmployeeDocuments)
|
||||
.Select(x => new { x.EmployeeId, FullName = x.Employee.FName + " " + x.Employee.LName, x.Employee.Gender });
|
||||
|
||||
|
||||
|
||||
|
||||
var EDItemsList = _companyContext.EmployeeDocumentItems
|
||||
.Where(x => x.WorkshopId == workshopId && x.DocumentStatus != DocumentStatus.Unsubmitted &&
|
||||
activeEmployeesInWorkshop.Any(y => y.EmployeeId == x.EmployeeId))
|
||||
.Include(x => x.EmployeeDocuments).Where(x=> x.EmployeeDocuments.IsSentToChecker == false &&
|
||||
( (x.DocumentStatus == DocumentStatus.SubmittedByClient) || x.EmployeeDocuments.HasRejectedItems) )
|
||||
.Include(x => x.EmployeeDocuments)
|
||||
.Where(x => x.EmployeeDocuments.IsSentToChecker == false &&
|
||||
((x.DocumentStatus == DocumentStatus.SubmittedByClient) ||
|
||||
x.EmployeeDocuments.HasRejectedItems))
|
||||
.GroupBy(x => new { x.EmployeeId, x.DocumentLabel })
|
||||
.Select(x =>
|
||||
x.Select(y => new
|
||||
{
|
||||
y.EmployeeDocumentId,
|
||||
Id = y.id,
|
||||
y.EmployeeDocuments.Gender,
|
||||
y.DocumentLabel,
|
||||
y.DocumentStatus,
|
||||
y.MediaId,
|
||||
y.RejectionReason,
|
||||
y.EmployeeId,
|
||||
y.CreationDate,
|
||||
IsSentToChecker = y.EmployeeDocuments.IsSentToChecker,
|
||||
y.EmployeeDocuments.IsConfirmed
|
||||
})
|
||||
.OrderByDescending(y => y.CreationDate).First())
|
||||
{
|
||||
y.EmployeeDocumentId,
|
||||
Id = y.id,
|
||||
y.EmployeeDocuments.Gender,
|
||||
y.DocumentLabel,
|
||||
y.DocumentStatus,
|
||||
y.MediaId,
|
||||
y.RejectionReason,
|
||||
y.EmployeeId,
|
||||
y.CreationDate,
|
||||
IsSentToChecker = y.EmployeeDocuments.IsSentToChecker,
|
||||
y.EmployeeDocuments.IsConfirmed
|
||||
}).OrderByDescending(y => y.CreationDate).First()).ToList();
|
||||
|
||||
var employeeClientTemp = _companyContext.EmployeeClientTemps.Where(x => x.WorkshopId == workshopId);
|
||||
var tempEmployees = _companyContext.Employees.Where(x => employeeClientTemp.Any(a => a.EmployeeId == x.id))
|
||||
.Select(x => new { EmployeeId = x.id, FullName = x.FName + " " + x.LName, x.Gender }).ToList();
|
||||
|
||||
var tempEmployeeDocuments = _companyContext.EmployeeDocuments
|
||||
.Where(x => x.WorkshopId == workshopId && employeeClientTemp.Any(e => e.EmployeeId == x.EmployeeId) &&
|
||||
x.IsSentToChecker == false && x.IsConfirmed == false)
|
||||
.SelectMany(x => x.EmployeeDocumentItemCollection.DefaultIfEmpty(), // اگر خالی بود، مقدار پیشفرض ایجاد کن
|
||||
(documents, y) => new
|
||||
{
|
||||
EmployeeDocumentId = documents.id, // اگر null بود مقدار نداشته باشد
|
||||
Id = y != null ? y.id : 0,
|
||||
documents.Gender,
|
||||
DocumentLabel = y != null ? y.DocumentLabel : default,
|
||||
DocumentStatus = y != null ? y.DocumentStatus : default,
|
||||
MediaId = y != null ? y.MediaId : 0,
|
||||
RejectionReason = y != null ? y.RejectionReason : default,
|
||||
EmployeeId = y != null ? y.EmployeeId : documents.EmployeeId, // اگر مقدار نداشت از EmployeeDocuments پر کن
|
||||
CreationDate = y != null ? y.CreationDate : documents.CreationDate,
|
||||
IsSentToChecker = documents.IsSentToChecker,
|
||||
IsConfirmed = documents.IsConfirmed
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
|
||||
var activeEmployeesInWorkshopList = activeEmployeesInWorkshop.ToList();
|
||||
var enumerable = EDItemsList.Concat(tempEmployeeDocuments);
|
||||
var activeEmployeesInWorkshopList = activeEmployeesInWorkshop.ToList().Concat(tempEmployees);
|
||||
|
||||
//get medias for current documents of employees
|
||||
var mediaIds = EDItemsList.Select(x => x.MediaId).ToList();
|
||||
var mediaIds = enumerable.Select(x => x.MediaId).ToList();
|
||||
var mediasList = _accountContext.Medias.Where(x => mediaIds.Contains(x.id))
|
||||
.Select(x => new MediaViewModel() { Id= x.id, Path = x.Path }).ToList();
|
||||
.Select(x => new MediaViewModel() { Id = x.id, Path = x.Path }).ToList();
|
||||
|
||||
|
||||
|
||||
return EDItemsList.GroupBy(x=>x.EmployeeId)
|
||||
var result = enumerable.GroupBy(x => x.EmployeeId)
|
||||
.Select(x =>
|
||||
{
|
||||
//var requiredDocs = EmployeeDocumentRequiredItems.GetByGender(x.Gender);
|
||||
var employeeLatestConfirmedDocuments = x
|
||||
|
||||
.Where(y => y.EmployeeId == x.Key &&(y.DocumentStatus == DocumentStatus.SubmittedByClient || y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.Rejected))
|
||||
.Select(y=>new EmployeeDocumentItemViewModel()
|
||||
{
|
||||
Status = y.DocumentStatus,
|
||||
MediaId = y.MediaId,
|
||||
DocumentItemLabel = y.DocumentLabel,
|
||||
Id = y.Id,
|
||||
RejectionMessage = y.RejectionReason,
|
||||
StatusString = y.DocumentStatus.ToString()
|
||||
}).ToList();
|
||||
|
||||
.Where(y => y.EmployeeId == x.Key && (y.DocumentStatus == DocumentStatus.SubmittedByClient || y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.Rejected))
|
||||
.Select(y => new EmployeeDocumentItemViewModel()
|
||||
{
|
||||
Status = y.DocumentStatus,
|
||||
MediaId = y.MediaId,
|
||||
DocumentItemLabel = y.DocumentLabel,
|
||||
Id = y.Id,
|
||||
RejectionMessage = y.RejectionReason,
|
||||
StatusString = y.DocumentStatus.ToString()
|
||||
}).ToList();
|
||||
|
||||
|
||||
//var requiredItemsUploaded = employeeLatestConfirmedDocuments
|
||||
@@ -542,7 +573,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
IdCardPage3 = GetByLabelAndLoadMedia(employeeLatestConfirmedDocuments, mediasList, DocumentItemLabel.IdCardPage3),
|
||||
IdCardPage4 = GetByLabelAndLoadMedia(employeeLatestConfirmedDocuments, mediasList, DocumentItemLabel.IdCardPage4),
|
||||
EducationalDegree = GetByLabelAndLoadMedia(employeeLatestConfirmedDocuments, mediasList, DocumentItemLabel.EducationalDegree),
|
||||
EmployeeFullName = activeEmployeesInWorkshopList.First(y=>y.EmployeeId==x.Key).FullName,
|
||||
EmployeeFullName = activeEmployeesInWorkshopList.First(y => y.EmployeeId == x.Key).FullName,
|
||||
NationalCardFront = GetByLabelAndLoadMedia(employeeLatestConfirmedDocuments, mediasList, DocumentItemLabel.NationalCardFront),
|
||||
NationalCardRear = GetByLabelAndLoadMedia(employeeLatestConfirmedDocuments, mediasList, DocumentItemLabel.NationalCardRear),
|
||||
MilitaryServiceCard = GetByLabelAndLoadMedia(employeeLatestConfirmedDocuments, mediasList, DocumentItemLabel.MilitaryServiceCard),
|
||||
@@ -552,6 +583,8 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -561,12 +594,12 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
public List<WorkshopWithEmployeeDocumentsViewModel> GetWorkshopsWithUploadedDocuments()
|
||||
{
|
||||
var itemsQuery = _companyContext.EmployeeDocumentItems
|
||||
.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted && x.DocumentStatus != DocumentStatus.SubmittedByClient)
|
||||
.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted)
|
||||
.Include(x => x.EmployeeDocuments)
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x=>x.WorkshopEmployers).ThenInclude(x=>x.Employer)
|
||||
.GroupBy(x=>x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
{
|
||||
SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin),
|
||||
SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
WorkshopId = x.Key,
|
||||
WorkshopFullName = x.First().EmployeeDocuments.Workshop.WorkshopName,
|
||||
EmployerName = x.First().EmployeeDocuments.Workshop.WorkshopEmployers.First().Employer.FullName
|
||||
@@ -633,7 +666,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
var workshopDocuments = _companyContext.EmployeeDocuments.Where(x => x.WorkshopId == workshopId)
|
||||
.Include(x => x.EmployeeDocumentItemCollection)
|
||||
.Where(x=>x.EmployeeDocumentItemCollection.Any(y =>
|
||||
y.DocumentStatus != DocumentStatus.Unsubmitted && y.DocumentStatus != DocumentStatus.SubmittedByClient));
|
||||
y.DocumentStatus != DocumentStatus.Unsubmitted));
|
||||
|
||||
var employeesList = _companyContext.Employees.Where(x =>
|
||||
workshopDocuments.Any(y => y.EmployeeId == x.id))
|
||||
@@ -655,8 +688,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
var workshopDocumentsListWithConfirmed = workshopDocumentsList.Select(x => new
|
||||
{
|
||||
EmployeeDocuments = x,
|
||||
EmployeeDocumentItemCollection = x.EmployeeDocumentItemCollection.Where(y=> y.DocumentStatus != DocumentStatus.Unsubmitted &&
|
||||
y.DocumentStatus != DocumentStatus.SubmittedByClient)
|
||||
EmployeeDocumentItemCollection = x.EmployeeDocumentItemCollection.Where(y=> y.DocumentStatus != DocumentStatus.Unsubmitted)
|
||||
.GroupBy(y => y.DocumentLabel)
|
||||
.Select(y => y.MaxBy(z => z.CreationDate))
|
||||
. ToList()
|
||||
@@ -676,8 +708,8 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
x.EmployeeDocumentItemCollection.All(y => y.DocumentStatus != DocumentStatus.SubmittedByAdmin)).ToList();
|
||||
else
|
||||
workshopDocumentsListWithConfirmed = workshopDocumentsListWithConfirmed.Where(x =>
|
||||
x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin)).ToList();
|
||||
|
||||
x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient)).ToList();
|
||||
|
||||
return workshopDocumentsListWithConfirmed.Select(x => new EmployeeDocumentsViewModel()
|
||||
{
|
||||
Id=x.EmployeeDocuments.id,
|
||||
@@ -704,7 +736,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
DocumentItemLabel.MilitaryServiceCard),
|
||||
EmployeePicture = GetByLabelAndLoadMedia(x.EmployeeDocumentItemCollection, mediasList,
|
||||
DocumentItemLabel.EmployeePicture),
|
||||
SubmittedItemsCount = x.EmployeeDocumentItemCollection.Count(y=>y.DocumentStatus==DocumentStatus.SubmittedByAdmin),
|
||||
SubmittedItemsCount = x.EmployeeDocumentItemCollection.Count(y=>y.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient),
|
||||
RejectedItemsCount = x.EmployeeDocumentItemCollection.Count(y => y.DocumentStatus == DocumentStatus.Rejected),
|
||||
ConfirmedItemsCount = x.EmployeeDocumentItemCollection.Count(y => y.DocumentStatus == DocumentStatus.Confirmed),
|
||||
EmployerFullName = employerName,
|
||||
@@ -717,30 +749,30 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
|
||||
|
||||
|
||||
public int GetCheckerWorkFlowCount()
|
||||
public async Task<int> GetCheckerWorkFlowCount()
|
||||
{
|
||||
return _companyContext.EmployeeDocumentItems.Include(x => x.EmployeeDocuments)
|
||||
.Count(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin);
|
||||
return await _companyContext.EmployeeDocumentItems.Include(x => x.EmployeeDocuments)
|
||||
.CountAsync(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin || x.DocumentStatus == DocumentStatus.SubmittedByClient);
|
||||
}
|
||||
|
||||
//ToDo آپلود مدارک و افزدن پرسنل
|
||||
//public int GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds)
|
||||
//{
|
||||
// //New employees created by client should have their documents uploaded or confirmed
|
||||
// var newEmployeesInWorkshop = _companyContext.LeftWorkTemps.Where(x => workshopIds.Contains(x.WorkshopId));
|
||||
|
||||
// var duty = _companyContext.EmployeeDocuments
|
||||
// .Count(x => workshopIds.Contains(x.WorkshopId) &&
|
||||
// newEmployeesInWorkshop.Any(y =>
|
||||
// y.EmployeeId == x.EmployeeId)
|
||||
// && x.IsSentToChecker == false && x.IsConfirmed == false);
|
||||
public async Task<int> GetAdminWorkFlowCountForNewEmployees(List<long> workshopIds)
|
||||
{
|
||||
//New employees created by client should have their documents uploaded or confirmed
|
||||
var newEmployeesInWorkshop = _companyContext.EmployeeClientTemps.Where(x => workshopIds.Contains(x.WorkshopId));
|
||||
|
||||
var duty = _companyContext.EmployeeDocuments
|
||||
.CountAsync(x => workshopIds.Contains(x.WorkshopId) &&
|
||||
newEmployeesInWorkshop.Any(y =>
|
||||
y.EmployeeId == x.EmployeeId)
|
||||
&& x.IsSentToChecker == false && x.IsConfirmed == false);
|
||||
|
||||
|
||||
|
||||
// return duty;
|
||||
//}
|
||||
return await duty;
|
||||
}
|
||||
|
||||
public int GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds)
|
||||
public async Task<int> GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List<long> workshopIds)
|
||||
{
|
||||
|
||||
|
||||
@@ -748,12 +780,12 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
var activeEmployeesInWorkshop = _companyContext.LeftWorkList
|
||||
.Where(x => workshopIds.Contains(x.WorkshopId) && x.LeftWorkDate.AddDays(-1) >= DateTime.Today);
|
||||
var dutyCount = _companyContext.EmployeeDocuments
|
||||
.Count(x => workshopIds.Contains(x.WorkshopId) &&
|
||||
activeEmployeesInWorkshop.Any(y => y.EmployeeId == x.EmployeeId) &&
|
||||
x.IsSentToChecker == false &&
|
||||
(x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus == DocumentStatus.SubmittedByClient) || x.HasRejectedItems));
|
||||
.CountAsync(x => workshopIds.Contains(x.WorkshopId) &&
|
||||
activeEmployeesInWorkshop.Any(y => y.EmployeeId == x.EmployeeId) &&
|
||||
x.IsSentToChecker == false &&
|
||||
(x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus == DocumentStatus.SubmittedByClient) || x.HasRejectedItems));
|
||||
|
||||
return dutyCount;
|
||||
return await dutyCount;
|
||||
}
|
||||
|
||||
public List<EmployeeDocumentsViewModel> GetDocumentsAwaitingReviewByWorkshopIdForCheckerWorkFlow(long workshopId)
|
||||
@@ -800,7 +832,7 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
.Select(x => new MediaViewModel() { Id = x.id, Path = x.Path }).ToList();
|
||||
|
||||
workshopDocumentsListWithConfirmed = workshopDocumentsListWithConfirmed.Where(x =>
|
||||
x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin)).ToList();
|
||||
x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient)).ToList();
|
||||
|
||||
return workshopDocumentsListWithConfirmed.Select(x => new EmployeeDocumentsViewModel()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,8 @@ using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -742,6 +744,64 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
EmployeeFullName = x.FullName
|
||||
}).ToList();
|
||||
}
|
||||
public Employee GetByNationalCodeIgnoreQueryFilter(string nationalCode)
|
||||
{
|
||||
return _context.Employees.IgnoreQueryFilters().FirstOrDefault(x => x.NationalCode == nationalCode);
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientStartedWorkEmployeesDto>> GetClientEmployeesStartWork(long workshopId)
|
||||
{
|
||||
var res = await _context.Employees
|
||||
.GroupJoin(_context.LeftWorkTemps.Where(x => x.WorkshopId == workshopId && x.LeftWorkType == LeftWorkTempType.StartWork),
|
||||
employees => employees.id,
|
||||
leftWorkTemp => leftWorkTemp.EmployeeId,
|
||||
(employee, leftWorkTemps) => new { employee, leftWorkTemps })
|
||||
.GroupJoin(_context.EmployeeDocuments.Where(x => x.WorkshopId == workshopId),
|
||||
(query) => query.employee.id,
|
||||
(employeeDoc) => employeeDoc.EmployeeId,
|
||||
(query, employeeDoc) => new
|
||||
{ query, employeeDoc }).SelectMany(x => x.employeeDoc.DefaultIfEmpty(),
|
||||
(q, doc) => new
|
||||
{
|
||||
q.query,
|
||||
EmployeeDoc = doc
|
||||
}).Where(x => x.query.leftWorkTemps.Any(l => l.WorkshopId == workshopId && l.LeftWorkType == LeftWorkTempType.StartWork)).Select(
|
||||
x => new ClientStartedWorkEmployeesDto()
|
||||
{
|
||||
WorkshopId = workshopId,
|
||||
EmployeeId = x.query.employee.id,
|
||||
EmployeeName = x.query.employee.FName + " " + x.query.employee.LName,
|
||||
// ReSharper disable once SimplifyConditionalTernaryExpression
|
||||
HasCompleteEmployeeDocument = x.EmployeeDoc == null ? false : x.EmployeeDoc.IsConfirmed
|
||||
}).ToListAsync();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientLeftWorkWorkEmployeesDto>> GetEmployeesForLeftWorkTemp(long workshopId)
|
||||
{
|
||||
var res = await _context.Employees
|
||||
.Join(_context.LeftWorkTemps.Where(x => x.WorkshopId == workshopId && x.LeftWorkType == LeftWorkTempType.LeftWork),
|
||||
employees => employees.id,
|
||||
leftWorkTemp => leftWorkTemp.EmployeeId,
|
||||
(employee, leftWorkTemps) => new { employee, leftWorkTemps })
|
||||
.Select(
|
||||
x => new ClientLeftWorkWorkEmployeesDto()
|
||||
{
|
||||
WorkshopId = workshopId,
|
||||
EmployeeId = x.employee.id,
|
||||
EmployeeName = x.employee.FName + " " + x.employee.LName,
|
||||
LeftWorkDateTime = x.leftWorkTemps.LeftWork.ToFarsi()
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public Employee GetIgnoreQueryFilter(long id)
|
||||
{
|
||||
return _context.Employees.IgnoreQueryFilters().FirstOrDefault(x => x.id == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
@@ -776,6 +836,38 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
|
||||
{
|
||||
var employee = await _context.Employees.Where(x => x.id == employeeId).Select(x => new GetEditEmployeeInEmployeeDocumentViewModel()
|
||||
{
|
||||
EmployeeId = x.id,
|
||||
LName = x.LName,
|
||||
BirthDate = x.DateOfBirth.ToFarsi(),
|
||||
FName = x.FName,
|
||||
FatherName = x.FatherName,
|
||||
MaritalStatus = x.MaritalStatus,
|
||||
MilitaryService = x.MilitaryService,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
Nationality = x.Nationality,
|
||||
Gender = x.Gender,
|
||||
IsAuthorized = x.IsAuthorized
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
var employeeClientTemp =
|
||||
await _context.EmployeeClientTemps.FirstOrDefaultAsync(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId);
|
||||
|
||||
if (employeeClientTemp != null)
|
||||
{
|
||||
employee.MaritalStatus = employeeClientTemp.MaritalStatus;
|
||||
}
|
||||
|
||||
return employee;
|
||||
}
|
||||
|
||||
|
||||
public List<(long Id, string Name)> SimpleGetRangeByIds(IEnumerable<long> newEmployeeIds)
|
||||
{
|
||||
return _context.Employees.Where(x => newEmployeeIds.Contains(x.id)).Select(x => new
|
||||
@@ -799,5 +891,18 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
Phone = x.Phone
|
||||
}).ToList();
|
||||
}
|
||||
public List<EmployeeViewModel> GetWorkedEmployeesByWorkshopIdsAndNationalCodeAndDate(List<long> workshopIds, string nationalCode, DateTime date)
|
||||
{
|
||||
return _context.Employees.Where(x => x.NationalCode.Contains(nationalCode)).Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
||||
.Where(x => x.LeftWorks.Any(y => workshopIds.Contains(y.WorkshopId)) || x.LeftWorkInsurances.Any(y => workshopIds.Contains(y.WorkshopId)))
|
||||
.Select(x => new EmployeeViewModel()
|
||||
{
|
||||
NationalCode = x.NationalCode,
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
Phone = x.Phone
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -91,7 +91,13 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
Id = x.id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode
|
||||
}).Where(x=>x.JobName.Contains(searchtText)).Take(100);
|
||||
});
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchtText))
|
||||
{
|
||||
query = query.Where(x => x.JobName.Contains(searchtText));
|
||||
}
|
||||
//if (!string.IsNullOrWhiteSpace(searchtText))
|
||||
// query = query.Where(x => (x.JobName + " " + x.JobCode).Contains(searchtText));
|
||||
//return query.OrderBy(x => x.Id).ToList();
|
||||
@@ -107,7 +113,7 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
|
||||
|
||||
//var jobList = _context.Jobs.FromSqlInterpolated($"SelectQuery_AllJobs {searchtText}").AsNoTracking().ToList();
|
||||
var jobViewModelList = query.Select(x => new JobViewModel
|
||||
var jobViewModelList = query.Take(100).Select(x => new JobViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
JobName = x.JobName+ " " + '-' + " " + x.JobCode,
|
||||
|
||||
@@ -163,15 +163,17 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
if (item != null)
|
||||
{
|
||||
|
||||
|
||||
_context.LeftWorkList.Remove(item);
|
||||
_context.SaveChanges();
|
||||
if (!_context.LeftWorkList.Any(x => x.WorkshopId == item.WorkshopId && x.EmployeeId == item.EmployeeId && item.id != x.id) && HasActiveRollCallStatus(item.WorkshopId, item.EmployeeId))
|
||||
{
|
||||
RemoveEmployeeRollCallStatus(item.WorkshopId,item.EmployeeId);
|
||||
RemoveEmployeeRollCallStatus(item.WorkshopId, item.EmployeeId);
|
||||
}
|
||||
_context.LeftWorkList.Remove(item);
|
||||
}
|
||||
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -208,6 +210,8 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
return leftWorks.Concat(insuranceLeftWork).Distinct().ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<LeftWorkViewModel> GetLeftPersonelByWorkshopId(List<long> workshopIds)
|
||||
{
|
||||
return _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
||||
@@ -239,8 +243,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
}
|
||||
|
||||
|
||||
if (HasActiveRollCallStatus(workshopId, employeeId))
|
||||
RemoveEmployeeRollCallStatus(workshopId, employeeId);
|
||||
|
||||
|
||||
|
||||
var list = _context.LeftWorkList.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId).ToList();
|
||||
@@ -256,7 +259,12 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
|
||||
transaction.Commit();
|
||||
|
||||
if (HasActiveRollCallStatus(workshopId, employeeId))
|
||||
RemoveEmployeeRollCallStatus(workshopId, employeeId);
|
||||
if (hasLeftWorkInsurance)
|
||||
return
|
||||
op.Succcedded(1, "حذف با موفقیت انجام شد."); //+ "<br/>" + "<span class='text-danger'>" + "کد پرسنلی این شخص به دلیل استفاده در ترک کار بیمه قابل حذف نمی باشد. " + "</span>");
|
||||
@@ -627,6 +635,12 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
HasLeft = entity.HasLeft
|
||||
};
|
||||
}
|
||||
public LeftWork GetLastLeftWorkByEmployeeIdAndWorkshopId(long workshopId, long employeeId)
|
||||
{
|
||||
return _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
||||
.OrderByDescending(x => x.StartWorkDate).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
|
||||
{
|
||||
@@ -638,19 +652,49 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
||||
private bool HasActiveRollCallStatus(long workshopId, long employeeId)
|
||||
{
|
||||
var now = DateTime.Today;
|
||||
var isDateUndefined = new DateTime(2121, 03, 21);
|
||||
return
|
||||
_context.RollCallEmployees.Include(x => x.EmployeesStatus).Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
|
||||
x.EmployeesStatus.Any(y => y.EndDate.Date > now && y.StartDate <= now));
|
||||
x.EmployeesStatus.Any(y => (y.EndDate.Date > now && y.StartDate <= now) || (y.EndDate.Date == isDateUndefined)));
|
||||
}
|
||||
private void RemoveEmployeeRollCallStatus(long workshopId, long employeeId)
|
||||
{
|
||||
var entity = _context.RollCallEmployees.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
var entity = _context.RollCallEmployees.Include(x=>x.EmployeesStatus).FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
_context.RollCallEmployees.Remove(entity);
|
||||
_context.SaveChanges();
|
||||
var hasLeftWork = _context.LeftWorkList.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
|
||||
//اگر هیچ شرع بکار ترک کاری نداشت
|
||||
if (!hasLeftWork)
|
||||
{
|
||||
var now = DateTime.Today;
|
||||
entity.DeActive();
|
||||
var rollCallEmployeeStatus =
|
||||
entity.EmployeesStatus.FirstOrDefault(x => x.EndDate.Date.IsDateUndefined() || x.EndDate.Date > now && x.StartDate <= now);
|
||||
|
||||
|
||||
|
||||
if (rollCallEmployeeStatus != null)
|
||||
{
|
||||
var end = rollCallEmployeeStatus.StartDate.Date > DateTime.Now.Date
|
||||
? rollCallEmployeeStatus.StartDate.Date
|
||||
: DateTime.Now.Date;
|
||||
rollCallEmployeeStatus.Deactivate(end);
|
||||
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
}
|
||||
//_context.RollCallEmployees.Remove(entity);
|
||||
|
||||
}
|
||||
#endregion
|
||||
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
|
||||
{
|
||||
var leftWork = await _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
||||
.OrderByDescending(x => x.StartWorkDate).FirstOrDefaultAsync();
|
||||
return leftWork;
|
||||
}
|
||||
}
|
||||
82
CompanyManagment.EFCore/Repository/LeftWorkTempRepository.cs
Normal file
82
CompanyManagment.EFCore/Repository/LeftWorkTempRepository.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class LeftWorkTempRepository : RepositoryBase<long, LeftWorkTemp>, ILeftWorkTempRepository
|
||||
{
|
||||
private readonly CompanyContext _companyContext;
|
||||
|
||||
public LeftWorkTempRepository(CompanyContext companyContext) : base(companyContext)
|
||||
{
|
||||
_companyContext = companyContext;
|
||||
}
|
||||
|
||||
public async Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId)
|
||||
{
|
||||
var employee = await _companyContext.Employees.FindAsync(employeeId);
|
||||
var workshop = await _companyContext.Workshops.FindAsync(workshopId);
|
||||
|
||||
var leftWorkTemp =
|
||||
await _companyContext.LeftWorkTemps.FirstOrDefaultAsync(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
|
||||
if (employee == null || workshop == null || leftWorkTemp == null)
|
||||
{
|
||||
return new GetStartWorkTempDetails();
|
||||
}
|
||||
|
||||
var job = await _companyContext.Jobs.FindAsync(leftWorkTemp.JobId);
|
||||
|
||||
|
||||
var previousLeftWorks = _companyContext.LeftWorkList
|
||||
.Where(x => leftWorkTemp.EmployeeId == x.EmployeeId && leftWorkTemp.WorkshopId == x.WorkshopId).ToList();
|
||||
|
||||
|
||||
|
||||
if (leftWorkTemp.LeftWorkType == LeftWorkTempType.LeftWork)
|
||||
{
|
||||
previousLeftWorks = previousLeftWorks.Where(x => x.id != leftWorkTemp.LeftWorkId).ToList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
var personnelCode =
|
||||
_companyContext.PersonnelCodeSet.FirstOrDefault(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId)?.PersonnelCode;
|
||||
|
||||
return new GetStartWorkTempDetails
|
||||
{
|
||||
WorkshopId = leftWorkTemp.WorkshopId,
|
||||
EmployeeId = leftWorkTemp.EmployeeId,
|
||||
WorkshopFullName = workshop.WorkshopFullName,
|
||||
EmployeeFullName = employee.FullName,
|
||||
JobId = leftWorkTemp.JobId,
|
||||
JobName = job?.JobName,
|
||||
PersonnelCode = personnelCode ?? 0,
|
||||
LeftWorkTemp = new LeftWorkTempDetailsViewModel()
|
||||
{
|
||||
Id = leftWorkTemp.id,
|
||||
LastDayStanding = leftWorkTemp.LastDayStanding == new DateTime() ? "" : leftWorkTemp.LastDayStanding.ToFarsi(),
|
||||
LeftWork = leftWorkTemp.LeftWork == new DateTime() ? "" : leftWorkTemp.LeftWork.ToFarsi(),
|
||||
StartWork = leftWorkTemp.StartWork.ToFarsi()
|
||||
},
|
||||
PreviousLeftWorks = previousLeftWorks.Select(x => new LeftWorkTempDetailsViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
LastDayStanding = x.LeftWorkDate.AddDays(-1).ToFarsi(),
|
||||
LeftWork = x.LeftWorkDate.ToFarsi(),
|
||||
StartWork = x.StartWorkDate.ToFarsi()
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -90,4 +90,12 @@ public class PersonnelCodeRepository : RepositoryBase<long, PersonnelCodeDomain>
|
||||
return res.EmployeeId;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
public long GetLastPersonnelCodeByWorkshop(long workshopId)
|
||||
{
|
||||
return _context.PersonnelCodeSet.Where(x => x.WorkshopId == workshopId).Max(x => x.PersonnelCode);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class ReportRepository : IReportRepository
|
||||
// };
|
||||
|
||||
//}
|
||||
public async Task<AllReport> GetAllActiveWorkshopsNew(string year, string month)
|
||||
public Task<AllReport> GetAllActiveWorkshopsNew(string year, string month)
|
||||
{
|
||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
//یافتن آغاز و پایان ماه جاری
|
||||
@@ -442,7 +442,7 @@ public class ReportRepository : IReportRepository
|
||||
|
||||
};
|
||||
Console.WriteLine("new metod >>>>>: " + watch.Elapsed);
|
||||
return finalResult;
|
||||
return Task.FromResult(finalResult);
|
||||
}
|
||||
|
||||
public AllReport GetAllActiveWorkshops(string year, string month)
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.RollCallEmployeeAgg;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -48,12 +49,11 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
|
||||
public EditRollCallEmployee GetDetails(long id)
|
||||
{
|
||||
return _context.RollCallEmployees.Select(x => new RollCallEmployeeViewModel()
|
||||
return _context.RollCallEmployees.Select(x => new EditRollCallEmployee()
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
EmployeeFName = x.FName,
|
||||
EmployeeLName = x.LName,
|
||||
EmployeeId = x.EmployeeId,
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
IsActiveString = x.IsActiveString,
|
||||
HasUploadedImage = x.HasUploadedImage
|
||||
@@ -79,7 +79,7 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
public List<RollCallEmployeeViewModel> GetPersonnelRollCallListPaginate(RollCallEmployeeSearchModel command)
|
||||
{
|
||||
var dateNow = DateTime.Now;
|
||||
var employeeQuery = _context.Employees.AsQueryable();
|
||||
var employeeQuery = _context.Employees.IgnoreQueryFilters().AsQueryable();
|
||||
|
||||
//if (!string.IsNullOrWhiteSpace(command.Name))
|
||||
//{
|
||||
@@ -95,39 +95,59 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
//}
|
||||
|
||||
var rawQuery = employeeQuery.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
||||
.Where(x => x.LeftWorks.Any(y =>
|
||||
(y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
|
||||
y.LeftWorkDate > dateNow) || y.StartWorkDate>dateNow) ||
|
||||
x.LeftWorkInsurances.Any(y =>
|
||||
.GroupJoin(_context.LeftWorkTemps.Where(x => x.WorkshopId == command.WorkshopId),
|
||||
employee => employee.id,
|
||||
leftWorkTemp => leftWorkTemp.EmployeeId,
|
||||
((employee, temp) => new { employee, temp }))
|
||||
.SelectMany(x => x.temp.DefaultIfEmpty(),
|
||||
(x, temp) => new { x.employee, temp })
|
||||
.Where(x => x.employee.LeftWorks.Any(y =>
|
||||
y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
|
||||
(y.LeftWorkDate > dateNow || y.LeftWorkDate == null))).OrderByDescending(x => x.id)
|
||||
y.LeftWorkDate > dateNow || (y.WorkshopId == command.WorkshopId && y.StartWorkDate > dateNow)) ||
|
||||
x.temp != null).OrderByDescending(x => x.employee.id)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.id,
|
||||
FullName =x.FName +" "+x.LName,
|
||||
x.NationalCode,
|
||||
Id = x.employee.id,
|
||||
FullName = x.employee.FName + " " + x.employee.LName,
|
||||
x.employee.NationalCode,
|
||||
workshopTemp = x.temp
|
||||
|
||||
}).AsSplitQuery();
|
||||
|
||||
|
||||
|
||||
var rollCallEmployees = _context.RollCallEmployees.Where(x => x.WorkshopId == command.WorkshopId);
|
||||
|
||||
|
||||
var employeeClient = _context.EmployeeClientTemps.Where(x => x.WorkshopId == command.WorkshopId);
|
||||
|
||||
|
||||
var joinedQuery = from employee in rawQuery
|
||||
join rollCallEmployee in rollCallEmployees
|
||||
on employee.Id equals rollCallEmployee.EmployeeId into grp
|
||||
from joinedRollCall in grp.DefaultIfEmpty()
|
||||
select new RollCallEmployeeViewModel()
|
||||
{
|
||||
WorkshopId = command.WorkshopId,
|
||||
EmployeeId = employee.Id,
|
||||
Id = joinedRollCall == null ? 0 : joinedRollCall.id,
|
||||
EmployeeFullName = joinedRollCall == null ? employee.FullName : joinedRollCall.EmployeeFullName,
|
||||
NationalCode = employee.NationalCode,
|
||||
IsActiveString = joinedRollCall.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow.Date && y.EndDate.Date > dateNow.Date) ? "true" : "false",
|
||||
HasUploadedImage = joinedRollCall == null ? "false" : joinedRollCall.HasUploadedImage
|
||||
};
|
||||
join rollCallEmployee in rollCallEmployees
|
||||
on employee.Id equals rollCallEmployee.EmployeeId into grp
|
||||
from joinedRollCall in grp.DefaultIfEmpty()
|
||||
join employeeClientT in employeeClient on employee.Id equals employeeClientT.EmployeeId into employeeCT
|
||||
from clientTemp in employeeCT.DefaultIfEmpty()
|
||||
select new RollCallEmployeeViewModel()
|
||||
{
|
||||
WorkshopId = command.WorkshopId,
|
||||
EmployeeId = employee.Id,
|
||||
Id = joinedRollCall == null ? 0 : joinedRollCall.id,
|
||||
EmployeeFullName = joinedRollCall == null ? employee.FullName : joinedRollCall.EmployeeFullName,
|
||||
NationalCode = employee.NationalCode,
|
||||
IsActiveString =
|
||||
joinedRollCall.EmployeesStatus.Any(y =>
|
||||
y.StartDate.Date <= dateNow.Date && y.EndDate.Date > dateNow.Date)
|
||||
? "true"
|
||||
: "false",
|
||||
HasUploadedImage = joinedRollCall == null ? "false" : joinedRollCall.HasUploadedImage,
|
||||
CreatedByClient = clientTemp != null || (employee.workshopTemp != null &&employee.workshopTemp.LeftWorkType == LeftWorkTempType.StartWork)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.Name))
|
||||
@@ -136,9 +156,9 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
}
|
||||
var firstlist = joinedQuery.AsSplitQuery();
|
||||
|
||||
|
||||
|
||||
var list = firstlist.OrderByDescending(x => x.IsActiveString == "true" ? 1 : 0)
|
||||
|
||||
var list = firstlist.OrderByDescending(x => x.CreatedByClient).ThenByDescending(x => x.IsActiveString == "true" ? 1 : 0)
|
||||
.ThenByDescending(x => x.HasUploadedImage == "true" ? 1 : 0)
|
||||
.Skip(command.PageIndex).Take(30).ToList();
|
||||
var watch = new Stopwatch();
|
||||
@@ -244,19 +264,6 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
;
|
||||
}
|
||||
|
||||
public bool HasEmployees(long workshopId)
|
||||
{
|
||||
var dateNow = DateTime.Now;
|
||||
return _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
||||
.Any(x => x.LeftWorks.Any(y =>
|
||||
y.WorkshopId == workshopId && y.StartWorkDate <= dateNow &&
|
||||
y.LeftWorkDate > dateNow) ||
|
||||
x.LeftWorkInsurances.Any(y =>
|
||||
y.WorkshopId == workshopId && y.StartWorkDate <= dateNow &&
|
||||
(y.LeftWorkDate > dateNow || y.LeftWorkDate == null)));
|
||||
|
||||
}
|
||||
|
||||
public List<RollCallEmployeeViewModel> GetActivePersonnelByWorkshopId(long workshopId)
|
||||
{
|
||||
var dateNow = DateTime.Now.Date;
|
||||
@@ -333,46 +340,14 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
return new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Farokhi&Mahan
|
||||
|
||||
public (int activeEmployees, int deActiveEmployees) GetActiveAndDeActiveRollCallEmployees(long workshopId)
|
||||
{
|
||||
var dateNow = DateTime.Now;
|
||||
//var employeeQuery = _context.Employees.AsQueryable();
|
||||
|
||||
|
||||
//var rawQuery = employeeQuery.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
||||
// .Where(x => x.LeftWorks.Any(y =>
|
||||
// y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
|
||||
// y.LeftWorkDate > dateNow) ||
|
||||
// x.LeftWorkInsurances.Any(y =>
|
||||
// y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
|
||||
// (y.LeftWorkDate > dateNow || y.LeftWorkDate == null))).OrderByDescending(x => x.id)
|
||||
// .Select(x => new
|
||||
// {
|
||||
// Id = x.id,
|
||||
// x.FullName,
|
||||
// x.NationalCode,
|
||||
|
||||
// }).AsSplitQuery();
|
||||
|
||||
|
||||
|
||||
//var rollCallEmployees = _context.RollCallEmployees.Where(x => x.WorkshopId == command.WorkshopId);
|
||||
|
||||
|
||||
//var joinedQuery = from employee in rawQuery
|
||||
// join rollCallEmployee in rollCallEmployees
|
||||
// on employee.Id equals rollCallEmployee.EmployeeId into grp
|
||||
// from joinedRollCall in grp.DefaultIfEmpty()
|
||||
// select new RollCallEmployeeViewModel()
|
||||
// {
|
||||
// WorkshopId = command.WorkshopId,
|
||||
// EmployeeId = employee.Id,
|
||||
// Id = joinedRollCall == null ? 0 : joinedRollCall.id,
|
||||
// EmployeeFullName = joinedRollCall == null ? employee.FullName : joinedRollCall.EmployeeFullName,
|
||||
// NationalCode = employee.NationalCode,
|
||||
// IsActiveString = joinedRollCall == null ? "false" : joinedRollCall.IsActiveString,
|
||||
// HasUploadedImage = joinedRollCall == null ? "false" : joinedRollCall.HasUploadedImage
|
||||
// };
|
||||
var rawQuery = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
||||
.Where(x => x.LeftWorks.Any(y =>
|
||||
y.WorkshopId == workshopId && y.StartWorkDate <= dateNow &&
|
||||
@@ -385,20 +360,41 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
Id = x.id,
|
||||
}).Distinct();
|
||||
|
||||
var rollCallEmployees = _context.RollCallEmployees.Where(x => x.WorkshopId == workshopId);
|
||||
var rollCallEmployees = _context.RollCallEmployees.Include(x => x.EmployeesStatus).Where(x => x.WorkshopId == workshopId);
|
||||
|
||||
var joinedQuery = from employee in rawQuery
|
||||
join rollCallEmployee in rollCallEmployees
|
||||
on employee.Id equals rollCallEmployee.EmployeeId into grp
|
||||
from joinedRollCall in grp.DefaultIfEmpty()
|
||||
select new RollCallEmployeeViewModel()
|
||||
{
|
||||
IsActiveString = joinedRollCall == null ? "false" : joinedRollCall.IsActiveString,
|
||||
};
|
||||
join rollCallEmployee in rollCallEmployees
|
||||
on employee.Id equals rollCallEmployee.EmployeeId into grp
|
||||
from joinedRollCall in grp.DefaultIfEmpty()
|
||||
select new RollCallEmployeeViewModel()
|
||||
{
|
||||
IsActiveString = joinedRollCall.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow.Date && y.EndDate.Date > dateNow.Date) ? "true" : "false",
|
||||
|
||||
};
|
||||
var deActiveCount = joinedQuery.Count(x => x.IsActiveString == "false");
|
||||
var ActiveCount = joinedQuery.Count(x => x.IsActiveString == "true");
|
||||
return (ActiveCount, deActiveCount);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public bool HasEmployees(long workshopId)
|
||||
{
|
||||
var dateNow = DateTime.Now;
|
||||
return _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
||||
.Any(x => x.LeftWorks.Any(y =>
|
||||
y.WorkshopId == workshopId && y.StartWorkDate <= dateNow &&
|
||||
y.LeftWorkDate > dateNow) ||
|
||||
x.LeftWorkInsurances.Any(y =>
|
||||
y.WorkshopId == workshopId && y.StartWorkDate <= dateNow &&
|
||||
(y.LeftWorkDate > dateNow || y.LeftWorkDate == null)));
|
||||
|
||||
}
|
||||
|
||||
public RollCallEmployee GetBy(long employeeId, long workshopId)
|
||||
{
|
||||
return _context.RollCallEmployees.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -71,13 +71,16 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
|
||||
//گرفتن ساعت استراحت پرسنل از تنظیمات
|
||||
#region breakTime
|
||||
BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
|
||||
BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery()
|
||||
.Include(x=>x.CustomizeWorkshopGroupSettings).FirstOrDefault(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
//اگر ساعت استراحت پرسنل وجود نداشت صفر است
|
||||
var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
|
||||
#endregion
|
||||
|
||||
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
|
||||
|
||||
#endregion
|
||||
|
||||
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date &&
|
||||
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel()
|
||||
{
|
||||
@@ -148,6 +151,8 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
}).ToList();
|
||||
leavingDayCout += afterCheckout.Sum(x => x.DayCounter);
|
||||
Console.WriteLine(leavingDayCout);
|
||||
|
||||
|
||||
TimeSpan workingPerDayAve = sumSpans / groupedRollCall.Count;//میانگین ساعت کار در روز
|
||||
TimeSpan sumLeave = new TimeSpan();
|
||||
if (workingPerDayAve <= new TimeSpan(7, 20, 0))
|
||||
@@ -1694,8 +1699,8 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#endregion
|
||||
|
||||
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date &&
|
||||
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null)
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.ShiftDate.Date >= contractStart.Date &&
|
||||
x.ShiftDate.Date <= contractEnd.Date && x.EndDate != null)
|
||||
.Select(x => new RollCallViewModel()
|
||||
{
|
||||
StartDate = x.StartDate,
|
||||
|
||||
@@ -1791,43 +1791,62 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
IsBirthDay = isBirthday
|
||||
};
|
||||
});
|
||||
var presentDays = rollCalls.Where(x => x.EmployeeId == employeeId).GroupBy(x => x.ShiftDate.Date).Select(x =>
|
||||
{
|
||||
var orderedRollcalls = x.OrderBy(y => y.StartDate!.Value).ToList();
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
StartDate1 = orderedRollcalls.FirstOrDefault()?.StartDate?.ToString("HH:mm"),
|
||||
EndDate1 = orderedRollcalls.FirstOrDefault()?.EndDate?.ToString("HH:mm"),
|
||||
var presentDays = rollCalls.Where(x => x.EmployeeId == employeeId).GroupBy(x => x.ShiftDate.Date).Select(x =>
|
||||
{
|
||||
var orderedRollcalls = x.OrderBy(y => y.StartDate!.Value).ToList();
|
||||
var firstRollCall = orderedRollcalls.FirstOrDefault();
|
||||
var secondRollCall = orderedRollcalls.Skip(1).FirstOrDefault();
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
StartDate1 = orderedRollcalls.FirstOrDefault()?.StartDate?.ToString("HH:mm"),
|
||||
EndDate1 = orderedRollcalls.FirstOrDefault()?.EndDate?.ToString("HH:mm"),
|
||||
|
||||
StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "",
|
||||
EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "",
|
||||
StartDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.StartDate?.ToString("HH:mm") ?? "",
|
||||
EndDate2 = orderedRollcalls.Skip(1).FirstOrDefault()?.EndDate?.ToString("HH:mm") ?? "",
|
||||
|
||||
TotalhourseSpan =
|
||||
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks)),
|
||||
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
|
||||
RollCallDateFa = x.Key.Date.ToFarsi(),
|
||||
DateTimeGr = x.Key.Date,
|
||||
IsSliced = x.Count() > 2,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = pc.GetMonth(x.Key) == pc.GetMonth(birthDay) && pc.GetDayOfMonth(x.Key) == pc.GetDayOfMonth(birthDay)
|
||||
};
|
||||
});
|
||||
presentDays = presentDays.Select(x => new CheckoutDailyRollCallViewModel
|
||||
{
|
||||
StartDate1 = x.StartDate1,
|
||||
EndDate1 = x.EndDate1,
|
||||
EndDate2 = x.EndDate2,
|
||||
StartDate2 = x.StartDate2,
|
||||
TotalWorkingHours = $"{(int)(x.TotalhourseSpan.TotalHours)}:{x.TotalhourseSpan.Minutes.ToString("00")}",
|
||||
DayOfWeek = x.DayOfWeek,
|
||||
RollCallDateFa = x.RollCallDateFa,
|
||||
DateTimeGr = x.DateTimeGr,
|
||||
IsSliced = x.IsSliced,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = x.IsBirthDay
|
||||
});
|
||||
TotalhourseSpan =
|
||||
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks)),
|
||||
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
|
||||
RollCallDateFa = x.Key.Date.ToFarsi(),
|
||||
DateTimeGr = x.Key.Date,
|
||||
IsSliced = x.Count() > 2,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = pc.GetMonth(x.Key) == pc.GetMonth(birthDay) && pc.GetDayOfMonth(x.Key) == pc.GetDayOfMonth(birthDay),
|
||||
|
||||
List<CheckoutDailyRollCallViewModel> checkoutDailyRollCalls = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList();
|
||||
EnterDifferencesMinutes1 = firstRollCall != null && firstRollCall.LateEntryDuration > TimeSpan.Zero && workshopId == 170
|
||||
? CalculateEntryMinuteDifference(firstRollCall.EarlyEntryDuration,
|
||||
firstRollCall.LateEntryDuration)
|
||||
: "",
|
||||
ExitDifferencesMinutes1 = "",
|
||||
|
||||
EnterDifferencesMinutes2 = secondRollCall != null && secondRollCall.LateEntryDuration > TimeSpan.Zero && workshopId == 170
|
||||
? CalculateEntryMinuteDifference(secondRollCall.EarlyEntryDuration,
|
||||
secondRollCall.LateEntryDuration)
|
||||
: "",
|
||||
ExitDifferencesMinutes2 = ""
|
||||
};
|
||||
});
|
||||
presentDays = presentDays.Select(x => new CheckoutDailyRollCallViewModel
|
||||
{
|
||||
StartDate1 = x.StartDate1,
|
||||
EndDate1 = x.EndDate1,
|
||||
EndDate2 = x.EndDate2,
|
||||
StartDate2 = x.StartDate2,
|
||||
TotalWorkingHours = $"{(int)(x.TotalhourseSpan.TotalHours)}:{x.TotalhourseSpan.Minutes.ToString("00")}",
|
||||
DayOfWeek = x.DayOfWeek,
|
||||
RollCallDateFa = x.RollCallDateFa,
|
||||
DateTimeGr = x.DateTimeGr,
|
||||
IsSliced = x.IsSliced,
|
||||
IsAbsent = false,
|
||||
IsBirthDay = x.IsBirthDay,
|
||||
EnterDifferencesMinutes1 = x.EnterDifferencesMinutes1,
|
||||
ExitDifferencesMinutes1 = x.ExitDifferencesMinutes1,
|
||||
EnterDifferencesMinutes2 = x.EnterDifferencesMinutes2,
|
||||
ExitDifferencesMinutes2 = x.ExitDifferencesMinutes2,
|
||||
});
|
||||
|
||||
|
||||
List<CheckoutDailyRollCallViewModel> checkoutDailyRollCalls = presentDays.Concat(absentRecords).OrderBy(x => x.DateTimeGr).ToList();
|
||||
|
||||
checkoutDailyRollCalls.ForEach(x =>
|
||||
{
|
||||
|
||||
@@ -123,4 +123,9 @@ public class RollCallServiceRepository : RepositoryBase<long, RollCallService>,
|
||||
|
||||
}).Where(x => x.AccountId == accountId).ToList();
|
||||
}
|
||||
|
||||
public bool IsExistActiveServiceByWorkshopId(long workshopId)
|
||||
{
|
||||
return _context.RollCallServices.AsSplitQuery().Any(x => x.WorkshopId == workshopId && x.IsActiveString == "true");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,9 +45,11 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
||||
var y = Convert.ToInt32(endDateNowFa.Substring(0, 4));
|
||||
var m = Convert.ToInt32(endDateNowFa.Substring(5, 2));
|
||||
var d = Convert.ToInt32(endDateNowFa.Substring(8, 2));
|
||||
if (m == 12)
|
||||
y += 1;
|
||||
|
||||
PersianDateTime endDate = new PersianDateTime(y, m, d);
|
||||
|
||||
if (m == 12)
|
||||
endDate.AddYears(1);
|
||||
for (PersianDateTime date = endDate; date >= startDate; date = date.AddYears(-1))
|
||||
{
|
||||
yearlist.Add(date.ToString("yyyy"));
|
||||
|
||||
@@ -197,6 +197,12 @@ using Company.Domain.EmployeeDocumentsAgg;
|
||||
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
||||
using CompanyManagment.App.Contracts.EmployeeDocumentsAdminSelection;
|
||||
using Company.Domain.EmployeeClientTempAgg;
|
||||
using Company.Domain.LeftWorkTempAgg;
|
||||
using Company.Domain.TemporaryClientRegistrationAgg;
|
||||
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
|
||||
namespace PersonalContractingParty.Config;
|
||||
|
||||
@@ -409,6 +415,12 @@ public class PersonalBootstrapper
|
||||
services.AddTransient<IAndroidApkVersionApplication, AndroidApkVersionApplication>();
|
||||
|
||||
services.AddTransient<SalaryAidImportExcel>();
|
||||
|
||||
services.AddTransient<IEmployeeClientTempRepository, EmployeeClientTempRepository>();
|
||||
services.AddTransient<IEmployeeClientTempApplication, EmployeeClientTempApplication>();
|
||||
|
||||
services.AddTransient<ILeftWorkTempRepository, LeftWorkTempRepository>();
|
||||
services.AddTransient<ILeftWorkTempApplication, LeftWorkTempApplication>();
|
||||
#endregion
|
||||
#region Pooya
|
||||
|
||||
@@ -431,9 +443,15 @@ public class PersonalBootstrapper
|
||||
|
||||
services.AddTransient<IEmployeeBankInformationRepository, EmployeeBankInformationRepository>();
|
||||
services.AddTransient<IEmployeeBankInformationApplication, EmployeeBankInformationApplication>();
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
services.AddTransient<IRollCallDomainService, RollCallDomainService>();
|
||||
#region TemporaryClientRegisteration
|
||||
|
||||
services.AddTransient<ITemporaryClientRegistrationApplication, TemporaryClientRegistrationApplication>();
|
||||
services.AddTransient<IContractingPartyTempRepository, ContractingPartyTempRepository>();
|
||||
|
||||
#endregion
|
||||
services.AddTransient<IRollCallDomainService, RollCallDomainService>();
|
||||
//=========End Of Main====================================
|
||||
|
||||
//---File Project------------------------------------
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Query.AdminReports.Handlers
|
||||
var allWorkshops = _companyContext.Workshops.AsSplitQuery().Select(x => new { x.id, x.WorkshopFullName });
|
||||
|
||||
if (parameters.WorkshopId != 0)
|
||||
allWorkshops = allWorkshops.Where(x => x.id == parameters.WorkshopId);
|
||||
allWorkshops = allWorkshops.Where(x => x.id == parameters.WorkshopId);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parameters.WorkshopName))
|
||||
allWorkshops = allWorkshops.Where(x => x.WorkshopFullName.Contains(parameters.WorkshopName));
|
||||
@@ -45,10 +45,10 @@ namespace Query.AdminReports.Handlers
|
||||
if (!string.IsNullOrWhiteSpace(parameters.RollCallServiceType))
|
||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.ServiceType == parameters.RollCallServiceType);
|
||||
|
||||
if (parameters.FilterMode == FilterMode.Active)
|
||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.StartService.Date <= now && x.EndService.Date >= now);
|
||||
else if(parameters.FilterMode == FilterMode.DeActive)
|
||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.EndService.Date < now || x.StartService.Date > now);
|
||||
if (parameters.FilterMode == FilterMode.Active)
|
||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.StartService.Date <= now && x.EndService.Date >= now);
|
||||
else if (parameters.FilterMode == FilterMode.DeActive)
|
||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.EndService.Date < now || x.StartService.Date > now);
|
||||
|
||||
var workshopsWithService = rollCallServiceQuery.Join(allWorkshops, x => x.WorkshopId, y => y.id, (rcs, workshop) =>
|
||||
new WorkshopWithRollCallServiceQueryModel()
|
||||
@@ -60,7 +60,7 @@ namespace Query.AdminReports.Handlers
|
||||
IsActive = rcs.StartService <= DateTime.Now && rcs.EndService >= DateTime.Now,
|
||||
ServiceStart = rcs.StartService,
|
||||
ServiceEnd = rcs.EndService
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//workshop population
|
||||
@@ -73,12 +73,15 @@ namespace Query.AdminReports.Handlers
|
||||
}).ToList();
|
||||
|
||||
var workshopsWorkingEmployeesList = workshopLeftWorks
|
||||
.Select(x => new { x.WorkshopId, TotalWorkingEmployeesCount = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct().Count() }).ToList();
|
||||
.Select(x => new { x.WorkshopId, TotalWorkingEmployeesCount = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct().Count(), EmployeeIds = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct() }).ToList();
|
||||
|
||||
|
||||
|
||||
var activeEmployees = _companyContext.RollCallEmployees.AsSplitQuery().Include(x => x.EmployeesStatus).Where(x => x.EmployeesStatus.Any(y =>
|
||||
y.EndDate.Date >= now) && workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => new { x.WorkshopId, x.EmployeeId });
|
||||
var activeEmployees = _companyContext.RollCallEmployees.AsSplitQuery()
|
||||
.Include(x => x.EmployeesStatus)
|
||||
.Where(x => x.EmployeesStatus.Any(y => y.EndDate.Date >= now) &&
|
||||
workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId))
|
||||
.Select(x => new { x.WorkshopId, x.EmployeeId });
|
||||
|
||||
var lastWeekRollCalls = _companyContext.RollCalls.AsSplitQuery().Where(x => x.StartDate.HasValue && x.StartDate.Value >= lastWeek
|
||||
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).GroupBy(x => x.EmployeeId).Select(x => x.Key);
|
||||
@@ -88,27 +91,27 @@ namespace Query.AdminReports.Handlers
|
||||
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => x.EmployeeId);
|
||||
|
||||
|
||||
var activeEmployeesList = activeEmployees.ToList();
|
||||
var activeEmployeesList = activeEmployees.ToList().Where(x => workshopsWorkingEmployeesList.Any(w => w.WorkshopId == x.WorkshopId && w.EmployeeIds.Contains(x.EmployeeId)));
|
||||
var lastWeekRollCallsList = lastWeekRollCalls.ToList();
|
||||
var leavesList = leaves.ToList();
|
||||
var workshopsWithServiceList = workshopsWithService.ToList();
|
||||
return workshopsWithServiceList.GroupBy(x=>x.WorkshopId)
|
||||
.Select(x=>x.OrderByDescending(y=>y.ServiceStartFa).First())
|
||||
.Select(x => new WorkshopWithRollCallServiceQueryModel()
|
||||
{
|
||||
IsActive = x.IsActive,
|
||||
ServiceStartFa = x.ServiceStart.ToFarsi(),
|
||||
ServiceEndFa = x.ServiceEnd.ToFarsi(),
|
||||
WorkshopId = x.WorkshopId,
|
||||
RollCallServiceType = x.RollCallServiceType,
|
||||
MaxPersonValid = x.MaxPersonValid,
|
||||
WorkshopName = x.WorkshopName,
|
||||
ActiveEmployeesCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId),
|
||||
ActiveEmployeesWithRollCallInLastWeekCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId &&
|
||||
lastWeekRollCallsList.Contains(y.EmployeeId) && !leavesList.Contains(y.EmployeeId)),
|
||||
TotalEmployeesCount = workshopsWorkingEmployeesList.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.TotalWorkingEmployeesCount ?? 0,
|
||||
//UndoneWorkFlowsCount = workFlowApplication.GetAllWorkFlowCount(x.WorkshopId).Result
|
||||
}).OrderByDescending(x=>x.IsActive).ToList();
|
||||
return workshopsWithServiceList.GroupBy(x => x.WorkshopId)
|
||||
.Select(x => x.OrderByDescending(y => y.ServiceStartFa).First())
|
||||
.Select(x => new WorkshopWithRollCallServiceQueryModel()
|
||||
{
|
||||
IsActive = x.IsActive,
|
||||
ServiceStartFa = x.ServiceStart.ToFarsi(),
|
||||
ServiceEndFa = x.ServiceEnd.ToFarsi(),
|
||||
WorkshopId = x.WorkshopId,
|
||||
RollCallServiceType = x.RollCallServiceType,
|
||||
MaxPersonValid = x.MaxPersonValid,
|
||||
WorkshopName = x.WorkshopName,
|
||||
ActiveEmployeesCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId),
|
||||
ActiveEmployeesWithRollCallInLastWeekCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId &&
|
||||
lastWeekRollCallsList.Contains(y.EmployeeId) && !leavesList.Contains(y.EmployeeId)),
|
||||
TotalEmployeesCount = workshopsWorkingEmployeesList.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.TotalWorkingEmployeesCount ?? 0,
|
||||
//UndoneWorkFlowsCount = workFlowApplication.GetAllWorkFlowCount(x.WorkshopId).Result
|
||||
}).OrderByDescending(x => x.IsActive).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
</div>
|
||||
<div class="card p-0">
|
||||
<div class="card-section-btn">
|
||||
<a class="btn loadingButton @(authHelper.GetPermissions().Any(x => x == 2) ? "" : "disable")" asp-area="AdminNew" asp-page="/Company/FileBackup/Index">
|
||||
<a class="btn loadingButton @(authHelper.GetPermissions().Any(x => x == 2) || authHelper.CurrentAccountId() == 322 ? "" : "disable")" asp-area="AdminNew" asp-page="/Company/FileBackup/Index">
|
||||
<svg width="50" height="50" viewBox="0 0 54 54" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M42.75 7.875H11.25C10.0125 7.875 9 8.8875 9 10.125V16.875C9 18.1125 10.0125 19.125 11.25 19.125H42.75C43.9875 19.125 45 18.1125 45 16.875V10.125C45 8.8875 43.9875 7.875 42.75 7.875ZM42.75 21.375H11.25C10.0125 21.375 9 22.3875 9 23.625V30.375C9 31.6125 10.0125 32.625 11.25 32.625H42.75C43.9875 32.625 45 31.6125 45 30.375V23.625C45 22.3875 43.9875 21.375 42.75 21.375ZM42.75 34.875H11.25C10.0125 34.875 9 35.8875 9 37.125V43.875C9 45.1125 10.0125 46.125 11.25 46.125H42.75C43.9875 46.125 45 45.1125 45 43.875V37.125C45 35.8875 43.9875 34.875 42.75 34.875Z" fill="#C4E8E8"/>
|
||||
<path d="M34.875 33.7492L42.75 40.0492V27.4492L34.875 33.7492Z" fill="#23A8A8"/>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user