merge With Master

This commit is contained in:
SamSys
2025-02-01 18:18:15 +03:30
202 changed files with 64390 additions and 8063 deletions

View File

@@ -39,6 +39,7 @@ public class AuthHelper : IAuthHelper
result.WorkshopSlug = claims.FirstOrDefault(x => x is { Type: "WorkshopSlug" }).Value;
result.Mobile = claims.FirstOrDefault(x => x is { Type: "Mobile" }).Value;
result.SubAccountId = long.Parse(claims.FirstOrDefault(x => x.Type == "SubAccountId").Value);
result.WorkshopName = claims.FirstOrDefault(x => x is { Type: "WorkshopName" })?.Value;
return result;
}
@@ -71,46 +72,64 @@ public class AuthHelper : IAuthHelper
: "";
}
#region Vafa
#region Vafa
public void UpdateWorkshopSlugClaim(string workshopSlug)
{
var user = _contextAccessor.HttpContext.User;
public void UpdateWorkshopSlugClaim(string newWorkshopSlug, string newWorkshopName)
{
var user = _contextAccessor.HttpContext.User;
if (user.Identity.IsAuthenticated)
{
var claimsIdentity = (ClaimsIdentity)user.Identity;
var existingClaim = claimsIdentity.FindFirst("WorkshopSlug");
if (user.Identity.IsAuthenticated)
{
var claimsIdentity = (ClaimsIdentity)user.Identity;
var existingClaimSlug = claimsIdentity.FindFirst("WorkshopSlug");
var existingClaimName = claimsIdentity.FindFirst("WorkshopName");
if (existingClaim != null)
{
claimsIdentity.RemoveClaim(existingClaim);
}
if (existingClaimSlug != null)
{
claimsIdentity.RemoveClaim(existingClaimSlug);
}
claimsIdentity.AddClaim(new Claim("WorkshopSlug", workshopSlug));
if (existingClaimName != null)
{
claimsIdentity.RemoveClaim(existingClaimName);
}
var authProperties = new AuthenticationProperties
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1)
};
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
}
claimsIdentity.AddClaim(new Claim("WorkshopSlug", newWorkshopSlug));
claimsIdentity.AddClaim(new Claim("workshopName", newWorkshopName));
public string GetWorkshopSlug()
var authProperties = new AuthenticationProperties
{
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(1)
};
_contextAccessor.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity),
authProperties);
}
}
public string GetWorkshopSlug()
{
return CurrentAccountInfo().ClientAriaPermission == "true"
? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopSlug")?.Value
: "";
}
public string GetWorkshopName()
{
var workshopName = _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "ClientAriaPermission")?.Value == "true";
if (workshopName)
{
return _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopName")?.Value;
}
#endregion
return "";
}
#endregion
public string CurrentAccountRole()
public string CurrentAccountRole()
{
if (IsAuthenticated())
return _contextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value;
@@ -154,9 +173,10 @@ public class AuthHelper : IAuthHelper
new Claim("PositionValue",account.PositionValue.ToString()),
//mahanChanges
new("workshopList",workshopBson),
new("WorkshopSlug",slug)
new("WorkshopSlug",slug),
new("WorkshopName",account.WorkshopName??"")
};
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);

View File

@@ -20,7 +20,8 @@ public class AuthViewModel
public int? PositionValue { get; set; }
public string WorkshopSlug { get; set; }
public List<WorkshopClaim> WorkshopList { get; set; }
public string WorkshopName { get; set; }
public List<WorkshopClaim> WorkshopList { get; set; }
#endregion

View File

@@ -15,11 +15,12 @@ public interface IAuthHelper
long CurrentAccountId();
string CurrentAccountMobile();
#region Vafa
#region Vafa
void UpdateWorkshopSlugClaim(string workshopSlug);
void UpdateWorkshopSlugClaim(string workshopSlug, string workshopName);
#endregion
long CurrentSubAccountId();
#endregion
long CurrentSubAccountId();
string GetWorkshopSlug();
string GetWorkshopName();
}

View File

@@ -72,16 +72,40 @@
/// </summary>
public const int PaymentToEmployeePermissionCode = 10304;
#region عملیات وام
/// <summary>
/// عملیات وام
/// عملیات حساب بانکی پرسنل
/// </summary>
public const int LoanOperationsPermissionCode = 10305;
public const int EmployeeBankInformationPermissionCode = 10309;
/// <summary>
/// ایجاد وام
/// </summary>
public const int CreateLoanPermissionCode = 1030501;
public const int CreateLoanPermissionCode = 114;
/// <summary>
/// ایجاد پاداش
/// </summary>
public const int CreateRewardPermissionCode = 115;
/// <summary>
/// ایجاد مساعده
/// </summary>
public const int CreateSalaryAidPermissionCode = 116;
/// <summary>
/// ایجاد جریمه
/// </summary>
public const int CreateFinePermissionCode = 117;
#region عملیات وام
/// <summary>
/// عملیات وام
/// </summary>
public const int LoanOperationsPermissionCode = 10305;
///// <summary>
///// ایجاد وام
///// </summary>
//public const int CreateLoanPermissionCode = 1030501;
/// <summary>
/// ویرایش وام
@@ -100,10 +124,10 @@
/// </summary>
public const int RewardOperationsPermissionCode = 10306;
/// <summary>
/// ایجاد پاداش
/// </summary>
public const int CreateRewardPermissionCode = 1030601;
///// <summary>
///// ایجاد پاداش
///// </summary>
//public const int CreateRewardPermissionCode = 1030601;
/// <summary>
/// ویرایش پاداش
@@ -123,10 +147,10 @@
/// </summary>
public const int SalaryAidOperationsPermissionCode = 10307;
/// <summary>
/// ایجاد مساعده
/// </summary>
public const int CreateSalaryAidPermissionCode = 1030701;
///// <summary>
///// ایجاد مساعده
///// </summary>
//public const int CreateSalaryAidPermissionCode = 1030701;
/// <summary>
/// ویرایش مساعده
@@ -145,10 +169,10 @@
/// </summary>
public const int FineOperationsPermissionCode = 10308;
/// <summary>
/// ایجاد جریمه
/// </summary>
public const int CreateFinePermissionCode = 1030801;
///// <summary>
///// ایجاد جریمه
///// </summary>
//public const int CreateFinePermissionCode = 1030801;
/// <summary>
/// ایجاد عنوان جریمه
@@ -409,7 +433,39 @@
Code = PersonnelOperationsPermissionCode,
ParentId = 0
};
public static SubAccountPermissionDto CustomizeCheckoutOperationsPermission { get; } = new()
public static SubAccountPermissionDto LoanOperationsPermission { get; } = new()
{
Id = LoanOperationsPermissionCode,
Name = "عملیات وام",
Code = LoanOperationsPermissionCode,
ParentId = 0
};
public static SubAccountPermissionDto RewardOperationsPermission { get; } = new()
{
Id = RewardOperationsPermissionCode,
Name = "عملیات پاداش",
Code = RewardOperationsPermissionCode,
ParentId = 0
};
public static SubAccountPermissionDto SalaryAidOperationsPermission { get; } = new()
{
Id = SalaryAidOperationsPermissionCode,
Name = "عملیات مساعده",
Code = SalaryAidOperationsPermissionCode,
ParentId = 0
};
public static SubAccountPermissionDto FineOperationsPermission { get; } = new()
{
Id = FineOperationsPermissionCode,
Name = "عملیات جرایم",
Code = FineOperationsPermissionCode,
ParentId = PersonnelOperationsPermissionCode
};
public static SubAccountPermissionDto CustomizeCheckoutOperationsPermission { get; } = new()
{
Id = CustomizeCheckoutOperationsPermissionCode,
Name = "فیش حقوقی غیر رسمی",
@@ -540,6 +596,7 @@
ParentId = PersonnelOperationsPermissionCode
};
public static SubAccountPermissionDto PaymentToEmployeePermission { get; } = new()
{
Id = PaymentToEmployeePermissionCode,
@@ -548,44 +605,20 @@
ParentId = PersonnelOperationsPermissionCode
};
public static SubAccountPermissionDto LoanOperationsPermission { get; } = new()
public static SubAccountPermissionDto EmployeeBankInformationPermission { get; } = new()
{
Id = LoanOperationsPermissionCode,
Name = "عملیات وام",
Code = LoanOperationsPermissionCode,
ParentId = PersonnelOperationsPermissionCode
Id = EmployeeBankInformationPermissionCode,
Name = "عملیات حساب بانکی پرسنل",
Code = EmployeeBankInformationPermissionCode,
ParentId = PersonnelOperationsPermissionCode
};
public static SubAccountPermissionDto RewardOperationsPermission { get; } = new()
{
Id = RewardOperationsPermissionCode,
Name = "عملیات پاداش",
Code = RewardOperationsPermissionCode,
ParentId = PersonnelOperationsPermissionCode
};
#endregion
public static SubAccountPermissionDto SalaryAidOperationsPermission { get; } = new()
{
Id = SalaryAidOperationsPermissionCode,
Name = "عملیات مساعده",
Code = SalaryAidOperationsPermissionCode,
ParentId = PersonnelOperationsPermissionCode
};
public static SubAccountPermissionDto FineOperationsPermission { get; } = new()
{
Id = FineOperationsPermissionCode,
Name = "عملیات جرایم",
Code = FineOperationsPermissionCode,
ParentId = PersonnelOperationsPermissionCode
};
#endregion
#region فیش حقوقی غیر رسمی,ParentId = CustomizeCheckoutOperationsPermissionCode
#region فیش حقوقی غیر رسمی,ParentId = CustomizeCheckoutOperationsPermissionCode
public static SubAccountPermissionDto CustomizeCheckoutSetGroupAndSalaryPermission { get; } = new()
public static SubAccountPermissionDto CustomizeCheckoutSetGroupAndSalaryPermission { get; } = new()
{
Id = CustomizeCheckoutSetGroupAndSalaryPermissionCode,
Name = "تنظیم گروه بندی و حقوق پرسنل",

View File

@@ -127,7 +127,7 @@ public static class Tools
int years = 0;
var firstYearCounter = start.AddYears(1);
//اگر سنش هنوز به یک سال نرسیده بود
if (firstYearCounter > end)
{
start = start.AddYears(-1);
@@ -183,7 +183,7 @@ public static class Tools
if (yearCouner.Year == end.Year)
{
var endMonthCounter = new PersianDateTime(end.Year, end.Month, yearCouner.Day);
var endMonthCounter = new PersianDateTime(end.Year, end.Month, (yearCouner.Day > end.Day ? end.Day : yearCouner.Day));
if (yearCouner.Day <= end.Day)
{

View File

@@ -1,180 +1,231 @@
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)
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)
{
OfficeOpenXml.ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using var package = new OfficeOpenXml.ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
//worksheet.Cells["A1:AC1"].Merge = true;
//var headerImagePath = Path.Combine("wwwroot", "Excel", "header", "2.png");
//using (var stream = new FileStream(headerImagePath, FileMode.Open, FileAccess.Read))
//{
// var picture = worksheet.Drawings.AddPicture("HeaderImage", stream);
// picture.SetPosition(0, 0, 0, 0); // Set position to the merged cell
// //picture.SetSize(600, 75); // Adjust the size as needed
//}
string[] headers =
[
//جزییات
"ردیف", "سال", "ماه", "نام و نام خانوادگی", "شماره پرسنلی", "کدملی", "روز کارکرد",
//مطالبات
"حقوق ماهانه", "پاداش", "جمعه کاری", "اضافه کاری", "نوبت کاری", "شب کاری",
"حق تاهل", "حق فرزند", "عیدی", "سنوات", "مزد مرخصی",
//کسورات
"غیبت", "تاخیر در ورود", "تعجیل در خروج", "مساعده", "قسط وام", "جریمه", "حق بیمه", "مالیات",
//مجموع
"جمع مطالبات", "جمع کسورات", "مبلغ قابل پرداخت"
];
for (int i = 0; i < headers.Length; i++)
for (int rowIndex = 2; rowIndex < dataRow; rowIndex++)
{
worksheet.Cells[1, i + 1].Value = headers[i];
}
// Lock cells A1 to H6
//worksheet.Cells.Style.Locked = false;
//worksheet.Cells["A1:AC1"].Style.Locked = true;
//// Set worksheet protection with password
//worksheet.Protection.IsProtected = true;
//worksheet.Protection.SetPassword("Gozareshgir2049"); // Set your desired password here
//worksheet.Protection.AllowSelectLockedCells = true; // Unlock all other cells
using (var range = worksheet.Cells[1, 1, 1, 29])
{
range.Style.Font.Bold = true;
range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
range.Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
range.Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
range.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
range.Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
}
var dataRow = 2;
var numberFormat = "#,##0";
for (int i = 0; i < data.Count; i++)
{
var checkout = data[i];
worksheet.Cells[i + dataRow, 1].Value = i + 1;
worksheet.Cells[i + dataRow, 2].Value = checkout.Year;
worksheet.Cells[i + dataRow, 3].Value = checkout.Month;
worksheet.Cells[i + dataRow, 4].Value = checkout.EmployeeFullName;
worksheet.Cells[i + dataRow, 5].Value = checkout.PersonnelCodeString;
worksheet.Cells[i + dataRow, 6].Value = checkout.NationalCode;
worksheet.Cells[i + dataRow, 7].Value = checkout.SumOfWorkingDays;
worksheet.Cells[i + dataRow, 8].Value = checkout.MonthlySalary.MoneyToDouble();
worksheet.Cells[i + dataRow, 9].Value = checkout.RewardPay.MoneyToDouble();
worksheet.Cells[i + dataRow, 10].Value = checkout.FridayPay.MoneyToDouble();
worksheet.Cells[i + dataRow, 11].Value = checkout.OvertimePay.MoneyToDouble();
worksheet.Cells[i + dataRow, 12].Value = checkout.ShiftPay.MoneyToDouble();
worksheet.Cells[i + dataRow, 13].Value = checkout.NightworkPay.MoneyToDouble();
worksheet.Cells[i + dataRow, 14].Value = checkout.MarriedAllowance.MoneyToDouble();
worksheet.Cells[i + dataRow, 15].Value = checkout.FamilyAllowance.MoneyToDouble();
worksheet.Cells[i + dataRow, 16].Value = checkout.BonusesPay.MoneyToDouble();
worksheet.Cells[i + dataRow, 17].Value = checkout.BaseYearsPay.MoneyToDouble();
worksheet.Cells[i + dataRow, 18].Value = checkout.LeavePay.MoneyToDouble();
worksheet.Cells[i + dataRow, 19].Value = checkout.AbsenceDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 20].Value = checkout.LateToWorkDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 21].Value = checkout.EarlyExitDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 22].Value = checkout.SalaryAidDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 23].Value = checkout.InstallmentDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 24].Value = checkout.FineDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 25].Value = checkout.InsuranceDeduction.MoneyToDouble();
worksheet.Cells[i + dataRow, 26].Value = checkout.TaxDeducation.MoneyToDouble();
worksheet.Cells[i + dataRow, 27].Value = checkout.TotalClaims.MoneyToDouble();
worksheet.Cells[i + dataRow, 28].Value = checkout.TotalDeductions.MoneyToDouble();
worksheet.Cells[i + dataRow, 29].Value = checkout.TotalPayment.MoneyToDouble();
// Style data cells
for (int j = 1; j <= 29; j++)
var totalPaymentValue = worksheet.Cells[rowIndex, totalPaymentColumnIndex].Value;
if (totalPaymentValue != null && double.TryParse(totalPaymentValue.ToString(), out double payment))
{
var cell = worksheet.Cells[i + 2, j];
cell.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
cell.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
cell.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
cell.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
if (j >= 1 && j <= 7)
if (payment < 0)
{
cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightYellow);
}
else if (j >= 8 && j <= 18)
{
cell.Style.Fill.BackgroundColor.SetColor(1,208,248,208);
cell.Style.Numberformat.Format = numberFormat;
}
else if (j >= 19 && j <= 26)
{
cell.Style.Fill.BackgroundColor.SetColor(1,246,176,176);
cell.Style.Numberformat.Format = numberFormat;
}
switch (j)
{
//جمع مطالبات
case 27:
cell.Style.Fill.BackgroundColor.SetColor(1, 169, 208, 142);
cell.Style.Numberformat.Format = numberFormat;
break;
//جمع کسورات
case 28:
cell.Style.Fill.BackgroundColor.SetColor(1, 241, 143, 143);
cell.Style.Numberformat.Format = numberFormat;
break;
//مبلغ قابل پرداخت
case 29:
cell.Style.Fill.BackgroundColor.SetColor(1, 168, 186, 254);
cell.Style.Numberformat.Format = numberFormat;
break;
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);
}
}
}
}
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; // Scale to fit content within A4 width
worksheet.View.RightToLeft = true;
worksheet.PrinterSettings.RepeatRows = new OfficeOpenXml.ExcelAddress("1:1"); // Repeat rows 1 to 6 on every page
return package.GetAsByteArray();
}
}
}

View File

@@ -48,5 +48,9 @@ public class CustomizeCheckoutTempExcelViewModel
public string TotalDeductions { get; set; }
public string TotalPayment { get; set; }
public string BankAccountNumber { get; set; }
public string CardNumber { get; set; }
public string ShebaNumber { get; set; }
}

View File

@@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using LicenseContext = OfficeOpenXml.LicenseContext;
@@ -198,5 +199,5 @@ public class ExcelGenerator
return resultList;
}
}

View File

@@ -0,0 +1,15 @@
using _0_Framework.Application;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
namespace AccountManagement.Application.Contracts.Media
{
public interface IMediaApplication
{
MediaViewModel Get(long id);
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength, List<string> allowedExtensions);
OperationResult MoveFile(long mediaId, string newRelativePath);
OperationResult DeleteFile(long mediaId);
List<MediaViewModel> GetRange(IEnumerable<long> select);
}
}

View File

@@ -63,9 +63,16 @@ public interface ITaskApplication
List<AssignViewModel> GetAssignsByTaskId(long taskId);
int RequestedAndOverdueTasksCount(long userId);
/// <summary>
///تعداد تسک های شخصی و دریافتی برای امروز و یا عقب افتاده
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
int OverdueTasksCount(long userId);
//متد انتقال داده از تسک به ارجاعی ها
//OperationResult MoveDataFRomTaskToAssign();
//متد انتقال داده از تسک به ارجاعی ها
//OperationResult MoveDataFRomTaskToAssign();
}

View File

@@ -254,9 +254,13 @@ public class AccountApplication : IAccountApplication
Slug = _passwordHasher.SlugHasher(x.Id)
}).OrderByDescending(x => x.PersonnelCount).ToList();
authViewModel.WorkshopList = workshopList;
if (workshopList.Any())
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshopList.First().Id);
}
if (workshopList.Any())
{
var workshop = workshopList.First();
authViewModel.WorkshopName = workshop.Name;
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
}
}
_authHelper.Signin(authViewModel);
@@ -309,7 +313,11 @@ public class AccountApplication : IAccountApplication
}).ToList();
if (workshopList.Any())
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshopList.First().WorkshopId);
{
var workshop = workshopList.First();
authViewModel.WorkshopName = workshop.WorkshopName;
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.WorkshopId);
}
_authHelper.Signin(authViewModel);
idAutoriz = 2;
}
@@ -347,19 +355,21 @@ public class AccountApplication : IAccountApplication
{
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
authViewModel.Permissions = clientPermissions;
var workshopList = _workshopRepository.SearchForClient(new WorkshopSearchModel() { AccountId = account.id })
.OrderByDescending(x => x.PersonnelCount).ToList().Select(x => new WorkshopClaim()
{
Slug = _passwordHasher.SlugHasher(x.Id),
Name = x.WorkshopFullName,
PersonnelCount = x.PersonnelCount,
Id = x.Id
}
).ToList();
authViewModel.WorkshopList = workshopList;
if (workshopList.Any())
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshopList.First().Id);
}
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
{
PersonnelCount = x.PersonnelCount,
Id = x.Id,
Name = x.WorkshopFullName,
Slug = _passwordHasher.SlugHasher(x.Id)
}).OrderByDescending(x => x.PersonnelCount).ToList();
authViewModel.WorkshopList = workshopList;
if (workshopList.Any())
{
var workshop = workshopList.First();
authViewModel.WorkshopName = workshop.Name;
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
}
}
_authHelper.Signin(authViewModel);
long idAutoriz = 0;
@@ -486,26 +496,27 @@ public class AccountApplication : IAccountApplication
_authHelper.SignOut();
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, "false", "true",null);
authViewModel.WorkshopList = _workshopRepository.SearchForClient(new WorkshopSearchModel() { AccountId = account.id })
.OrderByDescending(x => x.PersonnelCount).ToList().Select(x => new WorkshopClaim()
{
Slug = _passwordHasher.SlugHasher(x.Id),
Name = x.WorkshopFullName,
PersonnelCount = x.PersonnelCount,
Id = x.Id
}
).ToList();
var workshopList = _workshopRepository.GetWorkshopsByClientAccountId(account.id).Select(x => new WorkshopClaim
{
PersonnelCount = x.PersonnelCount,
Id = x.Id,
Name = x.WorkshopFullName,
Slug = _passwordHasher.SlugHasher(x.Id)
}).OrderByDescending(x => x.PersonnelCount).ToList();
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
authViewModel.WorkshopList = workshopList;
var clientPermissions = _accountPermissionSubtitle1Repository.GetAllPermissionCodes();
authViewModel.Permissions = clientPermissions;
if (authViewModel.WorkshopList.Any())
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(authViewModel.WorkshopList.First().Id);
_authHelper.Signin(authViewModel);
{
var workshop = authViewModel.WorkshopList.First();
authViewModel.WorkshopSlug = _passwordHasher.SlugHasher(workshop.Id);
authViewModel.WorkshopName = workshop.Name;
}
_authHelper.Signin(authViewModel);
return operation.Succcedded(2);
}
public OperationResult DirectCameraLogin(long cameraAccountId)

View File

@@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Media;
using AccountManagement.Domain.MediaAgg;
using Microsoft.AspNetCore.Http;
namespace AccountManagement.Application
{
public class MediaApplication:IMediaApplication
{
private const string _basePath = "Medias";
private readonly IMediaRepository _mediaRepository;
public MediaApplication(IMediaRepository mediaRepository)
{
_mediaRepository = mediaRepository;
}
/// <summary>
/// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا
/// </summary>
/// <param name="file">فایل</param>
/// <param name="fileLabel">برچسب فایل که در نام فایل ظاهر می شود</param>
/// <param name="relativePath">مسیر فایل</param>
/// <param name="allowedExtensions">[.png,.jpg,.jpeg] پسوند های مجاز مثلا </param>
/// <param name="maximumFileLength">حداکثر حجم فایل به مگابایت</param>
/// <returns></returns>
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath,int maximumFileLength,List<string> allowedExtensions)
{
OperationResult op = new();
var path = Path.Combine(_basePath, relativePath);
var fileExtension = Path.GetExtension(file.FileName);
if (file == null || file.Length == 0)
return op.Failed("خطای سیستمی");
if (file.Length > (maximumFileLength * 1024 * 1024))
return op.Failed($"حجم فایل نمی تواند بیشتر از " +
$"{maximumFileLength}" +
$"مگابایت باشد");
if (!allowedExtensions.Contains(fileExtension.ToLower()))
{
var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد";
operationMessage += "\n";
operationMessage += string.Join(" ", allowedExtensions);
return op.Failed(operationMessage);
}
Directory.CreateDirectory(path);
var extension = Path.GetExtension(file.FileName);
var uniqueFileName = $"{fileLabel}-{DateTime.Now.Ticks}{extension}";
var filePath = Path.Combine(path, uniqueFileName);
using (var fileStream = new FileStream(filePath, FileMode.CreateNew))
{
file.CopyTo(fileStream);
}
var mediaEntity = new Media(filePath, extension, "فایل", "EmployeeDocuments");
_mediaRepository.Create(mediaEntity);
_mediaRepository.SaveChanges();
return op.Succcedded(mediaEntity.id);
}
/// <summary>
/// حذف فایل
/// </summary>
public OperationResult DeleteFile(long mediaId)
{
OperationResult op = new();
var media = _mediaRepository.Get(mediaId);
if (media == null)
return op.Failed("رکورد مورد نظر یافت نشد");
try
{
if (File.Exists(media.Path))
File.Delete(media.Path);
else
return op.Failed("فایل یافت نشد");
}
catch
{
return op.Failed("خطایی در حذف فایل رخ داده است");
}
_mediaRepository.Remove(media.id);
_mediaRepository.SaveChanges();
return op.Succcedded();
}
/// <summary>
/// جابجا کردن فایل
/// </summary>
public OperationResult MoveFile(long mediaId, string newRelativePath)
{
OperationResult op = new();
var media = _mediaRepository.Get(mediaId);
var oldPath = media.Path;
var path = Path.Combine(_basePath, newRelativePath);
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, Path.GetFileName(oldPath));
try
{
File.Move(oldPath, filepath);
}
catch
{
return op.Failed("در جابجایی فایل خطایی رخ داده است");
}
media.Edit(filepath, media.Type, media.Category);
_mediaRepository.SaveChanges();
return op.Succcedded();
}
public MediaViewModel Get(long id)
{
var media = _mediaRepository.Get(id);
return new MediaViewModel()
{
Category = media.Category,
Path = media.Path,
Id = media.id,
Type = media.Type
};
}
public List<MediaViewModel> GetRange(IEnumerable<long> ids)
{
var medias = _mediaRepository.GetRange(ids);
return medias.Select(x=>new MediaViewModel()
{
Category = x.Category,
Path = x.Path,
Id = x.id,
Type = x.Type,
}).ToList();
}
}
}

View File

@@ -943,7 +943,7 @@ public class TaskApplication : ITaskApplication
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
var media = new Media(filepath, type, "فایل", "Task");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
return operation.Succcedded(media.id);
@@ -1007,10 +1007,15 @@ public class TaskApplication : ITaskApplication
return _assignRepository.GetAssignsByTaskId(taskId);
}
public int RequestedAndOverdueTasksCount(long userId)
{
return _taskRepository.RequestedAndOverdueTasksCount(userId);
}
public int OverdueTasksCount(long userId)
{
return _taskRepository.OverdueTasksCount(userId);
}
//public OperationResult MoveDataFRomTaskToAssign()

View File

@@ -461,7 +461,7 @@ public class TicketApplication : ITicketApplication
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
var media = new Media(filepath, type, "فایل", "Ticket");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
return operation.Succcedded(media.id);

View File

@@ -1,6 +1,7 @@
using AccountManagement.Application;
using AccountManagement.Application.Contracts.Account;
using AccountManagement.Application.Contracts.CameraAccount;
using AccountManagement.Application.Contracts.Media;
using AccountManagement.Application.Contracts.Position;
using AccountManagement.Application.Contracts.Role;
using AccountManagement.Application.Contracts.SubAccount;
@@ -68,8 +69,9 @@ namespace AccountManagement.Configuration
services.AddTransient<IAssignRepository, AssignRepository>();
services.AddTransient<IMediaRepository, MediaRepository>();
services.AddTransient<IMediaApplication, MediaApplication>();
services.AddTransient<ITicketRepository, TicketRepository>();
services.AddTransient<ITicketRepository, TicketRepository>();
services.AddTransient<ITicketApplication, TicketApplication>();
services.AddTransient<ITaskMessageRepository, TaskMessageRepository>();

View File

@@ -10,8 +10,17 @@ public interface IMediaRepository:IRepository<long,Media>
void CreateMediaWithTaskMedia(long taskId, long mediaId);
List<MediaViewModel> GetMediaByTaskId(long taskId);
void Remove(long id);
void RemoveRange(IEnumerable<Media> medias);
void CreateTicketMedia(long ticketId, long mediaId);
void CreateAdminResponseMedia(long adminResponseId, long mediaId);
void CreateClientResponseMedia(long clientResponseId, long mediaId);
#region Pooya
List<MediaViewModel> GetMedias(List<long> ids);
List<Media> GetRange(IEnumerable<long> mediaIds);
#endregion
}

View File

@@ -1,20 +1,22 @@
using System.Collections.Generic;
using _0_Framework.Domain;
using _0_Framework.Domain;
using AccountManagement.Domain.AdminResponseMediaAgg;
using AccountManagement.Domain.ClientResponseMediaAgg;
using AccountManagement.Domain.TaskMediaAgg;
using AccountManagement.Domain.TicketMediasAgg;
using System.Collections.Generic;
namespace AccountManagement.Domain.MediaAgg;
public class Media : EntityBase
{
public Media(string path, string type, string category)
public Media(string path, string type, string category, string serviceName)
{
Path = path;
Type = type;
Category = category;
ServiceName = serviceName;
}
@@ -26,6 +28,10 @@ public class Media : EntityBase
//دسته بندی ذخیره فایل
public string Category { get; private set; }
//نام ماژولی که رکورد را ایجاد کرده
public string ServiceName { get; private set; }
public List<TaskMedia> TaskMedias { get; set; }
public List<AdminResponseMedia> AdminResponseMedias { get; set; }
public List<ClientResponseMedia> ClientResponseMedias { get; set; }
@@ -33,8 +39,8 @@ public class Media : EntityBase
public void Edit(string path, string type, string category)
{
Path = path;
Type = type;
Path = path;
Type = type;
Category = category;
}

View File

@@ -115,11 +115,11 @@ public interface ITaskRepository:IRepository<long,Tasks>
bool HasOverdueTasks(long userId);
/// <summary>
/// تعداد تسک های عقب افتاده
///مجوع تعداد تسک های عقب افتاده و درخواستی
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
int OverdueTasksCount(long userId);
int RequestedAndOverdueTasksCount(long userId);
/// <summary>
/// تعداد تسک های دارای تیکت
@@ -135,6 +135,12 @@ public interface ITaskRepository:IRepository<long,Tasks>
/// <returns></returns>
int TasksHaveTicketRequestsCount(long userId);
/// <summary>
///تعداد تسک های شخصی و دریافتی برای امروز و یا عقب افتاده
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
int OverdueTasksCount(long userId);
// گرفتن پیام های مربوط به هر تسک

View File

@@ -77,7 +77,7 @@ namespace AccountMangement.Infrastructure.EFCore
{
var assembly = typeof(AccountMapping).Assembly;
modelBuilder.ApplyConfigurationsFromAssembly(assembly);
// SubAccountPermissionSeeder.Seed(modelBuilder);
//SubAccountPermissionSeeder.Seed(modelBuilder);
base.OnModelCreating(modelBuilder);
}
}

View File

@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace AccountMangement.Infrastructure.EFCore.Mappings;
public class MediaMapping:IEntityTypeConfiguration<Media>
public class MediaMapping : IEntityTypeConfiguration<Media>
{
public void Configure(EntityTypeBuilder<Media> builder)
{
@@ -14,6 +14,7 @@ public class MediaMapping:IEntityTypeConfiguration<Media>
builder.Property(x => x.Path).HasColumnType("ntext");
builder.Property(x => x.Type).HasMaxLength(10);
builder.Property(x => x.Category).HasMaxLength(10);
builder.Property(x => x.ServiceName).HasMaxLength(50);

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AccountMangement.Infrastructure.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddServiceNameToMedia : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ServiceName",
table: "Medias",
type: "nvarchar(50)",
maxLength: 50,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ServiceName",
table: "Medias");
}
}
}

View File

@@ -355,6 +355,10 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
b.Property<string>("Path")
.HasColumnType("ntext");
b.Property<string>("ServiceName")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Type")
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");

View File

@@ -13,17 +13,17 @@ namespace AccountMangement.Infrastructure.EFCore.Repository;
public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
{
private readonly AccountContext _taskManagerContext;
private readonly AccountContext _accountContext;
public MediaRepository( AccountContext taskManagerContext) : base(taskManagerContext)
{
_taskManagerContext = taskManagerContext;
_accountContext = taskManagerContext;
}
//ساخت جدول واسط بین مدیا و نسک
//نکته: این متد ذخیره انجام نمیدهد
public void CreateMediaWithTaskMedia(long taskId, long mediaId)
{
var Taskmedias = new TaskMedia(taskId,mediaId);
_taskManagerContext.Add(Taskmedias);
_accountContext.Add(Taskmedias);
}
public void Remove(long id)
{
@@ -34,24 +34,24 @@ public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
public void CreateTicketMedia(long ticketId, long mediaId)
{
var ticketMedias = new TicketMedia(ticketId, mediaId);
_taskManagerContext.Add(ticketMedias);
_accountContext.Add(ticketMedias);
}
public void CreateAdminResponseMedia(long adminResponseId, long mediaId)
{
var adminResMedia = new AdminResponseMedia(adminResponseId, mediaId);
_taskManagerContext.Add(adminResMedia);
_accountContext.Add(adminResMedia);
}
public void CreateClientResponseMedia(long clientResponseId, long mediaId)
{
var clientResMedia = new ClientResponseMedia(clientResponseId, mediaId);
_taskManagerContext.Add(clientResMedia);
_accountContext.Add(clientResMedia);
}
public List<MediaViewModel> GetMediaByTaskId(long taskId)
{
return _taskManagerContext.TaskMedias.Include(x => x.Media).Where(x => x.TaskId == taskId).Select(x =>
return _accountContext.TaskMedias.Include(x => x.Media).Where(x => x.TaskId == taskId).Select(x =>
new MediaViewModel()
{
Id = x.Media.id,
@@ -59,4 +59,24 @@ public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
Type = x.Media.Type,
}).ToList();
}
}
#region Pooya
public List<MediaViewModel> GetMedias(List<long> ids)
{
return _accountContext.Medias.Where(x => ids.Contains(x.id)).Select(x => new MediaViewModel()
{
Id = x.id,
Path = x.Path,
Category = x.Category,
Type = x.Type
}).ToList();
}
public List<Media> GetRange(IEnumerable<long> mediaIds)
{
return _accountContext.Medias.Where(x => mediaIds.Contains(x.id)).ToList();
}
}
#endregion

View File

@@ -0,0 +1,24 @@
using _0_Framework.Domain;
namespace Company.Domain.BankAgg
{
public class Bank : EntityBaseWithoutCreationDate
{
public string BankName { get; private set; }
public long BankLogoMediaId { get; private set; }
public Bank(string bankName, long bankLogoMediaId)
{
BankName = bankName;
BankLogoMediaId = bankLogoMediaId;
}
public void Edit(string bankName, long bankLogoMediaId)
{
BankName = bankName;
BankLogoMediaId = bankLogoMediaId;
}
}
}

View File

@@ -0,0 +1,12 @@
using System.Collections.Generic;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.Bank;
namespace Company.Domain.BankAgg
{
public interface IBankRepository:IRepository<long,Bank>
{
public void Remove(Bank entity);
List<BankViewModel> Search(string name);
}
}

View File

@@ -5,16 +5,20 @@ namespace Company.Domain.CustomizeCheckoutAgg.ValueObjects;
public class CustomizeCheckoutLoanInstallments
{
public CustomizeCheckoutLoanInstallments(string amountForMonth, string month, string year, IsActive isActive)
public CustomizeCheckoutLoanInstallments(string amountForMonth, string month, string year, IsActive isActive, string loanRemaining, string loanAmount)
{
AmountForMonth = amountForMonth;
Month = month;
Year = year;
IsActive = isActive;
LoanRemaining = loanRemaining;
LoanAmount = loanAmount;
}
public string AmountForMonth { get; private set; }
public string Month { get; private set; }
public string Year { get; private set; }
public string LoanRemaining { get; set; }
public string LoanAmount { get; set; }
public IsActive IsActive { get; private set; }
}

View File

@@ -5,13 +5,14 @@ namespace Company.Domain.CustomizeCheckoutAgg.ValueObjects;
public class CustomizeCheckoutReward
{
public CustomizeCheckoutReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive)
public CustomizeCheckoutReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive, string title)
{
Amount = amount;
Description = description;
GrantDate = grantDate;
GrantDateFa = grantDateFa;
IsActive = isActive;
Title = title;
}
/// <summary>
@@ -19,6 +20,9 @@ public class CustomizeCheckoutReward
/// </summary>
public string Amount { get; private set; }
public string Title { get; private set; }
/// <summary>
/// توضیحات
/// </summary>

View File

@@ -4,16 +4,21 @@ namespace Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
public class CustomizeCheckoutTempLoanInstallments
{
public CustomizeCheckoutTempLoanInstallments(string amountForMonth, string month, string year, IsActive isActive)
public CustomizeCheckoutTempLoanInstallments(string amountForMonth, string month, string year, IsActive isActive, string loanRemaining, string loanAmount)
{
AmountForMonth = amountForMonth;
Month = month;
Year = year;
IsActive = isActive;
LoanRemaining = loanRemaining;
LoanAmount = loanAmount;
}
public string AmountForMonth { get; private set; }
public string Month { get; private set; }
public string Year { get; private set; }
public IsActive IsActive { get; private set; }
public string LoanRemaining { get; set; }
public string LoanAmount { get; set; }
}

View File

@@ -5,13 +5,14 @@ namespace Company.Domain.CustomizeCheckoutTempAgg.ValueObjects;
public class CustomizeCheckoutTempReward
{
public CustomizeCheckoutTempReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive)
public CustomizeCheckoutTempReward(string amount, string description, DateTime grantDate, string grantDateFa, IsActive isActive, string title)
{
Amount = amount;
Description = description;
GrantDate = grantDate;
GrantDateFa = grantDateFa;
IsActive = isActive;
Title = title;
}
/// <summary>
@@ -35,5 +36,5 @@ public class CustomizeCheckoutTempReward
public IsActive IsActive { get; private set; }
public string Title { get; set; }
}

View File

@@ -22,4 +22,7 @@ public interface ICustomizeWorkshopGroupSettingsRepository : IRepository<long, C
long workshopSettingsId);
void Remove(long groupId);
CustomizeWorkshopGroupSettingsViewModel GetEmployeesGroupSettingsByEmployeeId(long employeeId, long workshopId);
bool HasAnyEmployeeWithoutGroup(long workshopId);
}

View File

@@ -4,6 +4,7 @@ using _0_Framework.Domain;
using Company.Domain.ClientEmployeeWorkshopAgg;
using Company.Domain.ContractAgg;
using Company.Domain.CustomizeCheckoutAgg;
using Company.Domain.EmployeeBankInformationAgg;
using Company.Domain.EmployeeChildrenAgg;
using Company.Domain.EmployeeInsuranceRecordAgg;
using Company.Domain.InsuranceEmployeeInfoAgg;
@@ -129,6 +130,10 @@ public class Employee : EntityBase
public string FullName => $"{FName} {LName}";
#region Pooya
public List<EmployeeBankInformation> EmployeeBankInformationList { get; set; }
#endregion
//public List<Checkout> Checkouts { get; set; }
public Employee()
{

View File

@@ -0,0 +1,62 @@
using _0_Framework.Domain;
using Company.Domain.BankAgg;
using Company.Domain.EmployeeAgg;
namespace Company.Domain.EmployeeBankInformationAgg
{
public class EmployeeBankInformation : EntityBase
{
public long EmployeeId { get;private set; }
public long WorkshopId { get; private set; }
public Bank Bank { get; set; }
public long BankId { get; private set; }
/// <summary>
/// شماره حساب
/// </summary>
public string BankAccountNumber { get;private set; }
/// <summary>
/// شماره کارت
/// </summary>
public string CardNumber { get; private set; }
/// <summary>
/// شماره شبا
/// </summary>
public string ShebaNumber { get; private set; }
public bool IsDefault { get; private set; } = false;
//ONE TO MANY WITH EMPLOYEE
public Employee Employee { get; set; }
private EmployeeBankInformation()
{
}
public EmployeeBankInformation(long employeeId, long workshopId, long bankId, string bankAccountNumber, string cardNumber, string shebaNumber)
{
EmployeeId = employeeId;
WorkshopId = workshopId;
BankId = bankId;
BankAccountNumber = bankAccountNumber;
CardNumber = cardNumber;
ShebaNumber = shebaNumber;
}
public void Edit(long bankId, string bankAccountNumber, string cardNumber, string shebaNumber)
{
BankId = bankId;
BankAccountNumber = bankAccountNumber;
CardNumber = cardNumber;
ShebaNumber = shebaNumber;
}
public void SetDefault(bool setAsDefault = true)
{
IsDefault = setAsDefault;
}
}
}

View File

@@ -0,0 +1,20 @@
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
using System.Collections.Generic;
namespace Company.Domain.EmployeeBankInformationAgg
{
public interface IEmployeeBankInformationRepository : IRepository<long, EmployeeBankInformation>
{
List<GroupedEmployeeBankInformationViewModel> Search(long workshopId, EmployeeBankInformationSearchModel searchParams);
void Remove(EmployeeBankInformation bankInformation);
GroupedEmployeeBankInformationViewModel GetByEmployeeId(long workshopId, long employeeId);
List<EmployeeBankInformation> GetRangeByEmployeeId(long workshopId, long employeeId);
void RemoveRange(List<EmployeeBankInformation> entities);
EmployeeBankInformationViewModel GetDetails(long id);
List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId);
}
}

View File

@@ -122,11 +122,13 @@ public class LoanInstallment
}
public int Id { get; set; }
public double AmountForMonth { get; private set; }
public string Month { get; private set; }
public string Year { get; private set; }
public DateTime InstallmentDate { get; set; }
public IsActive IsActive { get; private set; }
public long LoanId { get; set; }
internal void DeActive()
{

View File

@@ -11,4 +11,13 @@ public interface IRewardRepository : IRepository<long, Reward>
void Remove(Reward entity);
List<Reward> GetBy(IEnumerable<long> ids);
void RemoveRange(IEnumerable<Reward> rewards);
#region Pooya
/// <summary>
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
/// </summary>
List<MonthlyGroupedEmployeeRewardsViewModel> GetSearchListByEmployee(RewardSearchModel searchModel);
#endregion
}

View File

@@ -7,11 +7,12 @@ namespace Company.Domain.RewardAgg;
public class Reward:EntityBase
{
private Reward()
private Reward(string title)
{
Title = title;
}
public Reward(long employeeId, long workshopId, double amount, string description, long rewardedByAccountId, DateTime grantDate)
public Reward(long employeeId, long workshopId, double amount, string description, long rewardedByAccountId, DateTime grantDate, string title)
{
EmployeeId = employeeId;
WorkshopId = workshopId;
@@ -19,6 +20,7 @@ public class Reward:EntityBase
Description = description;
RewardedByAccountId = rewardedByAccountId;
GrantDate = grantDate;
Title = title;
IsActive = IsActive.True;
}
@@ -30,6 +32,11 @@ public class Reward:EntityBase
/// </summary>
public double Amount { get; private set; }
/// <summary>
/// عنوان
/// </summary>
public string Title { get; set; }
/// <summary>
/// توضیحات
/// </summary>
@@ -48,12 +55,13 @@ public class Reward:EntityBase
public IsActive IsActive { get; private set; }
public void Edit(double amount, string description, long rewardedByAccountId, DateTime grantDate)
public void Edit(double amount, string description, long rewardedByAccountId, DateTime grantDate,string title)
{
Amount = amount;
Description = description;
RewardedByAccountId = rewardedByAccountId;
GrantDate = grantDate;
Title = title;
}
public void Active()

View File

@@ -78,13 +78,56 @@ public class RollCallDomainService : IRollCallDomainService
return Tools.CalculateOffset(workshopSettings.CustomizeWorkshopSettingsShifts
.Select(x => (CustomizeSifts)x).ToList());
if (employeeSettings == null )
if (employeeSettings == null)
return Tools.CalculateOffset(workshopSettings.CustomizeWorkshopSettingsShifts.Select(x => (CustomizeSifts)x).ToList());
if (workshopSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular && employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
{
return Tools.CalculateOffset(workshopSettings.CustomizeWorkshopSettingsShifts.Select(x => (CustomizeSifts)x).ToList());
// تعریف بازه‌های زمانی
var workshopStartTime = workshopSettings.CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime; // شروع کارگاه
var workshopEndTime = workshopSettings.CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime; // پایان کارگاه
var employeeStartTime = employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.MinBy(x => x.Placement).StartTime; // شروع بازه پرسنل
var employeeEndTime = employeeSettings.CustomizeWorkshopEmployeeSettingsShifts.MaxBy(x => x.Placement).EndTime; // پایان پرسنل
// تبدیل زمان‌ها به TimeSpan برای مقایسه
var workshopStartTimeSpan = workshopStartTime.ToTimeSpan();
var workshopEndTimeSpan = workshopEndTime.ToTimeSpan();
var employeeStartTimeSpan = employeeStartTime.ToTimeSpan();
var employeeEndTimeSpan = employeeEndTime.ToTimeSpan();
// مدیریت زمان‌های بعد از نیمه شب
if (workshopEndTimeSpan < workshopStartTimeSpan)
workshopEndTimeSpan = workshopEndTimeSpan.Add(TimeSpan.FromDays(1)); // افزودن یک روز به پایان بازه اول
if (employeeEndTimeSpan < employeeStartTimeSpan)
employeeEndTimeSpan = employeeEndTimeSpan.Add(TimeSpan.FromDays(1)); // افزودن یک روز به پایان بازه دوم
// محاسبه بزرگ‌ترین زمان شروع و کوچک‌ترین زمان پایان
var overlapStart = workshopStartTimeSpan > employeeStartTimeSpan ? workshopStartTimeSpan : employeeStartTimeSpan;
var overlapEnd = workshopEndTimeSpan < employeeEndTimeSpan ? workshopEndTimeSpan : employeeEndTimeSpan;
if (overlapStart >= overlapEnd) // اگر بازه هم‌پوشانی وجود ندارد
return Tools.CalculateOffset(employeeSettings.CustomizeWorkshopEmployeeSettingsShifts
.Select(x => (CustomizeSifts)x).ToList());
var overlapDuration = (overlapEnd - overlapStart).TotalMinutes; // مدت زمان هم‌پوشانی بر حسب دقیقه
var duration2 = (employeeEndTime - employeeStartTime).TotalMinutes; // مدت زمان بازه دوم
var overlapPercentage = (overlapDuration / duration2) * 100; // درصد هم‌پوشانی
if (overlapPercentage < 40)
{
return Tools.CalculateOffset(employeeSettings.CustomizeWorkshopEmployeeSettingsShifts
.Select(x => (CustomizeSifts)x).ToList());
}
return Tools.CalculateOffset(workshopSettings.CustomizeWorkshopSettingsShifts
.Select(x => (CustomizeSifts)x).ToList());
}
else if (employeeSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular)

View File

@@ -0,0 +1,9 @@
namespace CompanyManagment.App.Contracts.Bank;
public class BankViewModel
{
public long Id { get; set; }
public string BankName { get; set; }
public string BankLogoPicturePath { get; set; }
public long BankLogoPictureMediaId { get; set; }
}

View File

@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Http;
namespace CompanyManagment.App.Contracts.Bank
{
public class CreateBank
{
public string BankName { get; set; }
public IFormFile BankLogoPictureFile { get; set; }
}
}

View File

@@ -0,0 +1,6 @@
namespace CompanyManagment.App.Contracts.Bank;
public class EditBank : CreateBank
{
public long Id { get; set; }
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.Bank
{
public interface IBankApplication
{
BankViewModel GetBy(long id);
OperationResult Remove(long id);
OperationResult Create(CreateBank command);
OperationResult Edit(EditBank command);
List<BankViewModel> Search(string name);
}
}

View File

@@ -82,6 +82,17 @@ public class CustomizeCheckoutMandatoryViewModel
/// </summary>
public double FineAbsenceDeduction { get; set; }
/// <summary>
/// غیبت
/// </summary>
public double AbsenceDaysDeduction { get; set; }
/// <summary>
/// کسری ساعت
/// </summary>
public double AbsenceHoursDeduction { get; set; }
/// <summary>
/// تاخیر در ورود
/// </summary>

View File

@@ -85,4 +85,8 @@ public interface ICustomizeWorkshopSettingsApplication
List<EmployeeViewModel> GetEmployeesWithoutGroupByWorkshopId(long workshopId);
List<ChangedGroupedViewModel> GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId);
List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsByWorkshopId(long workshopId);
CustomizeWorkshopGroupSettingsViewModel GetEmployeesGroupSettingsByEmployeeId(long employeeId, long workshopId);
bool HasAnyEmployeeWithoutGroup(long workshopId);
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.EmployeeBankInformation
{
public class CreateEmployeeInformation
{
public long EmployeeId { get; set; }
public string EmployeeName { get; set; }
public long WorkshopId { get; set; }
public long BankId { get; set; }
//شماره حساب
public string BankAccountNumber { get; set; }
//شماره کارت
public string CardNumber { get; set; }
//شماره شبا
public string ShebaNumber { get; set; }
}
}

View File

@@ -0,0 +1,6 @@
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class EditEmployeeInformation:CreateEmployeeInformation
{
public long Id { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class EmployeeBankInformationSearchModel
{
public long EmployeeId { get; set; }
public long BankId { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System.Security.AccessControl;
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class EmployeeBankInformationViewModel
{
public long Id { get; set; }
public long EmployeeId { get; set; }
public string EmployeeName { get; set; }
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; }
}

View File

@@ -0,0 +1,21 @@
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class EmployeeInformationViewModel
{
public long EmployeeId { get; set; }
public string EmployeeName { get; set; }
public long WorkshopId { get; set; }
//نام بانک
public string BankName { get; set; }
//شماره حساب
public string BankAccountNumber { get; set; }
//شماره کارت
public string CardNumber { get; set; }
//شماره شبا
public string ShebaNumber { get; set; }
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.EmployeeBankInformation;
public class GroupedEmployeeBankInformationViewModel
{
public long EmployeeId { get; set; }
public long WorkshopId { get; set; }
public string EmployeeName { get; set; }
public string PersonnelCode { get; set; }
public int TotalBankAccountsCount { get; set; }
public List<EmployeeBankInformationViewModel> BankInformation { get; set; }
public List<string> BankPicturesList { get; set; }
}

View File

@@ -0,0 +1,18 @@
using _0_Framework.Application;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.EmployeeBankInformation
{
public interface IEmployeeBankInformationApplication
{
OperationResult Create(CreateEmployeeInformation command);
OperationResult Edit(EditEmployeeInformation command);
List<GroupedEmployeeBankInformationViewModel> Search(long workshopId, EmployeeBankInformationSearchModel searchParams);
GroupedEmployeeBankInformationViewModel GetByEmployeeId(long workshopId, long employeeId);
EmployeeBankInformationViewModel GetDetails(long id);
OperationResult Remove(long id);
OperationResult RemoveByEmployeeId(long workshopId, long employeeId);
List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId);
OperationResult SetDefault(long workshopId, long bankInfoId);
}
}

View File

@@ -14,4 +14,6 @@ public class LoanInstallmentViewModel
public string DateFa { get; set; }
public DateTime DateGr { get; set; }
public IsActive IsActive { get; set; }
public string RemainingAmount { get; set; }
public string LoanAmount { get; set; }
}

View File

@@ -22,5 +22,5 @@ public class CreateRewardViewModel
public long RewardedByAccountId { get; set; }
public string GrantDate { get; set; }
public string Title { get; set; }
}

View File

@@ -12,5 +12,12 @@ public interface IRewardApplication
OperationResult Remove(long id);
OperationResult RemoveRange(IEnumerable<long> ids);
#region Pooya
/// <summary>
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
/// </summary>
List<MonthlyGroupedEmployeeRewardsViewModel> GetSearchListByEmployee(RewardSearchModel searchModel);
#endregion
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.Reward;
public class MonthlyGroupedEmployeeRewardsViewModel
{
public long EmployeeId { get; set; }
public string PersonnelCode { get; set; }
public string MonthFa { get; set; }
public string YearFa { get; set; }
public List<RewardViewModel> Rewards { get; set; }
public string MonthFaName { get; set; }
}

View File

@@ -17,4 +17,12 @@ public class RewardViewModel
public string Description { get; set; }
public string CreationDate { get; set; }
public IsActive IsActive { get; set; }
#region Pooya
public string MonthFa { get; set; }
public string YearFa { get; set; }
public string Title { get; set; }
#endregion
}

View File

@@ -11,5 +11,6 @@ public class GroupedRollCalls
public bool HasFriday { get; set; }
public List<ShiftList> ShiftList { get; set; }
public TimeSpan BreakTime { get; set; }
public DateTime ShiftDate { get; set; }
}

View File

@@ -17,7 +17,8 @@ public class RollCallViewModel
public string EndDayOfWeekFa { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public TimeSpan ShiftSpan { get; set; }
public DateTime ShiftDate { get; set; }
public TimeSpan ShiftSpan { get; set; }
public DateTime CreationDate { get; set; }
public string StartDateFa { get; set; }
public string EndDateFa { get; set; }

View File

@@ -11,6 +11,7 @@ public interface IWorkshopApplication
OperationResult Edit(EditWorkshop command);
string GetWorkshopFullname(long id);
EditWorkshop GetDetails(long id);
List<WorkshopViewModel> GetWorkshop();
List<WorkshopViewModel> GetWorkshopAll();

View File

@@ -3,18 +3,27 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CompanyManagment.App.Contracts.CustomizeWorkshopSettings;
using Microsoft.AspNetCore.Http;
namespace CompanyManagment.App.Contracts.Workshop
{
public class TakePictureModel
{
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public string Name { get; set; }
public IFormFile ProfilePhoto { get; set; }
public string Pic1 { get; set; }
public string Pic2 { get; set; }
public bool HasPicture { get; set; }
}
public long WorkshopId { get; set; }
public long EmployeeId { get; set; }
public string Name { get; set; }
public IFormFile ProfilePhoto { get; set; }
public string Pic1 { get; set; }
public string Pic2 { get; set; }
public bool HasPicture { get; set; }
public long WorkshopGroupSettingsId { get; set; }
public CustomizeWorkshopSettingsViewModel GroupSettings { get; set; }
public CustomizeWorkshopEmployeeSettingsViewModel EmployeeSettings { get; set; }
public string FirstNickName { get; set; }
public string LastNickName { get; set; }
public bool HasUploadedImage { get; set; }
}
}

View File

@@ -0,0 +1,109 @@
using System.Collections.Generic;
using System.Linq;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Media;
using AccountManagement.Domain.MediaAgg;
using Company.Domain.BankAgg;
using CompanyManagment.App.Contracts.Bank;
namespace CompanyManagment.Application
{
public class BankApplication : IBankApplication
{
private readonly IBankRepository _bankRepository;
private readonly IMediaApplication _mediaApplication;
private const string _basePath = "BankLogos";
public BankApplication(IBankRepository bankRepository, IMediaApplication mediaApplication)
{
_bankRepository = bankRepository;
_mediaApplication = mediaApplication;
}
public BankViewModel GetBy(long id)
{
var entity = _bankRepository.Get(id);
if (entity == null)
return new();
var media = _mediaApplication.Get(entity.BankLogoMediaId);
return new BankViewModel()
{
Id = entity.id,
BankName = entity.BankName,
BankLogoPicturePath = media.Path
};
}
public OperationResult Remove(long id)
{
OperationResult op = new();
var entity = _bankRepository.Get(id);
if (entity == null)
return op.Failed(ApplicationMessages.RecordNotFound);
_bankRepository.Remove(entity);
_bankRepository.SaveChanges();
return op.Succcedded();
}
public OperationResult Create(CreateBank command)
{
OperationResult op = new();
if (string.IsNullOrWhiteSpace(command.BankName))
return op.Failed("فیلد نام بانک نمی تواند خالی باشد");
long mediaId = 0;
if(command.BankLogoPictureFile != null && command.BankLogoPictureFile.Length >0 )
{
var uploadResult = _mediaApplication.UploadFile(command.BankLogoPictureFile, command.BankName,
_basePath, 10, [".jpg", ".jpeg", ".png"]);
if (uploadResult.IsSuccedded == false)
return uploadResult;
mediaId = uploadResult.SendId;
}
var newEntity = new Bank(command.BankName, mediaId);
_bankRepository.Create(newEntity);
_bankRepository.SaveChanges();
return op.Succcedded();
}
public OperationResult Edit(EditBank command)
{
OperationResult op = new();
if (string.IsNullOrWhiteSpace(command.BankName))
return op.Failed("فیلد نام بانک نمی تواند خالی باشد");
var entity = _bankRepository.Get(command.Id);
if (entity == null)
return op.Failed(ApplicationMessages.RecordNotFound);
long mediaId = entity.BankLogoMediaId;
if (command.BankLogoPictureFile != null && command.BankLogoPictureFile.Length > 0)
{
var uploadResult = _mediaApplication.UploadFile(command.BankLogoPictureFile, command.BankName,
_basePath, 10, [".jpg", ".jpeg", ".png"]);
if (uploadResult.IsSuccedded == false)
return uploadResult;
_mediaApplication.DeleteFile(entity.BankLogoMediaId);
mediaId = uploadResult.SendId;
}
entity.Edit(command.BankName,mediaId);
_bankRepository.SaveChanges();
return op.Succcedded();
}
public List<BankViewModel> Search(string name)
{
var banks = _bankRepository.Search(name);
var medias = _mediaApplication.GetRange(banks.Select(x => x.Id));
return banks.Select(x=> new BankViewModel()
{
BankLogoPicturePath = medias.FirstOrDefault(y=>y.Id == x.BankLogoPictureMediaId)?.Path ??"",
BankName = x.BankName,
Id = x.Id
}).ToList();
}
}
}

View File

@@ -93,10 +93,10 @@ namespace CompanyManagment.Application
var rewards = result.RewardViewModels.Select(x =>
new CustomizeCheckoutReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
x.IsActive)).ToList();
x.IsActive,x.Title)).ToList();
var loanInstallments = result.InstallmentViewModels.Select(x =>
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive)).ToList();
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive,x.RemainingAmount,x.LoanAmount)).ToList();
var salaryAids = result.SalaryAidViewModels.Select(x =>
new CustomizeCheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();
@@ -147,10 +147,10 @@ namespace CompanyManagment.Application
var rewards = computations.RewardViewModels.Select(x =>
new CustomizeCheckoutReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
x.IsActive)).ToList();
x.IsActive,x.Title)).ToList();
var loanInstallments = computations.InstallmentViewModels.Select(x =>
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive)).ToList();
new CustomizeCheckoutLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive,x.RemainingAmount,x.LoanAmount)).ToList();
var salaryAids = computations.SalaryAidViewModels.Select(x =>
new CustomizeCheckoutSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();

View File

@@ -76,10 +76,10 @@ namespace CompanyManagment.Application
var rewards = result.RewardViewModels.Select(x =>
new CustomizeCheckoutTempReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
x.IsActive)).ToList();
x.IsActive,x.Title)).ToList();
var loanInstallments = result.InstallmentViewModels.Select(x =>
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive)).ToList();
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount,x.LoanAmount)).ToList();
var salaryAids = result.SalaryAidViewModels.Select(x =>
new CustomizeCheckoutTempSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();
@@ -125,10 +125,10 @@ namespace CompanyManagment.Application
var rewards = computations.RewardViewModels.Select(x =>
new CustomizeCheckoutTempReward(x.Amount, x.Description, x.GrantDateGr, x.GrantDateFa,
x.IsActive)).ToList();
x.IsActive,x.Title)).ToList();
var loanInstallments = computations.InstallmentViewModels.Select(x =>
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive)).ToList();
new CustomizeCheckoutTempLoanInstallments(x.Amount, x.Month, x.Year, x.IsActive, x.RemainingAmount, x.LoanAmount)).ToList();
var salaryAids = computations.SalaryAidViewModels.Select(x =>
new CustomizeCheckoutTempSalaryAid(x.Amount, x.SalaryAidDateTimeGe, x.SalaryAidDateTimeFa)).ToList();

View File

@@ -328,181 +328,200 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
public OperationResult CreateEmployeesSettingsAndSetChanges(EditCustomizeEmployeeSettings command)
{
var op = new OperationResult();
var customizeWorkshopGroupSettings = _customizeWorkshopGroupSettingsRepository.Get(command.GroupId);
if (customizeWorkshopGroupSettings ==null)
{
return op.Failed("گروه انتخاب شده نا معتبر است");
}
var customizeWorkshopGroupSettings = _customizeWorkshopGroupSettingsRepository.Get(command.GroupId);
if (customizeWorkshopGroupSettings == null)
{
return op.Failed("گروه انتخاب شده نا معتبر است");
}
if (customizeWorkshopGroupSettings.MainGroup)
{
var createDefaultEmployee = CreateEmployeeSettings(command);
return createDefaultEmployee;
}
List<CustomizeWorkshopEmployeeSettingsShift> shiftCollection = new List<CustomizeWorkshopEmployeeSettingsShift>();
var isChanged = false;
#region validation
if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
{
if (command.ShiftViewModel.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
try
{
shiftCollection =
command.ShiftViewModel.Select(x =>
{
var placement = x.Placement switch
{
ShiftPlacement.First => "اول",
ShiftPlacement.Second => "دوم",
ShiftPlacement.Third => "سوم"
};
if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
if (customizeWorkshopGroupSettings.MainGroup)
{
var createDefaultEmployee = CreateEmployeeSettings(command);
return createDefaultEmployee;
}
return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
}).ToList();
}
catch (InvalidDataException e)
{
return op.Failed(e.Message);
}
DateTime previousEnd = new DateTime();
var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
foreach (var shift in shiftCollection)
{
(DateTime start, DateTime end, ShiftPlacement placement) newShift =
new()
{
placement = shift.Placement,
start = new DateTime(DateOnly.MinValue, shift.StartTime),
end = new DateTime(DateOnly.MinValue, shift.EndTime)
List<CustomizeWorkshopEmployeeSettingsShift> shiftCollection = new List<CustomizeWorkshopEmployeeSettingsShift>();
List<CustomizeRotatingShift> rotatingShift = [];
var isChanged = false;
#region validation
};
if (previousEnd != new DateTime())
{
if (newShift.start <= previousEnd)
{
newShift.start = newShift.start.AddDays(1);
}
}
while (newShift.start >= newShift.end)
{
newShift.end = newShift.end.AddDays(1);
}
finalShiftList.Add(newShift);
previousEnd = newShift.end;
}
//var firstWorkshopTimeShift = workshopSettings.CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime;
//var lastWorkshopTimeShift = workshopSettings.CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime;
//var startDateTime = new DateTime(DateOnly.MinValue, firstWorkshopTimeShift);
//var lastDateTime = new DateTime(DateOnly.MinValue, lastWorkshopTimeShift);
//if (lastDateTime < startDateTime)
//{
// lastDateTime = lastDateTime.AddDays(1);
//}
//var lastGroupShift = finalShiftList.MaxBy(x => x.placement).end;
//var firstGroupShift = finalShiftList.MinBy(x => x.placement).start;
//if (lastDateTime < lastGroupShift || firstGroupShift < startDateTime)
//{
// return op.Failed("ساعت کاری گروه باید بین ساعت کاری کارگاه باشد");
//}
if (command.WorkshopShiftStatus == WorkshopShiftStatus.Regular)
{
if (command.ShiftViewModel.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
return op.Failed("ساعات کاری شروع و پایان نمیتواند خالی باشد");
try
{
shiftCollection =
command.ShiftViewModel.Select(x =>
{
var placement = x.Placement switch
{
ShiftPlacement.First => "اول",
ShiftPlacement.Second => "دوم",
ShiftPlacement.Third => "سوم"
};
if (!TimeOnly.TryParseExact(x.StartTime, "HH:mm", out TimeOnly start))
throw new InvalidDataException($"فرمت شروع نوبت{placement}نادرست است");
if (!TimeOnly.TryParseExact(x.EndTime, "HH:mm", out TimeOnly end))
throw new InvalidDataException($"فرمت پایان نوبت{placement}نادرست است");
if (shiftCollection.All(x => customizeWorkshopGroupSettings.CustomizeWorkshopGroupSettingsShifts.Any(y => x.Equals(y)))
&& command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus && command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork && command.BreakTime == customizeWorkshopGroupSettings.BreakTime)
{
isChanged = false;
}
return new CustomizeWorkshopEmployeeSettingsShift(start, end, x.Placement);
else
{
isChanged = true;
}
}
else
{
var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
}).ToList();
}
catch (InvalidDataException e)
{
var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
return op.Failed(e.Message);
}
DateTime previousEnd = new DateTime();
var finalShiftList = new List<(DateTime start, DateTime end, ShiftPlacement placement)>();
if (irregularShiftEndTime < irregularShiftStartTime)
{
irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
}
shiftCollection = shiftCollection.OrderBy(x => x.Placement).ToList();
switch (command.IrregularShift.WorkshopIrregularShifts)
{
case WorkshopIrregularShifts.TwelveThirtySix:
foreach (var shift in shiftCollection)
{
(DateTime start, DateTime end, ShiftPlacement placement) newShift =
new()
{
placement = shift.Placement,
start = new DateTime(DateOnly.MinValue, shift.StartTime),
end = new DateTime(DateOnly.MinValue, shift.EndTime)
if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
{
return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
}
break;
case WorkshopIrregularShifts.TwelveTwentyFour:
if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
{
return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
}
break;
}
if (command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus && command.BreakTime == customizeWorkshopGroupSettings.BreakTime &&
command.IrregularShift == customizeWorkshopGroupSettings.IrregularShift && command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork)
{
isChanged = false;
}
else
{
isChanged = true;
}
}
#endregion
};
var breakTime = new BreakTime(command.BreakTime.HasBreakTimeValue, command.BreakTime.BreakTimeValue);
if (previousEnd != new DateTime())
{
if (newShift.start <= previousEnd)
{
newShift.start = newShift.start.AddDays(1);
}
}
while (newShift.start >= newShift.end)
{
newShift.end = newShift.end.AddDays(1);
}
finalShiftList.Add(newShift);
previousEnd = newShift.end;
}
//var firstWorkshopTimeShift = workshopSettings.CustomizeWorkshopSettingsShifts.MinBy(x => x.Placement).StartTime;
//var lastWorkshopTimeShift = workshopSettings.CustomizeWorkshopSettingsShifts.MaxBy(x => x.Placement).EndTime;
double salary = command.Salary.MoneyToDouble();
//var startDateTime = new DateTime(DateOnly.MinValue, firstWorkshopTimeShift);
//var lastDateTime = new DateTime(DateOnly.MinValue, lastWorkshopTimeShift);
//if (lastDateTime < startDateTime)
//{
// lastDateTime = lastDateTime.AddDays(1);
//}
//var lastGroupShift = finalShiftList.MaxBy(x => x.placement).end;
//var firstGroupShift = finalShiftList.MinBy(x => x.placement).start;
//if (lastDateTime < lastGroupShift || firstGroupShift < startDateTime)
//{
// return op.Failed("ساعت کاری گروه باید بین ساعت کاری کارگاه باشد");
//}
if (shiftCollection.All(x => customizeWorkshopGroupSettings.CustomizeWorkshopGroupSettingsShifts.Any(y => x.Equals(y)))
&& command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus && command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork && command.BreakTime == customizeWorkshopGroupSettings.BreakTime)
{
isChanged = false;
}
else
{
isChanged = true;
}
}
else if (command.WorkshopShiftStatus == WorkshopShiftStatus.Irregular)
{
var irregularShiftStartTime = new DateTime(DateOnly.MinValue, command.IrregularShift.StartTime);
var irregularShiftEndTime = new DateTime(DateOnly.MinValue, command.IrregularShift.EndTime);
if (irregularShiftEndTime < irregularShiftStartTime)
{
irregularShiftEndTime = irregularShiftEndTime.AddDays(1);
}
switch (command.IrregularShift.WorkshopIrregularShifts)
{
case WorkshopIrregularShifts.TwelveThirtySix:
if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
{
return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
}
break;
case WorkshopIrregularShifts.TwelveTwentyFour:
if ((irregularShiftEndTime - irregularShiftStartTime).TotalHours > 12)
{
return op.Failed("ساعت کاری شما نمیتواند بیشتر از 12 ساعت باشد");
}
break;
}
if (command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus && command.BreakTime == customizeWorkshopGroupSettings.BreakTime &&
command.IrregularShift == customizeWorkshopGroupSettings.IrregularShift && command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork)
{
isChanged = false;
}
else
{
isChanged = true;
}
}
else
{
rotatingShift = command.CustomizeRotatingShifts
.Select(x => new CustomizeRotatingShift(TimeOnly.Parse(x.StartTime), TimeOnly.Parse(x.EndTime)))
.ToList();
if (rotatingShift.All(x => customizeWorkshopGroupSettings.CustomizeRotatingShifts.Any(y => x.Equals(y)))
&& command.WorkshopShiftStatus == customizeWorkshopGroupSettings.WorkshopShiftStatus &&
command.FridayWork == customizeWorkshopGroupSettings.FridayWork &&
command.HolidayWork == customizeWorkshopGroupSettings.HolidayWork && command.BreakTime == customizeWorkshopGroupSettings.BreakTime)
{
isChanged = false;
}
else
{
isChanged = true;
}
}
#endregion
var breakTime = new BreakTime(command.BreakTime.HasBreakTimeValue, command.BreakTime.BreakTimeValue);
//var entity = new CustomizeWorkshopEmployeeSettings(customizeWorkshopGroupSettings.FridayPay, customizeWorkshopGroupSettings.OverTimePay,
// customizeWorkshopGroupSettings.BaseYearsPay, customizeWorkshopGroupSettings.BonusesPay, customizeWorkshopGroupSettings.NightWorkPay, customizeWorkshopGroupSettings.MarriedAllowance,
// customizeWorkshopGroupSettings.ShiftPay, customizeWorkshopGroupSettings.FamilyAllowance, customizeWorkshopGroupSettings.LeavePay, customizeWorkshopGroupSettings.InsuranceDeduction, customizeWorkshopGroupSettings.FineAbsenceDeduction,
// customizeWorkshopGroupSettings.LateToWork, customizeWorkshopGroupSettings.EarlyExit, command.EmployeeIds.First(),command.WorkshopId, salary, command.GroupId,
// shiftCollection, command.FridayWork, command.HolidayWork, command.IrregularShift, command.WorkshopShiftStatus, breakTime, command.LeavePermittedDays);
//_customizeWorkshopEmployeeSettingsRepository.Create(entity);
var entity = new CustomizeWorkshopEmployeeSettings(customizeWorkshopGroupSettings.FridayPay, customizeWorkshopGroupSettings.OverTimePay,
customizeWorkshopGroupSettings.BaseYearsPay, customizeWorkshopGroupSettings.BonusesPay, customizeWorkshopGroupSettings.NightWorkPay, customizeWorkshopGroupSettings.MarriedAllowance,
customizeWorkshopGroupSettings.ShiftPay, customizeWorkshopGroupSettings.FamilyAllowance, customizeWorkshopGroupSettings.LeavePay, customizeWorkshopGroupSettings.InsuranceDeduction, customizeWorkshopGroupSettings.FineAbsenceDeduction,
customizeWorkshopGroupSettings.LateToWork, customizeWorkshopGroupSettings.EarlyExit, command.EmployeeIds.First(), command.WorkshopId, customizeWorkshopGroupSettings.Salary, command.GroupId,
shiftCollection, command.FridayWork, command.HolidayWork, command.IrregularShift, command.WorkshopShiftStatus, breakTime, command.LeavePermittedDays, rotatingShift);
//entity.SimpleEdit(shiftCollection,command.IrregularShift,command.WorkshopShiftStatus,command.BreakTime,isChanged,command.FridayWork,command.HolidayWork);
_customizeWorkshopEmployeeSettingsRepository.Create(entity);
_customizeWorkshopGroupSettingsRepository.SaveChanges();
return op.Succcedded();
entity.SimpleEdit(shiftCollection, command.IrregularShift, command.WorkshopShiftStatus, command.BreakTime, isChanged, command.FridayWork, command.HolidayWork, rotatingShift);
_customizeWorkshopGroupSettingsRepository.SaveChanges();
return op.Succcedded();
}
public OperationResult EditWorkshopSettingShifts(List<CustomizeWorkshopShiftViewModel> shiftViewModels, long customizeWorkshopSettingsId,
}
public OperationResult EditWorkshopSettingShifts(List<CustomizeWorkshopShiftViewModel> shiftViewModels, long customizeWorkshopSettingsId,
WorkshopShiftStatus workshopShiftStatus, FridayWork fridayWork, HolidayWork holidayWork)
{
OperationResult op = new OperationResult();
@@ -1464,7 +1483,17 @@ public class CustomizeWorkshopSettingsApplication(ICustomizeWorkshopSettingsRepo
return _customizeWorkshopEmployeeSettingsRepository.GetEmployeeSettingsByWorkshopId(workshopId);
}
private OperationResult CreateGeneralGroup(CustomizeWorkshopSettings entity)
public CustomizeWorkshopGroupSettingsViewModel GetEmployeesGroupSettingsByEmployeeId(long employeeId, long workshopId)
{
return _customizeWorkshopGroupSettingsRepository.GetEmployeesGroupSettingsByEmployeeId(employeeId, workshopId);
}
public bool HasAnyEmployeeWithoutGroup(long workshopId)
{
return _customizeWorkshopGroupSettingsRepository.HasAnyEmployeeWithoutGroup(workshopId);
}
private OperationResult CreateGeneralGroup(CustomizeWorkshopSettings entity)
{
var op = new OperationResult();

View File

@@ -0,0 +1,207 @@
using _0_Framework.Application;
using Company.Domain.EmployeeBankInformationAgg;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
using System.Collections.Generic;
using System.Linq;
namespace CompanyManagment.Application
{
public class EmployeeBankInformationApplication : IEmployeeBankInformationApplication
{
private readonly IEmployeeBankInformationRepository _employeeBankInformationRepository;
public EmployeeBankInformationApplication(IEmployeeBankInformationRepository employeeBankInformationRepository)
{
_employeeBankInformationRepository = employeeBankInformationRepository;
}
//todo: add CardNumber, BankAccountNumber, etc validations
public OperationResult Create(CreateEmployeeInformation command)
{
OperationResult op = new();
if (HasAtLeastOneFormFilled(command) == false)
return op.Failed("لطفا حداقل یکی از مشخصات بانکی را کامل کنید");
//if (_employeeBankInformationRepository.Exists(x =>
// x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId &&
// x.BankId == command.BankId))
// return op.Failed("این کاربر در بانک انتخاب شده حساب دارد");
if (!string.IsNullOrWhiteSpace(command.BankAccountNumber) && _employeeBankInformationRepository.Exists(x =>
x.WorkshopId == command.WorkshopId &&
x.BankAccountNumber == command.BankAccountNumber))
return op.Failed("این شماره حساب قبلا ثبت شده است");
if (!string.IsNullOrWhiteSpace(command.CardNumber) && _employeeBankInformationRepository.Exists(x =>
x.WorkshopId == command.WorkshopId &&
x.CardNumber == command.CardNumber))
return op.Failed("این شماره کارت قبلا ثبت شده است");
if (!string.IsNullOrWhiteSpace(command.ShebaNumber) && _employeeBankInformationRepository.Exists(x =>
x.WorkshopId == command.WorkshopId &&
x.ShebaNumber == command.ShebaNumber))
return op.Failed("این شماره شبا قبلا ثبت شده است");
var entity = new EmployeeBankInformation(command.EmployeeId, command.WorkshopId, command.BankId,
command.BankAccountNumber, command.CardNumber, command.ShebaNumber);
if(HasNoRecordInWorkshop(command.WorkshopId,command.EmployeeId))
entity.SetDefault();
_employeeBankInformationRepository.Create(entity);
_employeeBankInformationRepository.SaveChanges();
return op.Succcedded(entity.id);
}
public OperationResult SetDefault(long workshopId, long bankInfoId)
{
OperationResult op = new();
var entity = _employeeBankInformationRepository.Get(bankInfoId);
if (entity == null)
return op.Failed("خطای سیستمی");
var employeeRecordsInWorkshop =
_employeeBankInformationRepository.GetRangeByEmployeeId(workshopId, entity.EmployeeId);
if(employeeRecordsInWorkshop.Count > 1)
employeeRecordsInWorkshop.ForEach(x =>
{
if (x.id != entity.id)
x.SetDefault(false);
else
x.SetDefault();
});
_employeeBankInformationRepository.SaveChanges();
return op.Succcedded();
}
//todo: add CardNumber, BankAccountNumber, etc validations
public OperationResult Edit(EditEmployeeInformation command)
{
OperationResult op = new();
var entity = _employeeBankInformationRepository.Get(command.Id);
if (entity == null)
return op.Failed(ApplicationMessages.RecordNotFound);
if (HasAtLeastOneFormFilled(command) == false)
return op.Failed("لطفا حداقل یکی از مشخصات بانکی را کامل کنید");
//if (_employeeBankInformationRepository.Exists(x =>
// x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId &&
// x.BankId == command.BankId && x.id!= command.Id))
// return op.Failed("این کاربر در بانک انتخاب شده حساب دارد");
if (!string.IsNullOrWhiteSpace(command.BankAccountNumber) && _employeeBankInformationRepository.Exists(x =>
x.WorkshopId == command.WorkshopId &&
x.BankAccountNumber == command.BankAccountNumber && x.id != command.Id))
return op.Failed("این شماره حساب قبلا ثبت شده است");
if (!string.IsNullOrWhiteSpace(command.CardNumber) && _employeeBankInformationRepository.Exists(x =>
x.WorkshopId == command.WorkshopId &&
x.CardNumber == command.CardNumber && x.id != command.Id))
return op.Failed("این شماره کارت قبلا ثبت شده است");
if (!string.IsNullOrWhiteSpace(command.ShebaNumber) && _employeeBankInformationRepository.Exists(x =>
x.WorkshopId == command.WorkshopId &&
x.ShebaNumber == command.ShebaNumber && x.id != command.Id))
return op.Failed("این شماره شبا قبلا ثبت شده است");
entity.Edit(command.BankId, command.BankAccountNumber, command.CardNumber, command.ShebaNumber);
_employeeBankInformationRepository.SaveChanges();
return op.Succcedded();
}
public List<GroupedEmployeeBankInformationViewModel> Search(long workshopId, EmployeeBankInformationSearchModel searchParams)
{
return _employeeBankInformationRepository.Search(workshopId, searchParams);
}
public List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId, EmployeeBankInformationSearchModel searchParams)
{
return _employeeBankInformationRepository.GetAllByWorkshopId(workshopId);
}
/// <summary>
/// دریافت مشخصات بانکی پرسنل
/// </summary>
/// <returns>تمامی رکورد های مربوط به پرسنل</returns>
public GroupedEmployeeBankInformationViewModel GetByEmployeeId(long workshopId, long employeeId)
{
var entity = _employeeBankInformationRepository.GetByEmployeeId(workshopId, employeeId);
if (entity == null)
return new();
return entity;
}
public EmployeeBankInformationViewModel GetDetails(long id)
{
return _employeeBankInformationRepository.GetDetails(id);
}
public OperationResult Remove(long id)
{
OperationResult op = new();
var entity = _employeeBankInformationRepository.Get(id);
if (entity == null)
return op.Failed(ApplicationMessages.RecordNotFound);
_employeeBankInformationRepository.Remove(entity);
_employeeBankInformationRepository.SaveChanges();
return op.Succcedded();
}
public OperationResult RemoveByEmployeeId(long workshopId, long employeeId)
{
OperationResult op = new();
var entities = _employeeBankInformationRepository.GetRangeByEmployeeId(workshopId, employeeId);
if (entities == null || !entities.Any())
return op.Failed(ApplicationMessages.RecordNotFound);
_employeeBankInformationRepository.RemoveRange(entities);
_employeeBankInformationRepository.SaveChanges();
return op.Succcedded();
}
public List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId)
{
return _employeeBankInformationRepository.GetAllByWorkshopId(workshopId);
}
#region Private Methods
private bool HasAtLeastOneFormFilled(CreateEmployeeInformation inputs)
{
return !string.IsNullOrWhiteSpace(inputs.BankAccountNumber) ||
!string.IsNullOrWhiteSpace(inputs.CardNumber) ||
!string.IsNullOrWhiteSpace(inputs.ShebaNumber);
}
private bool HasNoRecordInWorkshop(long workshopId, long employeeId)
{
return !_employeeBankInformationRepository.Exists(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
}
#endregion
}
}

View File

@@ -51,15 +51,15 @@ public class LoanApplication : ILoanApplication
var lastInstallment = installment.MaxBy(x => x.DateGr).DateGr;
#region Validation
if (startInstallmentDate.Date < now.Date)
{
return op.Failed("تاریخ شروع وام نمیتواند در گذشته باشد");
}
//if (startInstallmentDate.Date < now.Date)
//{
// return op.Failed("تاریخ شروع وام نمیتواند در گذشته باشد");
//}
if (loanGrantDate>now)
{
return op.Failed("تاریخ پرداخت وام می بایست تاریخ امروز یا قبل تر باشد");
}
//if (loanGrantDate>now)
//{
// return op.Failed("تاریخ پرداخت وام می بایست تاریخ امروز یا قبل تر باشد");
//}
if (!command.LoanGrantDate.TryToGeorgianDateTime(out var grantDate))
{
@@ -68,12 +68,12 @@ public class LoanApplication : ILoanApplication
if (amountD < 1000000)
return op.Failed("حداقل مبلغ وام 1.000.000 ریال میباشد");
if (_customizeCheckoutRepository.Exists(x =>
command.EmployeeIds.Contains(x.EmployeeId) && x.WorkshopId == command.WorkshopId &&
(x.ContractStart > startInstallmentDate && x.ContractStart < lastInstallment)))
{
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است وام دهید");
}
//if (_customizeCheckoutRepository.Exists(x =>
// command.EmployeeIds.Contains(x.EmployeeId) && x.WorkshopId == command.WorkshopId &&
// (x.ContractStart > startInstallmentDate && x.ContractStart < lastInstallment)))
//{
// return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است وام دهید");
//}
#endregion

View File

@@ -30,6 +30,11 @@ public class RewardApplication : IRewardApplication
return _rewardRepository.GetSearchList(searchModel);
}
public EditRewardViewModel GetDetails(long id)
{
return _rewardRepository.GetDetails(id);
@@ -100,7 +105,7 @@ public class RewardApplication : IRewardApplication
foreach (var employeeId in command.EmployeeIds)
{
var entity = new Reward(employeeId, command.WorkshopId, command.Amount.MoneyToDouble(), command.Description,
command.RewardedByAccountId, grantDate);
command.RewardedByAccountId, grantDate,command.Title);
_rewardRepository.Create(entity);
}
@@ -140,9 +145,20 @@ public class RewardApplication : IRewardApplication
return op.Failed("شما نمیتوانید برای پرسنلی در تاریخی که برای فیش حقوقی صادر شده است پاداشی دهید");
}
entity.Edit(command.Amount.MoneyToDouble(),command.Description,command.RewardedByAccountId, grantDate);
entity.Edit(command.Amount.MoneyToDouble(),command.Description,command.RewardedByAccountId, grantDate,command.Title);
_rewardRepository.SaveChanges();
return op.Succcedded(entity.id);
}
#region Pooya
/// <summary>
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
/// </summary>
public List<MonthlyGroupedEmployeeRewardsViewModel> GetSearchListByEmployee(RewardSearchModel searchModel)
{
return _rewardRepository.GetSearchListByEmployee(searchModel);
}
#endregion
}

View File

@@ -414,7 +414,7 @@ public class RollCallApplication : IRollCallApplication
List<(DateTime Start, DateTime End, long RollCallId)> result = new();
if (workshopSettings.WorkshopShiftStatus == WorkshopShiftStatus.Regular || employeeSettings == WorkshopShiftStatus.Regular)
if (employeeSettings == WorkshopShiftStatus.Regular)
{
TimeOnly offset =
@@ -554,7 +554,7 @@ public class RollCallApplication : IRollCallApplication
//---
if (result == null || !result.All(x => employeeStatuses.Any(y => x.Start >= y.StartDateGr || x.End <= y.EndDateGr)))
if (result == null || !result.All(newRollcall => employeeStatuses.Any(status => newRollcall.Start >= status.StartDateGr && newRollcall.End <= status.EndDateGr)))
return operation.Failed("کارمند در بازه وارد شده غیر فعال است");

View File

@@ -62,8 +62,11 @@ namespace CompanyManagment.Application
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
{
//موقت
//یکتا تجارت گیل 108 - کهن سرویس وارنا 215 - دادمهرگستر 11
if(workshopId == 108 || workshopId == 215 || workshopId == 11)
// دادمهرگستر 11
//585 کاشی گالری سرامیس (بابک ابراهیمی )
//آموزشگاه ملل 604
//کاریابی ملل 605
if(workshopId == 11 || workshopId == 585 || workshopId == 604 || workshopId == 605)
return false;
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);

View File

@@ -331,6 +331,12 @@ public class WorkshopAppliction : IWorkshopApplication
}
public string GetWorkshopFullname(long id)
{
var workshop = _workshopRepository.Get(id);
return workshop == null ? "" : workshop.WorkshopFullName;
}
public EditWorkshop GetDetails(long id)
{
var workshop = _workshopRepository.GetDetails(id);

View File

@@ -1,4 +1,5 @@
using Company.Domain.AndroidApkVersionAgg;
using Company.Domain.BankAgg;
using Company.Domain.BillAgg;
using Company.Domain.Board;
using Company.Domain.BoardType;
@@ -22,6 +23,7 @@ using Company.Domain.DateSalaryAgg;
using Company.Domain.DateSalaryItemAgg;
using Company.Domain.EmployeeAccountAgg;
using Company.Domain.EmployeeAgg;
using Company.Domain.EmployeeBankInformationAgg;
using Company.Domain.EmployeeChildrenAgg;
using Company.Domain.EmployeeComputeOptionsAgg;
using Company.Domain.EmployeeInsuranceRecordAgg;
@@ -170,10 +172,13 @@ public class CompanyContext : DbContext
public DbSet<WorkshopSubAccount> WorkshopSubAccounts { get; set; }
#endregion
public DbSet<Bank> Banks { get; set; }
public DbSet<EmployeeBankInformation> EmployeeBankInformationSet { get; set; }
#endregion
public DbSet<CustomizeCheckout> CustomizeCheckouts { get; set; }
public DbSet<CustomizeCheckout> CustomizeCheckouts { get; set; }
public DbSet<CustomizeCheckoutTemp> CustomizeCheckoutTemps { get; set; }
public DbSet<TaxLeftWorkItem> TaxLeftWorkItems { get; set; }
public DbSet<TaxLeftWorkCategory> TaxLeftWorkCategories { get; set; }

View File

@@ -0,0 +1,15 @@
using Company.Domain.BankAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping
{
public class BankMapping : IEntityTypeConfiguration<Bank>
{
public void Configure(EntityTypeBuilder<Bank> builder)
{
builder.ToTable("Banks");
builder.Property(x => x.BankName).HasMaxLength(50);
}
}
}

View File

@@ -72,6 +72,8 @@ public class CustomizeCheckoutMapping : IEntityTypeConfiguration<CustomizeChecko
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
installments.Property(x => x.Year).HasMaxLength(4);
installments.Property(x => x.Month).HasMaxLength(2);
installments.Property(x => x.LoanRemaining).HasMaxLength(25);
installments.Property(x => x.LoanAmount).HasMaxLength(30);
});
builder.OwnsMany(x => x.CustomizeCheckoutSalaryAids, salaryAid =>
@@ -83,6 +85,7 @@ public class CustomizeCheckoutMapping : IEntityTypeConfiguration<CustomizeChecko
builder.OwnsMany(x => x.CustomizeCheckoutRewards, rewards =>
{
rewards.Property(x => x.GrantDateFa).HasMaxLength(15);
rewards.Property(x => x.Title).HasMaxLength(255);
rewards.Property(x=>x.IsActive).HasConversion(
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);

View File

@@ -72,7 +72,10 @@ public class CustomizeCheckoutTempMapping : IEntityTypeConfiguration<CustomizeCh
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
installments.Property(x => x.Year).HasMaxLength(4);
installments.Property(x => x.Month).HasMaxLength(2);
});
installments.Property(x => x.LoanRemaining).HasMaxLength(25);
installments.Property(x => x.LoanAmount).HasMaxLength(30);
});
builder.OwnsMany(x => x.CustomizeCheckoutSalaryAids, salaryAid =>
{
@@ -83,7 +86,8 @@ public class CustomizeCheckoutTempMapping : IEntityTypeConfiguration<CustomizeCh
builder.OwnsMany(x => x.CustomizeCheckoutRewards, rewards =>
{
rewards.Property(x => x.GrantDateFa).HasMaxLength(15);
rewards.Property(x => x.IsActive).HasConversion(
rewards.Property(x => x.Title).HasMaxLength(255);
rewards.Property(x => x.IsActive).HasConversion(
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
rewards.Property(x => x.Amount).HasMaxLength(25);

View File

@@ -0,0 +1,22 @@
using Company.Domain.EmployeeBankInformationAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping
{
public class EmployeeBankInformationMapping:IEntityTypeConfiguration<EmployeeBankInformation>
{
public void Configure(EntityTypeBuilder<EmployeeBankInformation> builder)
{
builder.ToTable("EmployeeBankInformationSet");
builder.Property(x => x.BankAccountNumber).HasMaxLength(20);
builder.Property(x => x.CardNumber).HasMaxLength(16);
builder.Property(x => x.ShebaNumber).HasMaxLength(26);
builder.HasOne(x => x.Employee).WithMany(x => x.EmployeeBankInformationList)
.HasForeignKey(x => x.EmployeeId);
}
}
}

View File

@@ -74,10 +74,12 @@ public class EmployeeMapping : IEntityTypeConfiguration<Employee>
.WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
#region Pooya
#region Pooya
builder.HasMany(x => x.EmployeeBankInformationList).WithOne(x => x.Employee)
.HasForeignKey(x => x.EmployeeId);
builder.Ignore(x => x.FullName);
builder.Ignore(x => x.FullName);
#endregion
}

View File

@@ -17,6 +17,7 @@ public class LoanMapping : IEntityTypeConfiguration<Loan>
builder.OwnsMany(x => x.LoanInstallments, installment =>
{
installment.HasKey(x=>x.Id);
installment.Property(x => x.Month).HasMaxLength(2);
installment.Property(x => x.Year).HasMaxLength(4);
@@ -25,7 +26,7 @@ public class LoanMapping : IEntityTypeConfiguration<Loan>
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
installment.WithOwner().HasForeignKey("LoanId");
installment.WithOwner().HasForeignKey(x=>x.LoanId);
});
builder.Ignore(x => x.StartDateYear);

View File

@@ -16,6 +16,7 @@ public class RewardMapping:IEntityTypeConfiguration<Reward>
v => v.ToString(),
v => (IsActive)Enum.Parse(typeof(IsActive), v)).HasMaxLength(5);
builder.Property(x => x.Description).HasColumnType("ntext");
builder.Property(x => x.Title).HasMaxLength(255);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddtitleToReward : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Title",
table: "Rewards",
type: "nvarchar(255)",
maxLength: 255,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Title",
table: "Rewards");
}
}
}

View File

@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddRmaningAmountToChekoutOInstallments : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Title",
table: "CustomizeCheckoutTempReward",
type: "nvarchar(255)",
maxLength: 255,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LoanRemaining",
table: "CustomizeCheckoutTempLoanInstallments",
type: "nvarchar(25)",
maxLength: 25,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Title",
table: "CustomizeCheckoutReward",
type: "nvarchar(255)",
maxLength: 255,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LoanRemaining",
table: "CustomizeCheckoutLoanInstallments",
type: "nvarchar(25)",
maxLength: 25,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Title",
table: "CustomizeCheckoutTempReward");
migrationBuilder.DropColumn(
name: "LoanRemaining",
table: "CustomizeCheckoutTempLoanInstallments");
migrationBuilder.DropColumn(
name: "Title",
table: "CustomizeCheckoutReward");
migrationBuilder.DropColumn(
name: "LoanRemaining",
table: "CustomizeCheckoutLoanInstallments");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class LoaneIdAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,81 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class EbiAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Banks",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
BankName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
BankLogoMediaId = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Banks", x => x.id);
});
migrationBuilder.CreateTable(
name: "EmployeeBankInformationSet",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<long>(type: "bigint", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: false),
BankId = table.Column<long>(type: "bigint", nullable: false),
BankAccountNumber = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
CardNumber = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: true),
ShebaNumber = table.Column<string>(type: "nvarchar(26)", maxLength: 26, nullable: true),
IsDefault = table.Column<bool>(type: "bit", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeBankInformationSet", x => x.id);
table.ForeignKey(
name: "FK_EmployeeBankInformationSet_Banks_BankId",
column: x => x.BankId,
principalTable: "Banks",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EmployeeBankInformationSet_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_EmployeeBankInformationSet_BankId",
table: "EmployeeBankInformationSet",
column: "BankId");
migrationBuilder.CreateIndex(
name: "IX_EmployeeBankInformationSet_EmployeeId",
table: "EmployeeBankInformationSet",
column: "EmployeeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EmployeeBankInformationSet");
migrationBuilder.DropTable(
name: "Banks");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addloanamounttocheckout : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "LoanAmount",
table: "CustomizeCheckoutTempLoanInstallments",
type: "nvarchar(30)",
maxLength: 30,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LoanAmount",
table: "CustomizeCheckoutLoanInstallments",
type: "nvarchar(30)",
maxLength: 30,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LoanAmount",
table: "CustomizeCheckoutTempLoanInstallments");
migrationBuilder.DropColumn(
name: "LoanAmount",
table: "CustomizeCheckoutLoanInstallments");
}
}
}

View File

@@ -59,6 +59,26 @@ namespace CompanyManagment.EFCore.Migrations
b.ToTable("AndroidApkVersions", (string)null);
});
modelBuilder.Entity("Company.Domain.BankAgg.Bank", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<long>("BankLogoMediaId")
.HasColumnType("bigint");
b.Property<string>("BankName")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("id");
b.ToTable("Banks", (string)null);
});
modelBuilder.Entity("Company.Domain.BillAgg.EntityBill", b =>
{
b.Property<long>("id")
@@ -1513,6 +1533,50 @@ namespace CompanyManagment.EFCore.Migrations
b.ToTable("Employees", (string)null);
});
modelBuilder.Entity("Company.Domain.EmployeeBankInformationAgg.EmployeeBankInformation", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<string>("BankAccountNumber")
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<long>("BankId")
.HasColumnType("bigint");
b.Property<string>("CardNumber")
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<long>("EmployeeId")
.HasColumnType("bigint");
b.Property<bool>("IsDefault")
.HasColumnType("bit");
b.Property<string>("ShebaNumber")
.HasMaxLength(26)
.HasColumnType("nvarchar(26)");
b.Property<long>("WorkshopId")
.HasColumnType("bigint");
b.HasKey("id");
b.HasIndex("BankId");
b.HasIndex("EmployeeId");
b.ToTable("EmployeeBankInformationSet", (string)null);
});
modelBuilder.Entity("Company.Domain.EmployeeChildrenAgg.EmployeeChildren", b =>
{
b.Property<long>("id")
@@ -3983,6 +4047,10 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<long>("RewardedByAccountId")
.HasColumnType("bigint");
b.Property<string>("Title")
.HasMaxLength(255)
.HasColumnType("nvarchar(255)");
b.Property<long>("WorkshopId")
.HasColumnType("bigint");
@@ -5525,6 +5593,14 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b1.Property<string>("LoanAmount")
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b1.Property<string>("LoanRemaining")
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b1.Property<string>("Month")
.HasMaxLength(2)
.HasColumnType("nvarchar(2)");
@@ -5571,6 +5647,10 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b1.Property<string>("Title")
.HasMaxLength(255)
.HasColumnType("nvarchar(255)");
b1.HasKey("CustomizeCheckoutid", "Id");
b1.ToTable("CustomizeCheckoutReward");
@@ -5698,6 +5778,14 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b1.Property<string>("LoanAmount")
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b1.Property<string>("LoanRemaining")
.HasMaxLength(25)
.HasColumnType("nvarchar(25)");
b1.Property<string>("Month")
.HasMaxLength(2)
.HasColumnType("nvarchar(2)");
@@ -5744,6 +5832,10 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b1.Property<string>("Title")
.HasMaxLength(255)
.HasColumnType("nvarchar(255)");
b1.HasKey("CustomizeCheckoutTempid", "Id");
b1.ToTable("CustomizeCheckoutTempReward");
@@ -7423,6 +7515,25 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("Employee");
});
modelBuilder.Entity("Company.Domain.EmployeeBankInformationAgg.EmployeeBankInformation", b =>
{
b.HasOne("Company.Domain.BankAgg.Bank", "Bank")
.WithMany()
.HasForeignKey("BankId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Company.Domain.EmployeeAgg.Employee", "Employee")
.WithMany("EmployeeBankInformationList")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bank");
b.Navigation("Employee");
});
modelBuilder.Entity("Company.Domain.EmployeeChildrenAgg.EmployeeChildren", b =>
{
b.HasOne("Company.Domain.EmployeeAgg.Employee", "Employee")
@@ -7744,9 +7855,6 @@ namespace CompanyManagment.EFCore.Migrations
{
b.OwnsMany("Company.Domain.LoanAgg.Entities.LoanInstallment", "LoanInstallments", b1 =>
{
b1.Property<long>("LoanId")
.HasColumnType("bigint");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
@@ -7764,6 +7872,9 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b1.Property<long>("LoanId")
.HasColumnType("bigint");
b1.Property<string>("Month")
.HasMaxLength(2)
.HasColumnType("nvarchar(2)");
@@ -7772,7 +7883,9 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b1.HasKey("LoanId", "Id");
b1.HasKey("Id");
b1.HasIndex("LoanId");
b1.ToTable("LoanInstallment");
@@ -8165,6 +8278,8 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("CustomizeCheckouts");
b.Navigation("EmployeeBankInformationList");
b.Navigation("EmployeeChildrenList");
b.Navigation("EmployeeInsuranceRecords");

View File

@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using _0_Framework.InfraStructure;
using Company.Domain.BankAgg;
using CompanyManagment.App.Contracts.Bank;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository
{
public class BankRepository:RepositoryBase<long,Bank>,IBankRepository
{
private readonly CompanyContext context;
public BankRepository(CompanyContext context) : base(context)
{
this.context = context;
}
public List<BankViewModel> Search(string name)
{
var query = context.Banks.AsQueryable();
if (!string.IsNullOrWhiteSpace(name))
query = query.Where(x => x.BankName.Contains(name));
return query.Select(x => new BankViewModel()
{
BankName = x.BankName,
Id = x.id,
BankLogoPictureMediaId = x.BankLogoMediaId
}).ToList();
}
}
}

View File

@@ -16,6 +16,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Company.Domain.CustomizeCheckoutAgg.ValueObjects;
using CompanyManagment.App.Contracts.Fine;
using CompanyManagment.App.Contracts.Loan;
using CompanyManagment.App.Contracts.Reward;
@@ -88,7 +89,7 @@ namespace CompanyManagment.EFCore.Repository
//IQueryable<Employee> employeesQuery = _companyContext.Employees.Where(x => customizeCheckoutsQuery.Any(y => y.EmployeeId == x.id));
var loans = _companyContext.Loans.AsSplitQuery().Where(x => x.WorkshopId == workshopId).ToList();
List<CustomizeCheckoutViewModel> customizeCheckoutsList = customizeCheckoutsQuery.Select(x => new CustomizeCheckoutViewModel
{
@@ -140,15 +141,19 @@ namespace CompanyManagment.EFCore.Repository
}).ToList(),
InstallmentViewModels = x.CustomizeCheckoutLoanInstallments.Select(i=>new LoanInstallmentViewModel()
{
Amount = i.AmountForMonth,
//موقتا مبلغ کل وام بجای قسط ارسال شده است
Amount = i.LoanAmount,
AmountDouble = i.AmountForMonth.MoneyToDouble(),
Year = i.Year,
Month = i.Month,
IsActive = i.IsActive,
RemainingAmount = i.LoanRemaining,
LoanAmount = i.LoanAmount
}).ToList(),
RewardViewModels = x.CustomizeCheckoutRewards.Select(r=>new RewardViewModel()
{
IsActive = r.IsActive,
Title = r.Title,
Amount = r.Amount,
AmountDouble =r.Amount.MoneyToDouble(),
Description = r.Description,

View File

@@ -8,8 +8,12 @@ using Company.Domain.RollCallAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.CustomizeCheckout;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.Fine;
using CompanyManagment.App.Contracts.Loan;
using CompanyManagment.App.Contracts.PersonnleCode;
using CompanyManagment.App.Contracts.Reward;
using CompanyManagment.App.Contracts.RollCall;
using CompanyManagment.App.Contracts.SalaryAid;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.EntityFrameworkCore;
using System;
@@ -263,7 +267,43 @@ namespace CompanyManagment.EFCore.Repository
EmployeeLName = x.EmployeeLName,
EarlyExitDeduction = x.EarlyExitDeduction.ToMoney(),
LateToWorkDeduction = x.LateToWorkDeduction.ToMoney(),
FineDeduction = x.FineDeduction.ToMoney()
FineDeduction = x.FineDeduction.ToMoney(),
FineViewModelList = x.CheckoutFines.Select(y => new FineViewModel()
{
Amount = y.Amount,
FineDate = y.FineDateFa,
Title = y.Title
}).ToList(),
InstallmentViewModels = x.CustomizeCheckoutLoanInstallments.Select(i => new LoanInstallmentViewModel()
{
//موقتا مبلغ کل وام بجای قسط ارسال شده است
Amount = i.LoanAmount,
AmountDouble = i.AmountForMonth.MoneyToDouble(),
Year = i.Year,
Month = i.Month,
IsActive = i.IsActive,
RemainingAmount = i.LoanRemaining,
LoanAmount = i.LoanAmount
}).ToList(),
RewardViewModels = x.CustomizeCheckoutRewards.Select(r => new RewardViewModel()
{
IsActive = r.IsActive,
Title = r.Title,
Amount = r.Amount,
AmountDouble = r.Amount.MoneyToDouble(),
Description = r.Description,
GrantDateFa = r.GrantDateFa,
GrantDateGr = r.GrantDate
}).ToList(),
SalaryAidViewModels = x.CustomizeCheckoutSalaryAids.Select(s => new SalaryAidViewModel()
{
Amount = s.Amount,
AmountDouble = s.Amount.MoneyToDouble(),
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
SalaryAidDateTimeGe = s.SalaryAidDateTime
}).ToList(),
}).ToList();
List<WorkshopViewModel> workshopsList = workshopsQuery.Select(x => new WorkshopViewModel

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.JavaScript;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.CustomizeWorkshopGroupSettingsAgg;
@@ -73,29 +74,76 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
public List<EmployeeViewModel> GetEmployeesWithoutGroupByWorkshopId(long workshopId)
{
var workshopSettings = _companyContext.CustomizeWorkshopSettings.Where(x=>x.WorkshopId==workshopId);
//var workshopSettings = _companyContext.CustomizeWorkshopSettings.Where(x=>x.WorkshopId==workshopId);
if (workshopSettings == null)
return new();
//if (workshopSettings == null)
// return new();
var existsEmployees = _companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => x.WorkshopId == workshopId && !x.CustomizeWorkshopGroupSettings.MainGroup)
.Select(x => x.EmployeeId).ToList();
var dateNow = DateTime.Now.Date;
var rollCallEmployees = _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
//var existsEmployees = _companyContext.CustomizeWorkshopEmployeeSettings
// .AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettings)
// .Where(x => x.WorkshopId == workshopId && !x.CustomizeWorkshopGroupSettings.MainGroup)
// .Select(x => x.EmployeeId).ToList();
var employees = rollCallEmployees
.Where(x => !existsEmployees.Contains(x.EmployeeId))
.Select(x => new EmployeeViewModel()
{
EmployeeFullName = x.EmployeeFullName,
Id = x.EmployeeId
}).ToList();
//var rollCallEmployees = _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
return employees;
//var employees = rollCallEmployees
// .Where(x => !existsEmployees.Contains(x.EmployeeId))
// .Select(x => new EmployeeViewModel()
// {
// EmployeeFullName = x.EmployeeFullName,
// Id = x.EmployeeId
// }).ToList();
var employees = _companyContext.RollCallEmployees
.Include(x =>
x.EmployeesStatus)
.Where(
x =>
x.WorkshopId == workshopId &&
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
x.HasUploadedImage == "true")
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery()
.Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => !x.CustomizeWorkshopGroupSettings.MainGroup && x.WorkshopId == workshopId), rollCallEmployee => rollCallEmployee.EmployeeId,
cws => cws.EmployeeId,
(rollCallEmployee, cws) => new { rollCallEmployee, cws })
.SelectMany(x => x.cws.DefaultIfEmpty(), (x, cws) => new { x.rollCallEmployee, cws })
.Where(x => x.cws == null).Select(x=> new EmployeeViewModel()
{
EmployeeFullName = x.rollCallEmployee.EmployeeFullName,
Id = x.rollCallEmployee.EmployeeId
});
return employees.ToList();
}
public bool HasAnyEmployeeWithoutGroup(long workshopId)
{
var dateNow = DateTime.Now.Date;
var rollCallEmployeesWithoutCWS = _companyContext.RollCallEmployees
.Include(x =>
x.EmployeesStatus)
.Where(
x =>
x.WorkshopId == workshopId &&
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
x.HasUploadedImage == "true")
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery()
.Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => !x.CustomizeWorkshopGroupSettings.MainGroup && x.WorkshopId == workshopId), rollCallEmployee => rollCallEmployee.EmployeeId,
cws => cws.EmployeeId,
(rollCallEmployee, cws) => new { rollCallEmployee, cws })
.SelectMany(x => x.cws.DefaultIfEmpty(), (x, cws) => new { x.rollCallEmployee, cws })
.Any(x => x.cws == null);
return rollCallEmployeesWithoutCWS;
}
public CustomizeWorkshopGroupSettings GetWithEmployees(long groupId)
{
return _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery().Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
@@ -308,4 +356,20 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
_companyContext.Remove(entity);
_companyContext.SaveChanges();
}
public CustomizeWorkshopGroupSettingsViewModel GetEmployeesGroupSettingsByEmployeeId(long employeeId, long workshopId)
{
return _companyContext.CustomizeWorkshopGroupSettings
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.AsSplitQuery()
.Where(x => x.CustomizeWorkshopEmployeeSettingsCollection.Any(e =>
e.EmployeeId == employeeId && e.WorkshopId == workshopId)).Select(x =>
new CustomizeWorkshopGroupSettingsViewModel()
{
Id = x.id,
GroupName = x.GroupName,
Salary = x.Salary,
MainGroup = x.MainGroup
}).FirstOrDefault();
}
}

View File

@@ -0,0 +1,192 @@
using _0_Framework.InfraStructure;
using AccountMangement.Infrastructure.EFCore;
using Company.Domain.EmployeeBankInformationAgg;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
namespace CompanyManagment.EFCore.Repository
{
public class EmployeeBankInformationRepository : RepositoryBase<long, EmployeeBankInformation>, IEmployeeBankInformationRepository
{
private readonly CompanyContext _companyContext;
private readonly AccountContext _accountContext;
public EmployeeBankInformationRepository(CompanyContext context, CompanyContext companyContext, AccountContext accountContext) : base(context)
{
_companyContext = companyContext;
_accountContext = accountContext;
}
public List<GroupedEmployeeBankInformationViewModel> Search(long workshopId, EmployeeBankInformationSearchModel searchParams)
{
var bankInfoQuery = _companyContext.EmployeeBankInformationSet.Where(x => x.WorkshopId == workshopId)
.Include(x => x.Employee).Include(x => x.Bank)
.Select(x => new
{
x.Bank,
x.BankId,
FullName = (x.Employee.FName + " " + x.Employee.LName),
x.EmployeeId,
x.WorkshopId,
})
.AsQueryable();
if (searchParams.BankId > 0)
bankInfoQuery = bankInfoQuery.Where(x => x.BankId == searchParams.BankId);
if (searchParams.EmployeeId > 0)
bankInfoQuery = bankInfoQuery.Where(x => x.EmployeeId == searchParams.EmployeeId);
var personnelCodes =
_companyContext.PersonnelCodeSet.Where(x => bankInfoQuery.Any(y => y.EmployeeId == x.EmployeeId)).ToList();
var bankInfoList = bankInfoQuery.ToList();
var groupedBanks = bankInfoList.GroupBy(x => x.Bank).Select(x => x.Key).ToList();
//Get bank logos from account context
var mediaIds = groupedBanks.Select(x => x.BankLogoMediaId).ToList();
var banksLogos = _accountContext.Medias.Where(y => mediaIds.Contains(y.id))
.Select(media => new { media.Path, MediaId = media.id }).ToList();
return bankInfoList.GroupBy(x => x.EmployeeId).Select(x => new GroupedEmployeeBankInformationViewModel()
{
BankPicturesList = banksLogos.Select(y => y.Path).ToList(),
EmployeeId = x.Key,
WorkshopId = workshopId,
EmployeeName = x.FirstOrDefault()?.FullName ?? "",
TotalBankAccountsCount = x.Count(),
PersonnelCode = personnelCodes.FirstOrDefault(y => y.EmployeeId == x.Key)?.PersonnelCode.ToString() ?? "",
}).ToList();
}
public void RemoveByEmployeeId(IEnumerable<EmployeeBankInformation> entities)
{
_companyContext.EmployeeBankInformationSet.RemoveRange(entities);
}
public GroupedEmployeeBankInformationViewModel GetByEmployeeId(long workshopId, long employeeId)
{
//todo: optimize
var entities = _companyContext.EmployeeBankInformationSet
.Include(x => x.Bank).Include(x => x.Employee)
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
var personnelCode =
_companyContext.PersonnelCodeSet.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)?
.PersonnelCode.ToString() ?? "";
var bankInfoList = entities.ToList();
var groupedBanks = bankInfoList.GroupBy(x => x.Bank).Select(x => x.Key).ToList();
var mediaIds = groupedBanks.Select(x => x.BankLogoMediaId).ToList();
var banksLogos = _accountContext.Medias.Where(y => mediaIds.Contains(y.id))
.Select(media => new { media.Path, MediaId = media.id }).ToList();
return new GroupedEmployeeBankInformationViewModel()
{
BankPicturesList = banksLogos.Select(y => y.Path).ToList(),
EmployeeId = employeeId,
WorkshopId = workshopId,
EmployeeName = entities.FirstOrDefault()?.Employee.FullName ?? "",
TotalBankAccountsCount = entities.Count(),
PersonnelCode = personnelCode,
BankInformation = entities.Select(y => new EmployeeBankInformationViewModel()
{
Id = y.id,
BankId = y.BankId,
BankAccountNumber = y.BankAccountNumber,
BankName = y.Bank.BankName,
CardNumber = y.CardNumber,
ShebaNumber = y.ShebaNumber,
IsDefault = y.IsDefault
}).OrderByDescending(y=>y.IsDefault).ToList()
};
}
public List<EmployeeBankInformation> GetRangeByEmployeeId(long workshopId, long employeeId)
{
return _companyContext.EmployeeBankInformationSet.Where(x =>
x.WorkshopId == workshopId && x.EmployeeId == employeeId).ToList();
}
public void RemoveRange(List<EmployeeBankInformation> entities)
{
_companyContext.EmployeeBankInformationSet.RemoveRange(entities);
}
public EmployeeBankInformationViewModel GetDetails(long id)
{
var entity = _companyContext.EmployeeBankInformationSet.Include(x => x.Bank)
.Include(x => x.Employee).FirstOrDefault(x => x.id == id);
if (entity == null)
return new();
var mediaId = entity.Bank.BankLogoMediaId;
var mediaPath = _accountContext.Medias.FirstOrDefault(x => x.id == mediaId)?.Path ?? "";
return new EmployeeBankInformationViewModel()
{
EmployeeId = entity.EmployeeId,
BankAccountNumber = entity.BankAccountNumber,
BankLogoPath = mediaPath,
BankName = entity.Bank.BankName,
CardNumber = entity.CardNumber,
EmployeeName = entity.Employee.FullName,
Id = entity.id,
ShebaNumber = entity.ShebaNumber,
IsDefault = entity.IsDefault
};
}
public List<GroupedEmployeeBankInformationViewModel> GetAllByWorkshopId(long workshopId)
{
//todo: optimize
var bankInfoQuery = _companyContext.EmployeeBankInformationSet.Where(x => x.WorkshopId == workshopId)
.Include(x => x.Employee).Include(x => x.Bank).AsQueryable();
var personnelCodes =
_companyContext.PersonnelCodeSet.Where(x => bankInfoQuery.Any(y => y.EmployeeId == x.EmployeeId));
var bankInfoList = bankInfoQuery.ToList();
//Get bank logos from account context
var groupedBanks = bankInfoList.GroupBy(x => x.Bank).Select(x => x.Key).ToList();
var mediaIds = groupedBanks.Select(x => x.BankLogoMediaId).ToList();
var banksLogos = _accountContext.Medias.Where(y => mediaIds.Contains(y.id))
.Select(media => new { media.Path, MediaId = media.id }).ToList();
return bankInfoQuery.GroupBy(x => x.Employee).Select(x => new GroupedEmployeeBankInformationViewModel()
{
BankPicturesList = banksLogos.Select(y => y.Path).ToList(),
EmployeeId = x.Key.id,
WorkshopId = workshopId,
EmployeeName = x.Key.FullName,
TotalBankAccountsCount = x.Count(),
PersonnelCode = personnelCodes.FirstOrDefault(y => y.EmployeeId == x.Key.id).PersonnelCode.ToString(),
BankInformation = x.OrderByDescending(y=>y.IsDefault).Select(y => new EmployeeBankInformationViewModel()
{
Id = y.id,
BankAccountNumber = y.BankAccountNumber,
BankName = y.Bank.BankName,
CardNumber = y.CardNumber,
ShebaNumber = y.ShebaNumber,
IsDefault = y.IsDefault,
}).ToList()
}).ToList();
}
}
}

View File

@@ -89,7 +89,8 @@ public class HolidayItemRepository : RepositoryBase<long, HolidayItem>, IHoliday
Id = x.id,
Holidaydate = x.Holidaydate.ToFarsi(),
HolidayId = x.HolidayId,
HolidayYear = x.HolidayYear
HolidayYear = x.HolidayYear,
HolidaydateGr = x.Holidaydate
});
if (!string.IsNullOrWhiteSpace(searchModel.HolidayYear))
query = query.Where(x => x.HolidayYear.Contains(searchModel.HolidayYear));

View File

@@ -32,6 +32,7 @@ public class RewardRepository : RepositoryBase<long, Reward>, IRewardRepository
var result = query.OrderByDescending(x=>x.CreationDate).Select(x => new RewardViewModel()
{
Id = x.id,
Title = x.Title,
EmployeeId = x.EmployeeId,
Description = x.Description,
Amount = x.Amount.ToMoney(),
@@ -45,9 +46,10 @@ public class RewardRepository : RepositoryBase<long, Reward>, IRewardRepository
.Where(x => result.Any(a => a.EmployeeId == x.EmployeeId && x.WorkshopId == a.WorkshopId));
return result.Select(x => new RewardViewModel()
{
Title = x.Title,
Amount = x.Amount,
CreationDate = x.CreationDate,
Description = x.Description,
Description = x.Description ?? "-",
GrantDateFa = x.GrantDateFa,
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName ,
Id = x.Id,
@@ -67,6 +69,7 @@ public class RewardRepository : RepositoryBase<long, Reward>, IRewardRepository
var res = new EditRewardViewModel()
{
Id = entity.id,
Title = entity.Title,
WorkshopId = entity.WorkshopId,
EmployeeId = entity.EmployeeId,
Amount = entity.Amount.ToMoney(),
@@ -84,4 +87,55 @@ public class RewardRepository : RepositoryBase<long, Reward>, IRewardRepository
{
return _companyContext.Rewards.Where(x => ids.Contains(x.id)).ToList();
}
#region Pooya
/// <summary>
/// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند
/// </summary>
public List<MonthlyGroupedEmployeeRewardsViewModel> GetSearchListByEmployee(RewardSearchModel searchModel)
{
var query = _companyContext.Rewards.Where(x => x.EmployeeId == searchModel.EmployeeId && x.WorkshopId == searchModel.WorkshopId && x.IsActive == IsActive.True);
if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
{
var startDate = searchModel.StartDate.ToGeorgianDateTime();
var endDate = searchModel.EndDate.ToGeorgianDateTime();
query = query.Where(x => x.GrantDate >= startDate && x.GrantDate <= endDate);
}
var personnelCode = _companyContext.PersonnelCodeSet
.FirstOrDefault(x => x.EmployeeId == searchModel.EmployeeId && x.WorkshopId == searchModel.WorkshopId);
var employee = _companyContext.Employees.FirstOrDefault(x => x.id == searchModel.EmployeeId);
if (employee == null)
return new();
var result = query.Select(x => new RewardViewModel()
{
Id = x.id,
EmployeeId = x.EmployeeId,
Description = x.Description,
Amount = x.Amount.ToMoney(),
WorkshopId = x.WorkshopId,
CreationDate = x.CreationDate.ToFarsi(),
GrantDateFa = x.GrantDate.ToFarsi(),
PersonnelCode = personnelCode.PersonnelCode.ToString(),
EmployeeFullName = employee.FullName,
}).Skip(searchModel.PageIndex).Take(30).ToList();
result.ForEach(x =>
{
x.YearFa = x.GrantDateFa.Substring(0, 4);
x.MonthFa = x.GrantDateFa.Substring(5, 2);
});
return result.GroupBy(x => new { x.YearFa, x.MonthFa }).Select(x => new MonthlyGroupedEmployeeRewardsViewModel()
{
YearFa = x.Key.YearFa,
MonthFa = x.Key.MonthFa,
MonthFaName = x.Key.MonthFa.ToFarsiMonthByNumber(),
Rewards = x.ToList(),
EmployeeId = searchModel.EmployeeId,
PersonnelCode = personnelCode.PersonnelCode.ToString()
}).OrderByDescending(x => x.YearFa).ThenByDescending(x=>x.MonthFa).ToList();
}
#endregion
}

View File

@@ -581,7 +581,7 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
//initialize
DateTime searchDurationEnd = DateTime.Now.AddDays(-1).Date;
DateTime searchDurationStart = searchDurationEnd.AddDays(-16);
DateTime searchDurationStart = DateTime.MinValue;
@@ -792,9 +792,10 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
{
List<RollCallEmployee> activatedEmployeesListInDay = new();
bool isHoliday = totalHolidays.Any(x => x.HolidaydateGr == day);
//in working days everyone should be present
if (day.DayOfWeek != DayOfWeek.Friday && totalHolidays.All(x => x.HolidaydateGr != day))
if (day.DayOfWeek != DayOfWeek.Friday && !isHoliday)
{
activatedEmployeesListInDay = activatedEmployeesList;
}
@@ -832,7 +833,7 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
Id = x.id,
WorkshopId = x.WorkshopId
}),
IsHoliday = _holidayItemApplication.IsHoliday(day),
IsHoliday = isHoliday,
IsFriday = day.DayOfWeek == DayOfWeek.Friday
};
result.Add(item);

View File

@@ -179,6 +179,7 @@ using CompanyManagment.App.Contracts.Loan;
using CompanyManagment.App.Contracts.Reward;
using CompanyManagment.App.Contracts.SalaryAid;
using Company.Domain.AndroidApkVersionAgg;
using Company.Domain.BankAgg;
using CompanyManagment.App.Contracts.AndroidApkVersion;
using Company.Domain.FineSubjectAgg;
using CompanyManagment.App.Contracts.FineSubject;
@@ -186,7 +187,10 @@ using Company.Domain.CustomizeCheckoutAgg;
using CompanyManagment.App.Contracts.CustomizeCheckout;
using Company.Domain.WorkshopSubAccountAgg;
using Company.Domain.CustomizeCheckoutTempAgg;
using Company.Domain.EmployeeBankInformationAgg;
using Company.Domain.RollCallAgg.DomainService;
using CompanyManagment.App.Contracts.Bank;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
namespace PersonalContractingParty.Config;
@@ -406,6 +410,12 @@ public class PersonalBootstrapper
services.AddTransient<ICustomizeCheckoutTempApplication, CustomizeCheckoutTempApplication>();
services.AddTransient<IWorkshopSubAccountRepository, WorkshopSubAccountRepository>();
services.AddTransient<IBankRepository, BankRepository>();
services.AddTransient<IBankApplication, BankApplication>();
services.AddTransient<IEmployeeBankInformationRepository, EmployeeBankInformationRepository>();
services.AddTransient<IEmployeeBankInformationApplication, EmployeeBankInformationApplication>();
#endregion
services.AddTransient<IRollCallDomainService, RollCallDomainService>();

Some files were not shown because too many files have changed in this diff Show More