Mandatory Compute Added to CreateCheckoutApi
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Company.Domain.RollCallAgg;
|
||||
|
||||
public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
|
||||
{
|
||||
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute);
|
||||
Task<ComputingViewModel> MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout, bool rotatingShiftCompute, double dailyWageUnAffected, bool totalLeaveCompute);
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه ساعات کارکرد پرسنل در صورت داشتن حضور غیاب
|
||||
|
||||
@@ -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<long, RollCallEmployee>
|
||||
{
|
||||
bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd);
|
||||
Task<bool> HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd);
|
||||
List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId);
|
||||
EditRollCallEmployee GetDetails(long id);
|
||||
RollCallEmployeeViewModel GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId);
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public string ArchiveCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا تنظیمات کارگاه بر رو ایجاد فیش استاتیک است
|
||||
/// </summary>
|
||||
public bool IsStaticCheckout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا کارگاه در تعطیلات رسمی باز است
|
||||
/// </summary>
|
||||
public bool WorkshopHolidayWorking { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// محاسبه نوبت کاری در فیش حقوقی
|
||||
/// </summary>
|
||||
public bool RotatingShiftCompute { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آیا پاداش در فیش حقوقی محاسبه شود
|
||||
/// </summary>
|
||||
public bool RewardComputeOnCheckout { get; set; }
|
||||
|
||||
|
||||
public List<ContractIncludedData> ContractIncludedData { get; set; }
|
||||
@@ -85,10 +106,71 @@ public class ContractIncludedData
|
||||
/// <summary>
|
||||
/// اطلاعات جداسازی تاریخ فیش
|
||||
/// </summary>
|
||||
public ContractSeparationViewModel Saparation { get; set; }
|
||||
public ContractSeparationViewModel Separation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تنظیمات فنی پرسنل
|
||||
/// سنوات
|
||||
/// </summary>
|
||||
public EmployeeComputeOptionsViewModel EmployeeOption { get; set; }
|
||||
public string YearsOption { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تنظیمات فنی پرسنل
|
||||
/// عیدی و پاداش
|
||||
/// </summary>
|
||||
public string BonusesOption { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تنظیمات فنی پرسنل
|
||||
/// مزد مرخصی
|
||||
/// </summary>
|
||||
public string ComputeOption { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ترایخ شروع قراداد
|
||||
/// شمسی
|
||||
/// </summary>
|
||||
public string ContractStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان قرارداد
|
||||
/// شمسی
|
||||
/// </summary>
|
||||
public string ContractEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ترایخ شروع قراداد
|
||||
/// میلادی
|
||||
/// </summary>
|
||||
public DateTime ContractStartGr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان قرارداد
|
||||
/// میلادی
|
||||
/// </summary>
|
||||
public DateTime ContractEndGr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی قراداد
|
||||
/// </summary>
|
||||
public long ContractId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مزد روزانه قرداد بدون تاثیر ساعات کار
|
||||
/// </summary>
|
||||
public double DailySalaryUnAffected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع مزد روزانه
|
||||
/// </summary>
|
||||
public string DailyWageType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// اولین شروع بکار پرسنل
|
||||
/// </summary>
|
||||
public string FirstGetWorkingDay { get; set; }
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public interface ICheckoutApplication
|
||||
/// <param name="year"></param>
|
||||
/// <param name="month"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult<GetContractAndIncludesDataToCreateDto>> CreateCheckoutApi(List<long> ids, string year, string month, long workshopId);
|
||||
Task<OperationResult> CreateCheckoutApi(List<long> ids, string year, string month, long workshopId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
18
CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs
Normal file
18
CompanyManagment.App.Contracts/Hubs/CheckoutHub.cs
Normal file
@@ -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}";
|
||||
}
|
||||
}
|
||||
@@ -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<CheckoutHub> _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<CheckoutHub> 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<OperationResult<GetContractAndIncludesDataToCreateDto>> CreateCheckoutApi(List<long> ids, string year, string month, long workshopId)
|
||||
public async Task<OperationResult> CreateCheckoutApi(List<long> 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
|
||||
|
||||
|
||||
@@ -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<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr)
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, 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<long, Checkout>, 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<long, Checkout>, 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<PeriodStartEnd>();
|
||||
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<PeriodStartEnd>();
|
||||
// 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<PeriodStartEnd>();
|
||||
var CheckoutMonth = int.Parse(month);
|
||||
// var start = contractStart.ToFarsi();
|
||||
// var end = ContractEnd.ToFarsi();
|
||||
// var ContractPreiodsList = new List<PeriodStartEnd>();
|
||||
// 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<PeriodStartEnd>();
|
||||
var CheckoutMonth = int.Parse(month);
|
||||
// }
|
||||
// else if (!leftWork.HasLeft)
|
||||
// {
|
||||
// var start = contractStart.ToFarsi();
|
||||
// var end = ContractEnd.ToFarsi();
|
||||
// var ContractPreiodsList = new List<PeriodStartEnd>();
|
||||
// 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<long, Checkout>, 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<long, Checkout>, 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<long, Checkout>, ICheckoutRepos
|
||||
WorkshopId = workshop.id,
|
||||
ArchiveCode = workshop.ArchiveCode,
|
||||
WorkshopName = workshop.WorkshopName,
|
||||
|
||||
IsStaticCheckout = workshop.IsStaticCheckout,
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -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<long, RollCallEmployee>
|
||||
}
|
||||
|
||||
|
||||
public bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
|
||||
public async Task<bool> HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
//موقت
|
||||
// دادمهرگستر 11 *
|
||||
@@ -89,8 +90,8 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
|
||||
//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<long, RollCallEmployee>
|
||||
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;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
|
||||
#region OfficialChckout
|
||||
|
||||
public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart,
|
||||
public async Task<ComputingViewModel> 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<long, RollCall>, 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<long, RollCall>, 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<long, RollCall>, 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<long, RollCall>, 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 =>
|
||||
{
|
||||
|
||||
@@ -2789,7 +2789,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, 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);
|
||||
|
||||
@@ -139,8 +139,9 @@ public class CheckoutController : AdminBaseController
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<OperationResult<GetContractAndIncludesDataToCreateDto>> CreateCheckout([FromBody]TestCreateCheckout command)
|
||||
public async Task<ActionResult> CreateCheckout([FromBody]TestCreateCheckout command)
|
||||
{
|
||||
var op = new OperationResult<List<Testresponse>>();
|
||||
var ids = new
|
||||
List<long>()
|
||||
{
|
||||
@@ -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<long>(){ 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; }
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user