Compare commits

..

5 Commits

37 changed files with 969 additions and 1420 deletions

View File

@@ -5,6 +5,8 @@ on:
branches:
- Main
env:
DOTNET_ENVIRONMENT: Development
jobs:
build-and-deploy:
@@ -35,11 +37,12 @@ jobs:
& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" `
-verb:sync `
-source:contentPath="$publishFolder" `
-dest:contentPath="dadmehrg",computerName="https://$env:SERVER_HOST:8172/msdeploy.axd?site=gozareshgir",userName="$env:DEPLOY_USER",password="$env:DEPLOY_PASSWORD",authType="Basic" `
-dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R",authType="Basic" `
-allowUntrusted `
-enableRule:AppOffline
env:
SERVER_HOST: 171.22.24.15
SERVER_HOST: your-server-ip-or-domain
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}

View File

@@ -75,6 +75,7 @@ public interface IAccountApplication
void CameraLogin(CameraLoginRequest request);
Task<GetPmUserDto> GetPmUserAsync(long accountId);
}
public class CameraLoginRequest

View File

@@ -1024,5 +1024,4 @@ public class AccountApplication : IAccountApplication
{
return await _pmUserQueryService.GetPmUserDataByAccountId(accountId);
}
}

View File

@@ -1,5 +1,4 @@
using System;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using System.Collections.Generic;
using _0_Framework.Application;
using _0_Framework.Domain;
@@ -33,9 +32,7 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2);
OperationResult DeletePersonalContractingParties(long id);
bool GetHasContract(long id);
[Obsolete("از متدهای async استفاده کنید")]
OperationResult DeActiveAll(long id);
[Obsolete("از متدهای async استفاده کنید")]
OperationResult ActiveAll(long id);
#endregion
@@ -79,9 +76,4 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
Task<PersonalContractingParty> GetByNationalCode(string nationalCode);
Task<PersonalContractingParty> GetByNationalId(string registerId);
Task<OperationResult> DeActiveAllAsync(long id);
Task<OperationResult> ActiveAllAsync(long id);
}

View File

@@ -48,10 +48,6 @@ public interface IContractRepository : IRepository<long, Contract>
bool Remove(long id);
List<ContractViweModel> SearchForClient(ContractSearchModel searchModel);
Task<PagedResult<GetContractListForClientResponse>> GetContractListForClient(GetContractListForClientRequest searchModel);
Task<List<ContractPrintViewModel>> PrintAllAsync(List<long> ids);
#endregion
#region NewChangeByHeydari
@@ -67,8 +63,4 @@ public interface IContractRepository : IRepository<long, Contract>
ContractViweModel GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime startOfMonth, DateTime endOfMonth);
List<ContractViweModel> GetByWorkshopIdInDates(long workshopId, DateTime contractStart, DateTime contractEnd);
#endregion
}
}

View File

@@ -54,6 +54,7 @@ public interface IEmployeeRepository : IRepository<long, Employee>
Employee GetIgnoreQueryFilter(long id);
[Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")]
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
@@ -77,7 +78,32 @@ public interface IEmployeeRepository : IRepository<long, Employee>
Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id);
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
#endregion
/// <summary>
/// دریافت لیست پرسنل کلاینت
/// api
/// </summary>
/// <param name="searchModel"></param>
/// <param name="workshopId"></param>
/// <returns></returns>
Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId);
/// <summary>
/// پرینت تجمیعی پرسنل کلاینت
/// api
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
/// <summary>
/// سلکت لیست پرسنل های کارگاه کلاینت
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId);
#endregion
}

View File

@@ -23,8 +23,6 @@ public class InstitutionContractWorkshopGroup : EntityBase
!InitialWorkshops.Cast<InstitutionContractWorkshopBase>()
.SequenceEqual(CurrentWorkshops.Cast<InstitutionContractWorkshopBase>());
public bool IsInPersonContract => InitialWorkshops.Any(x => x.Services.ContractInPerson);
public InstitutionContractWorkshopGroup(long institutionContractId,
List<InstitutionContractWorkshopInitial> initialDetails)
{

View File

@@ -78,7 +78,6 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
#endregion
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
Task<InsuranceClientPrintViewModel> ClientPrintOne(long id);
}

View File

@@ -8,129 +8,86 @@ using System.Text.RegularExpressions;
namespace CompanyManagement.Infrastructure.Excel.InstitutionContract;
// Enum برای تعریف ستون‌های موجود
public enum ExcelColumnType
{
RowNumber, // ردیف
PhysicalContract, // قرارداد فیزیکی
ContractNo, // شماره قرارداد
Representative, // معرف
ContractingPartyName, // طرف حساب
ArchiveCode, // شماره کارفرما
EmployerName, // کارفرما
WorkshopName, // کارگاه‌ها (چندخطی)
WorkshopCount, // تعداد کارگاه
EmployeeCount, // مجموع پرسنل
ContractStartDate, // شروع قرارداد
ContractEndDate, // پایان قرارداد
InstallmentAmount, // مبلغ قسط
ContractAmount, // مبلغ قرارداد
FinancialStatus // وضعیت مالی
}
// کلاس کانفیگ برای تنظیم ستون‌های نمایشی
public class ExcelColumnConfig
{
public List<ExcelColumnType> VisibleColumns { get; set; }
public ExcelColumnConfig()
{
// فعلاً تمام ستون‌ها فعال هستند
VisibleColumns = new List<ExcelColumnType>
{
ExcelColumnType.PhysicalContract,
ExcelColumnType.ContractNo,
ExcelColumnType.Representative,
ExcelColumnType.ContractingPartyName,
ExcelColumnType.ArchiveCode,
ExcelColumnType.EmployerName,
ExcelColumnType.WorkshopName,
ExcelColumnType.WorkshopCount,
ExcelColumnType.EmployeeCount,
ExcelColumnType.ContractStartDate,
ExcelColumnType.ContractEndDate,
ExcelColumnType.InstallmentAmount,
ExcelColumnType.ContractAmount,
ExcelColumnType.FinancialStatus
};
}
}
public class InstitutionContractExcelGenerator
{
private static ExcelColumnConfig _columnConfig = new ExcelColumnConfig();
public static byte[] GenerateExcel(List<InstitutionContractExcelViewModel> contractViewModels)
public static byte[] GenerateExcel(List<InstitutionContractViewModel> institutionContractViewModels)
{
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization");
using var package = new ExcelPackage();
var allWorksheet = package.Workbook.Worksheets.Add("همه");
var blueWorksheet = package.Workbook.Worksheets.Add("آبی");
blueWorksheet.TabColor = Color.LightBlue;
var grayWorksheet = package.Workbook.Worksheets.Add("خاکستری");
grayWorksheet.TabColor = Color.LightGray;
var redWorksheet = package.Workbook.Worksheets.Add("قرمز");
redWorksheet.TabColor = Color.LightCoral;
var purpleWorksheet = package.Workbook.Worksheets.Add("بنفش");
purpleWorksheet.TabColor = Color.MediumPurple;
var blackWorksheet = package.Workbook.Worksheets.Add("مشکی");
blackWorksheet.TabColor = Color.DimGray;
var yellowWorksheet = package.Workbook.Worksheets.Add("زرد");
yellowWorksheet.TabColor = Color.Yellow;
var whiteWorksheet = package.Workbook.Worksheets.Add("سفید");
whiteWorksheet.TabColor = Color.White;
CreateExcelSheet(institutionContractViewModels, allWorksheet);
var blueContracts = institutionContractViewModels.Where(x=>x.ExpireColor == "blue").ToList();
CreateExcelSheet(blueContracts, blueWorksheet);
institutionContractViewModels = institutionContractViewModels.Except(blueContracts).ToList();
var grayContracts = institutionContractViewModels.Where(x => x.IsContractingPartyBlock == "true").ToList();
CreateExcelSheet(grayContracts, grayWorksheet);
institutionContractViewModels = institutionContractViewModels.Except(grayContracts).ToList();
var redContracts = institutionContractViewModels.Where(x=>x.ExpireColor == "red").ToList();
CreateExcelSheet(redContracts, redWorksheet);
institutionContractViewModels = institutionContractViewModels.Except(redContracts).ToList();
var purpleContracts = institutionContractViewModels.Where(x=>x.ExpireColor == "purple").ToList();
CreateExcelSheet(purpleContracts, purpleWorksheet);
institutionContractViewModels = institutionContractViewModels.Except(purpleContracts).ToList();
// ایجاد شیت برای هر تب با داده‌های مربوطه
foreach (var viewModel in contractViewModels)
{
var worksheet = CreateWorksheet(package, viewModel.Tab);
CreateExcelSheet(viewModel.GetInstitutionContractListItemsViewModels ?? new List<GetInstitutionContractListItemsViewModel>(), worksheet);
}
var blackContracts = institutionContractViewModels.Where(x=>x.ExpireColor == "black").ToList();
CreateExcelSheet(blackContracts, blackWorksheet);
institutionContractViewModels = institutionContractViewModels.Except(blackContracts).ToList();
var yellowContracts = institutionContractViewModels
.Where(x => string.IsNullOrWhiteSpace(x.ExpireColor) && x.WorkshopCount == "0").ToList();
CreateExcelSheet(yellowContracts, yellowWorksheet);
institutionContractViewModels = institutionContractViewModels.Except(yellowContracts).ToList();
var otherContracts = institutionContractViewModels;
CreateExcelSheet(otherContracts, whiteWorksheet);
return package.GetAsByteArray();
}
/// <summary>
/// ایجاد شیت بر اساس نوع تب
/// </summary>
private static ExcelWorksheet CreateWorksheet(ExcelPackage package, InstitutionContractListStatus? status)
private static void CreateExcelSheet(List<InstitutionContractViewModel> institutionContractViewModels, ExcelWorksheet worksheet)
{
return status switch
{
InstitutionContractListStatus.DeactiveWithDebt =>
CreateColoredWorksheet(package, "غیرفعال دارای بدهی", Color.LightBlue),
InstitutionContractListStatus.Deactive =>
CreateColoredWorksheet(package, "غیرفعال", Color.LightGray),
InstitutionContractListStatus.PendingForRenewal =>
CreateColoredWorksheet(package, "در انتظار تمدید", Color.LightCoral),
InstitutionContractListStatus.Free =>
CreateColoredWorksheet(package, "بنفش", Color.MediumPurple),
InstitutionContractListStatus.Block =>
CreateColoredWorksheet(package, "بلاک", Color.DimGray),
InstitutionContractListStatus.WithoutWorkshop =>
CreateColoredWorksheet(package, "بدون کارگاه", Color.Yellow),
InstitutionContractListStatus.Active =>
CreateColoredWorksheet(package, "فعال", Color.White),
InstitutionContractListStatus.PendingForVerify =>
CreateColoredWorksheet(package, "در انتظار تایید", Color.OrangeRed),
null => CreateColoredWorksheet(package, "کل قرارداد ها", Color.White),
_ => throw new ArgumentOutOfRangeException(nameof(status), status, null)
};
}
// Headers
worksheet.Cells[1, 1].Value = "شماره قرارداد";
worksheet.Cells[1, 2].Value = "طرف حساب";
worksheet.Cells[1, 3].Value = "شماره کارفرما";
worksheet.Cells[1, 4].Value = "کارفرما ها";
worksheet.Cells[1, 5].Value = "کارگاه ها";
worksheet.Cells[1, 6].Value = "مجبوع پرسنل";
worksheet.Cells[1, 7].Value = "شروع قرارداد";
worksheet.Cells[1, 8].Value = "پایان قرارداد";
worksheet.Cells[1, 9].Value = "مبلغ قرارداد (بدون کارگاه)";
worksheet.Cells[1, 10].Value = "مبلغ قرارداد";
worksheet.Cells[1, 11].Value = "وضعیت مالی";
/// <summary>
/// ایجاد شیت با رنگ تب
/// </summary>
private static ExcelWorksheet CreateColoredWorksheet(ExcelPackage package, string sheetName, Color tabColor)
{
var worksheet = package.Workbook.Worksheets.Add(sheetName);
worksheet.TabColor = tabColor;
return worksheet;
}
private static void CreateExcelSheet(List<GetInstitutionContractListItemsViewModel> contractItems, ExcelWorksheet worksheet)
{
// دریافت نقشه ستون‌های مرئی
var visibleColumnIndices = GetVisibleColumnIndices();
int columnCount = visibleColumnIndices.Count;
// تنظیم Headers
SetupHeaders(worksheet, visibleColumnIndices, columnCount);
using (var range = worksheet.Cells[1, 1, 1, columnCount])
using (var range = worksheet.Cells[1, 1, 1, 11])
{
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
@@ -153,35 +110,30 @@ public class InstitutionContractExcelGenerator
int row = 2;
for (int i = 0; i < contractItems.Count; i++)
for (int i = 0; i < institutionContractViewModels.Count; i++)
{
var contract = contractItems[i];
var employers = contract.EmployerNames?.ToList() ?? new();
var workshops = contract.WorkshopNames?.ToList() ?? new();
var contract = institutionContractViewModels[i];
var employers = contract.EmployerViewModels?.ToList() ?? new();
var workshops = contract.WorkshopViewModels?.ToList() ?? new();
int maxRows = 1; // هر قرارداد فقط یک ردیف؛ نیازی به مرج عمودی نیست
int maxRows = Math.Max(employers.Count, workshops.Count);
maxRows = Math.Max(1, maxRows);
int startRow = row;
int endRow = row + maxRows - 1;
// 🎨 دریافت رنگ پس‌زمینه بر اساس وضعیت قرارداد
var fillColor = GetColorByStatus(contract.ListStatus, contract.WorkshopsCount);
// 🎨 دریافت رنگ پس‌زمینه از مقدار رنگ موجود در داده
string colorName = contract.ExpireColor.ToLower();
var fillColor = GetColorByName(colorName, contract.WorkshopCount, contract.IsContractingPartyBlock);
for (int j = 0; j < maxRows; j++)
{
int currentRow = row + j;
// پر کردن ستون‌های employer و workshop
var employerColIndex = GetColumnIndexForType(ExcelColumnType.EmployerName, visibleColumnIndices);
var workshopColIndex = GetColumnIndexForType(ExcelColumnType.WorkshopName, visibleColumnIndices);
worksheet.Cells[currentRow, 4].Value = j < employers.Count ? employers[j].FullName : null;
worksheet.Cells[currentRow, 5].Value = j < workshops.Count ? workshops[j].WorkshopFullName : null;
if (employerColIndex > 0)
worksheet.Cells[currentRow, employerColIndex].Value = j < employers.Count ? employers[j] : null;
if (workshopColIndex > 0)
worksheet.Cells[currentRow, workshopColIndex].Value = j < workshops.Count ? workshops[j] : null;
for (int col = 1; col <= columnCount; col++)
for (int col = 1; col <= 11; col++)
{
var cell = worksheet.Cells[currentRow, col];
@@ -202,235 +154,109 @@ public class InstitutionContractExcelGenerator
}
// 🧱 مرج و مقداردهی ستون‌های اصلی
FillColumnData(worksheet, contract, startRow, endRow, visibleColumnIndices);
worksheet.Cells[startRow, 1, endRow, 1].Merge = true;
worksheet.Cells[startRow, 1].Value = contract.ContractNo;
worksheet.Cells[startRow, 2, endRow, 2].Merge = true;
worksheet.Cells[startRow, 2].Value = contract.ContractingPartyName;
worksheet.Cells[startRow, 3, endRow, 3].Merge = true;
worksheet.Cells[startRow, 3].Value = contract.ArchiveCode;
worksheet.Cells[startRow, 6, endRow, 6].Merge = true;
worksheet.Cells[startRow, 6].Value = contract.EmployeeCount;
worksheet.Cells[startRow, 7, endRow, 7].Merge = true;
worksheet.Cells[startRow, 7].Value = contract.ContractStartFa;
worksheet.Cells[startRow, 8, endRow, 8].Merge = true;
worksheet.Cells[startRow, 8].Value = contract.ContractEndFa;
worksheet.Cells[startRow, 9, endRow, 9].Merge = true;
var contractWithoutWorkshopAmountCell = worksheet.Cells[startRow, 9];
contractWithoutWorkshopAmountCell.Value = contract.WorkshopCount == "0" ? MoneyToDouble(contract.ContractAmount) : "";
contractWithoutWorkshopAmountCell.Style.Numberformat.Format = "#,##0";
worksheet.Cells[startRow, 10, endRow, 10].Merge = true;
var contractAmountCell = worksheet.Cells[startRow, 10];
contractAmountCell.Value = contract.WorkshopCount != "0" ? MoneyToDouble(contract.ContractAmount) : "";
contractAmountCell.Style.Numberformat.Format = "#,##0";
worksheet.Cells[startRow, 11, endRow, 11].Merge = true;
var balance = MoneyToDouble(contract.BalanceStr);
var balanceCell = worksheet.Cells[startRow, 11];
balanceCell.Value = balance;
balanceCell.Style.Numberformat.Format = "#,##0";
if (balance > 0)
balanceCell.Style.Font.Color.SetColor(Color.Red);
else if (balance < 0)
balanceCell.Style.Font.Color.SetColor(Color.Green);
// 📦 بوردر ضخیم خارجی برای هر سطر
var boldRange = worksheet.Cells[startRow, 1, endRow, columnCount];
var boldRange = worksheet.Cells[startRow, 1, endRow, 11];
boldRange.Style.Border.BorderAround(ExcelBorderStyle.Medium);
row += maxRows;
}
SetupPrintSettings(worksheet, visibleColumnIndices, columnCount);
}
/// <summary>
/// دریافت فهرست ستون‌های مرئی بر اساس کانفیگ
/// </summary>
private static List<ExcelColumnType> GetVisibleColumnIndices()
{
return _columnConfig.VisibleColumns;
}
/// <summary>
/// دریافت شماره ستون برای یک نوع ستون خاص
/// </summary>
private static int GetColumnIndexForType(ExcelColumnType columnType, List<ExcelColumnType> visibleColumns)
{
var index = visibleColumns.IndexOf(columnType);
return index >= 0 ? index + 1 : 0; // 1-based indexing
}
/// <summary>
/// دریافت متن header برای یک نوع ستون
/// </summary>
private static string GetColumnHeader(ExcelColumnType columnType)
{
return columnType switch
{
ExcelColumnType.RowNumber => "ردیف",
ExcelColumnType.PhysicalContract => "قرارداد فیزیکی",
ExcelColumnType.ContractNo => "شماره قرارداد",
ExcelColumnType.Representative => "معرف",
ExcelColumnType.ContractingPartyName => "طرف حساب",
ExcelColumnType.ArchiveCode => "شماره کارفرما",
ExcelColumnType.EmployerName => "کارفرما",
ExcelColumnType.WorkshopName => "کارگاه‌ها",
ExcelColumnType.WorkshopCount => "تعداد کارگاه",
ExcelColumnType.EmployeeCount => "مجموع پرسنل",
ExcelColumnType.ContractStartDate => "شروع قرارداد",
ExcelColumnType.ContractEndDate => "پایان قرارداد",
ExcelColumnType.InstallmentAmount => "مبلغ قسط",
ExcelColumnType.ContractAmount => "مبلغ قرارداد",
ExcelColumnType.FinancialStatus => "وضعیت مالی",
_ => ""
};
}
/// <summary>
/// تنظیم Headerهای ستون‌ها
/// </summary>
private static void SetupHeaders(ExcelWorksheet worksheet, List<ExcelColumnType> visibleColumns, int columnCount)
{
for (int i = 0; i < visibleColumns.Count; i++)
{
worksheet.Cells[1, i + 1].Value = GetColumnHeader(visibleColumns[i]);
}
}
/// <summary>
/// پر کردن داده‌های ستون‌ها برای یک قرارداد
/// </summary>
private static void FillColumnData(ExcelWorksheet worksheet, GetInstitutionContractListItemsViewModel contract, int startRow, int endRow, List<ExcelColumnType> visibleColumns)
{
for (int i = 0; i < visibleColumns.Count; i++)
{
int columnIndex = i + 1; // 1-based indexing
var columnType = visibleColumns[i];
// Merge cells for non-repeating columns
worksheet.Cells[startRow, columnIndex, endRow, columnIndex].Merge = true;
var cell = worksheet.Cells[startRow, columnIndex];
switch (columnType)
{
case ExcelColumnType.PhysicalContract:
var physicalText = contract.IsOldContract
? (contract.HasSigniture ? "موجود" : "ناموجود")
: (contract.IsInPersonContract ? "الکترونیکی حضوری" : "الکترونیکی غیر حضوری");
cell.Value = physicalText;
cell.Style.Font.Bold = true;
cell.Style.Font.Color.SetColor(physicalText switch
{
"موجود" => Color.Green,
"ناموجود" => Color.Red,
"الکترونیکی حضوری" => Color.Purple,
_ => Color.Blue
});
break;
case ExcelColumnType.ContractNo:
cell.Value = contract.ContractNo;
break;
case ExcelColumnType.Representative:
cell.Value = contract.RepresentativeName;
break;
case ExcelColumnType.ContractingPartyName:
cell.Value = contract.ContractingPartyName;
break;
case ExcelColumnType.ArchiveCode:
cell.Value = contract.ArchiveNo;
break;
case ExcelColumnType.EmployerName:
// این ستون چندخطی است و داخل loop پر می‌شود
break;
case ExcelColumnType.WorkshopName:
// این ستون چندخطی است و داخل loop پر می‌شود
break;
case ExcelColumnType.WorkshopCount:
cell.Value = contract.WorkshopsCount;
break;
case ExcelColumnType.EmployeeCount:
cell.Value = contract.EmployeesCount;
break;
case ExcelColumnType.ContractStartDate:
cell.Value = contract.ContractStartFa;
break;
case ExcelColumnType.ContractEndDate:
cell.Value = contract.ContractEndFa;
break;
case ExcelColumnType.InstallmentAmount:
cell.Value = contract.InstallmentAmount;
cell.Style.Numberformat.Format = "#,##0";
break;
case ExcelColumnType.ContractAmount:
cell.Value = contract.ContractAmount;
cell.Style.Numberformat.Format = "#,##0";
break;
case ExcelColumnType.FinancialStatus:
cell.Value = contract.Balance;
cell.Style.Numberformat.Format = "#,##0";
if (contract.Balance > 0)
cell.Style.Font.Color.SetColor(Color.Red);
else if (contract.Balance < 0)
cell.Style.Font.Color.SetColor(Color.Green);
break;
}
}
}
/// <summary>
/// تنظیم تنظیمات چاپ و عرض ستون‌ها
/// </summary>
private static void SetupPrintSettings(ExcelWorksheet worksheet, List<ExcelColumnType> visibleColumns, int columnCount)
{
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;
// تنظیم عرض ستون‌ها بر اساس نوع ستون
for (int i = 0; i < visibleColumns.Count; i++)
{
int columnIndex = i + 1;
worksheet.Columns[columnIndex].Width = GetColumnWidth(visibleColumns[i]);
}
int contractNoCol = 1;
int contractingPartyNameCol = 2;
int archiveNoCol = 3;
int employersCol = 4;
int workshopsCol = 5;
int employeeCountCol = 6;
int startContractCol = 7;
int endContractCol = 8;
int contractWithoutWorkshopAmountCol = 9;
int contractAmountCol = 10;
int balanceCol = 11;
worksheet.Columns[contractNoCol].Width = 17;
worksheet.Columns[contractingPartyNameCol].Width = 40;
worksheet.Columns[archiveNoCol].Width = 10;
worksheet.Columns[employersCol].Width = 40;
worksheet.Columns[workshopsCol].Width = 45;
worksheet.Columns[employeeCountCol].Width = 12;
worksheet.Columns[startContractCol].Width = 12;
worksheet.Columns[endContractCol].Width = 12;
worksheet.Columns[contractWithoutWorkshopAmountCol].Width = 18;
worksheet.Columns[contractAmountCol].Width = 12;
worksheet.Columns[balanceCol].Width = 12;
worksheet.View.RightToLeft = true; // فارسی
}
/// <summary>
/// دریافت عرض ستون پیش‌فرض برای هر نوع ستون
/// </summary>
private static double GetColumnWidth(ExcelColumnType columnType)
{
return columnType switch
{
ExcelColumnType.RowNumber => 8,
ExcelColumnType.PhysicalContract => 15,
ExcelColumnType.ContractNo => 17,
ExcelColumnType.Representative => 15,
ExcelColumnType.ContractingPartyName => 40,
ExcelColumnType.ArchiveCode => 10,
ExcelColumnType.EmployerName => 40,
ExcelColumnType.WorkshopName => 45,
ExcelColumnType.WorkshopCount => 12,
ExcelColumnType.EmployeeCount => 12,
ExcelColumnType.ContractStartDate => 12,
ExcelColumnType.ContractEndDate => 12,
ExcelColumnType.InstallmentAmount => 15,
ExcelColumnType.ContractAmount => 15,
ExcelColumnType.FinancialStatus => 12,
_ => 12
};
//worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
}
private static double MoneyToDouble(string value)
{
if (string.IsNullOrEmpty(value))
return 0;
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;
}
/// <summary>
/// دریافت رنگ بر اساس وضعیت قرارداد
/// </summary>
private static Color GetColorByStatus(InstitutionContractListStatus status, int workshopsCount)
private static Color GetColorByName(string name, string workshopCount, string IsContractingPartyBlock)
{
return status switch
return name switch
{
InstitutionContractListStatus.DeactiveWithDebt => Color.LightBlue,
InstitutionContractListStatus.Deactive => Color.LightGray,
InstitutionContractListStatus.PendingForRenewal => Color.LightCoral,
InstitutionContractListStatus.Free => Color.MediumPurple,
InstitutionContractListStatus.Block => Color.DimGray,
InstitutionContractListStatus.WithoutWorkshop => Color.Yellow,
InstitutionContractListStatus.Active => Color.White,
"blue" => Color.LightBlue,
_ when IsContractingPartyBlock == "true" => Color.LightGray,
"red" => Color.LightCoral,
"purple" => Color.MediumPurple,
"black" => Color.DimGray,
var n when string.IsNullOrWhiteSpace(n) && workshopCount == "0" => Color.Yellow,
_ => Color.White
};
}
}
public class InstitutionContractExcelViewModel
{
public InstitutionContractListStatus? Tab { get; set; }
public List<GetInstitutionContractListItemsViewModel> GetInstitutionContractListItemsViewModels { get; set; }
}
}

View File

@@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,12 +0,0 @@
namespace CompanyManagment.App.Contracts.Contract;
public enum ContractListOrderType
{
ByContractCreationDate,
BySignedContract,
ByUnSignedContract,
ByPersonnelCode,
ByPersonnelCodeDescending,
ByContractStartDate,
ByContractStartDateDescending
}

View File

@@ -1,13 +0,0 @@
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.Contract;
public class GetContractListForClientRequest: PaginationRequest
{
public int Year { get; set; }
public int Month { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public long EmployeeId { get; set; }
public ContractListOrderType? OrderType { get; set; }
}

View File

@@ -1,15 +0,0 @@
namespace CompanyManagment.App.Contracts.Contract;
public class GetContractListForClientResponse
{
public long Id { get; set; }
public string PersonnelCode { get; set; }
public string ContractNo { get; set; }
public string EmployeeFullName { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public bool IsSigned { get; set; }
public string DailyWage { get; set; }
public string AvgWorkingHour { get; set; }
public string FamilyAllowance { get; set; }
}

View File

@@ -3,8 +3,6 @@ using System.Collections.Generic;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Workshop;
using System.Threading.Tasks;
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Contract;
public interface IContractApplication
@@ -47,101 +45,16 @@ public interface IContractApplication
#region Client
OperationResult Remove(long id);
[Obsolete("این متد منسوخ شده است. لطفاً از متد GetContractListForClient استفاده کنید.")]
List<ContractViweModel> SearchForClient(ContractSearchModel searchModel);
/// <summary>
/// لیست قراردادها برای کلاینت
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
Task<PagedResult<GetContractListForClientResponse>>
GetContractListForClient(GetContractListForClientRequest searchModel);
Task<ContractPrintViewModel> PrintOneAsync(long id);
Task<List<ContractPrintViewModel>> PrintAllAsync(List<long> ids);
#endregion
#endregion
#region NewChangeByHeydari
#region NewChangeByHeydari
OperationResult DeleteAllContarcts(List<long> ids);
OperationResult DeleteAllContarcts(List<long> ids);
OperationResult DeleteContarcts(long id);
List<long> CheckHasCheckout(List<long> ids);
List<long> CheckHasSignature(List<long> ids);
List<ContractViweModel> SearchForMainContract(ContractSearchModel searchModel);
#endregion
}
public class ContractPrintViewModel
{
public string ContractNo { get; set; }
public ContractPrintEmployerViewModel Employer { get; set; }
public ContractPrintEmployeeViewModel Employee { get; set; }
public ContractPrintTypeOfContractViewModel TypeOfContract { get; set; }
public ContractPrintFeesViewModel Fees { get; set; }
public string ConditionAndDetials { get; set; }
}
public class ContractPrintFeesViewModel
{
public string DailyWage { get; set; }
public string FamilyAllowance { get; set; }
public string ConsumableItems { get; set; }
public string HousingAllowance { get; set; }
}
public class ContractPrintTypeOfContractViewModel
{
public string ContractType { get; set; }
public string JobName { get; set; }
public string SetContractDate { get; set; }
public string ContarctStart { get; set; }
public string ContractEnd { get; set; }
public string WorkingHoursWeekly { get; set; }
public List<string> WorkshopAddress { get; set; }
}
public class ContractPrintEmployeeViewModel
{
public string FullName { get; set; }
public string NationalCode { get; set; }
public string IdNumber { get; set; }
public string DateOfBirth { get; set; }
public string FatherName { get; set; }
public string LevelOfEducation { get; set; }
public string Address { get; set; }
}
public class ContractPrintEmployerViewModel
{
public LegalType LegalType { get; set; }
public ContractPrintRealEmployerViewModel RealEmployer { get; set; }
public ContractPrintLegalEmployerViewModel LegalEmployer { get; set; }
public string WorkshopName { get; set; }
public string Address { get; set; }
public string WorkshopCode { get; set; }
}
public class ContractPrintLegalEmployerViewModel
{
public string CompanyName { get; set; }
public string NationalId { get; set; }
public string RegisterId { get; set; }
}
public class ContractPrintRealEmployerViewModel
{
public string FullName { get; set; }
public string NationalCode { get; set; }
public string IdNumber { get; set; }
}

View File

@@ -0,0 +1,92 @@
using System.Diagnostics.Contracts;
namespace CompanyManagment.App.Contracts.Employee.DTO;
/// <summary>
/// لیست پرسنل کلاینت
/// api
/// </summary>
public class EmployeeListDto
{
/// <summary>
/// آی دی پرسنل
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام کامل پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// کد پرسنلی
/// </summary>
public int PersonnelCode { get; set; }
/// <summary>
/// وضعیت تاهل
/// </summary>
public string MaritalStatus { get; set; }
/// <summary>
///کد ملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
public string IdNumber { get; set; }
/// <summary>
/// تاریخ تولد
/// </summary>
public string DateOfBirth { get; set; }
/// <summary>
/// نام پدر
/// </summary>
public string FatherName { get; set; }
/// <summary>
/// تعداد فرزندان
/// </summary>
public string NumberOfChildren { get; set; }
/// <summary>
/// آخرین تاریخ شروع بکار قرارداد
/// </summary>
public string LatestContractStartDate { get; set; }
/// <summary>
/// تاریخ ترک کار قرارداد
/// </summary>
public string ContractLeftDate { get; set; }
/// <summary>
/// آخرین تاریخ شروع بکار بیمه
/// </summary>
public string LatestInsuranceStartDate { get; set; }
/// <summary>
/// تاریخ ترک کار بیمه
/// </summary>
public string InsuranceLeftDate { get; set; }
/// <summary>
/// دارای قرارداد است؟
/// </summary>
public bool HasContract { get; set; }
/// <summary>
/// دارای بیمه است؟
/// </summary>
public bool HasInsurance { get; set; }
/// <summary>
/// وضعیت پرسنل در کارگاه
/// </summary>
public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; }
}

View File

@@ -0,0 +1,18 @@
namespace CompanyManagment.App.Contracts.Employee.DTO;
/// <summary>
/// سرچ مدل پرسنل
/// api
/// </summary>
public class EmployeeSearchModelDto
{
/// <summary>
/// نام پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// کد ملی
/// </summary>
public string NationalCode { get; set; }
}

View File

@@ -0,0 +1,29 @@
namespace CompanyManagment.App.Contracts.Employee.DTO;
/// <summary>
/// وضعیت پرسنل در کارگاه
/// api
/// </summary>
public enum EmployeeStatusInWorkshop
{
/// <summary>
/// ایجاد شده توسط کارفرما
/// </summary>
CreatedByClient,
/// <summary>
/// ترک کار موقت
/// </summary>
LefWorkTemp,
/// <summary>
/// در حال کار در کارگاه
/// </summary>
Working,
/// <summary>
/// قطع ارتباط و ترک کار کامب
/// </summary>
HasLeft,
}

View File

@@ -0,0 +1,96 @@
namespace CompanyManagment.App.Contracts.Employee.DTO;
/// <summary>
/// پرینت تجمیعی پرسنل
/// </summary>
public class PrintAllEmployeesInfoDtoClient
{
public PrintAllEmployeesInfoDtoClient(EmployeeListDto source)
{
Id = source.Id;
EmployeeFullName = source.EmployeeFullName;
PersonnelCode = source.PersonnelCode;
MaritalStatus = source.MaritalStatus;
NationalCode = source.NationalCode;
IdNumber = source.IdNumber;
DateOfBirth = source.DateOfBirth;
FatherName = source.FatherName;
NumberOfChildren = source.NumberOfChildren;
LatestContractStartDate = source.LatestContractStartDate;
ContractLeftDate = source.ContractLeftDate;
LatestInsuranceStartDate = source.LatestInsuranceStartDate;
InsuranceLeftDate = source.InsuranceLeftDate;
EmployeeStatusInWorkshop = source.EmployeeStatusInWorkshop;
}
/// <summary>
/// آی دی پرسنل
/// </summary>
public long Id { get; set; }
/// <summary>
/// نام کامل پرسنل
/// </summary>
public string EmployeeFullName { get; set; }
/// <summary>
/// کد پرسنلی
/// </summary>
public int PersonnelCode { get; set; }
/// <summary>
/// وضعیت تاهل
/// </summary>
public string MaritalStatus { get; set; }
/// <summary>
///کد ملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// شماره شناسنامه
/// </summary>
public string IdNumber { get; set; }
/// <summary>
/// تاریخ تولد
/// </summary>
public string DateOfBirth { get; set; }
/// <summary>
/// نام پدر
/// </summary>
public string FatherName { get; set; }
/// <summary>
/// تعداد فرزندان
/// </summary>
public string NumberOfChildren { get; set; }
/// <summary>
/// آخرین تاریخ شروع بکار قرارداد
/// </summary>
public string LatestContractStartDate { get; set; }
/// <summary>
/// تاریخ ترک کار قرارداد
/// </summary>
public string ContractLeftDate { get; set; }
/// <summary>
/// آخرین تاریخ شروع بکار بیمه
/// </summary>
public string LatestInsuranceStartDate { get; set; }
/// <summary>
/// تاریخ ترک کار بیمه
/// </summary>
public string InsuranceLeftDate { get; set; }
/// <summary>
/// وضعیت پرسنل در کارگاه
/// </summary>
public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; }
}

View File

@@ -1,8 +1,10 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Employee.DTO;
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
using Microsoft.AspNetCore.Mvc;
namespace CompanyManagment.App.Contracts.Employee;
@@ -73,6 +75,7 @@ public interface IEmployeeApplication
long workshopId);
Task<OperationResult> EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command);
[Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")]
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate);
@@ -103,8 +106,26 @@ public interface IEmployeeApplication
/// <returns></returns>
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
#endregion
/// <summary>
/// دریافت لیست پرسنل کلاینت
/// api
/// </summary>
/// <param name="searchModel"></param>
/// <param name="workshopId"></param>
/// <returns></returns>
Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId);
/// <summary>
/// پرینت تجمیعی پرسنل کلاینت
/// api
/// </summary>
/// <param name="workshopId"></param>
/// <returns></returns>
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
#endregion
Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId);
}
public class GetClientEmployeeListSearchModel

View File

@@ -5,7 +5,6 @@ using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -97,94 +96,6 @@ public interface IInsuranceListApplication
#endregion
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
Task<InsuranceClientPrintViewModel> ClientPrintOne(long id);
}
public class InsuranceClientPrintViewModel
{
public string Month { get; set; }
public string Year { get; set; }
public string WorkshopName { get; set; }
public string ListNo { get; set; }
public string AgreementNumber { get; set; }
public string WorkshopInsuranceCode { get; set; }
public string WorkshopEmployerName { get; set; }
public string WorkshopAddress { get; set; }
public List<InsuranceClientPrintItemsViewModel> Items { get; set; }
public string EmployerShare { get; set; }
public string InsuredShare { get; set; }
public string UnEmploymentInsurance { get; set; }
public string AllInsuredShare { get; set; }
}
public class InsuranceClientPrintItemsViewModel
{
/// <summary>
/// شماره بیمه
/// </summary>
public string InsuranceCode { get; set; }
/// <summary>
/// نام و نام خانوادگی
/// </summary>
public string FullName { get; set; }
/// <summary>
/// شغل
/// </summary>
public string JobName { get; set; }
/// <summary>
/// کد ملی
/// </summary>
public string NationalCode { get; set; }
/// <summary>
/// شروع به کار
/// </summary>
public string StartWork { get; set; }
/// <summary>
/// ترک کار
/// </summary>
public string LeftWork { get; set; }
/// <summary>
/// روزهای کارکرد
/// </summary>
public string WorkingDays { get; set; }
/// <summary>
/// دستمزد روزانه
/// </summary>
public string DailyWage { get; set; }
/// <summary>
/// پایه سنوات روزانه
/// </summary>
public string BaseYears { get; set; }
/// <summary>
/// دستمزد ماهانه
/// </summary>
public string MonthlySalary { get; set; }
/// <summary>
/// مزایای ماهیانه مشمول
/// </summary>
public string MonthlyBenefits { get; set; }
/// <summary>
/// حق تاهل
/// </summary>
public string MarriedAllowance { get; set; }
/// <summary>
/// حقوق و مزایای ماهیانه مشمول
/// </summary>
public string BenefitsIncludedContinuous { get; set; }
/// <summary>
/// حقوق و مزایای ماهیانه غیر مشمول
/// </summary>
public string BenefitsIncludedNonContinuous { get; set; }
/// <summary>
/// مجموع مزایای ماهیانه مشمول و غیر مشمول
/// </summary>
public string IncludedAndNotIncluded { get; set; }
/// <summary>
/// حق بیمه سهم بیمه شده
/// </summary>
public string InsuranceShare { get; set; }
}
public class InsuranceClientSearchModel:PaginationRequest
@@ -202,11 +113,4 @@ public class InsuranceClientListViewModel
public int YearInt { get; set; }
public string MonthName { get; set; }
public int MonthInt { get; set; }
public int PersonnelCount { get; set; }
public int LeftWorkCount { get; set; }
public string AllInsuredShare { get; set; }
public string InsuredShare { get; set; }
public string EmployerShare { get; set; }
public string UnEmploymentInsurance { get; set; }
}

View File

@@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account;
using CompanyManagment.App.Contracts.Employee.DTO;
using CompanyManagment.App.Contracts.Workshop.DTOs;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.Workshop;
@@ -92,6 +93,8 @@ public interface IWorkshopApplication
#endregion
Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command);
}
public class CreateWorkshopWorkflowRegistration

View File

@@ -2712,9 +2712,7 @@ public class ContractApplication : IContractApplication
var emp = workshopEmpList.Where(x => x.WorkshopId == res.WorkshopIds)
.Select(x => x.EmployerId).ToList();
res.Employers = _employerRepository.GetEmployers(emp);
var workshopSelect = _workshopApplication.GetDetails(res.WorkshopIds);
var workshop = new WorkshopViewModel()
{
@@ -3109,21 +3107,6 @@ public class ContractApplication : IContractApplication
return _contractRepository.SearchForClient(searchModel);
}
public async Task<PagedResult<GetContractListForClientResponse>> GetContractListForClient(GetContractListForClientRequest searchModel)
{
return await _contractRepository.GetContractListForClient(searchModel);
}
public async Task<ContractPrintViewModel> PrintOneAsync(long id)
{
return (await _contractRepository.PrintAllAsync([id])).FirstOrDefault();
}
public async Task<List<ContractPrintViewModel>> PrintAllAsync(List<long> ids)
{
return await _contractRepository.PrintAllAsync(ids);
}
#endregion
#region NewChangeByHeydari

View File

@@ -1734,5 +1734,20 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return await _EmployeeRepository.GetClientEmployeeList(searchModel, workshopId);
}
public async Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId)
{
return await _EmployeeRepository.ListOfAllEmployeesClient(searchModel, workshopId);
}
public async Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId)
{
return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId);
}
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
{
return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId);
}
#endregion
}

View File

@@ -1,30 +1,40 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Application.PaymentGateway;
using _0_Framework.Application.Sms;
using _0_Framework.Application.UID;
using _0_Framework.Exceptions;
using AccountManagement.Application.Contracts.Account;
using Company.Domain.ContarctingPartyAgg;
using Company.Domain.EmployeeAgg;
using Company.Domain.empolyerAgg;
using Company.Domain.FinancialInvoiceAgg;
using Company.Domain.FinancialStatmentAgg;
using Company.Domain.FinancialTransactionAgg;
using Company.Domain.InstitutionContractAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.PaymentTransactionAgg;
using Company.Domain.RepresentativeAgg;
using Company.Domain.RollCallServiceAgg;
using Company.Domain.TemporaryClientRegistrationAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.FinancialInvoice;
using CompanyManagment.App.Contracts.FinancialStatment;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
using CompanyManagment.App.Contracts.PaymentTransaction;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.EFCore.Migrations;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.Packaging.Ionic.Zip;
using PersianTools.Core;
using ConnectedPersonnelViewModel = CompanyManagment.App.Contracts.Workshop.ConnectedPersonnelViewModel;
using FinancialStatment = Company.Domain.FinancialStatmentAgg.FinancialStatment;
@@ -39,11 +49,14 @@ public class InstitutionContractApplication : IInstitutionContractApplication
private readonly IFinancialStatmentApplication _financialStatmentApplication;
private readonly IEmployerRepository _employerRepository;
private readonly IWorkshopRepository _workshopRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IWorkshopApplication _workshopApplication;
private readonly IContractingPartyTempRepository _contractingPartyTempRepository;
private readonly IFinancialStatmentRepository _financialStatmentRepository;
private readonly IContactInfoApplication _contactInfoApplication;
private readonly IAccountApplication _accountApplication;
private readonly ISmsService _smsService;
private readonly IUidService _uidService;
private readonly IFinancialInvoiceRepository _financialInvoiceRepository;
private readonly IPaymentGateway _paymentGateway;
private readonly IPaymentTransactionRepository _paymentTransactionRepository;
@@ -53,10 +66,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
IPersonalContractingPartyRepository contractingPartyRepository,
IRepresentativeRepository representativeRepository, IEmployerRepository employerRepository,
IWorkshopRepository workshopRepository,
IWorkshopRepository workshopRepository, ILeftWorkRepository leftWorkRepository,
IFinancialStatmentApplication financialStatmentApplication, IWorkshopApplication workshopApplication,
IContractingPartyTempRepository contractingPartyTempRepository,
IFinancialStatmentRepository financialStatmentRepository, IContactInfoApplication contactInfoApplication,
IAccountApplication accountApplication, ISmsService smsService,
IAccountApplication accountApplication, ISmsService smsService, IUidService uidService,
IFinancialInvoiceRepository financialInvoiceRepository, IHttpClientFactory httpClientFactory,
IPaymentTransactionRepository paymentTransactionRepository, IRollCallServiceRepository rollCallServiceRepository)
{
@@ -65,12 +79,15 @@ public class InstitutionContractApplication : IInstitutionContractApplication
_representativeRepository = representativeRepository;
_employerRepository = employerRepository;
_workshopRepository = workshopRepository;
_leftWorkRepository = leftWorkRepository;
_financialStatmentApplication = financialStatmentApplication;
_workshopApplication = workshopApplication;
_contractingPartyTempRepository = contractingPartyTempRepository;
_financialStatmentRepository = financialStatmentRepository;
_contactInfoApplication = contactInfoApplication;
_accountApplication = accountApplication;
_smsService = smsService;
_uidService = uidService;
_financialInvoiceRepository = financialInvoiceRepository;
_paymentTransactionRepository = paymentTransactionRepository;
_rollCallServiceRepository = rollCallServiceRepository;
@@ -800,11 +817,20 @@ public class InstitutionContractApplication : IInstitutionContractApplication
var contractingParty = _contractingPartyRepository.Get(institutionContract.ContractingPartyId);
if (contractingParty != null)
{
var accountsDeActiveRes = _contractingPartyRepository.DeActiveAllAsync(contractingParty.id)
.GetAwaiter().GetResult();
if (!accountsDeActiveRes.IsSuccedded)
return opration.Failed(accountsDeActiveRes.Message);
contractingParty.DeActive();
_contractingPartyRepository.SaveChanges();
var employers =
_employerRepository.GetEmployerByContracrtingPartyID(institutionContract.ContractingPartyId);
//var employersIdList = employers.Select(x => x.Id).ToList();
//var workshops = _workshopApplication.GetWorkshopsByEmployerId(employersIdList);
//foreach (var workshop in workshops)
//{
// var res = _workshopApplication.DeActive(workshop.Id);
//}
foreach (var employer in employers)
{
var res = _employerRepository.DeActiveAll(employer.Id);
}
}
return opration.Succcedded();
@@ -821,10 +847,20 @@ public class InstitutionContractApplication : IInstitutionContractApplication
var contractingParty = _contractingPartyRepository.Get(institutionContract.ContractingPartyId);
if (contractingParty != null)
{
var activeRes = _contractingPartyRepository.ActiveAllAsync(contractingParty.id).GetAwaiter()
.GetResult();
if (!activeRes.IsSuccedded)
return opration.Failed(activeRes.Message);
contractingParty.Active();
_contractingPartyRepository.SaveChanges();
var employers =
_employerRepository.GetEmployerByContracrtingPartyID(institutionContract.ContractingPartyId);
//var employersIdList = employers.Select(x => x.Id).ToList();
//var workshops = _workshopApplication.GetWorkshopsByEmployerId(employersIdList);
//foreach (var workshop in workshops)
//{
// var res = _workshopApplication.DeActive(workshop.Id);
//}
foreach (var employer in employers)
{
var res = _employerRepository.ActiveAll(employer.Id);
}
}
return opration.Succcedded();
@@ -1598,11 +1634,6 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (institutionContract.VerificationStatus == InstitutionContractVerificationStatus.Verified)
return op.Failed("قرارداد مالی قبلا تایید شده است");
if (!institutionContract.WorkshopGroup.IsInPersonContract)
{
return op.Failed("قرارداد مالی غیر حضوری نمی تواند به صورت دستی تایید شود");
}
var transaction = await _institutionContractRepository.BeginTransactionAsync();
await SetPendingWorkflow(institutionContractId,InstitutionContractSigningType.Physical);

View File

@@ -2381,10 +2381,5 @@ public class InsuranceListApplication : IInsuranceListApplication
return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel);
}
public async Task<InsuranceClientPrintViewModel> ClientPrintOne(long id)
{
return await _insuranceListRepositpry.ClientPrintOne(id);
}
#endregion
}

View File

@@ -12,6 +12,7 @@ using Company.Domain.LeftWorkAgg;
using Company.Domain.LeftWorkInsuranceAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.Employee.DTO;
using CompanyManagment.App.Contracts.EmployeeChildren;
using CompanyManagment.App.Contracts.LeftWork;
using CompanyManagment.App.Contracts.RollCallService;
@@ -1126,5 +1127,6 @@ public class WorkshopAppliction : IWorkshopApplication
return operation.Succcedded();
}
#endregion
}

View File

@@ -5,8 +5,6 @@ using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Exceptions;
using _0_Framework.InfraStructure;
using Company.Domain.ContractAgg;
using Company.Domain.empolyerAgg;
@@ -1083,7 +1081,30 @@ public class ContractRepository : RepositoryBase<long, Contract>, IContractRepos
var weeklyDouble = 0.0;
var weekly = c.WorkingHoursWeekly;
c.WorkingHoursWeekly = WeeklyHourConvertor(weekly);
if (!string.IsNullOrWhiteSpace(weekly) &&
weekly != "24 - 12" && weekly != "24 - 24" && weekly != "36 - 12" && weekly != "48 - 24")
{
if (weekly.Contains("/"))
{
weeklyDouble = double.Parse(weekly);
var minute = (int)((weeklyDouble % 1) * 60);
var hour = (int)(weeklyDouble);
c.WorkingHoursWeekly = hour + " " + "ساعت و" + " " + minute + " " + "دقیقه";
}
else if (weekly.Contains("."))
{
weeklyDouble = double.Parse(weekly, CultureInfo.InvariantCulture);
var minute = (int)((weeklyDouble % 1) * 60);
var hour = (int)(weeklyDouble);
c.WorkingHoursWeekly = hour + " " + "ساعت و" + " " + minute + " " + "دقیقه";
}
else
{
c.WorkingHoursWeekly = c.WorkingHoursWeekly + " " + "ساعت";
}
}
var emp = workshopEmpList.Where(x => x.WorkshopId == c.WorkshopIds)
.Select(x => x.EmployerId).ToList();
c.Employers = _employerRepository.GetEmployers(emp);
@@ -1140,37 +1161,6 @@ public class ContractRepository : RepositoryBase<long, Contract>, IContractRepos
return query;
}
private static string WeeklyHourConvertor(string weekly)
{
double weeklyDouble;
if (!string.IsNullOrWhiteSpace(weekly) &&
weekly != "24 - 12" && weekly != "24 - 24" && weekly != "36 - 12" && weekly != "48 - 24")
{
if (weekly.Contains("/"))
{
weeklyDouble = double.Parse(weekly);
var minute = (int)((weeklyDouble % 1) * 60);
var hour = (int)(weeklyDouble);
return hour + " " + "ساعت و" + " " + minute + " " + "دقیقه";
}
else if (weekly.Contains("."))
{
weeklyDouble = double.Parse(weekly, CultureInfo.InvariantCulture);
var minute = (int)((weeklyDouble % 1) * 60);
var hour = (int)(weeklyDouble);
return hour + " " + "ساعت و" + " " + minute + " " + "دقیقه";
}
else
{
return weekly + " " + "ساعت";
}
}
return "";
}
public IQueryable<WorkshopEmployerViewModel> GetWorkshopEmployer()
{
return _context.WorkshopEmployers.Select(x => new WorkshopEmployerViewModel
@@ -1516,195 +1506,6 @@ public class ContractRepository : RepositoryBase<long, Contract>, IContractRepos
}
public async Task<PagedResult<GetContractListForClientResponse>> GetContractListForClient(GetContractListForClientRequest searchModel)
{
var workshopId = _authHelper.GetWorkshopId();
var query = _context.Contracts
.Where(c => c.WorkshopIds == workshopId);
#region Search
if (searchModel.EmployeeId > 0)
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate))
{
if (!searchModel.StartDate.TryToGeorgianDateTime(out var startDate))
throw new BadRequestException("تاریخ شروع وارد شده معتبر نمی باشد.");
if (!searchModel.EndDate.TryToGeorgianDateTime(out var endDate))
throw new BadRequestException("تاریخ پایان وارد شده معتبر نمی باشد.");
query = query.Where(x => x.ContarctStart <=endDate && x.ContractEnd >= startDate);
}
if (searchModel.Year>0 && searchModel.Month >0)
{
var startDateFa = $"{searchModel.Year:0000}/{searchModel.Month:00}/01";
if (!startDateFa.TryToGeorgianDateTime(out var startDate))
throw new BadRequestException("سال و ماه وارد شده معتبر نمی باشد.");
if(!startDateFa.FindeEndOfMonth().TryToGeorgianDateTime(out var endDate))
throw new BadRequestException("سال و ماه وارد شده معتبر نمی باشد.");
query = query.Where(x => x.ContarctStart <=endDate && x.ContractEnd >= startDate);
}
if (searchModel.OrderType != null)
{
switch (searchModel.OrderType)
{
case ContractListOrderType.ByContractCreationDate:
query = query.OrderBy(x => x.CreationDate);
break;
case ContractListOrderType.ByContractStartDate:
query = query.OrderBy(x => x.ContarctStart);
break;
case ContractListOrderType.ByContractStartDateDescending:
query = query.OrderByDescending(x=>x.ContarctStart);
break;
case ContractListOrderType.ByPersonnelCode:
query = query.OrderBy(x => x.PersonnelCode);
break;
case ContractListOrderType.ByPersonnelCodeDescending:
query = query.OrderByDescending(x => x.PersonnelCode);
break;
case ContractListOrderType.BySignedContract:
query = query.OrderByDescending(x => x.Signature == "1");
break;
case ContractListOrderType.ByUnSignedContract:
query = query.OrderBy(x => x.Signature == "1");
break;
}
}
else
{
query = query.OrderByDescending(x => x.id);
}
#endregion
var pagedList =await query
.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
var employeeIds = pagedList.Select(x => x.EmployeeId).ToList();
var employees = await _context.Employees
.Where(x => employeeIds.Contains(x.id)).Select(x => new
{
Id = x.id,
x.FullName
}).ToListAsync();
var result = new PagedResult<GetContractListForClientResponse>
{
TotalCount = await query.CountAsync(),
List = pagedList.Select(c =>
{
var employeeFullName = employees
.FirstOrDefault(e => e.Id == c.EmployeeId)?.FullName ?? "";
return new GetContractListForClientResponse
{
Id = c.id,
PersonnelCode = c.PersonnelCode.ToString(),
ContractStart = c.ContarctStart.ToFarsi(),
ContractEnd = c.ContractEnd.ToFarsi(),
ContractNo = c.ContractNo,
IsSigned = c.Signature == "1",
EmployeeFullName = employeeFullName,
AvgWorkingHour = WeeklyHourConvertor(c.WorkingHoursWeekly),
DailyWage = c.DayliWage,
FamilyAllowance = c.FamilyAllowance
};
}).ToList()
};
return result;
}
public async Task<List<ContractPrintViewModel>> PrintAllAsync(List<long> ids)
{
var query =await _context.Contracts.Include(x => x.Employer)
.Include(x => x.Employee).Where(x => ids.Contains(x.id))
.ToListAsync();
var workshopIds = query.Select(x => x.WorkshopIds).Distinct().ToList();
var workshops = await _context.Workshops
.Where(x => workshopIds.Contains(x.id))
.ToListAsync();
List<long> exceptionWorkshops = [516,63,38,39];
var res = query.Select(x =>
{
var workshop = workshops.FirstOrDefault(w => w.id == x.WorkshopIds);
var employerRes = new ContractPrintEmployerViewModel()
{
WorkshopName = workshop!.WorkshopName,
Address =$"{workshop.State} - {workshop.City} - {workshop.Address}",
LegalType = x.Employer.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
LegalEmployer = x.Employer.IsLegal == "حقیقی"
? null
: new ContractPrintLegalEmployerViewModel()
{
NationalId = x.Employer.NationalId,
RegisterId = x.Employer.RegisterId,
CompanyName = x.Employer.LName,
},
RealEmployer = x.Employer.IsLegal == "حقیقی"
? new ContractPrintRealEmployerViewModel()
{
FullName = x.Employer.FullName,
IdNumber = x.Employer.IdNumber,
NationalCode = x.Employer.Nationalcode
}
: null,
WorkshopCode = workshop.InsuranceCode
};
var employeeRes = new ContractPrintEmployeeViewModel()
{
Address =$"{x.Employee.State} - {x.Employee.City} - {x.Employee.Address}" ,
FullName = x.Employee.FullName,
IdNumber = x.Employee.IdNumber,
NationalCode = x.Employee.NationalCode,
DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
FatherName = x.Employee.FatherName,
LevelOfEducation = x.Employee.LevelOfEducation
};
var typeOfContract = new ContractPrintTypeOfContractViewModel()
{
ContarctStart = x.ContarctStart.ToFarsi(),
ContractEnd = x.ContractEnd.ToFarsi(),
JobName = x.JobType,
ContractType = x.ContractType,
SetContractDate = x.SetContractDate.ToFarsi(),
WorkingHoursWeekly = WeeklyHourConvertor(x.WorkingHoursWeekly),
WorkshopAddress = [x.WorkshopAddress1, x.WorkshopAddress2],
};
ContractPrintFeesViewModel fees= new ContractPrintFeesViewModel()
{
DailyWage = x.DayliWage,
FamilyAllowance = x.FamilyAllowance,
HousingAllowance = x.HousingAllowance,
ConsumableItems = x.ConsumableItems,
};
return new ContractPrintViewModel()
{
Employer = employerRes,
Employee = employeeRes,
TypeOfContract = typeOfContract,
Fees = fees,
ContractNo = x.ContractNo,
ConditionAndDetials = exceptionWorkshops.Contains(x.WorkshopIds) ? "بر اساس ماده 190 قانون کار جمهوری اسلامی ایران ، پرسنل اقرار مینماید کلیه مبالغ پیش بینی شده در قانون کار را وفق قرارداد منعقده دریافت مینماید. این مبالغ قسمتی بصورت مستقیم از سوی کارفرما و قسمتی بر اساس شرایط کارگاه از محل درآمد حاصله از مشتری اخذ میگردد . با توجه به شرایط کارگاه کلیه مبالغ بصورت واریز به حساب و وجه نقد رایج کشور ، تواما به پرسنل پرداخت میگردد. امضا تصفیه حساب دارای مبالغ ، توسط پرسنل نشانگر تصفیه قطعی ایشان میباشد.": "",
};
}).ToList();
return res;
}
#endregion
#region NewChangeByHeydari

View File

@@ -1,23 +1,24 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Exceptions;
using _0_Framework.InfraStructure;
using Company.Domain.ClientEmployeeWorkshopAgg;
using Company.Domain.EmployeeAccountAgg;
using Company.Domain.EmployeeAgg;
using CompanyManagment.App.Contracts.Employee;
using Company.Domain.EmployeeInsuranceRecordAgg;
using Company.Domain.InsuranceListAgg;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.Employee.DTO;
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
using CompanyManagment.App.Contracts.LeftWorkTemp;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using CompanyManagment.App.Contracts.Employee.DTO;
using CompanyManagment.App.Contracts.LeftWorkTemp;
using _0_Framework.Application.Enums;
using _0_Framework.Exceptions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace CompanyManagment.EFCore.Repository;
@@ -33,7 +34,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
public bool city = true;
public DateTime initial = new DateTime(1922, 01, 01, 00, 00, 00, 0000000);
private readonly IAuthHelper _authHelper;
public EmployeeRepository(CompanyContext context, IConfiguration configuration, IAuthHelper authHelper) :base(context)
public EmployeeRepository(CompanyContext context, IConfiguration configuration, IAuthHelper authHelper) : base(context)
{
_context = context;
_configuration = configuration;
@@ -42,13 +43,13 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
public List<EmployeeViewModel> GetEmployee()
{
return _context.Employees.Where(x=>x.IsActive).Select(x => new EmployeeViewModel
return _context.Employees.Where(x => x.IsActive).Select(x => new EmployeeViewModel
{
Id = x.id,
FName = x.FName,
LName = x.LName,
EmployeeFullName = x.FName +" "+x.LName,
EmployeeFullName = x.FName + " " + x.LName,
FatherName = x.FatherName,
NationalCode = x.NationalCode,
IdNumber = x.IdNumber,
@@ -61,48 +62,48 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
public EditEmployee GetDetails(long id)
{
return _context.Employees.Select(x => new EditEmployee
{
Id = x.id,
FName = x.FName,
LName = x.LName,
Gender = x.Gender,
NationalCode = x.NationalCode,
IdNumber = x.IdNumber,
Nationality = x.Nationality,
FatherName = x.FatherName,
DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
PlaceOfIssue = x.PlaceOfIssue,
Phone = x.Phone,
Address = x.Address,
State = x.State,
City = x.City,
MaritalStatus = x.MaritalStatus,
MilitaryService = x.MilitaryService,
LevelOfEducation = x.LevelOfEducation,
FieldOfStudy = x.FieldOfStudy,
BankCardNumber = x.BankCardNumber,
BankBranch = x.BankBranch,
InsuranceCode = x.InsuranceCode,
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
NumberOfChildren = x.NumberOfChildren,
OfficePhone = x.OfficePhone,
EmployeeFullName = x.FName + " " + x.LName,
MclsUserName =x.MclsUserName,
MclsPassword = x.MclsPassword,
EserviceUserName = x.EserviceUserName,
EservicePassword = x.EservicePassword,
TaxOfficeUserName = x.TaxOfficeUserName,
TaxOfficepassword = x.TaxOfficepassword,
SanaUserName = x.SanaUserName,
SanaPassword = x.SanaPassword,
{
Id = x.id,
FName = x.FName,
LName = x.LName,
Gender = x.Gender,
NationalCode = x.NationalCode,
IdNumber = x.IdNumber,
Nationality = x.Nationality,
FatherName = x.FatherName,
DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
PlaceOfIssue = x.PlaceOfIssue,
Phone = x.Phone,
Address = x.Address,
State = x.State,
City = x.City,
MaritalStatus = x.MaritalStatus,
MilitaryService = x.MilitaryService,
LevelOfEducation = x.LevelOfEducation,
FieldOfStudy = x.FieldOfStudy,
BankCardNumber = x.BankCardNumber,
BankBranch = x.BankBranch,
InsuranceCode = x.InsuranceCode,
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
NumberOfChildren = x.NumberOfChildren,
OfficePhone = x.OfficePhone,
EmployeeFullName = x.FName + " " + x.LName,
MclsUserName = x.MclsUserName,
MclsPassword = x.MclsPassword,
EserviceUserName = x.EserviceUserName,
EservicePassword = x.EservicePassword,
TaxOfficeUserName = x.TaxOfficeUserName,
TaxOfficepassword = x.TaxOfficepassword,
SanaUserName = x.SanaUserName,
SanaPassword = x.SanaPassword,
})
})
.FirstOrDefault(x => x.Id == id);
}
public async Task<List<EmployeeViewModel>> Search(EmployeeSearchModel searchModel)
@@ -182,10 +183,10 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
return query.OrderByDescending(x => x.Id).Take(100).ToList();
}
public async Task<List<EmployeeSelectListViewModel>> GetEmployeeToList()
public async Task<List<EmployeeSelectListViewModel>> GetEmployeeToList()
{
var watch = System.Diagnostics.Stopwatch.StartNew();
List<EmployeeSelectListViewModel> result = null;
var connection = _configuration.GetConnectionString("MesbahDb");
using (var conn = new SqlConnection(connection))
@@ -195,7 +196,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
var command = new SqlCommand("EmployeeFullNameId", conn);
command.CommandType = CommandType.StoredProcedure;
using (var reader = await command.ExecuteReaderAsync())
{
@@ -273,45 +274,45 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
public EditEmployee GetDetailsByADDate(long id)
{
return _context.Employees.Select(x => new EditEmployee
{
Id = x.id,
FName = x.FName,
LName = x.LName,
Gender = x.Gender,
NationalCode = x.NationalCode,
IdNumber = x.IdNumber,
Nationality = x.Nationality,
FatherName = x.FatherName,
DateOfBirthGr = x.DateOfBirth ,
DateOfIssueGr = x.DateOfIssue ,
DateOfBirth = x.DateOfBirth.ToFarsi(),
DateOfIssue = x.DateOfIssue.ToFarsi(),
PlaceOfIssue = x.PlaceOfIssue,
Phone = x.Phone,
Address = x.Address,
State = x.State,
City = x.City,
MaritalStatus = x.MaritalStatus,
MilitaryService = x.MilitaryService,
LevelOfEducation = x.LevelOfEducation,
FieldOfStudy = x.FieldOfStudy,
BankCardNumber = x.BankCardNumber,
BankBranch = x.BankBranch,
InsuranceCode = x.InsuranceCode,
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
NumberOfChildren = x.NumberOfChildren,
OfficePhone = x.OfficePhone,
EmployeeFullName = x.FName + " " + x.LName,
MclsUserName = x.MclsUserName,
MclsPassword = x.MclsPassword,
EserviceUserName = x.EserviceUserName,
EservicePassword = x.EservicePassword,
TaxOfficeUserName = x.TaxOfficeUserName,
TaxOfficepassword = x.TaxOfficepassword,
SanaUserName = x.SanaUserName,
SanaPassword = x.SanaPassword,
})
{
Id = x.id,
FName = x.FName,
LName = x.LName,
Gender = x.Gender,
NationalCode = x.NationalCode,
IdNumber = x.IdNumber,
Nationality = x.Nationality,
FatherName = x.FatherName,
DateOfBirthGr = x.DateOfBirth,
DateOfIssueGr = x.DateOfIssue,
DateOfBirth = x.DateOfBirth.ToFarsi(),
DateOfIssue = x.DateOfIssue.ToFarsi(),
PlaceOfIssue = x.PlaceOfIssue,
Phone = x.Phone,
Address = x.Address,
State = x.State,
City = x.City,
MaritalStatus = x.MaritalStatus,
MilitaryService = x.MilitaryService,
LevelOfEducation = x.LevelOfEducation,
FieldOfStudy = x.FieldOfStudy,
BankCardNumber = x.BankCardNumber,
BankBranch = x.BankBranch,
InsuranceCode = x.InsuranceCode,
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
NumberOfChildren = x.NumberOfChildren,
OfficePhone = x.OfficePhone,
EmployeeFullName = x.FName + " " + x.LName,
MclsUserName = x.MclsUserName,
MclsPassword = x.MclsPassword,
EserviceUserName = x.EserviceUserName,
EservicePassword = x.EservicePassword,
TaxOfficeUserName = x.TaxOfficeUserName,
TaxOfficepassword = x.TaxOfficepassword,
SanaUserName = x.SanaUserName,
SanaPassword = x.SanaPassword,
})
.FirstOrDefault(x => x.Id == id);
}
@@ -324,7 +325,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
EmployeeFullName = x.FName + " " + x.LName,
IsActive = x.IsActive
}).Where(x=>x.IsActive).ToList();
}).Where(x => x.IsActive).ToList();
}
#region Client
@@ -452,7 +453,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth,
dateOfIssue,
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,command.IdNumberSerial,command.IdNumberSeri,
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.IdNumberSerial, command.IdNumberSeri,
command.Phone, command.Address,
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
command.FieldOfStudy, command.BankCardNumber,
@@ -706,20 +707,20 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
{
case null:
case "":
query = query.Where(x => x.IsActive == true).ToList();
break;
query = query.Where(x => x.IsActive == true).ToList();
break;
case "false":
query = query.Where(x => x.IsActive == false).ToList();
hasSearch = true;
break;
query = query.Where(x => x.IsActive == false).ToList();
hasSearch = true;
break;
case "both":
query = query.Where(x => x.IsActive == true || x.IsActive == false).ToList();
hasSearch = true;
break;
query = query.Where(x => x.IsActive == true || x.IsActive == false).ToList();
hasSearch = true;
break;
}
}
if (hasSearch)
{
return query.OrderByDescending(x => x.Id).ToList();
@@ -816,11 +817,11 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
var employeesQuery = _context.Employees.Where(x =>
workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id)).Select(x => new
{
leftWork = workshopActiveLeftWorksQuery.Where(l => l.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
insuranceLeftWork = workshopActiveInsuranceLeftWorksQuery.Where(i => i.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
Employee = x
});
{
leftWork = workshopActiveLeftWorksQuery.Where(l => l.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
insuranceLeftWork = workshopActiveInsuranceLeftWorksQuery.Where(i => i.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
Employee = x
});
@@ -878,7 +879,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
}).ToList();
}
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
{
var employee = await _context.Employees.Where(x => x.id == employeeId).Select(x => new GetEditEmployeeInEmployeeDocumentViewModel()
@@ -946,13 +947,13 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
}).ToList();
}
#endregion
#endregion
#region Api
#region Api
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id)
{
var query = _context.Employees.AsQueryable();
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText, long id)
{
var query = _context.Employees.AsQueryable();
EmployeeSelectListViewModel idSelected = null;
if (id > 0)
{
@@ -963,104 +964,104 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
}).FirstOrDefaultAsync(x => x.Id == id);
}
if (!string.IsNullOrWhiteSpace(searchText))
{
query = query.Where(x => (x.FName + " " + x.LName).Contains(searchText));
}
{
query = query.Where(x => (x.FName + " " + x.LName).Contains(searchText));
}
var list = await query.Take(100).Select(x => new EmployeeSelectListViewModel()
{
Id = x.id,
EmployeeFullName = x.FName + " " + x.LName
}).ToListAsync();
var list = await query.Take(100).Select(x => new EmployeeSelectListViewModel()
{
Id = x.id,
EmployeeFullName = x.FName + " " + x.LName
}).ToListAsync();
if (idSelected != null)
list.Add(idSelected);
return list.DistinctBy(x=>x.Id).ToList();
return list.DistinctBy(x => x.Id).ToList();
}
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
{
var query = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances).AsQueryable();
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
{
var query = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances).AsQueryable();
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
{
query = query.Where(x => x.NationalCode.Contains(searchModel.NationalCode));
}
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
{
query = query.Where(x => x.NationalCode.Contains(searchModel.NationalCode));
}
if (searchModel.EmployeeId > 0)
{
query = query.Where(x => x.id == searchModel.EmployeeId);
}
if (searchModel.EmployeeId > 0)
{
query = query.Where(x => x.id == searchModel.EmployeeId);
}
if (searchModel.WorkshopId > 0)
{
query = query.Where(x => x.LeftWorks.Any(l => l.WorkshopId == searchModel.WorkshopId) || x.LeftWorkInsurances.Any(l => l.WorkshopId == searchModel.WorkshopId));
}
if (searchModel.WorkshopId > 0)
{
query = query.Where(x => x.LeftWorks.Any(l => l.WorkshopId == searchModel.WorkshopId) || x.LeftWorkInsurances.Any(l => l.WorkshopId == searchModel.WorkshopId));
}
#region employer
#region employer
if (searchModel.EmployerId > 0)
{
if (searchModel.EmployerId > 0)
{
var workshopIdsByEmployer = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
.Include(x => x.Workshop).Select(x => x.Workshop.id).AsQueryable();
var workshopIdsByEmployer = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
.Include(x => x.Workshop).Select(x => x.Workshop.id).AsQueryable();
query = query.Where(x =>
x.LeftWorks.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)) ||
x.LeftWorkInsurances.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)));
query = query.Where(x =>
x.LeftWorks.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)) ||
x.LeftWorkInsurances.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)));
}
#endregion
}
#endregion
if (!string.IsNullOrEmpty(searchModel.InsuranceCode))
{
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
}
if (!string.IsNullOrEmpty(searchModel.InsuranceCode))
{
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
}
if (searchModel.EmployeeStatus != ActivationStatus.None)
{
var status = searchModel.EmployeeStatus switch
{
ActivationStatus.Active => true,
ActivationStatus.DeActive => false,
_ => throw new BadRequestException("پارامتر جستجو نامعتبر است")
};
query = query.Where(x => x.IsActiveString == status.ToString() || x.IsActive == status);
}
if (searchModel.EmployeeStatus != ActivationStatus.None)
{
var status = searchModel.EmployeeStatus switch
{
ActivationStatus.Active => true,
ActivationStatus.DeActive => false,
_ => throw new BadRequestException("پارامتر جستجو نامعتبر است")
};
query = query.Where(x => x.IsActiveString == status.ToString() || x.IsActive == status);
}
var list = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
var list = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
var employeeIds = list.Select(x => x.id);
var employeeIds = list.Select(x => x.id);
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
var result = list.Select(x => new GetEmployeeListViewModel()
{
BirthDate = x.DateOfBirth.ToFarsi(),
ChildrenCount = children.Count(c => c.EmployeeId == x.id).ToString(),
EmployeeFullName = x.FullName,
EmployeeStatus = x.IsActive switch
{
true => ActivationStatus.Active,
false => ActivationStatus.DeActive
},
Gender = x.Gender switch
{
"مرد" => Gender.Male,
"زن" => Gender.Female,
_ => Gender.None
},
Id = x.id,
InsuranceCode = x.InsuranceCode,
NationalCode = x.NationalCode
}).ToList();
var result = list.Select(x => new GetEmployeeListViewModel()
{
BirthDate = x.DateOfBirth.ToFarsi(),
ChildrenCount = children.Count(c => c.EmployeeId == x.id).ToString(),
EmployeeFullName = x.FullName,
EmployeeStatus = x.IsActive switch
{
true => ActivationStatus.Active,
false => ActivationStatus.DeActive
},
Gender = x.Gender switch
{
"مرد" => Gender.Male,
"زن" => Gender.Female,
_ => Gender.None
},
Id = x.id,
InsuranceCode = x.InsuranceCode,
NationalCode = x.NationalCode
}).ToList();
return result;
return result;
}
}
public Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId)
{
@@ -1170,7 +1171,144 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
//
// };
// }).OrderByDescending(x => x.StartWork).ToList();
throw new NotImplementedException();
throw new NotImplementedException();
}
public async Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId)
{
var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime();
var baseQuery = await
(
from personnelCode in _context.PersonnelCodeSet
join employee in _context.Employees
on personnelCode.EmployeeId equals employee.id
where personnelCode.WorkshopId == workshopId
select new
{
Employee = employee,
PersonnelCode = personnelCode
}
).ToListAsync();
if (!string.IsNullOrWhiteSpace(searchModel.EmployeeFullName))
baseQuery = baseQuery.Where(x => x.Employee.FullName.Contains(searchModel.EmployeeFullName)).ToList();
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
baseQuery = baseQuery.Where(x => x.Employee.NationalCode.Contains(searchModel.NationalCode)).ToList();
var employeeIds = baseQuery.Select(x => x.Employee.id).ToList();
var leftWorks = await _context.LeftWorkList
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
.ToListAsync();
var insuranceLeftWorks = await _context.LeftWorkInsuranceList
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
.ToListAsync();
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
var clientTemp = await _context.EmployeeClientTemps.Where(x => x.WorkshopId == workshopId)
.Select(x => x.EmployeeId).ToListAsync();
var leftWorkTempData = await _context.LeftWorkTemps.Where(x => x.WorkshopId == workshopId).ToListAsync();
var startWorkTemp = leftWorkTempData.Where(x => x.LeftWorkType == LeftWorkTempType.StartWork).ToList();
var leftWorkTemp = leftWorkTempData.Where(x => x.LeftWorkType == LeftWorkTempType.LeftWork).ToList();
var result = baseQuery.Select(x =>
{
var left = leftWorks
.Where(l => l.EmployeeId == x.Employee.id)
.MaxBy(l => l.StartWorkDate);
var insuranceLeftWork = insuranceLeftWorks
.Where(l => l.EmployeeId == x.Employee.id).MaxBy(l => l.StartWorkDate);
var contractStart = left != null ? left.StartWorkDate.ToFarsi() : "";
var contractLeft = left != null
? left.LeftWorkDate != hasNotStoppedWorkingYet ? left.LeftWorkDate.ToFarsi() : ""
: "";
var insuranceStart = insuranceLeftWork != null ? insuranceLeftWork.StartWorkDate.ToFarsi() : "";
var insuranceLeft = insuranceLeftWork != null
? insuranceLeftWork.LeftWorkDate != null ? insuranceLeftWork.LeftWorkDate.ToFarsi() : ""
: "";
int personnelCode = Convert.ToInt32($"{x.PersonnelCode.PersonnelCode}");
int numberOfChildren = children.Count(ch => ch.EmployeeId == x.Employee.id);
bool employeeHasLeft =
(!string.IsNullOrWhiteSpace(insuranceLeft) && !string.IsNullOrWhiteSpace(contractLeft))
|| (left == null && !string.IsNullOrWhiteSpace(insuranceLeft))
|| (insuranceLeftWork == null && !string.IsNullOrWhiteSpace(contractLeft));
bool hasClientTemp = clientTemp.Any(c => c == x.Employee.id);
bool hasStartWorkTemp = startWorkTemp.Any(st => st.EmployeeId == x.Employee.id);
bool hasLeftWorkTemp = leftWorkTemp.Any(lf => lf.EmployeeId == x.Employee.id);
return new EmployeeListDto
{
Id = x.Employee.id,
EmployeeFullName = x.Employee.FullName,
PersonnelCode = personnelCode,
MaritalStatus = x.Employee.MaritalStatus,
NationalCode = x.Employee.NationalCode,
IdNumber = x.Employee.IdNumber,
DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
FatherName = x.Employee.FatherName,
NumberOfChildren = $"{numberOfChildren}",
LatestContractStartDate = contractStart,
ContractLeftDate = contractLeft,
LatestInsuranceStartDate = insuranceStart,
InsuranceLeftDate = insuranceLeft,
HasContract = !string.IsNullOrWhiteSpace(contractStart),
HasInsurance = !string.IsNullOrWhiteSpace(insuranceStart),
EmployeeStatusInWorkshop =
hasClientTemp || hasStartWorkTemp ? EmployeeStatusInWorkshop.CreatedByClient :
hasLeftWorkTemp ? EmployeeStatusInWorkshop.LefWorkTemp :
employeeHasLeft ? EmployeeStatusInWorkshop.HasLeft : EmployeeStatusInWorkshop.Working,
};
}).OrderBy(x => x.EmployeeStatusInWorkshop).ThenBy(x => x.PersonnelCode).ToList();
return result;
}
public async Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId)
{
var res = await ListOfAllEmployeesClient(new EmployeeSearchModelDto(), workshopId);
return res
.Where(x=>x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.CreatedByClient
&& x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp)
.Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList();
}
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
{
var dateNow = DateTime.Now.Date;
var workshopActiveLeftWorksQuery = _context.LeftWorkList.Where(x => x.WorkshopId == workshopId &&
x.StartWorkDate <= dateNow && x.LeftWorkDate > dateNow);
var workshopActiveInsuranceLeftWorksQuery = _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId &&
x.StartWorkDate <= dateNow && (x.LeftWorkDate > dateNow || x.LeftWorkDate == null));
var employeesQuery = _context.Employees.Where(x => workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id));
return await employeesQuery.Select(x => new EmployeeSelectListViewModel()
{
Id = x.id,
EmployeeFullName = x.FullName
}).ToListAsync();
}
#endregion

View File

@@ -176,20 +176,18 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
if (item.InsuranceShare.ToMoney() != checkout.InsuranceDeduction.ToMoney())
{
checkout.SetUpdateNeeded();
if (!_context.CheckoutWarningMessages.Any(x =>
x.CheckoutId == checkout.id && x.TypeOfCheckoutWarning ==
TypeOfCheckoutWarning.InsuranceEmployeeShare))
if (!_context.CheckoutWarningMessages.Any(x => x.CheckoutId == checkout.id && x.TypeOfCheckoutWarning != TypeOfCheckoutWarning.InsuranceEmployeeShare))
{
var createWarrning =
new CheckoutWarningMessage(
"مبلغ بیمه سهم کارگر با مبلغ محاسبه شده در لیست بیمه مغایرت دارد",
checkout.id, TypeOfCheckoutWarning.InsuranceEmployeeShare);
"مبلغ بیمه سهم کارگر با مبلغ محاسبه شده در لیست بیمه مغایرت دارد", checkout.id, TypeOfCheckoutWarning.InsuranceEmployeeShare);
_context.CheckoutWarningMessages.Add(createWarrning);
}
_context.SaveChanges();
}
}
}
}
@@ -731,7 +729,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var id = insuranceListObj.id;
if (command.EmployeeInsurancListDataList != null && command.EmployeeInsurancListDataList.Count > 0)
{
var farisMonthName = Tools.ToFarsiMonthByNumber(command.Month);
var farisMonthName = Tools.ToFarsiMonthByNumber(command.Month);
var checkouts = _context.CheckoutSet.Where(x =>
x.WorkshopId == command.WorkshopId && x.Year == command.Year && x.Month == farisMonthName &&
@@ -761,15 +759,16 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
{
var createWarrning =
new CheckoutWarningMessage(
"مبلغ بیمه سهم کارگر با مبلغ محاسبه شده در لیست بیمه مغایرت دارد",
checkout.id, TypeOfCheckoutWarning.InsuranceEmployeeShare);
"مبلغ بیمه سهم کارگر با مبلغ محاسبه شده در لیست بیمه مغایرت دارد", checkout.id, TypeOfCheckoutWarning.InsuranceEmployeeShare);
_context.CheckoutWarningMessages.Add(createWarrning);
}
_context.SaveChanges();
}
}
}
}
_employeeInsurancListDataRepository.SaveChanges();
@@ -1778,76 +1777,46 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
return res;
}
public async Task<PagedResult<InsuranceClientListViewModel>> GetInsuranceClientList(
InsuranceClientSearchModel searchModel)
public async Task<PagedResult<InsuranceClientListViewModel>> GetInsuranceClientList(InsuranceClientSearchModel searchModel)
{
var workshopId = _authHelper.GetWorkshopId();
var query = _context.InsuranceListSet
.Where(x => x.WorkshopId == workshopId);
if (searchModel.Year > 0)
.Select(x => new InsuranceClientListViewModel
{
query = query.Where(x => x.Year == searchModel.Year.ToString("0000"));
}
Id = x.id,
WorkShopId = x.WorkshopId,
Year = x.Year,
YearInt = Convert.ToInt32(x.Year),
Month = x.Month,
MonthName = x.Month.ToFarsiMonthByNumber(),
MonthInt = Convert.ToInt32(x.Month),
}).Where(x => x.WorkShopId == workshopId);
if (searchModel.Year>0)
{
query = query.Where(x => x.YearInt == searchModel.Year);
}
if (searchModel.Month > 0)
{
query = query.Where(x => x.Month == searchModel.Month.ToString("00"));
query = query.Where(x => x.MonthInt == searchModel.Month);
}
var res = new PagedResult<InsuranceClientListViewModel>
{
TotalCount = query.Count()
};
var list = (await query.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync());
var insuranceListIds = list.Select(x => x.id).ToList();
var employeeData = await _context.EmployeeInsurancListDataSet
.Where(x => insuranceListIds.Contains(x.InsuranceListId))
.GroupBy(x => x.InsuranceListId)
.Select(g => new
{
g.Key,
Count = g.Count(x=>x.LeftWorkDate != null)
}).ToListAsync();
query = searchModel.Sorting switch
{
"CreationDate-Max" => query.OrderByDescending(x => x.id),
"CreationDate-Min" => query.OrderBy(x => x.id),
"Month-Max" => query.OrderByDescending(x => x.Month),
"Month-Min" => query.OrderBy(x => x.Month),
"Year-Max" => query.OrderByDescending(x => x.Year),
"Year-Min" => query.OrderBy(x => x.Year),
_ => query.OrderByDescending(x => x.id),
"CreationDate-Max" => query.OrderByDescending(x => x.Id),
"CreationDate-Min" => query.OrderBy(x => x.Id),
"Month-Max" => query.OrderByDescending(x => x.MonthInt),
"Month-Min" => query.OrderBy(x => x.MonthInt),
"Year-Max" => query.OrderByDescending(x => x.YearInt),
"Year-Min" => query.OrderBy(x => x.YearInt),
_ => query.OrderByDescending(x => x.Id),
};
var resList = list
.Select(x => new InsuranceClientListViewModel
{
Id = x.id,
WorkShopId = x.WorkshopId,
Year = x.Year,
YearInt = Convert.ToInt32(x.Year),
Month = x.Month,
MonthName = x.Month.ToFarsiMonthByNumber(),
MonthInt = Convert.ToInt32(x.Month),
EmployerShare = x.EmployerShare.ToMoney(),
InsuredShare = x.InsuredShare.ToMoney(),
UnEmploymentInsurance = x.UnEmploymentInsurance.ToMoney(),
PersonnelCount = x.SumOfEmployees,
AllInsuredShare = (x.InsuredShare +
x.EmployerShare +
x.UnEmploymentInsurance).ToMoney(),
LeftWorkCount =employeeData.FirstOrDefault(e=>e.Key == x.id)?.Count ?? 0,
}).ToList();
res.List = resList;
res.List =await query.ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToListAsync();
return res;
}
@@ -1913,10 +1882,10 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
query = query.Where(x => x.Month == searchModel.Month).OrderByDescending(x => x.WorkShopName)
.ThenByDescending(x => x.EmployerName).ThenByDescending(x => x.Year);
if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0")
query = query.Where(x => x.Year == searchModel.Year).OrderByDescending(x => x.EmployerName)
.ThenByDescending(x => x.WorkShopName).ThenByDescending(x => x.Month);
if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0")
query = query.Where(x => x.Year == searchModel.Year).OrderByDescending(x => x.EmployerName)
.ThenByDescending(x => x.WorkShopName).ThenByDescending(x => x.Month);
if (!string.IsNullOrEmpty(searchModel.WorkShopCode))
query = query.Where(x => x.WorkShopCode == searchModel.WorkShopCode).OrderByDescending(x => x.Year)
@@ -1996,77 +1965,6 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
return res;
}
public async Task<InsuranceClientPrintViewModel> ClientPrintOne(long id)
{
var insurance = await _context.InsuranceListSet.FirstOrDefaultAsync(x => x.id == id);
if (insurance == null)
return null;
var employeeInsurance = _context.EmployeeInsurancListDataSet
.Where(x => x.InsuranceListId == insurance.id);
var workshop = await _context.Workshops
.Include(x => x.InsuranceWorkshopInfo)
.FirstOrDefaultAsync(x => x.id == insurance.WorkshopId);
var employeeIds = await employeeInsurance
.Select(x => x.EmployeeId).ToListAsync();
var employees = await _context.Employees
.Where(x => employeeIds.Contains(x.id)).ToListAsync();
var jobIds = employeeInsurance.Select(x => x.JobId).ToList();
var jobs = await _context.Jobs
.Where(x => jobIds.Contains(x.id)).ToDictionaryAsync(x => x.id, x => x.JobName);
var employeeData = employeeInsurance.ToList().Select(x =>
{
var employee = employees.FirstOrDefault(e => e.id == x.EmployeeId);
return new InsuranceClientPrintItemsViewModel()
{
BaseYears = x.BaseYears.ToMoney(),
BenefitsIncludedContinuous = x.BenefitsIncludedContinuous.ToMoney(),
BenefitsIncludedNonContinuous = x.BenefitsIncludedNonContinuous.ToMoney(),
DailyWage = x.DailyWage.ToMoney(),
IncludedAndNotIncluded = (x.BenefitsIncludedNonContinuous + x.BenefitsIncludedContinuous).ToMoney(),
WorkingDays = x.WorkingDays.ToString(),
MarriedAllowance = x.MarriedAllowance.ToMoney(),
StartWork = x.StartWorkDate.ToFarsi(),
LeftWork = x.LeftWorkDate.ToFarsi(),
MonthlyBenefits = x.MonthlyBenefits.ToMoney(),
MonthlySalary = x.MonthlySalary.ToMoney(),
NationalCode = employee.NationalCode,
InsuranceCode = employee.InsuranceCode,
JobName = jobs.GetValueOrDefault(x.JobId, ""),
FullName = employee.FullName,
InsuranceShare = x.InsuranceShare.ToMoney(),
};
}).ToList();
var result = new InsuranceClientPrintViewModel()
{
Items = employeeData.ToList(),
AllInsuredShare = (insurance.InsuredShare +
insurance.EmployerShare +
insurance.UnEmploymentInsurance).ToMoney(),
EmployerShare = insurance.EmployerShare.ToMoney(),
InsuredShare = insurance.InsuredShare.ToMoney(),
UnEmploymentInsurance = insurance.UnEmploymentInsurance.ToMoney(),
WorkshopName = workshop.InsuranceWorkshopInfo.WorkshopName,
WorkshopAddress = workshop.InsuranceWorkshopInfo.Address,
WorkshopEmployerName = workshop.InsuranceWorkshopInfo.EmployerName,
WorkshopInsuranceCode = workshop.InsuranceWorkshopInfo.InsuranceCode,
AgreementNumber = workshop.InsuranceWorkshopInfo.AgreementNumber,
ListNo = "01",
Month = insurance.Month,
Year = insurance.Year
};
return result;
}
/// <summary>
///
/// </summary>

View File

@@ -773,137 +773,6 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
return await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.NationalId == nationalId);
}
public async Task<OperationResult> DeActiveAllAsync(long id)
{
OperationResult result = new OperationResult();
await using var transaction = await _context.Database.BeginTransactionAsync();
await using var accountTransaction = await _accountContext.Database.BeginTransactionAsync();
try
{
var contractingParty = _context.PersonalContractingParties
.FirstOrDefault(x => x.id == id);
if (contractingParty == null)
return result.Failed("طرف حساب یافت نشد");
contractingParty.DeActive();
var employers = _context.Employers
.Where(x => x.ContractingPartyId == id).ToList();
employers.ForEach(x => x.DeActive());
var employerIds = employers.Select(x => x.id).ToList();
var workshopIds = _context.WorkshopEmployers
.Where(x => employerIds.Contains(x.EmployerId))
.Select(x => x.WorkshopId).ToList();
var workshops = _context.Workshops
.Where(x => workshopIds.Contains(x.id)).ToList();
workshops.ForEach(x => x.DeActive(x.ArchiveCode));
var contracts = _context.Contracts
.Where(x => workshopIds.Contains(x.WorkshopIds)).ToList();
contracts.ForEach(x => x.DeActive());
var contractIds = contracts.Select(x => x.id).ToList();
var checkouts = _context.CheckoutSet
.Where(x => contractIds.Contains(x.ContractId)).ToList();
checkouts.ForEach(x => x.DeActive());
var contractingPartyAccount =await _context.ContractingPartyAccounts
.FirstOrDefaultAsync(x => x.PersonalContractingPartyId == id);
if (contractingPartyAccount != null)
{
var account = await _accountContext.Accounts
.FirstOrDefaultAsync(x => x.id == contractingPartyAccount.AccountId);
account?.DeActive();
var cameraAccount =await _accountContext.CameraAccounts
.FirstOrDefaultAsync(x=>x.AccountId==account.id);
cameraAccount?.DeActive();
await _accountContext.SaveChangesAsync();
}
await _context.SaveChangesAsync();
await transaction.CommitAsync();
await accountTransaction.CommitAsync();
result.Succcedded();
}
catch (Exception)
{
result.Failed("غیرفعال کردن طرف حساب با خطا مواجه شد");
await transaction.RollbackAsync();
await accountTransaction.RollbackAsync();
}
return result;
}
public async Task<OperationResult> ActiveAllAsync(long id)
{
OperationResult result = new OperationResult();
await using var transaction =await _context.Database.BeginTransactionAsync();
await using var accountTransaction = await _accountContext.Database.BeginTransactionAsync();
try
{
var personel = _context.PersonalContractingParties
.FirstOrDefault(x => x.id == id);
if (personel == null)
return result.Failed("طرف حساب یافت نشد");
personel.Active();
var employers = _context.Employers.Where(x => x.ContractingPartyId == id).ToList();
employers.ForEach(x => x.Active());
var employerIds = employers.Select(x => x.id).ToList();
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId))
.Select(x => x.WorkshopId).ToList();
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
workshops.ForEach(x => x.Active(x.ArchiveCode));
var contracts = _context.Contracts.Where(x => workshopIds.Contains(x.WorkshopIds)).ToList();
contracts.ForEach(x => x.Active());
var contractIds = contracts.Select(x => x.id).ToList();
var checkouts = _context.CheckoutSet.Where(x => contractIds.Contains(x.ContractId)).ToList();
checkouts.ForEach(x => x.Active());
var contractingPartyAccount =await _context.ContractingPartyAccounts
.FirstOrDefaultAsync(x => x.PersonalContractingPartyId == id);
if (contractingPartyAccount != null)
{
var account = await _accountContext.Accounts
.FirstOrDefaultAsync(x => x.id == contractingPartyAccount.AccountId);
account?.Active();
var cameraAccount =await _accountContext.CameraAccounts
.FirstOrDefaultAsync(x=>x.AccountId==account.id);
cameraAccount?.Active();
await _accountContext.SaveChangesAsync();
}
await _context.SaveChangesAsync();
await transaction.CommitAsync();
await accountTransaction.CommitAsync();
result.Succcedded();
}
catch (Exception)
{
result.Failed("فعال کردن طرف حساب با خطا مواجه شد");
await transaction.RollbackAsync();
await accountTransaction.RollbackAsync();
}
return result;
}
#endregion
}

View File

@@ -235,8 +235,7 @@ public class institutionContractController : AdminBaseController
if (balance == "0")
{
result = _institutionContractApplication.DeActive(id);
if (result.IsSuccedded)
result = _institutionContractApplication.DeActiveAllConnections(id);
if (result.IsSuccedded) result = _institutionContractApplication.DeActiveAllConnections(id);
}
else
{
@@ -333,6 +332,21 @@ public class institutionContractController : AdminBaseController
});
}
/// <summary>
/// دانلود اکسل
/// </summary>
/// <returns></returns>
[HttpGet("excel")]
public IActionResult OnGetDownloadExcel()
{
var institutionContractViewModels =
_institutionContractApplication.NewSearch(new() { IsActiveString = "both", TypeOfContract = "both" });
var bytes = InstitutionContractExcelGenerator.GenerateExcel(institutionContractViewModels);
return File(bytes,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
$"قرارداد های مالی.xlsx");
}
[HttpPost("create/inquiry")]
public async Task<ActionResult<OperationResult<ContractingPartyTempViewModel>>> CreateInquiry(
[FromBody] CreateInquiryRequest request)
@@ -800,34 +814,6 @@ public class institutionContractController : AdminBaseController
var res= await _institutionContractApplication.VerifyInstitutionContractManually(id);
return res;
}
[HttpGet("excel-download")]
public async Task<IActionResult> ExcelDownload()
{
var searchModel = new InstitutionContractListSearchModel();
var dataVm=new List<InstitutionContractExcelViewModel>();
foreach (var name in typeof(InstitutionContractListStatus).GetEnumNames())
{
var @enum = Enum.Parse<InstitutionContractListStatus>(name);
searchModel.Status = @enum;
searchModel.PageSize = 99999;
var data =( await(_institutionContractApplication.GetList(searchModel))).List;
dataVm.Add(new InstitutionContractExcelViewModel(){Tab = @enum, GetInstitutionContractListItemsViewModels = data});
}
searchModel.Status = null;
var nullData = ( await(_institutionContractApplication.GetList(searchModel))).List;
dataVm.Add(new InstitutionContractExcelViewModel(){Tab = null, GetInstitutionContractListItemsViewModels = nullData});
var bytes = InstitutionContractExcelGenerator.GenerateExcel(dataVm);
return File(bytes,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
$"قرارداد های مالی.xlsx");
}
}

View File

@@ -2,7 +2,6 @@
using System.Drawing;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account;
using Company.Domain.InstitutionContractAgg;
using CompanyManagement.Infrastructure.Excel.InstitutionContract;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.InstitutionContract;
@@ -39,7 +38,6 @@ public class IndexModel : PageModel
private readonly IInstitutionContractApplication _institutionContract;
private readonly ILeftWorkApplication _leftWorkApplication;
private readonly IRepresentativeApplication _representativeApplication;
private readonly IInstitutionContractRepository _institutionContractRepository;
private readonly string _viewName;
@@ -62,7 +60,7 @@ public class IndexModel : PageModel
IPersonalContractingPartyApp contractingPartyApplication,
IRepresentativeApplication representativeApplication, IInstitutionContractApplication institutionContract,
ILeftWorkApplication leftWorkApplication
, IContactInfoApplication contactInfoApplication, IAccountApplication accountApplication, IInstitutionContractRepository institutionContractRepository)
, IContactInfoApplication contactInfoApplication, IAccountApplication accountApplication)
{
_workshopApplication = workshopApplication;
@@ -73,7 +71,6 @@ public class IndexModel : PageModel
_leftWorkApplication = leftWorkApplication;
_contactInfoApplication = contactInfoApplication;
_accountApplication = accountApplication;
_institutionContractRepository = institutionContractRepository;
}
public string Message { get; set; }
@@ -923,27 +920,12 @@ public class IndexModel : PageModel
});
}
public async Task<IActionResult> OnGetDownloadExcel()
public IActionResult OnGetDownloadExcel()
{
var searchModel = new InstitutionContractListSearchModel();
var dataVm=new List<InstitutionContractExcelViewModel>();
foreach (var name in typeof(InstitutionContractListStatus).GetEnumNames())
{
var @enum = Enum.Parse<InstitutionContractListStatus>(name);
searchModel.Status = @enum;
searchModel.PageSize = 99999;
var data =( await(_institutionContractRepository.GetList(searchModel))).List;
dataVm.Add(new InstitutionContractExcelViewModel(){Tab = @enum, GetInstitutionContractListItemsViewModels = data});
}
searchModel.Status = null;
var nullData = ( await(_institutionContractRepository.GetList(searchModel))).List;
dataVm.Add(new InstitutionContractExcelViewModel(){Tab = null, GetInstitutionContractListItemsViewModels = nullData});
var bytes = InstitutionContractExcelGenerator.GenerateExcel(dataVm);
var institutionContractViewModels = _institutionContract.NewSearch(new() {IsActiveString = "both", TypeOfContract = "both" });
institutionContractViewModels= institutionContractViewModels.GroupBy(x=>x.ContractingPartyId).Select(g=>g.MaxBy(x=>x.ContractStartGr)).ToList();
var bytes = InstitutionContractExcelGenerator.GenerateExcel(institutionContractViewModels);
return File(bytes,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
$"قرارداد های مالی.xlsx");

View File

@@ -1,39 +0,0 @@
using _0_Framework.Application;
using Company.Domain.ContractAgg;
using CompanyManagment.App.Contracts.Contract;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Client.Controllers;
public class ContractController:ClientBaseController
{
private readonly IContractApplication _contractApplication;
public ContractController(IContractApplication contractApplication)
{
_contractApplication = contractApplication;
}
[HttpGet]
public async Task<ActionResult<PagedResult<GetContractListForClientResponse>>> GetList(
GetContractListForClientRequest searchModel)
{
var res = await _contractApplication
.GetContractListForClient(searchModel);
return res;
}
[HttpGet("print/{id}")]
public async Task<ActionResult<ContractPrintViewModel>> PrintOne(long id)
{
var res = await _contractApplication.PrintOneAsync(id);
return res;
}
[HttpGet("print")]
public async Task<ActionResult<List<ContractPrintViewModel>>> PrintAll([FromQuery] List<long> ids)
{
var res = await _contractApplication.PrintAllAsync(ids);
return res;
}
}

View File

@@ -1,5 +1,6 @@
using _0_Framework.Application;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.Employee.DTO;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
@@ -16,10 +17,38 @@ public class EmployeeController:ClientBaseController
_workshopId = authHelper.GetWorkshopId();
}
[HttpGet("select-list")]
public async Task<ActionResult<List<EmployeeSelectListViewModel>>> GetEmployeeSelectList()
{
var result = await _employeeApplication.WorkedEmployeesInWorkshopSelectList(_workshopId);
var result = await _employeeApplication.GetWorkingEmployeesSelectList(_workshopId);
return result;
}
/// <summary>
/// دریافت لیست پرسنل
/// </summary>
/// <param name="searchModel"></param>
/// <returns></returns>
[HttpGet]
public async Task<ActionResult<List<EmployeeListDto>>> GetList(EmployeeSearchModelDto searchModel)
{
var result = await _employeeApplication.ListOfAllEmployeesClient(searchModel, _workshopId);
return result;
}
/// <summary>
/// پرینت تجمیعی پرسنل
/// </summary>
/// <returns></returns>
[HttpGet("PrintAllEmployeesInfo")]
public async Task<ActionResult<List<PrintAllEmployeesInfoDtoClient>>> PrintAllEmployeesInfo()
{
var result = await _employeeApplication.PrintAllEmployeesInfoClient(_workshopId);
return result;
}
}

View File

@@ -19,15 +19,4 @@ public class InsuranceController:ClientBaseController
var insurances =await _insuranceListApplication.GetInsuranceClientList(searchModel);
return Ok(insurances);
}
[HttpGet("print-one")]
public async Task<ActionResult<InsuranceClientPrintViewModel>> ClientPrintList(long id)
{
InsuranceClientPrintViewModel res = await _insuranceListApplication.ClientPrintOne(id);
return res;
}
}
public class InsuranceClientViewModel
{
}

View File

@@ -91,9 +91,9 @@
</span>
</a>
<ul class="submenu">
<li Permission="@SubAccountPermissionHelper.ContractListPermissionCode"><a class="selectLi" href="https://client@(AppSetting.Value.Domain)/contract-list"><span>لیست قرارداد</span></a></li>
<li Permission="@SubAccountPermissionHelper.ContractListPermissionCode"><a class="selectLi" asp-page="/Company/Contracts/Index"><span>لیست قرارداد</span></a></li>
<li Permission="@SubAccountPermissionHelper.CheckoutListPermissionCode"><a class="selectLi" asp-page="/Company/Checkouts/Index"><span>لیست فیش حقوقی</span></a></li>
<li Permission="@SubAccountPermissionHelper.InsuranceListPermissionCode"><a class="selectLi" href="https://client@(AppSetting.Value.Domain)/insurance-list"><span>لیست بیمه</span></a></li>
<li Permission="@SubAccountPermissionHelper.InsuranceListPermissionCode"><a class="selectLi" asp-page="/Company/InsuranceList/Index"><span>لیست بیمه</span></a></li>
<li Permission="@SubAccountPermissionHelper.PersonnelStatusIndividualReportPermissionCode"><a class="selectLi disable" @*onclick="AjaxUrlContentModal('@Url.Page("/Company/Employees/Index", "ContractCheckoutStatus")');"*@><span>گزارش وضعیت انفرادی پرسنل</span></a></li>
<li Permission="@SubAccountPermissionHelper.PersonnelStatusGroupReportPermissionCode"><a class="selectLi disable" @*onclick="AjaxUrlContentModal('@Url.Page("/Company/Workshop/Index", "ContractCheckoutYearlyStatus")');"*@><span>گزارش وضعیت گروهی پرسنل</span></a></li>
</ul>

View File

@@ -289,7 +289,6 @@ builder.Services.AddCors(options =>
"http://localhost:3000",
"http://localhost:4000",
"http://localhost:4001",
"http://localhost:4002",
"http://localhost:3001",
"https://gozareshgir.ir",
"https://dad-mehr.ir",