Compare commits

...

40 Commits

Author SHA1 Message Date
3f55446f82 Merge branch 'Feature/loan/client-api' 2026-02-06 18:29:45 +03:30
3b4f880d54 Merge branch 'Feature/roll-call/client-api' 2026-02-05 15:11:09 +03:30
fb239e3159 Merge branch 'Feature/salary-aid/client-api' 2026-02-05 15:02:32 +03:30
c844867cab add OnPostCreateFromExcelData method to SalaryAidController for bulk salary aid creation from Excel data 2026-02-05 15:00:56 +03:30
779514f5c0 refactor ValidateExcel method in SalaryAidController to use ValidateExcelRequest model 2026-02-05 14:18:18 +03:30
bc491eec18 add EditDetails endpoint to SalaryAidController for salary aid detail retrieval 2026-02-05 13:55:02 +03:30
67910d2fa5 add EditDetails method to SalaryAidController for retrieving salary aid details 2026-02-05 12:50:53 +03:30
9475c786d3 add endpoint to remove employee roll calls by date 2026-02-05 11:58:52 +03:30
db32b1e6ea set WorkshopId in search model for salary aid list retrieval 2026-02-05 11:50:23 +03:30
79a9d72b86 rename SalaryAidViewModels property to Items in grouped view models 2026-02-05 11:32:16 +03:30
dddc4b143a add edit functionality for employee roll call details 2026-02-05 11:29:41 +03:30
a8cb226d20 change list key for salary aid 2026-02-05 11:05:54 +03:30
ffe8fa67e2 refactor salary aid controller to update Excel validation endpoint 2026-02-05 10:33:09 +03:30
a0d2023a6c add Excel validation for salary aid import and update pagination in salary aid list 2026-02-05 10:32:08 +03:30
c2fdc217b9 refactor SetTimeProjectCommandHandler to validate total time after applying changes 2026-02-05 10:14:13 +03:30
db0047d3d3 set time get details 2026-02-03 17:54:32 +03:30
fa4c39904a chnage loan list to new type 2026-02-03 13:44:47 +03:30
3dace574ff refactor date parsing method in RollCallCaseHistoryController 2026-02-02 19:08:25 +03:30
bf2a102a55 add Excel export functionality for roll call case history 2026-02-02 19:07:11 +03:30
88744bd4cf add endpoint to download case history as Excel file 2026-02-02 17:54:33 +03:30
5942075dd6 refactor roll call case history controller and add total working hours endpoint 2026-02-02 17:31:37 +03:30
0e7787dd56 add page size for search model 2026-02-01 18:14:28 +03:30
5c3c9739d1 fix regex and validation for rollcall history case details 2026-01-19 15:30:28 +03:30
355ec72140 comment excel data 2026-01-18 14:17:23 +03:30
b22aa86aea add create - edit - remove salary aid api controller 2026-01-15 10:35:43 +03:30
f0feac9601 add salary aid controller 2026-01-14 19:27:23 +03:30
90fa0ac8f8 change excel download api controller 2026-01-14 10:20:58 +03:30
eb8352e8fc add rollcall download excel controller. 2026-01-14 09:37:55 +03:30
4c7599b568 add print to rollcall case history 2026-01-13 18:50:18 +03:30
d179c90c48 change paginated to list 2026-01-13 18:31:10 +03:30
8850328fd4 add GetEditDetails controller method 2026-01-13 16:08:13 +03:30
915f16c7c0 add rollcall case history upsert 2026-01-13 14:03:10 +03:30
87c3cebb60 set workshopId to readonly 2026-01-13 09:38:44 +03:30
0d72392701 complete rollcall history details 2026-01-12 10:48:19 +03:30
8f6007835c complete rollcallCase history details by employee 2026-01-11 17:25:56 +03:30
05d860795e add rollcall title case history query 2026-01-11 15:12:08 +03:30
607c0780b6 Merge branch 'master' into Feature/loan/client-api 2026-01-10 11:50:52 +03:30
ef49302f8a feat: add workshop ID handling in LoanController for loan search filtering 2026-01-08 12:03:54 +03:30
4ab9f60932 feat: add methods for creating, calculating installments, and removing loans in LoanController 2026-01-01 14:41:13 +03:30
9cfae54db3 feat: add LoanController for managing loan applications and details 2026-01-01 13:13:04 +03:30
28 changed files with 1525 additions and 610 deletions

View File

@@ -7,7 +7,7 @@ namespace _0_Framework.Application;
public class PagedResult<T> where T : class
{
public int TotalCount { get; set; }
public List<T> List { get; set; }
public List<T> List { get; set; } = [];
}
public class PagedResult<T,TMeta>:PagedResult<T> where T : class
{

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.RollCall;
using CompanyManagment.App.Contracts.WorkingHoursTemp;
@@ -91,5 +92,9 @@ namespace Company.Domain.RollCallAgg
Task<List<RollCall>> GetRollCallsUntilNowWithWorkshopIdEmployeeIds(long workshopId, List<long> employeeIds,
DateTime fromDate);
#endregion
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
string titleId, RollCallCaseHistorySearchModel searchModel);
}
}

View File

@@ -1,6 +1,12 @@
using _0_Framework.Excel;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.RollCall;
using OfficeOpenXml;
using OfficeOpenXml.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace CompanyManagement.Infrastructure.Excel.RollCall;
@@ -308,6 +314,111 @@ public class RollCallExcelGenerator : ExcelGenerator
return package.GetAsByteArray();
}
public static byte[] CaseHistoryExcelForEmployee(List<RollCallCaseHistoryDetail> data, string titleId)
{
if (!Regex.IsMatch(titleId, @"^\d{4}_\d{2}$"))
throw new ArgumentException("Invalid titleId format.", nameof(titleId));
var splitDate = titleId.Split("_");
var year = Convert.ToInt32(splitDate.First());
var month = Convert.ToInt32(splitDate.Last());
var startDateFa = $"{year:D4}/{month:D2}/01";
var startDate = startDateFa.ToGeorgianDateTime();
var endDateFa = startDateFa.FindeEndOfMonth();
var endDate = endDateFa.ToGeorgianDateTime();
var dateRange = (int)(endDate.Date - startDate.Date).TotalDays + 1;
var dates = Enumerable.Range(0, dateRange).Select(x => startDate.AddDays(x)).ToList();
var safeData = data ?? new List<RollCallCaseHistoryDetail>();
var first = safeData.FirstOrDefault();
var totalWorkingTime = new TimeSpan(safeData.Sum(x => x.TotalWorkingTime.Ticks));
var viewModel = new CaseHistoryRollCallExcelForEmployeeViewModel
{
EmployeeId = first?.EmployeeId ?? 0,
DateGr = startDate,
PersonnelCode = first?.PersonnelCode,
EmployeeFullName = first?.EmployeeFullName,
PersianMonthName = month.ToFarsiMonthByIntNumber(),
PersianYear = year.ToString(),
TotalWorkingHoursFa = totalWorkingTime.ToFarsiHoursAndMinutes("-"),
TotalWorkingTimeSpan = $"{(int)totalWorkingTime.TotalHours}:{totalWorkingTime.Minutes:00}",
RollCalls = dates.Select((date, index) =>
{
var item = index < safeData.Count ? safeData[index] : null;
var records = item?.Records ?? new List<RollCallCaseHistoryDetailRecord>();
return new RollCallItemForEmployeeExcelViewModel
{
DateGr = date,
DateFa = date.ToFarsi(),
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian(),
PersonnelCode = item?.PersonnelCode,
EmployeeFullName = item?.EmployeeFullName,
IsAbsent = item?.Status == RollCallRecordStatus.Absent,
HasLeave = item?.Status == RollCallRecordStatus.Leaved,
IsHoliday = false,
TotalWorkingHours = (item?.TotalWorkingTime ?? TimeSpan.Zero).ToFarsiHoursAndMinutes("-"),
StartsItems = JoinRecords(records, r => r.StartTime),
EndsItems = JoinRecords(records, r => r.EndTime),
EnterTimeDifferences = JoinRecords(records, r => FormatSignedTimeSpan(r.EntryTimeDifference)),
ExitTimeDifferences = JoinRecords(records, r => FormatSignedTimeSpan(r.ExitTimeDifference))
};
}).ToList()
};
return CaseHistoryExcelForEmployee(viewModel);
}
public static byte[] CaseHistoryExcelForOneDay(List<RollCallCaseHistoryDetail> data, string titleId)
{
if (!Regex.IsMatch(titleId, @"^\d{4}/\d{2}/\d{2}$"))
throw new ArgumentException("Invalid titleId format.", nameof(titleId));
var dateGr = titleId.ToGeorgianDateTime();
var safeData = data ?? new List<RollCallCaseHistoryDetail>();
var viewModel = new CaseHistoryRollCallForOneDayViewModel
{
DateFa = titleId,
DateGr = dateGr,
DayOfWeekFa = dateGr.DayOfWeek.DayOfWeeKToPersian(),
RollCalls = safeData.Select(item =>
{
var records = item.Records ?? new List<RollCallCaseHistoryDetailRecord>();
return new RollCallItemForOneDayExcelViewModel
{
EmployeeFullName = item.EmployeeFullName,
PersonnelCode = item.PersonnelCode,
StartsItems = JoinRecords(records, r => r.StartTime),
EndsItems = JoinRecords(records, r => r.EndTime),
TotalWorkingHours = item.TotalWorkingTime.ToFarsiHoursAndMinutes("-")
};
}).ToList()
};
return CaseHistoryExcelForOneDay(viewModel);
}
private static string JoinRecords(IEnumerable<RollCallCaseHistoryDetailRecord> records, Func<RollCallCaseHistoryDetailRecord, string> selector)
{
var safeRecords = records ?? Enumerable.Empty<RollCallCaseHistoryDetailRecord>();
var values = safeRecords.Select(selector).Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
return values.Count == 0 ? string.Empty : string.Join(Environment.NewLine, values);
}
private static string FormatSignedTimeSpan(TimeSpan value)
{
if (value == TimeSpan.Zero)
return "-";
var abs = value.Duration();
var sign = value.Ticks < 0 ? "-" : "+";
return $"{(int)abs.TotalHours}:{abs.Minutes:00}{sign}";
}
private string CalculateExitMinuteDifference(TimeSpan early, TimeSpan late)
{
if (early == TimeSpan.Zero && late == TimeSpan.Zero)

View File

@@ -21,6 +21,6 @@ public class LoanGroupedViewModel
{
public List<LoanGroupedByDateViewModel> GroupedByDate { get; set; }
public List<LoanGroupedByEmployeeViewModel>GroupedByEmployee { get; set; }
public List<LoanViewModel> LoanListViewModel { get; set; }
public PagedResult<LoanViewModel> LoanListViewModel { get; set; }
}

View File

@@ -16,5 +16,6 @@ public class LoanSearchViewModel
public string EndDate { get; set; }
public int PageIndex { get; set; }
public int PageSize { get; set; } = 30;
public bool ShowAsGrouped { get; set; }
}

View File

@@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Mvc;
namespace CompanyManagment.App.Contracts.RollCall
{
@@ -125,7 +127,62 @@ namespace CompanyManagment.App.Contracts.RollCall
/// <param name="command"></param>
/// <returns></returns>
Task<OperationResult> RecalculateValues(long workshopId, List<ReCalculateRollCallValues> command);
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId, string titleId,
RollCallCaseHistorySearchModel searchModel);
Task<RollCallCaseHistoryExcelDto> DownloadCaseHistoryExcel(long workshopId, string titleId,
RollCallCaseHistorySearchModel searchModel);
}
public class RollCallCaseHistoryExcelDto
{
public byte[] Bytes { get; set; }
public string FileName { get; set; }
public string MimeType { get; set; }
}
public class RollCallCaseHistoryDetail
{
public string EmployeeFullName { get; set; }
public string PersonnelCode { get; set; }
public TimeSpan TotalWorkingTime { get; set; }
public List<RollCallCaseHistoryDetailRecord> Records { get; set; }
public RollCallRecordStatus Status { get; set; }
public long EmployeeId { get; set; }
}
public enum RollCallRecordStatus
{
Worked = 0,
Absent = 1,
Leaved = 2
}
public class RollCallCaseHistoryDetailRecord
{
public TimeSpan EntryTimeDifference { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public TimeSpan ExitTimeDifference { get; set; }
}
public class RollCallCaseHistorySearchModel:PaginationRequest
{
public string StartDate { get; set; }
public string EndDate { get; set; }
public string OneDayDate { get; set; }
public long? EmployeeId { get; set; }
}
public class RollCallCaseHistoryTitleDto
{
public string Id { get; set; }
public string Title { get; set; }
}
public class ReCalculateRollCallValues
{
public long EmployeeId { get; set; }

View File

@@ -8,7 +8,6 @@ public class CreateSalaryAidViewModel
public long WorkshopId { get; set; }
public string Amount { get; set; }
public string SalaryDateTime { get; set; }
public string CalculationDateTime { get; set; }
public string NationalCode { get; set; }
public int CalculationMonth { get; set; }
public int CalculationYear { get; set; }

View File

@@ -8,7 +8,7 @@ public class SalaryAidGroupedByDateViewModel
public string YearFa { get; set; }
public int Month { get; set; }
public int Year { get; set; }
public List<SalaryAidGroupedByDateViewModelItems> SalaryAidViewModels { get; set; }
public List<SalaryAidGroupedByDateViewModelItems> Items { get; set; }
public string TotalAmount { get; set; }
}

View File

@@ -6,7 +6,7 @@ public class SalaryAidGroupedByEmployeeViewModel
{
public string EmployeeName { get; set; }
public long EmployeeId { get; set; }
public List<SalaryAidGroupedByEmployeeViewModelItems> SalaryAidViewModels { get; set; }
public List<SalaryAidGroupedByEmployeeViewModelItems> Items { get; set; }
public string TotalAmount { get; set; }
}

View File

@@ -3,15 +3,15 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.SalaryAid;
public class SalaryAidSearchViewModel
public class SalaryAidSearchViewModel:PaginationRequest
{
public string StartDate { get; set; }
public string EndDate { get; set; }
public long EmployeeId { get; set; }
public long WorkshopId { get; set; }
public int PageIndex { get; set; }
public bool ShowAsGrouped { get; set; }
}

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Security.Cryptography;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.SalaryAid;
@@ -7,7 +8,7 @@ public class SalaryAidsGroupedViewModel
{
public List<SalaryAidGroupedByEmployeeViewModel> GroupedByEmployee { get; set; }
public List<SalaryAidGroupedByDateViewModel> GroupedByDate { get; set; }
public List<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
public PagedResult<SalaryAidViewModel> List { get; set; }
}

View File

@@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
<ProjectReference Include="..\CompanyManagement.Infrastructure.Excel\CompanyManagement.Infrastructure.Excel.csproj" />
<ProjectReference Include="..\CompanyManagment.App.Contracts\CompanyManagment.App.Contracts.csproj" />
<ProjectReference Include="..\CompanyManagment.EFCore\CompanyManagment.EFCore.csproj" />
</ItemGroup>

View File

@@ -3,9 +3,11 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using _0_Framework.Exceptions;
using Company.Domain.CheckoutAgg;
using Company.Domain.CustomizeCheckoutAgg;
using Company.Domain.CustomizeCheckoutTempAgg;
@@ -16,6 +18,8 @@ using Company.Domain.LeaveAgg;
using Company.Domain.RollCallAgg;
using Company.Domain.RollCallAgg.DomainService;
using Company.Domain.RollCallEmployeeAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagement.Infrastructure.Excel.RollCall;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Employee;
using CompanyManagment.App.Contracts.RollCall;
@@ -34,8 +38,9 @@ public class RollCallApplication : IRollCallApplication
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
private readonly IWorkshopRepository _workshopRepository;
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository)
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IWorkshopRepository workshopRepository)
{
_rollCallRepository = rollCallRepository;
_rollCallEmployeeRepository = rollCallEmployeeRepository;
@@ -47,7 +52,8 @@ public class RollCallApplication : IRollCallApplication
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
}
_workshopRepository = workshopRepository;
}
public OperationResult Create(CreateRollCall command)
{
@@ -862,4 +868,58 @@ public class RollCallApplication : IRollCallApplication
}
}
public async Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,
RollCallCaseHistorySearchModel searchModel)
{
return await _rollCallRepository.GetCaseHistoryTitles(workshopId,searchModel);
}
public async Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
string titleId, RollCallCaseHistorySearchModel searchModel)
{
return await _rollCallRepository.GetCaseHistoryDetails(workshopId, titleId, searchModel);
}
public async Task<RollCallCaseHistoryExcelDto> DownloadCaseHistoryExcel(long workshopId, string titleId,
RollCallCaseHistorySearchModel searchModel)
{
var data = await _rollCallRepository
.GetCaseHistoryDetails(workshopId, titleId, searchModel);
string nameSecondPart = "";
byte[] excelBytes;
if (Regex.IsMatch(titleId, @"^\d{4}_\d{2}$"))
{
var splitDate = titleId.Split("_");
var year = Convert.ToInt32(splitDate.First());
var month = Convert.ToInt32(splitDate.Last());
var monthName = Convert.ToInt32(month).ToFarsiMonthByIntNumber();
nameSecondPart = $"{year}/{monthName}";
excelBytes = RollCallExcelGenerator.CaseHistoryExcelForEmployee(data, titleId);
}
else if (Regex.IsMatch(titleId, @"^\d{4}/\d{2}/\d{2}$"))
{
var oneDayDate = titleId.ToGeorgianDateTime();
nameSecondPart = $" {oneDayDate.DayOfWeek.DayOfWeeKToPersian()}،{titleId}";
excelBytes = RollCallExcelGenerator.CaseHistoryExcelForOneDay(data, titleId);
}
else
{
throw new BadRequestException("شناسه سر تیتر وارد شده نامعتبر است");
}
var workshopFullName = _workshopRepository.Get(workshopId)?.WorkshopFullName ?? "بدون کارگاه";
var fileName = $"{workshopFullName} - {nameSecondPart}.xlsx";
var res = new RollCallCaseHistoryExcelDto()
{
Bytes = excelBytes,
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
FileName = fileName
};
return res;
}
}

View File

@@ -433,7 +433,7 @@ public class SalaryAidApplication : ISalaryAidApplication
var checkouts = _checkoutRepository.GetByWorkshopIdEmployeeIdInDate(
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
checkouts?.SetAmountConflict(true);
checkouts?.SetAmountConflict(true);
}
}

View File

@@ -713,10 +713,15 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
var itemsQuery = _companyContext.EmployeeDocumentItems
.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted)
.Include(x => x.EmployeeDocuments)
.ThenInclude(x => x.Workshop).ThenInclude(x => x.WorkshopEmployers).ThenInclude(x => x.Employer)
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
.ThenInclude(x => x.Workshop)
.ThenInclude(x => x.WorkshopEmployers)
.ThenInclude(x => x.Employer)
.GroupBy(x => x.WorkshopId)
.Select(x => new WorkshopWithEmployeeDocumentsViewModel()
{
SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.SubmittedByClient),
SubmittedItemsCount = x
.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin
|| y.DocumentStatus == DocumentStatus.SubmittedByClient),
WorkshopId = x.Key,
WorkshopFullName = x.First().EmployeeDocuments.Workshop.WorkshopName,
EmployerName = x.First().EmployeeDocuments.Workshop.WorkshopEmployers.First().Employer.FullName

View File

@@ -171,22 +171,29 @@ public class LoanRepository : RepositoryBase<long, Loan>, ILoanRepository
query = query.Where(x => x.StartInstallmentPayment >= startDate && x.StartInstallmentPayment <= endDate);
}
result.LoanListViewModel = query.OrderByDescending(x => x.StartInstallmentPayment).Skip(searchModel.PageIndex)
.Take(30).ToList()
.Select(x => new LoanViewModel()
{
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
Amount = x.Amount.ToMoney(),
AmountPerMonth = x.AmountPerMonth.ToMoney(),
StartDateTime = x.StartInstallmentPayment.ToFarsi(),
Count = x.Count,
Id = x.id,
WorkshopId = x.WorkshopId,
EmployeeId = x.EmployeeId,
YearFa = pc.GetYear(x.StartInstallmentPayment).ToString(),
result.LoanListViewModel = new PagedResult<LoanViewModel>()
{
TotalCount = query.Count(),
List = query.OrderByDescending(x => x.StartInstallmentPayment)
.ApplyPagination(searchModel.PageIndex, searchModel.PageSize)
.Take(30).ToList()
.Select(x => new LoanViewModel()
{
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
.ToString(),
Amount = x.Amount.ToMoney(),
AmountPerMonth = x.AmountPerMonth.ToMoney(),
StartDateTime = x.StartInstallmentPayment.ToFarsi(),
Count = x.Count,
Id = x.id,
WorkshopId = x.WorkshopId,
EmployeeId = x.EmployeeId,
YearFa = pc.GetYear(x.StartInstallmentPayment).ToString(),
}).ToList()
};
}).ToList();
return result;
}

File diff suppressed because it is too large Load Diff

View File

@@ -146,7 +146,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
{
YearFa = x.Key.YearFa,
MonthFa = x.Key.MonthFa,
SalaryAidViewModels = x.Select(s => new SalaryAidGroupedByDateViewModelItems()
Items = x.Select(s => new SalaryAidGroupedByDateViewModelItems()
{
Amount = s.Amount,
EmployeeName = s.EmployeeFullName,
@@ -175,7 +175,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
EmployeeId = x.Key,
TotalAmount = x.Sum(s => s.Amount).ToMoney(),
EmployeeName = employees.FirstOrDefault(e => e.id == x.Key).FullName,
SalaryAidViewModels = x.Select(s => new SalaryAidGroupedByEmployeeViewModelItems()
Items = x.Select(s => new SalaryAidGroupedByEmployeeViewModelItems()
{
Amount = s.Amount.ToMoney(),
Id = s.id,
@@ -197,23 +197,28 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate);
}
result.SalaryAidListViewModels = query.OrderByDescending(x => x.SalaryAidDateTime).Skip(searchModel.PageIndex).Take(30).ToList().Select(
x => new SalaryAidViewModel()
{
Amount = x.Amount.ToMoney(),
CreationDate = x.CreationDate.ToFarsi(),
Id = x.id,
EmployeeId = x.EmployeeId,
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
SalaryAidDateTimeGe = x.SalaryAidDateTime,
WorkshopId = x.WorkshopId,
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
AmountDouble = x.Amount,
}).ToList();
result.List = new PagedResult<SalaryAidViewModel>()
{
TotalCount = query.Count(),
List = query.OrderByDescending(x => x.SalaryAidDateTime).ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToList()
.Select(x => new SalaryAidViewModel()
{
Amount = x.Amount.ToMoney(),
CreationDate = x.CreationDate.ToFarsi(),
Id = x.id,
EmployeeId = x.EmployeeId,
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
SalaryAidDateTimeGe = x.SalaryAidDateTime,
WorkshopId = x.WorkshopId,
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
.ToString(),
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
AmountDouble = x.Amount,
}).ToList()
};
return result;
}

View File

@@ -375,7 +375,6 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
// مدیریت هوشمند زمان‌های اضافی
var existingAdditionalTimes = section.AdditionalTimes.ToList();
var incomingAdditionalTimes = sectionItem.AdditionalTime ?? [];
var currentTotalSpent = section.GetTotalTimeSpent();
bool hasRealChange = false;
@@ -406,14 +405,6 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
// اگر آیتم با این ID وجود دارد، بررسی کن اگر تغییر کرده باشد
if (existingAdditionalTime.HasChanged(additionalTimeSpan, additionalTime.Description))
{
var newTotalTime = section.InitialEstimatedHours
.Add(existingAdditionalTimes
.Where(x => x.Id != existingAdditionalTime.Id)
.Aggregate(TimeSpan.Zero, (acc, x) => acc.Add(x.Hours))
.Add(additionalTimeSpan));
ValidateTotalTimeNotLessThanSpent(newTotalTime, currentTotalSpent);
// ویرایش بدون حذف و ایجاد دوباره
existingAdditionalTime.Update(additionalTimeSpan, additionalTime.Description);
hasRealChange = true;
@@ -424,15 +415,17 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
// اگر ID نداشت یا ID جدید بود، اضافه کن
if (additionalTime.Id == null || additionalTime.Id == Guid.Empty)
{
var newTotalTime = section.FinalEstimatedHours.Add(additionalTimeSpan);
ValidateTotalTimeNotLessThanSpent(newTotalTime, currentTotalSpent);
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
hasRealChange = true;
}
}
}
// اعتبارسنجی بعد از اعمال تمام تغییرات
var currentTotalSpent = section.GetTotalTimeSpent();
var newTotalTime = section.FinalEstimatedHours;
ValidateTotalTimeNotLessThanSpent(newTotalTime, currentTotalSpent);
// تغییر status به Incomplete فقط اگر تغییری واقعی اعمال شده باشد و در وضعیتی غیر از ReadyToStart باشد
if (hasRealChange && section.Status != TaskSectionStatus.ReadyToStart)
{

View File

@@ -26,6 +26,7 @@ public record ProjectSetTimeResponseSkill
public class ProjectSetTimeResponseSectionAdditionalTime
{
public Guid Id { get; set; }
public int Hours { get; init; }
public int Minutes { get; init; }
public string Description { get; init; }

View File

@@ -70,6 +70,7 @@ public class ProjectSetTimeDetailsQueryHandler
AdditionalTimes = section?.AdditionalTimes
.Select(x => new ProjectSetTimeResponseSectionAdditionalTime
{
Id = x.Id,
Description = x.Reason ?? "",
Hours = (int)x.Hours.TotalHours,
Minutes = x.Hours.Minutes,

View File

@@ -0,0 +1,59 @@
using _0_Framework.Application;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
using CompanyManagment.App.Contracts.Loan;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Client.Controllers;
public class LoanController: ClientBaseController
{
private readonly ILoanApplication _loanApplication;
private readonly long _workshopId;
public LoanController(ILoanApplication loanApplication, IAuthHelper authHelper)
{
_loanApplication = loanApplication;
_workshopId= authHelper.GetWorkshopId();
}
[HttpGet]
public ActionResult<LoanGroupedViewModel> GetList(LoanSearchViewModel searchModel)
{
searchModel.WorkshopId = _workshopId;
var loans = _loanApplication.GetSearchListAsGrouped(searchModel);
return loans;
}
[HttpGet("{id}")]
public async Task<ActionResult<LoanDetailsViewModel>> GetDetails(long id)
{
var loan = await _loanApplication.GetDetails(id);
return loan;
}
[HttpPost]
public ActionResult<OperationResult> Create([FromBody] CreateLoanViewModel command)
{
var result = _loanApplication.Create(command);
return result;
}
[HttpGet("create/installments")]
public ActionResult<List<LoanInstallmentViewModel>> CalculateLoanInstallment(string amount,
int installmentCount, string loanStartDate, bool getRounded)
{
var installments =
_loanApplication.CalculateLoanInstallment(amount, installmentCount, loanStartDate, getRounded);
return installments;
}
[HttpDelete("{id}")]
public ActionResult<OperationResult> Remove(long id)
{
var result = _loanApplication.Remove(id);
return result;
}
}

View File

@@ -0,0 +1,200 @@
using _0_Framework.Application;
using CompanyManagement.Infrastructure.Excel.RollCall;
using CompanyManagment.App.Contracts.RollCall;
using CompanyManagment.App.Contracts.RollCallEmployee;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Client.Controllers.RollCall;
public class RollCallCaseHistoryController : ClientBaseController
{
private readonly IRollCallApplication _rollCallApplication;
private readonly long _workshopId;
private readonly IWorkshopApplication _workshopApplication;
private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication;
public RollCallCaseHistoryController(IRollCallApplication rollCallApplication,
IAuthHelper authHelper, IWorkshopApplication workshopApplication,
IRollCallEmployeeApplication rollCallEmployeeApplication)
{
_rollCallApplication = rollCallApplication;
_workshopApplication = workshopApplication;
_rollCallEmployeeApplication = rollCallEmployeeApplication;
_workshopId = authHelper.GetWorkshopId();
}
[HttpGet]
public async Task<ActionResult<PagedResult<RollCallCaseHistoryTitleDto>>> GetTitles(
RollCallCaseHistorySearchModel searchModel)
{
return await _rollCallApplication.GetCaseHistoryTitles(_workshopId, searchModel);
}
[HttpGet("details")]
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetDetails(string titleId,
RollCallCaseHistorySearchModel searchModel)
{
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
}
/// <summary>
/// ایجاد و ویرایش
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
[HttpPost]
public ActionResult<OperationResult> Upsert(CreateOrEditEmployeeRollCall command)
{
command.WorkshopId = _workshopId;
return _rollCallApplication.ManualEdit(command);
}
[HttpGet("print")]
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetPrintDetails(string titleId,
RollCallCaseHistorySearchModel searchModel)
{
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
}
[HttpGet("total-working")]
public ActionResult<OperationResult<string>> OnGetTotalWorking(
string startDate,
string startTime,
string endDate,
string endTime)
{
var op = new OperationResult<string>();
const string emptyValue = "-";
if (!TryParseDateTime(startDate, startTime, out var start) ||
!TryParseDateTime(endDate, endTime, out var end))
{
return op.Succcedded(emptyValue);
}
if (start >= end)
{
return op.Succcedded(emptyValue);
}
var duration = (end - start).ToFarsiHoursAndMinutes(emptyValue);
return op.Succcedded(duration);
}
[HttpGet("excel")]
public async Task<IActionResult> GetDownload(string titleId, RollCallCaseHistorySearchModel searchModel)
{
var res =await _rollCallApplication.DownloadCaseHistoryExcel(_workshopId, titleId, searchModel);
return File(res.Bytes,
res.MimeType,
res.FileName);
}
[HttpGet("edit")]
public ActionResult<EditRollCallDetailsResult> GetEditDetails(string date, long employeeId)
{
var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
//var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
var total = new TimeSpan(result.Sum(x =>
(x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
var res = new EditRollCallDetailsResult()
{
EmployeeFullName = name.EmployeeFullName,
EmployeeId = employeeId,
DateFa = date,
//EditableDates = dates,
Records = result.Select(x=>new EmployeeRollCallRecord()
{
Date = x.DateGr,
EndDate = x.EndDateFa,
EndTime = x.EndTimeString,
RollCallId = x.Id,
StartDate = x.StartDateFa,
StartTime = x.StartTimeString
}).ToList(),
TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
};
return res;
}
[HttpPost("edit")]
public ActionResult<OperationResult> Edit(CreateOrEditEmployeeRollCall command)
{
command.WorkshopId = _workshopId;
var result = _rollCallApplication.ManualEdit(command);
return result;
}
[HttpDelete("delete")]
public IActionResult OnPostRemoveEmployeeRollCallsInDate(RemoveEmployeeRollCallRequest request)
{
var result = _rollCallApplication.RemoveEmployeeRollCallsInDate(_workshopId, request.EmployeeId, request.Date);
return new JsonResult(new
{
success = result.IsSuccedded,
message = result.Message,
});
}
// [HttpGet("edit")]
// public ActionResult<> GetEditDetails(string date,long employeeId)
// {
// var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
// //var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
// var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
//
// var total = new TimeSpan(result.Sum(x =>
// (x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
//
// var command = new EmployeeRollCallsViewModel()
// {
// EmployeeFullName = name.EmployeeFullName,
// EmployeeId = employeeId,
// DateFa = date,
// //EditableDates = dates,
// RollCalls = result,
// TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
// };
// }
private static bool TryParseDateTime(string date, string time, out DateTime result)
{
result = default;
try
{
var dateTime = date.ToGeorgianDateTime();
var timeOnly = TimeOnly.Parse(time);
result = dateTime.AddTicks(timeOnly.Ticks);
return true;
}
catch
{
return false;
}
}
}
public class EditRollCallDetailsResult
{
public string EmployeeFullName { get; set; }
public long EmployeeId { get; set; }
public string DateFa { get; set; }
public string TotalRollCallsDuration { get; set; }
public List<EmployeeRollCallRecord> Records { get; set; }
}
public class RemoveEmployeeRollCallRequest
{
public long EmployeeId { get; set; }
public string Date { get; set; }
}

View File

@@ -0,0 +1,138 @@
using _0_Framework.Application;
using CompanyManagement.Infrastructure.Excel.SalaryAid;
using CompanyManagment.App.Contracts.SalaryAid;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Build.Evaluation;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Client.Controllers;
public class SalaryAidController:ClientBaseController
{
private readonly ISalaryAidApplication _salaryAidApplication;
private readonly long _workshopId;
private readonly SalaryAidImportExcel _salaryAidImportExcel;
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel)
{
_salaryAidApplication = salaryAidApplication;
_salaryAidImportExcel = salaryAidImportExcel;
_workshopId = authHelper.GetWorkshopId();
}
[HttpGet]
public ActionResult<SalaryAidsGroupedViewModel> GetList([FromQuery]SalaryAidSearchViewModel searchModel)
{
searchModel.WorkshopId = _workshopId;
var result = _salaryAidApplication.GetSearchListAsGrouped(searchModel);
return Ok(result);
}
[HttpPost]
public ActionResult<OperationResult> Create([FromBody]CreateSalaryAidRequest request)
{
var command = new CreateSalaryAidViewModel()
{
Amount = request.Amount.ToMoney(),
CalculationMonth = request.CalculationMonth,
CalculationYear = request.CalculationYear,
EmployeeIds = request.EmployeeIds,
WorkshopId = _workshopId,
SalaryDateTime = request.SalaryDateTime,
};
var result = _salaryAidApplication.Create(command);
return result;
}
[HttpPut]
public ActionResult<OperationResult> Edit([FromBody]EditSalaryAidRequest request)
{
var command = new EditSalaryAidViewModel()
{
Id = request.Id,
Amount = request.Amount.ToMoney(),
CalculationMonth = request.CalculationMonth,
CalculationYear = request.CalculationYear,
SalaryDateTime = request.SalaryDateTime,
WorkshopId = _workshopId,
};
var result = _salaryAidApplication.Edit(command);
return result;
}
[HttpGet("{id}")]
public ActionResult<EditSalaryAidRequest> EditDetails(long id)
{
var data = _salaryAidApplication.GetDetails(id);
var res = new EditSalaryAidRequest()
{
Id = data.Id,
Amount = data.Amount.MoneyToDouble(),
CalculationMonth = data.CalculationMonth,
CalculationYear = data.CalculationYear,
SalaryDateTime = data.SalaryDateTime,
};
return res;
}
[HttpDelete("{id:long}")]
public ActionResult<OperationResult> Delete(long id)
{
var result = _salaryAidApplication.Remove(id);
return result;
}
[HttpPost("validate-excel")]
public ActionResult<ExcelValidation<SalaryAidImportData>> ValidateExcel([FromForm]ValidateExcelRequest request)
{
var validation = _salaryAidImportExcel.ReadAndValidateExcel(request.Excel, _workshopId);
return validation;
}
[HttpPost("create-from-excel")]
public async Task<ActionResult<OperationResult>> OnPostCreateFromExcelData(List<SalaryAidImportData> data)
{
var commands = data.Select(x => new CreateSalaryAidViewModel()
{
WorkshopId = x.WorkshopId,
Amount = x.Amount.ToMoney(),
EmployeeIds = [x.EmployeeId],
SalaryDateTime = x.SalaryAidDateTime,
NationalCode = x.NationalCode,
CalculationMonth = x.calculationMonth,
CalculationYear = x.calculationYear
}).ToList();
OperationResult result = await _salaryAidApplication.CreateRangeAsync(commands);
return new JsonResult(new
{
result.IsSuccedded,
result.Message
});
}
}
public class ValidateExcelRequest
{
public IFormFile Excel { get; set; }
}
public class EditSalaryAidRequest
{
public long Id { get; set; }
public long EmployeeId { get; set; }
public double Amount { get; set; }
public string SalaryDateTime { get; set; }
public int CalculationMonth { get; set; }
public int CalculationYear { get; set; }
}
public class CreateSalaryAidRequest
{
public List<long> EmployeeIds { get; set; }
public double Amount { get; set; }
public string SalaryDateTime { get; set; }
public int CalculationMonth { get; set; }
public int CalculationYear { get; set; }
}

View File

@@ -250,9 +250,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
var span = end - start;
var hours = (int)span.TotalHours;
var minutes = span.Minutes;
if (hours > 0 && minutes > 0)
{
return new JsonResult(new

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ServiceHost.BaseControllers;
[Authorize(Policy = "AdminArea")]

View File

@@ -42,6 +42,15 @@ public class GeneralController : GeneralBaseController
currentDate
});
}
[HttpGet("persian-day-of-week")]
public ActionResult<OperationResult<string>> OnGetDayOfWeek(string dateFa)
{
var op = new OperationResult<string>();
if (!dateFa.TryToGeorgianDateTime(out DateTime date))
return op.Failed("تاریخ وارد شده نامعتبر است");
return op.Succcedded(date.DayOfWeek.DayOfWeeKToPersian());
}
// [HttpGet("pm-permissions")]
// public IActionResult GetPMPermissions()
@@ -96,44 +105,8 @@ public class GeneralController : GeneralBaseController
var statusCode = isSuccess ? "1" : "0";
return $"{baseUrl}/callback?Status={statusCode}&transactionId={transactionId}";
}
}
public class TokenReq
{
public long Amount { get; set; }
public string CallbackUrl { get; set; }
[Display(Name = "شماره فاکتور")]
[MaxLength(100)]
[Required]
[Key]
// be ezaye har pazirande bayad yekta bashad
public string invoiceID { get; set; }
[Required] public long terminalID { get; set; }
/*
* JSON Bashad
* etelaate takmili site harchi
* nabayad char khas dashte bashe (*'"xp_%!+- ...)
*/
public string Payload { get; set; } = "";
public string email { get; set; }
}
public class TokenResp
{
// if 0 = success
public int Status { get; set; }
public string AccessToken { get; set; }
}
public class PayRequest
{
[Required] [MaxLength(3000)] public string token { get; set; }
[Required] public long terminalID { get; set; }
public string nationalCode { get; set; }
}
public class SepehrGatewayPayResponse
@@ -169,10 +142,4 @@ public class SepehrGatewayPayResponse
public string issuerbank { get; set; }
[Display(Name = " شماره کارت ")] public string cardnumber { get; set; }
}
public class AdviceReq
{
[Display(Name = " رسید دیجیتال ")] public string digitalreceipt { get; set; }
public long Tid { get; set; }
}

View File

@@ -19,7 +19,7 @@
"sqlDebugging": true,
"dotnetRunMessages": "true",
"nativeDebugging": true,
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
"applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5005",
"jsWebView2Debugging": false,
"hotReloadEnabled": true
},