change year and month
This commit is contained in:
@@ -50,4 +50,5 @@ public class ContractsListToCreateCheckoutDto
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
|
||||
public class CreateCheckoutDto
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست آی دی های قرارداد
|
||||
/// </summary>
|
||||
public List<long> Ids { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سال
|
||||
/// </summary>
|
||||
public int Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ماه
|
||||
/// </summary>
|
||||
public int Month { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی کارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
}
|
||||
@@ -4454,8 +4454,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
var acountID = _authHelper.CurrentAccountId();
|
||||
var workshopAccounts = _context.WorkshopAccounts.Where(x => x.AccountId == acountID)
|
||||
.Select(x => x.WorkshopId);
|
||||
var yearStr = searchModel.Year > 0 ? searchModel.Year.ToString() : "";
|
||||
var monthStr = searchModel.Month > 0 ? searchModel.Month.ToString() : "";
|
||||
var yearStr = searchModel.Year > 0 ? $"{searchModel.Year:0000}" : "";
|
||||
var monthStr = searchModel.Month > 0 ? $"{searchModel.Month:00}" : "";
|
||||
//var workshopAccounts = new List<long>();
|
||||
//workshopAccounts = [35];
|
||||
var watch = new Stopwatch();
|
||||
@@ -4527,14 +4527,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
//سرچ سال
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Year) && string.IsNullOrWhiteSpace(searchModel.Month) &&
|
||||
if (!string.IsNullOrWhiteSpace(yearStr) && string.IsNullOrWhiteSpace(monthStr) &&
|
||||
(string.IsNullOrWhiteSpace(searchModel.ContractStart) ||
|
||||
string.IsNullOrWhiteSpace(searchModel.ContractEnd)))
|
||||
{
|
||||
isSearched = true;
|
||||
var startYear = searchModel.Year + "/01/01";
|
||||
var startYear = yearStr + "/01/01";
|
||||
var startyearGr = startYear.ToGeorgianDateTime();
|
||||
var endYear = $"{searchModel.Year}/12/01".FindeEndOfMonth();
|
||||
var endYear = $"{yearStr}/12/01".FindeEndOfMonth();
|
||||
var endYearGr = endYear.ToGeorgianDateTime();
|
||||
|
||||
|
||||
@@ -4543,114 +4543,15 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
searchModel.EmployerId > 0)
|
||||
checkouts = checkouts.OrderByDescending(x => x.ContractEnd);
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month) &&
|
||||
else if (!string.IsNullOrWhiteSpace(yearStr) && !string.IsNullOrWhiteSpace(monthStr) &&
|
||||
string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
||||
string.IsNullOrWhiteSpace(searchModel.ContractEnd))
|
||||
{
|
||||
//سرچ سال و ماه
|
||||
isSearched = true;
|
||||
string y1 = $"{searchModel.Year}/{searchModel.Month}/01";
|
||||
var startDate = y1.ToGeorgianDateTime();
|
||||
string y2 = string.Empty;
|
||||
int month = Convert.ToInt32(searchModel.Month);
|
||||
int year = Convert.ToInt32(searchModel.Year);
|
||||
|
||||
if (month <= 6)
|
||||
{
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/31";
|
||||
}
|
||||
else if (month > 6 && month < 12)
|
||||
{
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
}
|
||||
else if (month == 12)
|
||||
{
|
||||
switch (year)
|
||||
{
|
||||
case 1346:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1350:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1354:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1358:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1362:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1366:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1370:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1375:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1379:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1383:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1387:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1391:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1395:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1399:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1403:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1408:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1412:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1416:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1420:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1424:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1428:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1432:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1436:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1441:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
case 1445:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/30";
|
||||
break;
|
||||
|
||||
default:
|
||||
y2 = $"{searchModel.Year}/{searchModel.Month}/29";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var endDate = y2.ToGeorgianDateTime();
|
||||
string startMonth = $"{yearStr}/{monthStr}/01";
|
||||
var startDate = startMonth.ToGeorgianDateTime();
|
||||
var endDate = startMonth.FindeEndOfMonthReturnGr();
|
||||
|
||||
//checkouts = checkouts.Where(x => x.ContractEndGr >= start && x.ContractEndGr <= end).ToList();
|
||||
checkouts = checkouts.Where(x =>
|
||||
@@ -4664,7 +4565,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.ContractStart) &&
|
||||
!string.IsNullOrWhiteSpace(searchModel.ContractEnd) &&
|
||||
string.IsNullOrWhiteSpace(searchModel.Year) && string.IsNullOrWhiteSpace(searchModel.Month))
|
||||
string.IsNullOrWhiteSpace(yearStr) && string.IsNullOrWhiteSpace(monthStr))
|
||||
{
|
||||
//سرچ تاریخ
|
||||
isSearched = true;
|
||||
|
||||
@@ -192,14 +192,15 @@ public class CheckoutController : AdminBaseController
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetContractsToCreateCheckout")]
|
||||
public async Task<OperationResult<List<ContractsListToCreateCheckoutDto>>> GetContractsToCreateCheckout(long workshopId, string year, string month, long employeeId)
|
||||
public async Task<OperationResult<List<ContractsListToCreateCheckoutDto>>> GetContractsToCreateCheckout(long workshopId, int year, int month, long employeeId)
|
||||
{
|
||||
|
||||
var result =await _checkoutApplication.GetContractToCreateCheckout(workshopId, year, month, employeeId);
|
||||
string yearStr = year > 0 ? $"{year:0000}" : "";
|
||||
string monthStr = month > 0 ? $"{month:00}" : "";
|
||||
var result =await _checkoutApplication.GetContractToCreateCheckout(workshopId, yearStr, monthStr, employeeId);
|
||||
if (!result.IsSuccedded)
|
||||
return result;
|
||||
|
||||
var hasWorkFlow = await _workFlowApplication.HasWorkFlow(workshopId, year, month);
|
||||
var hasWorkFlow = await _workFlowApplication.HasWorkFlow(workshopId, yearStr, monthStr);
|
||||
|
||||
if (hasWorkFlow)
|
||||
return new OperationResult<List<ContractsListToCreateCheckoutDto>>().Failed(
|
||||
@@ -218,6 +219,9 @@ public class CheckoutController : AdminBaseController
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<OperationResult>> CreateCheckout([FromBody] CreateCheckoutDto command)
|
||||
{
|
||||
string yearStr = command.Year > 0 ? $"{command.Year:0000}" : "";
|
||||
string monthStr = command.Month > 0 ? $"{command.Month:00}" : "";
|
||||
|
||||
var op = new OperationResult();
|
||||
//var ids = new
|
||||
// List<long>()
|
||||
@@ -247,12 +251,12 @@ public class CheckoutController : AdminBaseController
|
||||
// };
|
||||
//command.Ids = new List<long>(){ 290449 };
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month))
|
||||
if (!string.IsNullOrWhiteSpace(yearStr) && string.IsNullOrWhiteSpace(monthStr))
|
||||
return op.Failed("ماه را انتخاب کنید");
|
||||
if (string.IsNullOrWhiteSpace(command.year) && !string.IsNullOrWhiteSpace(command.Month))
|
||||
if (string.IsNullOrWhiteSpace(yearStr) && !string.IsNullOrWhiteSpace(monthStr))
|
||||
return op.Failed("سال را انتخاب کنید");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month))
|
||||
if (string.IsNullOrWhiteSpace(yearStr) && string.IsNullOrWhiteSpace(monthStr))
|
||||
{
|
||||
|
||||
|
||||
@@ -261,8 +265,8 @@ public class CheckoutController : AdminBaseController
|
||||
var convertedYear = FaToday.Substring(0, 4);
|
||||
var convertedMonth = FaToday.Substring(5, 2);
|
||||
|
||||
command.year = convertedYear;
|
||||
command.Month = convertedMonth;
|
||||
yearStr = convertedYear;
|
||||
monthStr = convertedMonth;
|
||||
}
|
||||
|
||||
if (command.WorkshopId == 0)
|
||||
@@ -271,7 +275,7 @@ public class CheckoutController : AdminBaseController
|
||||
return op.Failed("هیچ موردی انتخاب نشده است");
|
||||
|
||||
|
||||
var result = await _checkoutApplication.CreateCheckoutApi(command.Ids, command.year, command.Month, command.WorkshopId);
|
||||
var result = await _checkoutApplication.CreateCheckoutApi(command.Ids, yearStr, monthStr, command.WorkshopId);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -279,12 +283,5 @@ public class CheckoutController : AdminBaseController
|
||||
|
||||
}
|
||||
|
||||
public class CreateCheckoutDto
|
||||
{
|
||||
public List<long> Ids { get; set; }
|
||||
public string year { get; set; }
|
||||
public string Month { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -788,6 +788,10 @@ public class WorkFlowApplication : IWorkFlowApplication
|
||||
{
|
||||
var workshop = _workshopRepository.GetDetails(workshopId);
|
||||
bool hasWorkFlow = false;
|
||||
if (string.IsNullOrWhiteSpace(year))
|
||||
year = "0";
|
||||
if (string.IsNullOrWhiteSpace(month))
|
||||
month = "0";
|
||||
|
||||
var skipRollCallByWorkshopId = workshopId is 368 or 610;
|
||||
if (workshop.HasRollCallFreeVip == "true" && !skipRollCallByWorkshopId)
|
||||
|
||||
Reference in New Issue
Block a user