From d3dacceab12d053506652c4c878fdbfa3b8e268f Mon Sep 17 00:00:00 2001 From: gozareshgir Date: Thu, 22 Jan 2026 12:37:28 +0330 Subject: [PATCH] GetContractToCreateCheckout change --- .../CheckoutApplication.cs | 64 +++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/CompanyManagment.Application/CheckoutApplication.cs b/CompanyManagment.Application/CheckoutApplication.cs index 705ee241..deb70a9f 100644 --- a/CompanyManagment.Application/CheckoutApplication.cs +++ b/CompanyManagment.Application/CheckoutApplication.cs @@ -22,6 +22,7 @@ using CompanyManagment.App.Contracts.WorkingHoursTemp; using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.EFCore.Migrations; using CompanyManagment.EFCore.Repository; +using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -46,13 +47,13 @@ public class CheckoutApplication : ICheckoutApplication private readonly IHolidayItemApplication _holidayItemApplication; private readonly IWorkingHoursTempRepository _workingHoursTempRepository; private readonly IWorkshopRepository _workshopRepository; - + private readonly IAuthHelper _authHelper; 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) + IEmployerRepository employerRepository, IPersonalContractingPartyApp contractingPartyApp, ILeaveApplication leaveApplication, IMandatoryHoursApplication mandatoryHoursApplication, IRollCallMandatoryRepository rollCallMandatoryRepository, IRollCallRepository rollCallRepository, IHolidayItemApplication holidayItemApplication, IWorkingHoursTempRepository workingHoursTempRepository, IWorkshopRepository workshopRepository, IAuthHelper authHelper) { _checkoutRepository = checkoutRepository; _yearlySalaryRepository = yearlySalaryRepository; @@ -66,6 +67,7 @@ public class CheckoutApplication : ICheckoutApplication _holidayItemApplication = holidayItemApplication; _workingHoursTempRepository = workingHoursTempRepository; _workshopRepository = workshopRepository; + _authHelper = authHelper; } [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 241")] @@ -751,8 +753,19 @@ public class CheckoutApplication : ICheckoutApplication var op = new OperationResult>(); if (workshopId < 1) return op.Failed("کارگاه را انتخاب کنید"); - 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)) + return op.Failed("سال را انتخاب کنید"); + + if (string.IsNullOrWhiteSpace(year) && string.IsNullOrWhiteSpace(month)) + { + year = "0"; + month = "0"; + } + + var result = await GetContractResultToCreateCheckout(workshopId, employeeId, year, month, null, null); if(result.CreateCheckoutList.Count == 0) @@ -775,6 +788,49 @@ public class CheckoutApplication : ICheckoutApplication return op.Succcedded(finalResult); } + + public async Task CreateCheckoutApi(List ContractsId, string ConvertYear, string ConvertMonth) + { + var op = new OperationResult(); + + //آی دی کاربر لاگین شده برای استفاده در signalR + var currentAcc = _authHelper.CurrentAccountId(); + + #region Validation + + if (!string.IsNullOrWhiteSpace(ConvertYear) && string.IsNullOrWhiteSpace(ConvertMonth)) + return op.Failed("ماه را انتخاب کنید"); + if (string.IsNullOrWhiteSpace(ConvertYear) && !string.IsNullOrWhiteSpace(ConvertMonth)) + return op.Failed("سال را انتخاب کنید"); + + if (string.IsNullOrWhiteSpace(ConvertYear) && string.IsNullOrWhiteSpace(ConvertMonth)) + { + ConvertYear = "0"; + ConvertMonth = "0"; + + var today = DateTime.Now; + var FaToday = today.ToFarsi(); + var year = FaToday.Substring(0, 4); + var month = FaToday.Substring(5, 2); + + ConvertYear = year; + ConvertMonth = month; + } + + if (ContractsId.Count == 0) + return op.Failed("هیچ موردی انتخاب نشده اشت"); + + #endregion + + + #region GetInsuranceData + + + + #endregion + + return op.Succcedded(); + } #endregion