From a2c1fd30bf404d9bd49398e2ef0aa55634043601 Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Sun, 1 Feb 2026 19:36:09 +0330 Subject: [PATCH] Mandatory Compute Added to CreateCheckoutApi --- .../IRollCallMandatoryRepository.cs | 2 +- .../IRollCallEmployeeRepository.cs | 3 +- .../GetContractAndIncludesDataToCreateDto.cs | 88 +++- .../Checkout/ICheckoutApplication.cs | 2 +- .../Hubs/CheckoutHub.cs | 18 + .../CheckoutApplication.cs | 143 +++-- .../RollCallEmployeeStatusApplication.cs | 2 +- .../RollCallMandatoryApplication.cs | 2 +- .../Repository/CheckoutRepository.cs | 497 +++++++++--------- .../Repository/RollCallEmployeeRepository.cs | 23 +- .../Repository/RollCallMandatoryRepository.cs | 12 +- .../Repository/YearlySalaryRepository.cs | 2 +- .../Admin/Controllers/CheckoutController.cs | 43 +- .../Pages/Company/Checkouts/Index.cshtml.cs | 1 + ServiceHost/Hubs/CheckoutHub.cs | 18 - 15 files changed, 541 insertions(+), 315 deletions(-) create mode 100644 CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs delete mode 100644 ServiceHost/Hubs/CheckoutHub.cs diff --git a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs index f7bec585..d5af76a7 100644 --- a/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs +++ b/Company.Domain/RollCallAgg/IRollCallMandatoryRepository.cs @@ -16,7 +16,7 @@ namespace Company.Domain.RollCallAgg; public interface IRollCallMandatoryRepository : IRepository { - ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute); + Task MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute); /// /// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب diff --git a/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs b/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs index 3c164b50..537db5c7 100644 --- a/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs +++ b/Company.Domain/RollCallEmployeeAgg/IRollCallEmployeeRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using _0_Framework.Domain; using CompanyManagment.App.Contracts.RollCallEmployee; @@ -7,7 +8,7 @@ namespace Company.Domain.RollCallEmployeeAgg; public interface IRollCallEmployeeRepository : IRepository { - bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd); + Task HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd); List GetByWorkshopId(long workshopId); EditRollCallEmployee GetDetails(long id); RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId); diff --git a/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs b/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs index 6ee91430..dd5e7891 100644 --- a/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs +++ b/CompanyManagment.App.Contracts/Checkout/Dto/GetContractAndIncludesDataToCreateDto.cs @@ -1,4 +1,5 @@ -using CompanyManagment.App.Contracts.Contract; +using System; +using CompanyManagment.App.Contracts.Contract; using CompanyManagment.App.Contracts.EmployeeComputeOptions; using CompanyManagment.App.Contracts.WorkingHoursTemp; using System.Collections.Generic; @@ -25,6 +26,26 @@ public class GetContractAndIncludesDataToCreateDto /// public string ArchiveCode { get; set; } + /// + /// آیا تنظیمات کارگاه بر رو ایجاد فیش استاتیک است + /// + public bool IsStaticCheckout { get; set; } + + /// + /// آیا کارگاه در تعطیلات رسمی باز است + /// + public bool WorkshopHolidayWorking { get; set; } + + /// + /// محاسبه نوبت کاری در فیش حقوقی + /// + public bool RotatingShiftCompute { get; set; } + + + /// + /// آیا پاداش در فیش حقوقی محاسبه شود + /// + public bool RewardComputeOnCheckout { get; set; } public List ContractIncludedData { get; set; } @@ -85,10 +106,71 @@ public class ContractIncludedData /// /// اطلاعات جداسازی تاریخ فیش /// - public ContractSeparationViewModel Saparation { get; set; } + public ContractSeparationViewModel Separation { get; set; } /// /// تنظیمات فنی پرسنل + /// سنوات /// - public EmployeeComputeOptionsViewModel EmployeeOption { get; set; } + public string YearsOption { get; set; } + + + /// + /// تنظیمات فنی پرسنل + /// عیدی و پاداش + /// + public string BonusesOption { get; set; } + + + + /// + /// تنظیمات فنی پرسنل + /// مزد مرخصی + /// + public string ComputeOption { get; set; } + + + /// + /// ترایخ شروع قراداد + /// شمسی + /// + public string ContractStart { get; set; } + + /// + /// تاریخ پایان قرارداد + /// شمسی + /// + public string ContractEnd { get; set; } + + /// + /// ترایخ شروع قراداد + /// میلادی + /// + public DateTime ContractStartGr { get; set; } + + /// + /// تاریخ پایان قرارداد + /// میلادی + /// + public DateTime ContractEndGr { get; set; } + + /// + /// آی دی قراداد + /// + public long ContractId { get; set; } + + /// + /// مزد روزانه قرداد بدون تاثیر ساعات کار + /// + public double DailySalaryUnAffected { get; set; } + + /// + /// نوع مزد روزانه + /// + public string DailyWageType { get; set; } + + /// + /// اولین شروع بکار پرسنل + /// + public string FirstGetWorkingDay { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs index e513875c..d10e24e1 100644 --- a/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs +++ b/CompanyManagment.App.Contracts/Checkout/ICheckoutApplication.cs @@ -113,7 +113,7 @@ public interface ICheckoutApplication /// /// /// - Task> CreateCheckoutApi(List ids, string year, string month, long workshopId); + Task CreateCheckoutApi(List ids, string year, string month, long workshopId); #endregion } diff --git a/CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs b/CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs new file mode 100644 index 00000000..8c876cac --- /dev/null +++ b/CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.SignalR; + +namespace CompanyManagment.App.Contracts.Hubs; + +public class CheckoutHub : Hub +{ + + public async Task send(long id) + { + await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(id)); + } + + public static string GetGroupName(long id) + { + return $"group-Checkout-{id}"; + } +} \ No newline at end of file diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 11eedd3b..e5681473 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -7,6 +7,7 @@ using Company.Domain.empolyerAgg; using Company.Domain.LeaveAgg; using Company.Domain.LeftWorkAgg; using Company.Domain.RollCallAgg; +using Company.Domain.RollCallEmployeeAgg; using Company.Domain.WorkingHoursTempAgg; using Company.Domain.WorkshopAgg; using Company.Domain.YearlySalaryAgg; @@ -14,6 +15,7 @@ using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Checkout.Dto; using CompanyManagment.App.Contracts.Contract; using CompanyManagment.App.Contracts.HolidayItem; +using CompanyManagment.App.Contracts.Hubs; using CompanyManagment.App.Contracts.Leave; using CompanyManagment.App.Contracts.MandantoryHours; using CompanyManagment.App.Contracts.PersonalContractingParty; @@ -23,8 +25,10 @@ using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.EFCore.Migrations; using CompanyManagment.EFCore.Repository; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.SignalR; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; @@ -48,12 +52,13 @@ public class CheckoutApplication : ICheckoutApplication private readonly IWorkingHoursTempRepository _workingHoursTempRepository; private readonly IWorkshopRepository _workshopRepository; private readonly IAuthHelper _authHelper; - + private readonly IHubContext _hubContext; + private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository; public CheckoutApplication(ICheckoutRepository checkoutRepository, IYearlySalaryRepository yearlySalaryRepository, ILeftWorkRepository leftWorkRepository, - IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper) + IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper, IHubContext hubContext, IRollCallEmployeeRepository rollCallEmployeeRepository) { _checkoutRepository = checkoutRepository; _yearlySalaryRepository = yearlySalaryRepository; @@ -68,6 +73,8 @@ public class CheckoutApplication : ICheckoutApplication _workingHoursTempRepository = workingHoursTempRepository; _workshopRepository = workshopRepository; _authHelper = authHelper; + _hubContext = hubContext; + _rollCallEmployeeRepository = rollCallEmployeeRepository; } [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 241")] @@ -799,38 +806,15 @@ public class CheckoutApplication : ICheckoutApplication } - public async Task> CreateCheckoutApi(List ids, string year, string month, long workshopId) + public async Task CreateCheckoutApi(List ids, string year, string month, long workshopId) { + var op = new OperationResult(); //آی دی کاربر لاگین شده برای استفاده در signalR - var currentAcc = _authHelper.CurrentAccountId(); + var currntAcc = _authHelper.CurrentAccountId(); - #region Validation - //if (!string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) - // return op.Failed("ماه را انتخاب کنید"); - //if (string.IsNullOrWhiteSpace(year) && !string.IsNullOrWhiteSpace(month)) - // return op.Failed("سال را انتخاب کنید"); - - //if (string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) - //{ - // year = "0"; - // month = "0"; - - // var today = DateTime.Now; - // var FaToday = today.ToFarsi(); - // var convertedYear = FaToday.Substring(0, 4); - // var convertedMonth = FaToday.Substring(5, 2); - - // year = convertedYear; - // month = convertedMonth; - //} - - //if (ids.Count == 0) - // return op.Failed("هیچ موردی انتخاب نشده اشت"); - - #endregion #region GetInsuranceData @@ -839,9 +823,108 @@ public class CheckoutApplication : ICheckoutApplication #endregion - var getContcatsData = await + var getContractsData = await _checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, year, month, workshopId); - return getContcatsData; + + if (!getContractsData.IsSuccedded) + { + await _hubContext.Clients.Group(CheckoutHub.GetGroupName(currntAcc)) + .SendAsync("StartProcessingFailed", getContractsData.Message); + return op.Failed(getContractsData.Message); + } + var timer = new Stopwatch(); + timer.Start(); + int i = 0; + foreach (var item in getContractsData.Data.ContractIncludedData) + { + + //آیا کل مرخصی به ساعت کاراضافه شود؟ + bool totalLeaveCompute = false; + //آیا غیبت محاسبه شود؟ + bool abcenseDeduction = false; + switch (item.ComputeOption) + { + case "OnEndOfYear": + var endOfYearCheckout = item.Separation.ContractEnd.Substring(5, 2); + + totalLeaveCompute = true; + abcenseDeduction = item.Separation.HasLeft || endOfYearCheckout == "12"; + break; + case "OnLeftWork": + + totalLeaveCompute = true; + abcenseDeduction = item.Separation.HasLeft; + break; + case "OnEndOfContract": + var startMonth = item.ContractStart.Substring(5, 2); + var endMonth = item.ContractEnd.Substring(5, 2); + + totalLeaveCompute = startMonth != endMonth; + abcenseDeduction = (startMonth != endMonth && item.Separation.HasLeft) || (startMonth != endMonth && item.ContractEndGr == item.Separation.ContractEndGr); + break; + } + + + //دستمزد روزانه بدون تاثیر ساعت کار + #region DailyWageCompute + + var contract = new EditContract() + { + ContractStartGr = item.ContractStartGr, + ContractEndGr = item.ContractEndGr, + DailySalaryUnAffected = item.DailySalaryUnAffected, + DailyWageType = item.DailyWageType, + ContarctStart = item.ContractStart, + ContractEnd = item.ContractEnd, + GetWorkDate = item.FirstGetWorkingDay, + GetWorkDateHide = item.FirstGetWorkingDay, + + }; + + //دستمزد روزانه بدون تاثیر ساعت کار + var dailyWageUnAffected =await _yearlySalaryRepository.GetCheckoutDailyWage(contract, + item.Separation.ContractStartGr, item.Separation.ContractEndGr); + + #endregion + + + + + var hasRollCall =await _rollCallEmployeeRepository.HasRollCallRecord(item.EmployeeId, workshopId, item.Separation.ContractStartGr, item.Separation.ContractEndGr); + if (getContractsData.Data.IsStaticCheckout) + hasRollCall = false; + + //محاسبه موظفی + #region MandatoryCompute + var mandatoryCompute = new ComputingViewModel(); + + item.WorkingHours.ContractStartGr = item.Separation.ContractStartGr; + item.WorkingHours.ContractEndGr = item.Separation.ContractEndGr; + item.WorkingHours.ContarctStart = item.Separation.ContarctStart; + item.WorkingHours.ContractEnd = item.Separation.ContractEnd; + item.WorkingHours.GetWorkDate = contract.GetWorkDate; + item.WorkingHours.GetWorkDateHide = contract.GetWorkDate; + item.WorkingHours.WorkshopId = workshopId; + item.WorkingHours.EmployeeId = item.EmployeeId; + + mandatoryCompute =await _rollCallMandatoryRepository.MandatoryCompute(item.EmployeeId, workshopId, + item.Separation.ContractStartGr, item.Separation.ContractEndGr, item.WorkingHours, getContractsData.Data.WorkshopHolidayWorking, + hasRollCall, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute); + + #endregion + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine("================================================================== "); + Console.WriteLine("========================================Counter ================== " + (i+1)); + Console.WriteLine("================================================================== "); + Console.ResetColor(); + i += 1; + } + + + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("after GetData To mandatoryCompute" + timer.Elapsed); + Console.ResetColor(); + return op.Succcedded(); } #endregion diff --git a/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs b/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs index 44acfd3e..596fa3e9 100644 --- a/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs +++ b/CompanyManagment.Application/RollCallEmployeeStatusApplication.cs @@ -90,7 +90,7 @@ namespace CompanyManagment.Application public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd) { - return _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, contractStart, contractEnd); + return _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, contractStart, contractEnd).GetAwaiter().GetResult(); } public List GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr) diff --git a/CompanyManagment.Application/RollCallMandatoryApplication.cs b/CompanyManagment.Application/RollCallMandatoryApplication.cs index dd9bbd39..ea16f367 100644 --- a/CompanyManagment.Application/RollCallMandatoryApplication.cs +++ b/CompanyManagment.Application/RollCallMandatoryApplication.cs @@ -24,7 +24,7 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute) { - return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute); + return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout, rotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute).GetAwaiter().GetResult(); } diff --git a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs index 1321ab42..144cb9cd 100644 --- a/CompanyManagment.EFCore/Repository/CheckoutRepository.cs +++ b/CompanyManagment.EFCore/Repository/CheckoutRepository.cs @@ -301,7 +301,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos : startSreach; bool hasRollCall = _rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startStatusSearch, - endStatusSearch); + endStatusSearch).GetAwaiter().GetResult(); bool extension = true; bool laterThanEnd = false; @@ -321,7 +321,8 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos { // اگر ترک کار کرده بود // اگر ترک کارش در بازه انتخاب شده بود - if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch) + var leftFirstDayOfNextMonth = endSearch.AddDays(1); + if (leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= leftFirstDayOfNextMonth) { //اگر بازه انتخاب شده در تاریخ جاری بود if (startSreach == currentStart && endSearch == currentEnd) @@ -4007,293 +4008,293 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos } - foreach (var item in seprationData) - { - bool hasLeft = false; - var ContractEnd = item.ContractEnd; - var contractStart = item.ContarctStart; - var leftWork = leftWorks.FirstOrDefault(x => x.EmployeeId == item.EmployeeId && item.ContarctStart <= x.LeftWorkDate && item.ContractEnd >= x.StartWorkDate); - if (leftWork == null) - { - separation.Add(new ContractSeparationViewModel() - { - checker = false, - EmployeeId = item.EmployeeId - }); + //foreach (var item in seprationData) + //{ + // bool hasLeft = false; + // var ContractEnd = item.ContractEnd; + // var contractStart = item.ContarctStart; + // var leftWork = leftWorks.FirstOrDefault(x => x.EmployeeId == item.EmployeeId && item.ContarctStart <= x.LeftWorkDate && item.ContractEnd >= x.StartWorkDate); + // if (leftWork == null) + // { + // separation.Add(new ContractSeparationViewModel() + // { + // checker = false, + // EmployeeId = item.EmployeeId + // }); - } + // } - if (leftWork.HasLeft && leftWork.LeftWorkDate < item.ContractEnd && - leftWork.LeftWorkDate >= item.ContarctStart) - { - ContractEnd = leftWork.LeftWorkDate.AddDays(-1); - hasLeft = true; - var start = contractStart.ToFarsi(); - var end = ContractEnd.ToFarsi(); - var ContractPreiodsList = new List(); - var CheckoutMonth = int.Parse(month); + // if (leftWork.HasLeft && leftWork.LeftWorkDate < item.ContractEnd && + // leftWork.LeftWorkDate >= item.ContarctStart) + // { + // ContractEnd = leftWork.LeftWorkDate.AddDays(-1); + // hasLeft = true; + // var start = contractStart.ToFarsi(); + // var end = ContractEnd.ToFarsi(); + // var ContractPreiodsList = new List(); + // var CheckoutMonth = int.Parse(month); - var syear = Convert.ToInt32(start.Substring(0, 4)); - var smonth = Convert.ToInt32(start.Substring(5, 2)); - var sday = Convert.ToInt32(start.Substring(8, 2)); + // var syear = Convert.ToInt32(start.Substring(0, 4)); + // var smonth = Convert.ToInt32(start.Substring(5, 2)); + // var sday = Convert.ToInt32(start.Substring(8, 2)); - var eyear = Convert.ToInt32(end.Substring(0, 4)); - var emonth = Convert.ToInt32(end.Substring(5, 2)); - var eday = Convert.ToInt32(end.Substring(8, 2)); + // var eyear = Convert.ToInt32(end.Substring(0, 4)); + // var emonth = Convert.ToInt32(end.Substring(5, 2)); + // var eday = Convert.ToInt32(end.Substring(8, 2)); - var PersianStartDate = new PersianDateTime(syear, smonth, sday); - var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1); - var PersianEndDate = new PersianDateTime(eyear, emonth, eday); + // var PersianStartDate = new PersianDateTime(syear, smonth, sday); + // var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1); + // var PersianEndDate = new PersianDateTime(eyear, emonth, eday); - var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1; - for (int i = 0; i < totalmonth; i++) - { + // var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1; + // for (int i = 0; i < totalmonth; i++) + // { - var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1); - if (currentEndDate > PersianEndDate) - { - currentEndDate = PersianEndDate; - } + // var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1); + // if (currentEndDate > PersianEndDate) + // { + // currentEndDate = PersianEndDate; + // } - var period = new PeriodStartEnd - { - startC = PersianStartDate.ToString("yyyy/MM/dd"), - endC = currentEndDate.ToString("yyyy/MM/dd"), - monthC = currentEndDate.Month - }; - ContractPreiodsList.Add(period); - //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}"); + // var period = new PeriodStartEnd + // { + // startC = PersianStartDate.ToString("yyyy/MM/dd"), + // endC = currentEndDate.ToString("yyyy/MM/dd"), + // monthC = currentEndDate.Month + // }; + // ContractPreiodsList.Add(period); + // //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}"); - PersianStartDate = PersianStartDate.AddMonths(1); - PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1); + // PersianStartDate = PersianStartDate.AddMonths(1); + // PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1); - } + // } - var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth); - if (periodSelect != null) - { - var startDate = periodSelect.startC.ToGeorgianDateTime(); - var endDate = periodSelect.endC.ToGeorgianDateTime(); + // var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth); + // if (periodSelect != null) + // { + // var startDate = periodSelect.startC.ToGeorgianDateTime(); + // var endDate = periodSelect.endC.ToGeorgianDateTime(); - separation.Add(new ContractSeparationViewModel() - { - StartWorkDate = leftWork.StartWorkDate, - LeftWorkDate = ContractEnd, - HasLeft = hasLeft, - ContarctStart = periodSelect.startC, - ContractEnd = periodSelect.endC, - ContractStartGr = startDate, - ContractEndGr = endDate, - checker = true, - EmployeeId = item.EmployeeId - }); + // separation.Add(new ContractSeparationViewModel() + // { + // StartWorkDate = leftWork.StartWorkDate, + // LeftWorkDate = ContractEnd, + // HasLeft = hasLeft, + // ContarctStart = periodSelect.startC, + // ContractEnd = periodSelect.endC, + // ContractStartGr = startDate, + // ContractEndGr = endDate, + // checker = true, + // EmployeeId = item.EmployeeId + // }); - } - else - { - separation.Add(new ContractSeparationViewModel() - { - checker = false, - EmployeeId = item.EmployeeId - }); + // } + // else + // { + // separation.Add(new ContractSeparationViewModel() + // { + // checker = false, + // EmployeeId = item.EmployeeId + // }); - } - } + // } + // } - if (leftWork.HasLeft && leftWork.LeftWorkDate >= item.ContractEnd && - leftWork.LeftWorkDate > item.ContarctStart) - { - var lastWorkDay = leftWork.LeftWorkDate.AddDays(-1); + // if (leftWork.HasLeft && leftWork.LeftWorkDate >= item.ContractEnd && + // leftWork.LeftWorkDate > item.ContarctStart) + // { + // var lastWorkDay = leftWork.LeftWorkDate.AddDays(-1); - if (leftWork.LeftWorkDate == ContractEnd) - { - ContractEnd = lastWorkDay; - hasLeft = true; - } + // if (leftWork.LeftWorkDate == ContractEnd) + // { + // ContractEnd = lastWorkDay; + // hasLeft = true; + // } - if (lastWorkDay == ContractEnd) - { - hasLeft = true; - } + // if (lastWorkDay == ContractEnd) + // { + // hasLeft = true; + // } - var start = contractStart.ToFarsi(); - var end = ContractEnd.ToFarsi(); - var ContractPreiodsList = new List(); - var CheckoutMonth = int.Parse(month); + // var start = contractStart.ToFarsi(); + // var end = ContractEnd.ToFarsi(); + // var ContractPreiodsList = new List(); + // var CheckoutMonth = int.Parse(month); - var syear = Convert.ToInt32(start.Substring(0, 4)); - var smonth = Convert.ToInt32(start.Substring(5, 2)); - var sday = Convert.ToInt32(start.Substring(8, 2)); + // var syear = Convert.ToInt32(start.Substring(0, 4)); + // var smonth = Convert.ToInt32(start.Substring(5, 2)); + // var sday = Convert.ToInt32(start.Substring(8, 2)); - var eyear = Convert.ToInt32(end.Substring(0, 4)); - var emonth = Convert.ToInt32(end.Substring(5, 2)); - var eday = Convert.ToInt32(end.Substring(8, 2)); + // var eyear = Convert.ToInt32(end.Substring(0, 4)); + // var emonth = Convert.ToInt32(end.Substring(5, 2)); + // var eday = Convert.ToInt32(end.Substring(8, 2)); - var PersianStartDate = new PersianDateTime(syear, smonth, sday); - var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1); - var PersianEndDate = new PersianDateTime(eyear, emonth, eday); + // var PersianStartDate = new PersianDateTime(syear, smonth, sday); + // var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1); + // var PersianEndDate = new PersianDateTime(eyear, emonth, eday); - var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1; - for (int i = 0; i < totalmonth; i++) - { + // var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1; + // for (int i = 0; i < totalmonth; i++) + // { - var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1); - if (currentEndDate > PersianEndDate) - { - currentEndDate = PersianEndDate; - } + // var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1); + // if (currentEndDate > PersianEndDate) + // { + // currentEndDate = PersianEndDate; + // } - var period = new PeriodStartEnd - { - startC = PersianStartDate.ToString("yyyy/MM/dd"), - endC = currentEndDate.ToString("yyyy/MM/dd"), - monthC = currentEndDate.Month - }; - ContractPreiodsList.Add(period); - //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}"); + // var period = new PeriodStartEnd + // { + // startC = PersianStartDate.ToString("yyyy/MM/dd"), + // endC = currentEndDate.ToString("yyyy/MM/dd"), + // monthC = currentEndDate.Month + // }; + // ContractPreiodsList.Add(period); + // //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}"); - PersianStartDate = PersianStartDate.AddMonths(1); - PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1); + // PersianStartDate = PersianStartDate.AddMonths(1); + // PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1); - } + // } - var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth); - if (periodSelect != null) - { - var startDate = periodSelect.startC.ToGeorgianDateTime(); - var endDate = periodSelect.endC.ToGeorgianDateTime(); + // var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth); + // if (periodSelect != null) + // { + // var startDate = periodSelect.startC.ToGeorgianDateTime(); + // var endDate = periodSelect.endC.ToGeorgianDateTime(); - separation.Add(new ContractSeparationViewModel() - { - StartWorkDate = leftWork.StartWorkDate, - LeftWorkDate = ContractEnd, - HasLeft = hasLeft, - ContarctStart = periodSelect.startC, - ContractEnd = periodSelect.endC, - ContractStartGr = startDate, - ContractEndGr = endDate, - checker = true, - EmployeeId = item.EmployeeId - }); + // separation.Add(new ContractSeparationViewModel() + // { + // StartWorkDate = leftWork.StartWorkDate, + // LeftWorkDate = ContractEnd, + // HasLeft = hasLeft, + // ContarctStart = periodSelect.startC, + // ContractEnd = periodSelect.endC, + // ContractStartGr = startDate, + // ContractEndGr = endDate, + // checker = true, + // EmployeeId = item.EmployeeId + // }); - } - else - { - separation.Add(new ContractSeparationViewModel() - { - checker = false, - EmployeeId = item.EmployeeId - }); + // } + // else + // { + // separation.Add(new ContractSeparationViewModel() + // { + // checker = false, + // EmployeeId = item.EmployeeId + // }); - } - } - else if (leftWork.HasLeft && contractStart > leftWork.LeftWorkDate) - { + // } + // } + // else if (leftWork.HasLeft && contractStart > leftWork.LeftWorkDate) + // { - separation.Add(new ContractSeparationViewModel() - { - checker = false, - EmployeeId = item.EmployeeId - }); + // separation.Add(new ContractSeparationViewModel() + // { + // checker = false, + // EmployeeId = item.EmployeeId + // }); - } - else if (!leftWork.HasLeft) - { - var start = contractStart.ToFarsi(); - var end = ContractEnd.ToFarsi(); - var ContractPreiodsList = new List(); - var CheckoutMonth = int.Parse(month); + // } + // else if (!leftWork.HasLeft) + // { + // var start = contractStart.ToFarsi(); + // var end = ContractEnd.ToFarsi(); + // var ContractPreiodsList = new List(); + // var CheckoutMonth = int.Parse(month); - var syear = Convert.ToInt32(start.Substring(0, 4)); - var smonth = Convert.ToInt32(start.Substring(5, 2)); - var sday = Convert.ToInt32(start.Substring(8, 2)); + // var syear = Convert.ToInt32(start.Substring(0, 4)); + // var smonth = Convert.ToInt32(start.Substring(5, 2)); + // var sday = Convert.ToInt32(start.Substring(8, 2)); - var eyear = Convert.ToInt32(end.Substring(0, 4)); - var emonth = Convert.ToInt32(end.Substring(5, 2)); - var eday = Convert.ToInt32(end.Substring(8, 2)); + // var eyear = Convert.ToInt32(end.Substring(0, 4)); + // var emonth = Convert.ToInt32(end.Substring(5, 2)); + // var eday = Convert.ToInt32(end.Substring(8, 2)); - var PersianStartDate = new PersianDateTime(syear, smonth, sday); - var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1); - var PersianEndDate = new PersianDateTime(eyear, emonth, eday); + // var PersianStartDate = new PersianDateTime(syear, smonth, sday); + // var PersianStartDateAddingMount = new PersianDateTime(syear, smonth, 1); + // var PersianEndDate = new PersianDateTime(eyear, emonth, eday); - var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1; - for (int i = 0; i < totalmonth; i++) - { + // var totalmonth = ((PersianEndDate.Year - PersianStartDateAddingMount.Year) * 12) + (PersianEndDate.Month - PersianStartDateAddingMount.Month) + 1; + // for (int i = 0; i < totalmonth; i++) + // { - var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1); - if (currentEndDate > PersianEndDate) - { - currentEndDate = PersianEndDate; - } + // var currentEndDate = PersianStartDateAddingMount.AddMonths(1).AddDays(-1); + // if (currentEndDate > PersianEndDate) + // { + // currentEndDate = PersianEndDate; + // } - var period = new PeriodStartEnd - { - startC = PersianStartDate.ToString("yyyy/MM/dd"), - endC = currentEndDate.ToString("yyyy/MM/dd"), - monthC = currentEndDate.Month - }; - ContractPreiodsList.Add(period); - //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}"); + // var period = new PeriodStartEnd + // { + // startC = PersianStartDate.ToString("yyyy/MM/dd"), + // endC = currentEndDate.ToString("yyyy/MM/dd"), + // monthC = currentEndDate.Month + // }; + // ContractPreiodsList.Add(period); + // //Console.WriteLine($"Month {i + 1} : {PersianStartDate.ToString("yyyy-MM-dd")} to {currentEndDate.ToString("yyyy-MM-dd")}"); - PersianStartDate = PersianStartDate.AddMonths(1); - PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1); + // PersianStartDate = PersianStartDate.AddMonths(1); + // PersianStartDate = new PersianDateTime(PersianStartDate.Year, PersianStartDate.Month, 1); - } + // } - var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth); - if (periodSelect != null) - { - var startDate = periodSelect.startC.ToGeorgianDateTime(); - var endDate = periodSelect.endC.ToGeorgianDateTime(); + // var periodSelect = ContractPreiodsList.FirstOrDefault(x => x.monthC == CheckoutMonth); + // if (periodSelect != null) + // { + // var startDate = periodSelect.startC.ToGeorgianDateTime(); + // var endDate = periodSelect.endC.ToGeorgianDateTime(); - separation.Add(new ContractSeparationViewModel() - { - StartWorkDate = leftWork.StartWorkDate, - HasLeft = hasLeft, - ContarctStart = periodSelect.startC, - ContractEnd = periodSelect.endC, - ContractStartGr = startDate, - ContractEndGr = endDate, - checker = true, - LeftWorkDate = new DateTime(2121, 3, 21), - EmployeeId = item.EmployeeId - }); + // separation.Add(new ContractSeparationViewModel() + // { + // StartWorkDate = leftWork.StartWorkDate, + // HasLeft = hasLeft, + // ContarctStart = periodSelect.startC, + // ContractEnd = periodSelect.endC, + // ContractStartGr = startDate, + // ContractEndGr = endDate, + // checker = true, + // LeftWorkDate = new DateTime(2121, 3, 21), + // EmployeeId = item.EmployeeId + // }); - } - else - { - separation.Add(new ContractSeparationViewModel() - { - checker = false, - EmployeeId = item.EmployeeId - }); + // } + // else + // { + // separation.Add(new ContractSeparationViewModel() + // { + // checker = false, + // EmployeeId = item.EmployeeId + // }); - } - } - else - { - separation.Add(new ContractSeparationViewModel() - { - checker = false, - EmployeeId = item.EmployeeId - }); + // } + // } + // else + // { + // separation.Add(new ContractSeparationViewModel() + // { + // checker = false, + // EmployeeId = item.EmployeeId + // }); - } - } + // } + //} @@ -4325,14 +4326,21 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos var toListTimer = new Stopwatch(); toListTimer.Start(); + var yearsOption = workshop.YearsOptions; + var bonusesOption = workshop.BonusesOptions; + var computeOption = workshop.ComputeOptions; var incloudedData = getContracts.Select(x => { + + var employeeOption = employeeOptions.FirstOrDefault(option => option.EmployeeId == x.EmployeeId); + if(employeeOption != null) + { + yearsOption = employeeOption.YearsOptions; + bonusesOption = employeeOption.BonusesOptions; + computeOption = employeeOption.ComputeOptions; + } return new ContractIncludedData { - ContractNo = x.ContractNo, - - - //اطلاعات هویتی پرسنل #region EmployeeData EmployeeId = x.EmployeeId, @@ -4351,16 +4359,31 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos //اطلاعات جداسازی تاریخ فیش از قرارداد #region Saparation - Saparation = separation.FirstOrDefault(sep => sep.EmployeeId == x.EmployeeId), + Separation = separation.FirstOrDefault(sep => sep.EmployeeId == x.EmployeeId), #endregion //تنظیمات فنی پرسنل #region EmployeeOption - EmployeeOption = employeeOptions.FirstOrDefault(option=> option.EmployeeId == x.EmployeeId) + YearsOption = yearsOption, + BonusesOption = bonusesOption, + ComputeOption = computeOption, #endregion + //اطلاعات قراداد + #region ContractData + + ContractNo = x.ContractNo, + ContractStart = x.ContarctStart.ToFarsi(), + ContractEnd = x.ContractEnd.ToFarsi(), + ContractStartGr = x.ContarctStart, + ContractEndGr = x.ContractEnd, + ContractId = x.id, + DailySalaryUnAffected = x.DailySalaryUnAffected, + DailyWageType = x.DailyWageType, + FirstGetWorkingDay = x.GetWorkDate.ToFarsi(), + #endregion }; }).ToList(); @@ -4372,7 +4395,7 @@ public class CheckoutRepository : RepositoryBase, ICheckoutRepos WorkshopId = workshop.id, ArchiveCode = workshop.ArchiveCode, WorkshopName = workshop.WorkshopName, - + IsStaticCheckout = workshop.IsStaticCheckout, #endregion diff --git a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs index b0832169..bbc15222 100644 --- a/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallEmployeeRepository.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using _0_Framework.Application; +using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.RollCallEmployeeAgg; using Company.Domain.RollCallEmployeeStatusAgg; @@ -13,6 +8,12 @@ using CompanyManagment.App.Contracts.RollCallEmployee; using CompanyManagment.App.Contracts.RollCallEmployeeStatus; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Threading.Tasks; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; namespace CompanyManagment.EFCore.Repository; @@ -39,7 +40,7 @@ public class RollCallEmployeeRepository : RepositoryBase } - public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd) + public async Task HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd) { //موقت // دادمهرگستر 11 * @@ -89,8 +90,8 @@ public class RollCallEmployeeRepository : RepositoryBase //if (rollCallEmployee == null) // return false; - var rollCallEmployee = _context.RollCallEmployees.Include(xs => xs.EmployeesStatus) - .FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId); + var rollCallEmployee =await _context.RollCallEmployees.Include(xs => xs.EmployeesStatus) + .FirstOrDefaultAsync(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId); //اگر تنظیمات حضور غیاب نداشت if (rollCallEmployee == null) return false; @@ -99,8 +100,8 @@ public class RollCallEmployeeRepository : RepositoryBase if (!rollCallEmployee.EmployeesStatus.Any()) return false; - var leftWork = - _context.LeftWorkList.FirstOrDefault(x => + var leftWork = await + _context.LeftWorkList.FirstOrDefaultAsync(x => x.StartWorkDate <= contractEnd.Date && x.LeftWorkDate > contractStart); if (leftWork == null) return false; diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 7b6d8a7e..ee367bc9 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -65,7 +65,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll #region OfficialChckout - public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, + public async Task MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute) @@ -86,7 +86,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll int TotalContractDays = (int)(contractEnd - contractStart).TotalDays + 1; int fridays = 0; - int holiday = _context.HolidayItems.Count(x => x.Holidaydate >= contractStart && x.Holidaydate <= contractEnd); + int holiday =await _context.HolidayItems.CountAsync(x => x.Holidaydate >= contractStart && x.Holidaydate <= contractEnd); ; for (var gDate = contractStart; gDate <= contractEnd; gDate = gDate.AddDays(1)) { @@ -117,8 +117,8 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll #region breakTime - BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery() - .Include(x => x.CustomizeWorkshopGroupSettings).FirstOrDefault(x => + BaseCustomizeEntity settings =await _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery() + .Include(x => x.CustomizeWorkshopGroupSettings).FirstOrDefaultAsync(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId); //اگر ساعت استراحت پرسنل وجود نداشت صفر است var breakTimeEntity = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime; @@ -196,7 +196,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll } else { - rollCallResult = _context.RollCalls.Where(x => + rollCallResult =await _context.RollCalls.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date && x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel() @@ -206,7 +206,7 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll ShiftSpan = (x.EndDate.Value - x.StartDate.Value), CreationDate = x.ShiftDate, BreakTimeSpan = x.BreakTimeSpan - }).ToList(); + }).ToListAsync(); groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => { diff --git a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs index edef4117..70529b65 100644 --- a/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs +++ b/CompanyManagment.EFCore/Repository/YearlySalaryRepository.cs @@ -2789,7 +2789,7 @@ public class YearlySalaryRepository : RepositoryBase, IYearl private (bool hasRollCall, double WorkingTotalHours) GetTotalWorkingHoursIfHasRollCall(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd) { bool hasRollCall = _rollCallEmployeeRepository.HasRollCallRecord(employeeId, workshopId, - contractStart, contractEnd); + contractStart, contractEnd).GetAwaiter().GetResult(); double totalWorkingHours = 0; if (!hasRollCall) return (false, 0); diff --git a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs index 9be056d6..c53f0e30 100644 --- a/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs +++ b/ServiceHost/Areas/Admin/Controllers/CheckoutController.cs @@ -139,8 +139,9 @@ public class CheckoutController : AdminBaseController /// /// [HttpPost] - public async Task> CreateCheckout([FromBody]TestCreateCheckout command) + public async Task CreateCheckout([FromBody]TestCreateCheckout command) { + var op = new OperationResult>(); var ids = new List() { @@ -165,12 +166,34 @@ public class CheckoutController : AdminBaseController 290547, 290548, 290549, 290550, 290551, 290552, 290553, 290554, 290555, 290556, 290557, 290558, 290559, 290560, 290561, 290562, 290563, 290564, 290565, 290566, 290567, 290568, 290569, 290570, 290571, 290572, 290573, 290574, 290575, 290576, 290577, 290578, 290579, 290580, 290581, 290582, 290583, 290584, 290585, - 290586, 290587, 290588 + 299612, 290587, 290588 }; + // var ids = new List(){ 299612 }; + + if (!string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month)) + return BadRequest(); + if (string.IsNullOrWhiteSpace(command.year) && !string.IsNullOrWhiteSpace(command.Month)) + return BadRequest(); + + if (string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month)) + { - + + var today = DateTime.Now; + var FaToday = today.ToFarsi(); + var convertedYear = FaToday.Substring(0, 4); + var convertedMonth = FaToday.Substring(5, 2); + + command.year = convertedYear; + command.Month = convertedMonth; + } + + if (ids.Count == 0 || command.WorkshopId == 0) + return BadRequest(); + var test = await _checkoutApplication.CreateCheckoutApi(ids, command.year, command.Month, command.WorkshopId); - return test; + return Ok(); + } #endregion @@ -181,4 +204,16 @@ public class TestCreateCheckout public string year { get; set; } public string Month { get; set; } public long WorkshopId { get; set; } +} + + +public class Testresponse +{ + public string EmployeeName { get; set; } + public string ContractNo { get; set; } + public string Start { get; set; } + public string End { get; set; } + public bool HasLeft { get; set; } + + public string LeftDate { get; set; } } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs index 677ec096..55da8adc 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Checkouts/Index.cshtml.cs @@ -38,6 +38,7 @@ using Company.Domain.InsuranceListAgg; using CompanyManagment.App.Contracts.InsuranceList; using CompanyManagment.EFCore.Repository; using System.Linq; +using CompanyManagment.App.Contracts.Hubs; namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts; diff --git a/ServiceHost/Hubs/CheckoutHub.cs b/ServiceHost/Hubs/CheckoutHub.cs deleted file mode 100644 index 3d688680..00000000 --- a/ServiceHost/Hubs/CheckoutHub.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.AspNetCore.SignalR; - -namespace ServiceHost.Hubs -{ - public class CheckoutHub : Hub - { - - public async Task send(long id) - { - await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(id)); - } - - public static string GetGroupName(long id) - { - return $"group-Checkout-{id}"; - } - } -}