overTimePay static changes
This commit is contained in:
@@ -114,6 +114,146 @@ public class ReportRepository : IReportRepository
|
||||
// };
|
||||
|
||||
//}
|
||||
|
||||
//public async Task<AllReport> GetAllActiveWorkshopsNew(string year, string month)
|
||||
//{
|
||||
// var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
// // Parse the start and end dates for the current and next months
|
||||
// #region FindMonthStartAndEnd
|
||||
|
||||
// string nowFa = $"{(DateTime.Now.ToFarsi()).Substring(0, 8)}01";
|
||||
|
||||
// if (!string.IsNullOrWhiteSpace(year) && !string.IsNullOrWhiteSpace(month))
|
||||
// nowFa = $"{year}/{month}/01";
|
||||
|
||||
|
||||
// var currentEndOfMonth = nowFa.FindeEndOfMonth();
|
||||
|
||||
// //شروع ماه جاری
|
||||
// var currentMonthStart = nowFa.ToGeorgianDateTime();
|
||||
// // پایان کاه جاری
|
||||
// var currentMonthEnd = currentEndOfMonth.ToGeorgianDateTime();
|
||||
|
||||
|
||||
|
||||
// int currentYear = Convert.ToInt32(nowFa.Substring(0, 4));
|
||||
// var currentMonth = Convert.ToInt32(nowFa.Substring(5, 2));
|
||||
// var nextMonthStartFa = new PersianDateTime(currentYear, currentMonth, 1).AddMonths(1);
|
||||
|
||||
// //شروع ماه بعد
|
||||
// var nextMonthStart = ($"{nextMonthStartFa}").ToGeorgianDateTime();
|
||||
// //پایان ماه بعد
|
||||
// var nextMonthEnd = (($"{nextMonthStartFa}").FindeEndOfMonth()).ToGeorgianDateTime();
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
// // Preload data to reduce database calls
|
||||
// var accountLeftWorks = await _accountContext.AccountLeftWorks
|
||||
// .Where(x => x.RoleId == 5)
|
||||
// .ToListAsync();
|
||||
|
||||
// var leftWorkList = await _context.LeftWorkList
|
||||
// .Where(x => x.StartWorkDate <= nextMonthEnd && x.LeftWorkDate > currentMonthStart)
|
||||
// .ToListAsync();
|
||||
|
||||
// var institutionContracts = await _context.InstitutionContractSet
|
||||
// .Where(c => c.ContractStartGr <= nextMonthEnd && c.ContractEndGr >= currentMonthStart)
|
||||
// .ToListAsync();
|
||||
|
||||
// var accounts = await _accountContext.Accounts
|
||||
// .Where(x => x.RoleId == 5)
|
||||
// .ToListAsync();
|
||||
|
||||
// // Filter workshops
|
||||
// var activeWorkshops = await _context.WorkshopEmployers
|
||||
// .Include(x => x.Workshop)
|
||||
// .Include(x => x.Employer.ContractingParty)
|
||||
// .Where(x => x.Workshop.IsActiveString == "true" &&
|
||||
// x.Employer.ContractingParty.IsActiveString == "true" &&
|
||||
// x.Employer.ContractingParty.IsBlock != "true")
|
||||
// .ToListAsync();
|
||||
|
||||
// // Group workshops by contract type
|
||||
// var workshopsWithContracts = activeWorkshops
|
||||
// .Where(x => institutionContracts.Any(c => c.ContractingPartyId == x.Employer.ContractingPartyId))
|
||||
// .Select(x => x.WorkshopId)
|
||||
// .Distinct()
|
||||
// .ToList();
|
||||
|
||||
// var workshopsWithoutContracts = activeWorkshops
|
||||
// .Where(x => x.Employer.ContractingPartyId == 30428)
|
||||
// .Select(x => x.WorkshopId)
|
||||
// .Distinct()
|
||||
// .ToList();
|
||||
|
||||
// var allWorkshops = workshopsWithContracts.Concat(workshopsWithoutContracts).Distinct().ToList();
|
||||
|
||||
// // Calculate left works and contracts
|
||||
// var leftWorks = leftWorkList
|
||||
// .Where(x => allWorkshops.Contains(x.WorkshopId))
|
||||
// .ToList();
|
||||
|
||||
// var leftWorkEmployeeIds = leftWorks.Select(x => x.EmployeeId).ToHashSet();
|
||||
|
||||
// var contracts = await _context.Contracts
|
||||
// .Where(x => leftWorkEmployeeIds.Contains(x.EmployeeId) &&
|
||||
// x.ContarctStart.Date <= nextMonthEnd.Date &&
|
||||
// x.ContractEnd.Date > nextMonthStart.Date &&
|
||||
// x.IsActiveString == "true")
|
||||
// .ToListAsync();
|
||||
|
||||
// var signedContracts = contracts.Count(x => x.Signature == "1");
|
||||
|
||||
// // Calculate checkouts
|
||||
// var checkouts = await _context.CheckoutSet
|
||||
// .Where(x => leftWorkEmployeeIds.Contains(x.EmployeeId) &&
|
||||
// x.ContractStart.Date >= currentMonthStart.Date &&
|
||||
// x.ContractEnd.Date <= currentMonthEnd.Date &&
|
||||
// x.IsActiveString == "true")
|
||||
// .ToListAsync();
|
||||
|
||||
// var signedCheckouts = checkouts.Count(x => x.Signature == "1");
|
||||
|
||||
// // Calculate percentages
|
||||
// var contractToBe = leftWorks.Count;
|
||||
// var createdContracts = contracts.Count;
|
||||
// var checkoutToBe = leftWorks.Count;
|
||||
// var createdCheckouts = checkouts.Count;
|
||||
|
||||
// var contractPercent = contractToBe > 0 ? (createdContracts * 100) / contractToBe : 0;
|
||||
// var contractSignaturePercent = createdContracts > 0 ? (signedContracts * 100) / createdContracts : 0;
|
||||
// var checkoutPercent = checkoutToBe > 0 ? (createdCheckouts * 100) / checkoutToBe : 0;
|
||||
// var checkoutSignaturePercent = createdCheckouts > 0 ? (signedCheckouts * 100) / createdCheckouts : 0;
|
||||
|
||||
// // Prepare the final result
|
||||
// var finalResult = new AllReport
|
||||
// {
|
||||
// AllPercent = (contractPercent + contractSignaturePercent + checkoutPercent + checkoutSignaturePercent) / 4,
|
||||
// ContractPercent = contractPercent,
|
||||
// ContractSignaturePercent = contractSignaturePercent,
|
||||
// CheckoutPercent = checkoutPercent,
|
||||
// CheckoutSignaturePercent = checkoutSignaturePercent,
|
||||
// Year = $"{currentMonthStart.Year}",
|
||||
// Month = nowFa.Substring(5, 2),
|
||||
// AllContract = contractToBe,
|
||||
// ContractNotDone = contractToBe - createdContracts,
|
||||
// ContrcatDone = createdContracts,
|
||||
// ContractSignNotDone = createdContracts - signedContracts,
|
||||
// ContractSignDone = signedContracts,
|
||||
// AllCheckout = checkoutToBe,
|
||||
// CheckoutNotDone = checkoutToBe - createdCheckouts,
|
||||
// CheckoutDone = createdCheckouts,
|
||||
// CheckoutSignDone = signedCheckouts,
|
||||
// CheckoutSignNotDone = createdCheckouts - signedCheckouts
|
||||
// };
|
||||
|
||||
// Console.WriteLine("Optimized method execution time: " + watch.Elapsed);
|
||||
// return finalResult;
|
||||
//}
|
||||
|
||||
|
||||
public Task<AllReport> GetAllActiveWorkshopsNew(string year, string month)
|
||||
{
|
||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
@@ -10,6 +10,7 @@ using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.Job;
|
||||
using CompanyManagment.App.Contracts.Leave;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.MandantoryHours;
|
||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
|
||||
@@ -52,9 +53,10 @@ public class IndexModel : PageModel
|
||||
private readonly IWorkingHoursTempApplication _workingHoursTempApplication;
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly IYearlySalaryApplication _yearlySalaryApplication;
|
||||
private readonly IYearlySalaryRepository _yearlySalaryRepository;
|
||||
private readonly IYearlySalaryRepository _yearlySalaryRepository;
|
||||
|
||||
public List<CheckoutViewModel> chekoutlist;
|
||||
|
||||
public List<CheckoutViewModel> chekoutlist;
|
||||
public List<ComputingViewModel> ComputingView;
|
||||
public List<ContractViweModel> Contracts2;
|
||||
public string employeeFullName;
|
||||
@@ -116,7 +118,7 @@ public class IndexModel : PageModel
|
||||
_employeeComputeOptionsApplication = employeeComputeOptionsApplication;
|
||||
_rollCallMandatoryApplication = rollCallMandatoryApplication;
|
||||
_rollCallEmployeeStatusApp = rollCallEmployeeStatusApp;
|
||||
}
|
||||
}
|
||||
|
||||
public string Message { get; set; }
|
||||
public bool falseCheck { get; set; }
|
||||
@@ -6785,14 +6787,30 @@ public class IndexModel : PageModel
|
||||
var AllDaysCount = (conEnd - conStart).TotalDays + 1;
|
||||
var endContract = command.ContractEnd.ToGeorgianDateTime();
|
||||
var AllmandatoryDays = 0;
|
||||
for (var gDate = conStart; gDate <= endContract; gDate = gDate.AddDays(1))
|
||||
if (gDate.DayOfWeek != DayOfWeek.Friday)
|
||||
AllmandatoryDays += 1;
|
||||
int fridayCount = 0;
|
||||
int officialHolidayCount = 0;
|
||||
for (var gDate = conStart; gDate <= endContract; gDate = gDate.AddDays(1))
|
||||
{
|
||||
if (gDate.DayOfWeek != DayOfWeek.Friday)
|
||||
AllmandatoryDays += 1;
|
||||
if (gDate.DayOfWeek == DayOfWeek.Friday)
|
||||
fridayCount += 1;
|
||||
bool officialHoliday = _holidayItemRepository.GetHoliday(gDate);
|
||||
if (officialHoliday)
|
||||
officialHolidayCount += 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
var mandatoryFixComplex = new TimeSpan(7, 20, 0).Multiply(AllmandatoryDays);
|
||||
var mandatoryFixShifts = new TimeSpan(7, 20, 0).Multiply(notHolidaysCount);
|
||||
|
||||
var allDays = (endContract - conStart).TotalDays + 1;
|
||||
var allDays = (int)(endContract - conStart).TotalDays + 1;
|
||||
int mondatoryDaysInMonth = allDays - (fridayCount + officialHolidayCount);
|
||||
var mandatoryFixShifts = new TimeSpan(7, 20, 0).Multiply(mondatoryDaysInMonth);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var jomeh2 = new TimeSpan();
|
||||
|
||||
Reference in New Issue
Block a user