GetContractsToCreateCheckout Completed

This commit is contained in:
gozareshgir
2026-01-21 19:20:15 +03:30
parent dfc392f07a
commit 7a79343b2f
9 changed files with 856 additions and 593 deletions

View File

@@ -73,4 +73,15 @@ public interface IWorkFlowApplication
Task<List<DailyRollCallConfirmedWithoutLunchBreakViewModel>> GetEmployeesWithoutLunchBreak(long workshopId);
Task<List<(long Id, string Name)>> GetEmployeesWithoutGroup(long workshopId);
#region ForApi
/// <summary>
/// در زمان ایجاد فیش کارپوشه کارگاه را چک میکند
/// </summary>
/// <param name="workshopId"></param>
/// <param name="year"></param>
/// <param name="month"></param>
/// <returns></returns>
Task<bool> HasWorkFlow(long workshopId, string year, string month);
#endregion
}

View File

@@ -781,5 +781,66 @@ public class WorkFlowApplication : IWorkFlowApplication
return _customizedWorkshopSettingsACL.GetEmployeesWithoutGroup(workshopId);
}
#region ForApi
public async Task<bool> HasWorkFlow(long workshopId, string year, string month)
{
var workshop = _workshopRepository.GetDetails(workshopId);
bool hasWorkFlow = false;
var skipRollCallByWorkshopId = workshopId is 368 or 610;
if (workshop.HasRollCallFreeVip == "true" && !skipRollCallByWorkshopId)
{
DateTime startSreach;
DateTime endSearch;
if (month == "0" && year == "0")
{
DateTime now = DateTime.Now;
string startStr = $"{now.ToFarsi().Substring(0, 8)}01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
else if (month == "0" && year != "0")
{
DateTime now = DateTime.Now;
string startStr = $"{year}/{now.ToFarsi().Substring(5, 2)}/01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
else if (month != "0" && year == "0")
{
DateTime now = DateTime.Now;
string startStr = $"{now.ToFarsi().Substring(0, 4)}/{month}/01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
else
{
string startStr = $"{year}/{month}/01";
startSreach = startStr.ToGeorgianDateTime();
endSearch = (startStr.FindeEndOfMonth()).ToGeorgianDateTime();
}
DateTime lastMonthEnd = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime().AddDays(-1);
if (lastMonthEnd == endSearch)
{
var countWorkFlowCut = await CountCutByBgServiceLastMonth(workshopId);
var countWorkFlowAbsent = await CountAbsentRollCallLastMonth(workshopId);
var countWorkFlowLunchBreak = await CountEmployeesWithoutLunchBreakLastMonth(workshopId);
var countUndefinedRollCalls = await CountUndefinedLastMonth(workshopId);
hasWorkFlow = countWorkFlowCut > 0 || countWorkFlowAbsent > 0 || countWorkFlowLunchBreak > 0 ||
countUndefinedRollCalls > 0;
}
}
return hasWorkFlow;
}
#endregion
}