Insurance bug fix - CreateTransction for rolllCall
This commit is contained in:
@@ -33,4 +33,14 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
|
||||
int ArchiveCodeFinder(List<WorkshopViewModel> workshopViewModels);
|
||||
InstitutionContract InstitutionContractByEmployerId(long employerId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد سند مالی حضور غیاب
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
/// <param name="endOfMonthGr"></param>
|
||||
/// <param name="endOfMonth"></param>
|
||||
/// <param name="description"></param>
|
||||
void RollcallServiceCreateTransaction();
|
||||
}
|
||||
@@ -15,6 +15,14 @@ public interface IInstitutionContractApplication
|
||||
|
||||
List<InstitutionContractViewModel> Search(InstitutionContractSearchModel searchModel);
|
||||
List<InstitutionContractViewModel> NewSearch(InstitutionContractSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات قزداد های مالی فعال
|
||||
///دارای کارگاه
|
||||
/// جهت ست کردن سرویس ها از طریق اکسل
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<InstitutionContractViewModel> GetInstitutionContractToSetServicesExcelImport();
|
||||
List<InstitutionContractViewModel> PrintAll(List<long> id);
|
||||
InstitutionContractViewModel PrintOne(long id);
|
||||
OperationResult Active(long id);
|
||||
|
||||
@@ -579,6 +579,14 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return _institutionContractRepository.NewSearch(searchModel);
|
||||
}
|
||||
|
||||
|
||||
public List<InstitutionContractViewModel> GetInstitutionContractToSetServicesExcelImport()
|
||||
{
|
||||
var result = _institutionContractRepository.NewSearch(new InstitutionContractSearchModel());
|
||||
|
||||
return result.Where(x => x.IsActiveString == "true" && x.IsContractingPartyBlock !="true" && x.WorkshopCount != "0" && x.ContractStartGr <= DateTime.Now && x.ContractEndGr >= DateTime.Now).ToList();
|
||||
}
|
||||
|
||||
public string ExpCheckColor(DateTime now, DateTime ContractEndGr, DateTime endThisMontGr, string ContractAmount, string isActiveString)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
@@ -537,8 +537,9 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
var employeeListData = employeeInsurancDataPreviusList
|
||||
.FirstOrDefault(e => e.EmployeeId == employee.EmployeeId);
|
||||
//مزیای عیر مشمول لیست قبل
|
||||
var benefitsIncludedNonContinuous =
|
||||
employeeListData != null ? employeeListData.BenefitsIncludedNonContinuous : 0;
|
||||
//var benefitsIncludedNonContinuous =
|
||||
// employeeListData != null ? employeeListData.BenefitsIncludedNonContinuous : 0;
|
||||
double benefitsIncludedNonContinuous = 0;
|
||||
if (workshop.InsuranceCheckoutFamilyAllowance && employeeHasCheckout && !isManager)
|
||||
{
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using PersianTools.Core;
|
||||
|
||||
@@ -759,6 +760,150 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد سند مالی حضور غیاب
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
/// <param name="endOfMonthGr"></param>
|
||||
/// <param name="endOfMonth"></param>
|
||||
/// <param name="description"></param>
|
||||
|
||||
#region RollcallServicCreateTransaction
|
||||
|
||||
public void RollcallServiceCreateTransaction()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
var nowFa = now.ToFarsi();
|
||||
var endOfMonth = nowFa.FindeEndOfMonth();
|
||||
|
||||
DateTime endOfMonthGr = endOfMonth.ToGeorgianDateTime();
|
||||
|
||||
|
||||
#region FindeNextMonth 1th
|
||||
var year = Convert.ToInt32(endOfMonth.Substring(0, 4));
|
||||
var month = Convert.ToInt32(endOfMonth.Substring(5, 2));
|
||||
var nextM = new PersianDateTime(year, month, 1).AddMonths(1);
|
||||
var nextMonthGr = ($"{nextM}").ToGeorgianDateTime();
|
||||
var endOfCurrentMonth = (($"{endOfMonth.Substring(0, 8)}/01").FindeEndOfMonth()).ToGeorgianDateTime();
|
||||
#endregion
|
||||
#region GetAvtiveContracts
|
||||
var institutionContracts = _context.InstitutionContractSet.Where(x => x.IsActiveString == "true").Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
IsActiveString = x.IsActiveString,
|
||||
SearchAmount = x.ContractAmount,
|
||||
TypeOfContract = x.TypeOfContract
|
||||
}).Where(x =>
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.SearchAmount > 0)
|
||||
.ToList();
|
||||
#endregion
|
||||
|
||||
#region GetFutureContracts
|
||||
|
||||
List<InstitutionContractViewModel> futureContracts = _context.InstitutionContractSet
|
||||
.Where(x => x.IsActiveString == "true" &&
|
||||
x.ContractStartGr == nextMonthGr && x.ContractAmount > 0)
|
||||
.Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
IsActiveString = x.IsActiveString,
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
ExtensionNo = x.ExtensionNo,
|
||||
}).ToList();
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDectivedContractOnCurrentMonth
|
||||
|
||||
if (futureContracts.Any())
|
||||
{
|
||||
List<long> futureContractIds = futureContracts.Select(x => x.ContractingPartyId).ToList();
|
||||
List<InstitutionContractViewModel> deatcivedContract = _context.InstitutionContractSet
|
||||
.Where(x => x.IsActiveString == "false" && futureContractIds.Contains(x.ContractingPartyId) &&
|
||||
x.ContractEndGr == endOfCurrentMonth && x.ContractAmount > 0)
|
||||
.Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
ContractStartGr = x.ContractStartGr,
|
||||
ContractStartFa = x.ContractStartFa,
|
||||
ContractEndGr = x.ContractEndGr,
|
||||
ContractEndFa = x.ContractEndFa,
|
||||
IsActiveString = x.IsActiveString,
|
||||
SearchAmount = x.ContractAmount,
|
||||
TypeOfContract = x.TypeOfContract
|
||||
}).ToList();
|
||||
|
||||
if (deatcivedContract.Any())
|
||||
institutionContracts.AddRange(deatcivedContract);
|
||||
}
|
||||
|
||||
List<long> exceptionContractingPartyIds = [30520, 30739];
|
||||
institutionContracts = institutionContracts
|
||||
.Where(x => !exceptionContractingPartyIds.Contains(x.ContractingPartyId)).ToList();
|
||||
int counter = 0;
|
||||
var rollcallServiceList =
|
||||
_context.RollCallServices.Where(x => x.IsActiveString == "true").ToList();
|
||||
var activeStatusDate = new DateTime(2121, 03, 21);
|
||||
|
||||
foreach (var item in institutionContracts)
|
||||
{
|
||||
|
||||
//var isblock = contractingParty.IsBlock == "true" ? true : false;
|
||||
|
||||
var employers = _context.Employers.Where(x => x.ContractingPartyId == item.ContractingPartyId).Select(x => x.id);
|
||||
var workshops = _context.WorkshopEmployers.Where(x => employers.Contains(x.EmployerId)).Select(x => x.WorkshopId).Distinct().ToList();
|
||||
|
||||
|
||||
var srvices =
|
||||
rollcallServiceList.Where(x => workshops.Contains(x.WorkshopId)).ToList();
|
||||
if (rollcallServiceList.Count > 0)
|
||||
{
|
||||
foreach (var rollCallService in srvices)
|
||||
{
|
||||
var spaning = (int)(endOfMonthGr - rollCallService.StartService).TotalDays + 1;
|
||||
int monthCounter = spaning > 31 ? 2 : 1;
|
||||
|
||||
|
||||
|
||||
var employees =
|
||||
_context.RollCallEmployees.Where(x => x.WorkshopId == rollCallService.WorkshopId).Select(x=>x.id);
|
||||
|
||||
var employeeCount = _context.RollCallEmployeesStatus.Where(x => employees.Contains(x.RollCallEmployeeId))
|
||||
.Count(x => x.EndDate.Date == activeStatusDate.Date);
|
||||
|
||||
if (employeeCount > 0)
|
||||
{
|
||||
counter++;
|
||||
Console.WriteLine(" number : " + counter + " - " + rollCallService.StartService.ToFarsi() + " WorkshopId : " + rollCallService.WorkshopId + " monthCount : " + monthCounter + " employeeCount : " + employeeCount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region CustomViewModels
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user