|
|
|
|
@@ -27,7 +27,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
private readonly CompanyContext _context;
|
|
|
|
|
private readonly IEmployerRepository _employerRepository;
|
|
|
|
|
private readonly IWorkshopRepository _workshopRepository;
|
|
|
|
|
public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository, IWorkshopRepository workshopRepository) : base(context)
|
|
|
|
|
|
|
|
|
|
public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository,
|
|
|
|
|
IWorkshopRepository workshopRepository) : base(context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
_employerRepository = employerRepository;
|
|
|
|
|
@@ -37,82 +39,82 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
public EditInstitutionContract GetDetails(long id)
|
|
|
|
|
{
|
|
|
|
|
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractDateFa = x.ContractDateFa,
|
|
|
|
|
State = x.State,
|
|
|
|
|
City = x.City,
|
|
|
|
|
Address = x.Address,
|
|
|
|
|
Description = x.Description,
|
|
|
|
|
WorkshopManualCount = x.WorkshopManualCount,
|
|
|
|
|
EmployeeManualCount = x.EmployeeManualCount,
|
|
|
|
|
ContractAmountString = x.ContractAmount.ToMoney(),
|
|
|
|
|
ContractAmount = x.ContractAmount,
|
|
|
|
|
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
|
|
|
|
ObligationString = x.Obligation.ToMoney(),
|
|
|
|
|
TotalAmountString = x.TotalAmount.ToMoney(),
|
|
|
|
|
ExtensionNo = x.ExtensionNo,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature,
|
|
|
|
|
HasValueAddedTax = x.HasValueAddedTax,
|
|
|
|
|
ValueAddedTax = x.ValueAddedTax,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractDateFa = x.ContractDateFa,
|
|
|
|
|
State = x.State,
|
|
|
|
|
City = x.City,
|
|
|
|
|
Address = x.Address,
|
|
|
|
|
Description = x.Description,
|
|
|
|
|
WorkshopManualCount = x.WorkshopManualCount,
|
|
|
|
|
EmployeeManualCount = x.EmployeeManualCount,
|
|
|
|
|
ContractAmountString = x.ContractAmount.ToMoney(),
|
|
|
|
|
ContractAmount = x.ContractAmount,
|
|
|
|
|
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
|
|
|
|
ObligationString = x.Obligation.ToMoney(),
|
|
|
|
|
TotalAmountString = x.TotalAmount.ToMoney(),
|
|
|
|
|
ExtensionNo = x.ExtensionNo,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature,
|
|
|
|
|
HasValueAddedTax = x.HasValueAddedTax,
|
|
|
|
|
ValueAddedTax = x.ValueAddedTax,
|
|
|
|
|
})
|
|
|
|
|
.FirstOrDefault(x => x.Id == id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EditInstitutionContract GetFirstContract(long contractingPartyId, string typeOfContract)
|
|
|
|
|
{
|
|
|
|
|
return _context.InstitutionContractSet.Select(x => new EditInstitutionContract()
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractDateFa = x.ContractDateFa,
|
|
|
|
|
State = x.State,
|
|
|
|
|
City = x.City,
|
|
|
|
|
Address = x.Address,
|
|
|
|
|
Description = x.Description,
|
|
|
|
|
WorkshopManualCount = x.WorkshopManualCount,
|
|
|
|
|
EmployeeManualCount = x.EmployeeManualCount,
|
|
|
|
|
ContractAmountString = x.ContractAmount.ToMoney(),
|
|
|
|
|
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
|
|
|
|
ObligationString = x.Obligation.ToMoney(),
|
|
|
|
|
TotalAmountString = x.TotalAmount.ToMoney(),
|
|
|
|
|
ExtensionNo = x.ExtensionNo,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.Where(x => x.ContractingPartyId == contractingPartyId && x.TypeOfContract == typeOfContract).OrderBy(x => x.ExtensionNo).FirstOrDefault();
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractDateFa = x.ContractDateFa,
|
|
|
|
|
State = x.State,
|
|
|
|
|
City = x.City,
|
|
|
|
|
Address = x.Address,
|
|
|
|
|
Description = x.Description,
|
|
|
|
|
WorkshopManualCount = x.WorkshopManualCount,
|
|
|
|
|
EmployeeManualCount = x.EmployeeManualCount,
|
|
|
|
|
ContractAmountString = x.ContractAmount.ToMoney(),
|
|
|
|
|
DailyCompenseationString = x.DailyCompenseation.ToMoney(),
|
|
|
|
|
ObligationString = x.Obligation.ToMoney(),
|
|
|
|
|
TotalAmountString = x.TotalAmount.ToMoney(),
|
|
|
|
|
ExtensionNo = x.ExtensionNo,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature
|
|
|
|
|
})
|
|
|
|
|
.Where(x => x.ContractingPartyId == contractingPartyId && x.TypeOfContract == typeOfContract)
|
|
|
|
|
.OrderBy(x => x.ExtensionNo).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<InstitutionContractViewModel> InstitutionContractsWithoutAccount()
|
|
|
|
|
{
|
|
|
|
|
var now = DateTime.Now;
|
|
|
|
|
var contractHasClientAccountList = _context.InstitutionContractSet.AsSplitQuery().Where(x => x.IsActiveString == "true" && x.ContractStartGr <= now && x.ContractEndGr >= now)
|
|
|
|
|
var contractHasClientAccountList = _context.InstitutionContractSet.AsSplitQuery().Where(x =>
|
|
|
|
|
x.IsActiveString == "true" && x.ContractStartGr <= now && x.ContractEndGr >= now)
|
|
|
|
|
.Join(_context.ContractingPartyAccounts,
|
|
|
|
|
contract => contract.ContractingPartyId,
|
|
|
|
|
acc => acc.PersonalContractingPartyId,
|
|
|
|
|
((contract, account) => new {contract, account})).Select(x=>x.contract);
|
|
|
|
|
((contract, account) => new { contract, account })).Select(x => x.contract);
|
|
|
|
|
|
|
|
|
|
var allActiveContracts = _context.InstitutionContractSet.Where(x =>
|
|
|
|
|
x.IsActiveString == "true" && x.ContractStartGr <= now && x.ContractEndGr >= now);
|
|
|
|
|
@@ -137,21 +139,21 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<InstitutionContractViewModel> ContractWithoutValidContactInfo()
|
|
|
|
|
{
|
|
|
|
|
var now = DateTime.Now;
|
|
|
|
|
var contractHasContactInfo = _context.InstitutionContractSet.AsSplitQuery().Where(x => x.IsActiveString == "true" && x.ContractStartGr <= now && x.ContractEndGr >= now)
|
|
|
|
|
var contractHasContactInfo = _context.InstitutionContractSet.AsSplitQuery().Where(x =>
|
|
|
|
|
x.IsActiveString == "true" && x.ContractStartGr <= now && x.ContractEndGr >= now)
|
|
|
|
|
.Join(_context.InstitutionContractContactInfos,
|
|
|
|
|
contract => contract.id,
|
|
|
|
|
contactInfo => contactInfo.InstitutionContractId,
|
|
|
|
|
((contract, contactInfo) => new { contract, contactInfo }))
|
|
|
|
|
.Where(x => x.contactInfo.SendSms && x.contactInfo.Position == "طرف قرارداد" && x.contactInfo.PhoneType == "شماره همراه")
|
|
|
|
|
.Where(x => x.contactInfo.SendSms && x.contactInfo.Position == "طرف قرارداد" &&
|
|
|
|
|
x.contactInfo.PhoneType == "شماره همراه")
|
|
|
|
|
.Select(x => x.contract);
|
|
|
|
|
|
|
|
|
|
var allvalidCcntactInfoContracts = _context.InstitutionContractSet.Where(x =>
|
|
|
|
|
@@ -177,9 +179,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<InstitutionContractViewModel> Search(InstitutionContractSearchModel searchModel)
|
|
|
|
|
{
|
|
|
|
|
//var stored = _context.InstitutionContractSet.FromSqlInterpolated($"SelectQuery_InstitutionContract").AsNoTracking()
|
|
|
|
|
@@ -204,8 +206,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (searchModel.Id != 0)
|
|
|
|
|
@@ -224,6 +224,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.SearchAmount >= start && x.SearchAmount <= end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.StartAmount) &&
|
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.EndAmount))
|
|
|
|
|
{
|
|
|
|
|
@@ -232,6 +233,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.SearchAmount >= start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(searchModel.StartAmount) &&
|
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.EndAmount))
|
|
|
|
|
{
|
|
|
|
|
@@ -241,7 +243,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
x.SearchAmount >= start);
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.SearchAmount <= end);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchModel.IsActiveString == null)
|
|
|
|
|
@@ -255,7 +256,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
}
|
|
|
|
|
else if (searchModel.IsActiveString == "both")
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true" || x.IsActiveString == "blue");
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.IsActiveString == "false" || x.IsActiveString == "true" || x.IsActiveString == "blue");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchModel.OfficialCompany == "Official")
|
|
|
|
|
@@ -307,58 +309,64 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
var timer = Stopwatch.StartNew();
|
|
|
|
|
var query = _context.InstitutionContractSet.AsSplitQuery()
|
|
|
|
|
.Select(x => new InstitutionContractViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractAmount = x.ContractAmount.ToMoney(),
|
|
|
|
|
TotalAmount = x.TotalAmount.ToMoney(),
|
|
|
|
|
SearchAmount = x.ContractAmount,
|
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature,
|
|
|
|
|
|
|
|
|
|
WorkshopCount = "",
|
|
|
|
|
//WorkshopViewModels = _context.Workshops.Include(w=>w.WorkshopEmployers).Include(w => w.LeftWorks).Include(w => w.LeftWorkInsurances).Select(w => new WorkshopViewModel()
|
|
|
|
|
//{
|
|
|
|
|
// Id = w.id,
|
|
|
|
|
// WorkshopName = w.WorkshopName,
|
|
|
|
|
// WorkshopFullName = w.WorkshopFullName,
|
|
|
|
|
// ArchiveCode = w.ArchiveCode,
|
|
|
|
|
// ContractingPartId = w.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(),
|
|
|
|
|
// LeftWorkIds = w.LeftWorks.Where(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now).Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
// InsuranceLeftWorkIds = w.LeftWorkInsurances.Where(l => (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now) || (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate == null)).Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
//}).Where(w=>w.ContractingPartId == x.ContractingPartyId).ToList(),
|
|
|
|
|
WorkshopIds = _context.Workshops
|
|
|
|
|
.Include(w => w.WorkshopEmployers).Select(w => new WorkshopViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = w.id,
|
|
|
|
|
ContractingPartId = w.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(),
|
|
|
|
|
Id = x.id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractAmount = x.ContractAmount.ToMoney(),
|
|
|
|
|
TotalAmount = x.TotalAmount.ToMoney(),
|
|
|
|
|
SearchAmount = x.ContractAmount,
|
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature,
|
|
|
|
|
|
|
|
|
|
}).Where(c => c.ContractingPartId == x.ContractingPartyId).Select(w => w.Id).ToList(),
|
|
|
|
|
EmployerViewModels = _context.Employers.Where(e => e.ContractingPartyId == x.ContractingPartyId).Select(e =>
|
|
|
|
|
new EmployerViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = e.id,
|
|
|
|
|
FullName = e.FName + " " + e.LName,
|
|
|
|
|
WorkshopCount = "",
|
|
|
|
|
//WorkshopViewModels = _context.Workshops.Include(w=>w.WorkshopEmployers).Include(w => w.LeftWorks).Include(w => w.LeftWorkInsurances).Select(w => new WorkshopViewModel()
|
|
|
|
|
//{
|
|
|
|
|
// Id = w.id,
|
|
|
|
|
// WorkshopName = w.WorkshopName,
|
|
|
|
|
// WorkshopFullName = w.WorkshopFullName,
|
|
|
|
|
// ArchiveCode = w.ArchiveCode,
|
|
|
|
|
// ContractingPartId = w.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(),
|
|
|
|
|
// LeftWorkIds = w.LeftWorks.Where(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now).Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
// InsuranceLeftWorkIds = w.LeftWorkInsurances.Where(l => (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now) || (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate == null)).Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
//}).Where(w=>w.ContractingPartId == x.ContractingPartyId).ToList(),
|
|
|
|
|
WorkshopIds = _context.Workshops
|
|
|
|
|
.Include(w => w.WorkshopEmployers).Select(w => new WorkshopViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = w.id,
|
|
|
|
|
ContractingPartId = w.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId)
|
|
|
|
|
.FirstOrDefault(),
|
|
|
|
|
}).Where(c => c.ContractingPartId == x.ContractingPartyId).Select(w => w.Id).ToList(),
|
|
|
|
|
EmployerViewModels = _context.Employers.Where(e => e.ContractingPartyId == x.ContractingPartyId)
|
|
|
|
|
.Select(e =>
|
|
|
|
|
new EmployerViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = e.id,
|
|
|
|
|
FullName = e.FName + " " + e.LName,
|
|
|
|
|
}).GroupBy(e => e.Id).Select(e => e.First()).ToList(),
|
|
|
|
|
EmployerIds = _context.Employers.AsSplitQuery().Where(e => e.ContractingPartyId == x.ContractingPartyId)
|
|
|
|
|
.Select(e => e.id).ToList(),
|
|
|
|
|
EmployerNo = "",
|
|
|
|
|
EmployerName = "",
|
|
|
|
|
|
|
|
|
|
}).GroupBy(e => e.Id).Select(e => e.First()).ToList(),
|
|
|
|
|
EmployerIds = _context.Employers.AsSplitQuery().Where(e => e.ContractingPartyId == x.ContractingPartyId).Select(e => e.id).ToList(),
|
|
|
|
|
EmployerNo = "",
|
|
|
|
|
EmployerName = "",
|
|
|
|
|
|
|
|
|
|
IsContractingPartyBlock = _context.PersonalContractingParties.AsSplitQuery().Any(p => p.id == x.ContractingPartyId && p.IsBlock == "true") ? "true" : "false",
|
|
|
|
|
BlockTimes = _context.PersonalContractingParties.AsSplitQuery().Any(p => p.id == x.ContractingPartyId) ? _context.PersonalContractingParties.FirstOrDefault(p => p.id == x.ContractingPartyId).BlockTimes : 0,
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
IsContractingPartyBlock =
|
|
|
|
|
_context.PersonalContractingParties.AsSplitQuery()
|
|
|
|
|
.Any(p => p.id == x.ContractingPartyId && p.IsBlock == "true")
|
|
|
|
|
? "true"
|
|
|
|
|
: "false",
|
|
|
|
|
BlockTimes = _context.PersonalContractingParties.AsSplitQuery().Any(p => p.id == x.ContractingPartyId)
|
|
|
|
|
? _context.PersonalContractingParties.FirstOrDefault(p => p.id == x.ContractingPartyId).BlockTimes
|
|
|
|
|
: 0,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (searchModel.Id != 0)
|
|
|
|
|
query = query.Where(x => x.Id == searchModel.Id);
|
|
|
|
|
@@ -376,6 +384,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.SearchAmount >= start && x.SearchAmount <= end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.StartAmount) &&
|
|
|
|
|
string.IsNullOrWhiteSpace(searchModel.EndAmount))
|
|
|
|
|
{
|
|
|
|
|
@@ -384,6 +393,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.SearchAmount >= start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(searchModel.StartAmount) &&
|
|
|
|
|
!string.IsNullOrWhiteSpace(searchModel.EndAmount))
|
|
|
|
|
{
|
|
|
|
|
@@ -393,7 +403,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
x.SearchAmount >= start);
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.SearchAmount <= end);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -408,7 +417,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
}
|
|
|
|
|
else if (searchModel.IsActiveString == "both")
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true" || x.IsActiveString == "blue");
|
|
|
|
|
query = query.Where(x =>
|
|
|
|
|
x.IsActiveString == "false" || x.IsActiveString == "true" || x.IsActiveString == "blue");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchModel.OfficialCompany == "Official")
|
|
|
|
|
@@ -438,6 +448,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.EmployerIds.Count > 0 && x.EmployerIds.Any(e => e == searchModel.EmployerId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchModel.Signature == "2")
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.Signature == "0" || x.Signature == "1");
|
|
|
|
|
@@ -490,66 +501,67 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
BlockTimes = x.BlockTimes,
|
|
|
|
|
// EmployeeCount = ((x.WorkshopViewModels.Sum(w => w.LeftWorkIds.Count)) + (x.WorkshopViewModels.Sum(w => w.InsuranceLeftWorkIds.Count(c => !w.LeftWorkIds.Contains(c))))).ToString(),
|
|
|
|
|
// ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
|
|
|
|
WorkshopViewModels = _context.Workshops.AsSplitQuery().Where(w => x.WorkshopIds.Contains(w.id)).Include(w => w.LeftWorks).Include(w => w.LeftWorkInsurances).Select(w => new WorkshopViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = w.id,
|
|
|
|
|
WorkshopName = w.WorkshopName,
|
|
|
|
|
WorkshopFullName = w.WorkshopFullName,
|
|
|
|
|
ArchiveCode = w.ArchiveCode,
|
|
|
|
|
ContractingPartId = w.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(),
|
|
|
|
|
LeftWorkIds = w.LeftWorks.Where(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now).Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
InsuranceLeftWorkIds = w.LeftWorkInsurances.Where(l => (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now) || (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate == null)).Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
}).ToList(),
|
|
|
|
|
|
|
|
|
|
WorkshopViewModels = _context.Workshops.AsSplitQuery().Where(w => x.WorkshopIds.Contains(w.id))
|
|
|
|
|
.Include(w => w.LeftWorks).Include(w => w.LeftWorkInsurances).Select(w => new WorkshopViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = w.id,
|
|
|
|
|
WorkshopName = w.WorkshopName,
|
|
|
|
|
WorkshopFullName = w.WorkshopFullName,
|
|
|
|
|
ArchiveCode = w.ArchiveCode,
|
|
|
|
|
ContractingPartId = w.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(),
|
|
|
|
|
LeftWorkIds = w.LeftWorks
|
|
|
|
|
.Where(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now)
|
|
|
|
|
.Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
InsuranceLeftWorkIds = w.LeftWorkInsurances
|
|
|
|
|
.Where(l => (l.StartWorkDate <= DateTime.Now && l.LeftWorkDate > DateTime.Now) ||
|
|
|
|
|
(l.StartWorkDate <= DateTime.Now && l.LeftWorkDate == null))
|
|
|
|
|
.Select(l => l.EmployeeId).ToList(),
|
|
|
|
|
}).ToList(),
|
|
|
|
|
}).ToList();
|
|
|
|
|
listQuery = listQuery.Select(x => new InstitutionContractViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractAmount = x.ContractAmount,
|
|
|
|
|
TotalAmount = x.TotalAmount,
|
|
|
|
|
SearchAmount = x.SearchAmount,
|
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature,
|
|
|
|
|
ExpireColor = x.ExpireColor,
|
|
|
|
|
IsExpier = x.IsExpier,
|
|
|
|
|
BalanceDouble = x.BalanceDouble,
|
|
|
|
|
BalanceStr = x.BalanceStr,
|
|
|
|
|
EmployerViewModels = x.EmployerViewModels,
|
|
|
|
|
EmployerNo = x.EmployerNo,
|
|
|
|
|
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
|
|
|
|
WorkshopViewModels = x.WorkshopViewModels,
|
|
|
|
|
WorkshopCount = x.WorkshopCount,
|
|
|
|
|
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
|
|
|
|
BlockTimes = x.BlockTimes,
|
|
|
|
|
EmployeeCount =
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
ContractNo = x.ContractNo,
|
|
|
|
|
ContractStartGr = x.ContractStartGr,
|
|
|
|
|
ContractStartFa = x.ContractStartFa,
|
|
|
|
|
ContractEndGr = x.ContractEndGr,
|
|
|
|
|
ContractEndFa = x.ContractEndFa,
|
|
|
|
|
RepresentativeId = x.RepresentativeId,
|
|
|
|
|
RepresentativeName = x.RepresentativeName,
|
|
|
|
|
ContractingPartyName = x.ContractingPartyName,
|
|
|
|
|
ContractingPartyId = x.ContractingPartyId,
|
|
|
|
|
ContractAmount = x.ContractAmount,
|
|
|
|
|
TotalAmount = x.TotalAmount,
|
|
|
|
|
SearchAmount = x.SearchAmount,
|
|
|
|
|
IsActiveString = x.IsActiveString,
|
|
|
|
|
OfficialCompany = x.OfficialCompany,
|
|
|
|
|
TypeOfContract = x.TypeOfContract,
|
|
|
|
|
Signature = x.Signature,
|
|
|
|
|
ExpireColor = x.ExpireColor,
|
|
|
|
|
IsExpier = x.IsExpier,
|
|
|
|
|
BalanceDouble = x.BalanceDouble,
|
|
|
|
|
BalanceStr = x.BalanceStr,
|
|
|
|
|
EmployerViewModels = x.EmployerViewModels,
|
|
|
|
|
EmployerNo = x.EmployerNo,
|
|
|
|
|
EmployerName = x.EmployerViewModels.Select(n => n.FullName).FirstOrDefault(),
|
|
|
|
|
WorkshopViewModels = x.WorkshopViewModels,
|
|
|
|
|
WorkshopCount = x.WorkshopCount,
|
|
|
|
|
IsContractingPartyBlock = x.IsContractingPartyBlock,
|
|
|
|
|
BlockTimes = x.BlockTimes,
|
|
|
|
|
EmployeeCount =
|
|
|
|
|
((x.WorkshopViewModels.Sum(w => w.LeftWorkIds.Count)) + (x.WorkshopViewModels.Sum(w =>
|
|
|
|
|
w.InsuranceLeftWorkIds.Count(c => !w.LeftWorkIds.Contains(c))))).ToString(),
|
|
|
|
|
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
|
|
|
|
ArchiveCode = x.WorkshopViewModels.Count > 0 ? ArchiveCodeFinder(x.WorkshopViewModels) : 0,
|
|
|
|
|
}).OrderBy(x => x.WorkshopCount != "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
|
|
|
|
.ThenBy(x => x.WorkshopCount == "0" && string.IsNullOrWhiteSpace(x.ExpireColor))
|
|
|
|
|
.ThenBy(x => x.IsExpier == "true")
|
|
|
|
|
.ThenBy(x => x.ExpireColor == "purple")
|
|
|
|
|
.ThenBy(x => x.ExpireColor == "black").ToList();
|
|
|
|
|
Console.WriteLine("test >>> " + timer.Elapsed);
|
|
|
|
|
return listQuery;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<InstitutionContractViewModel> PrintAll(List<long> id)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
@@ -581,9 +593,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateContractingPartyAccount(long contractingPartyid, long accountId)
|
|
|
|
|
@@ -596,12 +605,12 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
public double GetcontractAmount(int countPerson)
|
|
|
|
|
{
|
|
|
|
|
var planPercentage = _context.PlanPercentages.FirstOrDefault();
|
|
|
|
|
int contarctAndCheckoutPercent = 100;
|
|
|
|
|
int insurancePercent = 50;
|
|
|
|
|
int rollCallPercent = 100;
|
|
|
|
|
int customizeCkeckoutPercen = 50;
|
|
|
|
|
int contarctAndCheckoutInPersonPercent = 900;
|
|
|
|
|
int insuranceInPersonPercent = 500;
|
|
|
|
|
int contarctAndCheckoutPercent = 100;
|
|
|
|
|
int insurancePercent = 50;
|
|
|
|
|
int rollCallPercent = 100;
|
|
|
|
|
int customizeCkeckoutPercen = 50;
|
|
|
|
|
int contarctAndCheckoutInPersonPercent = 900;
|
|
|
|
|
int insuranceInPersonPercent = 500;
|
|
|
|
|
if (planPercentage != null)
|
|
|
|
|
{
|
|
|
|
|
contarctAndCheckoutPercent = planPercentage.ContractAndCheckoutPercent;
|
|
|
|
|
@@ -611,10 +620,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
contarctAndCheckoutInPersonPercent = planPercentage.ContractAndCheckoutInPersonPercent;
|
|
|
|
|
insuranceInPersonPercent = planPercentage.InsuranceInPersonPercent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dailyWageYearlySalery = _context.YearlySalaries.Include(i=>i.YearlySalaryItemsList).FirstOrDefault(x =>
|
|
|
|
|
var dailyWageYearlySalery = _context.YearlySalaries.Include(i => i.YearlySalaryItemsList).FirstOrDefault(x =>
|
|
|
|
|
x.StartDate.Date <= DateTime.Now.Date && x.EndDate >= DateTime.Now.Date);
|
|
|
|
|
double res = 0;
|
|
|
|
|
if (countPerson > 0 && dailyWageYearlySalery != null)
|
|
|
|
|
@@ -641,8 +649,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
// plan.IncreasePercentage;
|
|
|
|
|
|
|
|
|
|
//خدمات حضوری قرارداد و تصفیه
|
|
|
|
|
var contarctAndCheckoutInPerson = ((dailyWage * contarctAndCheckoutInPersonPercent) / 100) * countPerson *
|
|
|
|
|
plan.IncreasePercentage;
|
|
|
|
|
var contarctAndCheckoutInPerson =
|
|
|
|
|
((dailyWage * contarctAndCheckoutInPersonPercent) / 100) * countPerson *
|
|
|
|
|
plan.IncreasePercentage;
|
|
|
|
|
|
|
|
|
|
//خدمات حضوری بیمه
|
|
|
|
|
var insuranceInPerson = ((dailyWage * insuranceInPersonPercent) / 100) * countPerson *
|
|
|
|
|
@@ -650,9 +659,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//جمع کل
|
|
|
|
|
res = contarctAndCheckout + insurance + contarctAndCheckoutInPerson + insuranceInPerson;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = contarctAndCheckout + insurance + contarctAndCheckoutInPerson + insuranceInPerson;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -694,7 +701,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
result = "blue";
|
|
|
|
|
isExpier = "false";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (result, isExpier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -719,8 +726,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
result.TotalBalanceDbl = debt - credit;
|
|
|
|
|
result.TotalBalanceStr = result.TotalBalanceDbl.ToMoney();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -740,28 +747,27 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
|
|
|
|
|
public InstitutionContract InstitutionContractByEmployerId(long employerId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
long contractingPryId = _context.Employers.FirstOrDefault(x => x.id == employerId)!.ContractingPartyId;
|
|
|
|
|
if (_context.PersonalContractingParties.Any(x => x.id == contractingPryId && x.IsBlock == "true"))
|
|
|
|
|
return new();
|
|
|
|
|
var contracts = _context.InstitutionContractSet.Where(x =>
|
|
|
|
|
x.ContractingPartyId == contractingPryId).ToList();
|
|
|
|
|
var contract = contracts.FirstOrDefault(x => x.IsActiveString != "false" &&
|
|
|
|
|
x.ContractStartGr.Date <= DateTime.Now.Date && x.ContractEndGr >= DateTime.Now.Date);
|
|
|
|
|
x.ContractStartGr.Date <= DateTime.Now.Date &&
|
|
|
|
|
x.ContractEndGr >= DateTime.Now.Date);
|
|
|
|
|
if (contract != null)
|
|
|
|
|
{
|
|
|
|
|
return contract;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var future = contracts.FirstOrDefault(x => x.IsActiveString != "false" &&
|
|
|
|
|
x.ContractStartGr.Date >= DateTime.Now.Date && x.ContractEndGr >= DateTime.Now.Date);
|
|
|
|
|
x.ContractStartGr.Date >= DateTime.Now.Date &&
|
|
|
|
|
x.ContractEndGr >= DateTime.Now.Date);
|
|
|
|
|
if (future != null)
|
|
|
|
|
return future;
|
|
|
|
|
return new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -783,30 +789,36 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@@ -866,18 +878,18 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
|
|
|
|
|
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 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;
|
|
|
|
|
@@ -891,41 +903,45 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
var yearCurrent = endOfMonth.Substring(0, 4);
|
|
|
|
|
var currentMonthName = monthCurrent.ToFarsiMonthByNumber();
|
|
|
|
|
var workshop = _context.Workshops.FirstOrDefault(x => x.id == rollCallService.WorkshopId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string description = "";
|
|
|
|
|
if (rollCallService.StartService <= prevMonthStart)
|
|
|
|
|
{
|
|
|
|
|
var monthPrev = prevMonthEnd.ToFarsi().Substring(5, 2);
|
|
|
|
|
var yearPrev = prevMonthEnd.ToFarsi().Substring(0, 4);
|
|
|
|
|
var prevMonthName = monthPrev.ToFarsiMonthByNumber();
|
|
|
|
|
description = $"{prevMonthName} و {currentMonthName} {yearCurrent} - {workshop.WorkshopFullName}";
|
|
|
|
|
description =
|
|
|
|
|
$"{prevMonthName} و {currentMonthName} {yearCurrent} - {workshop.WorkshopFullName}";
|
|
|
|
|
monthCounter = 2;
|
|
|
|
|
}else if (rollCallService.StartService <= currentMonthStart &&
|
|
|
|
|
rollCallService.StartService > prevMonthStart)
|
|
|
|
|
}
|
|
|
|
|
else if (rollCallService.StartService <= currentMonthStart &&
|
|
|
|
|
rollCallService.StartService > prevMonthStart)
|
|
|
|
|
{
|
|
|
|
|
monthCounter = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
description = $"{currentMonthName} {yearCurrent} - {workshop.WorkshopFullName}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var employees =
|
|
|
|
|
_context.RollCallEmployees.Where(x => x.WorkshopId == rollCallService.WorkshopId).Select(x=>x.id);
|
|
|
|
|
_context.RollCallEmployees.Where(x => x.WorkshopId == rollCallService.WorkshopId)
|
|
|
|
|
.Select(x => x.id);
|
|
|
|
|
|
|
|
|
|
var employeeCount = _context.RollCallEmployeesStatus.Where(x => employees.Contains(x.RollCallEmployeeId))
|
|
|
|
|
var employeeCount = _context.RollCallEmployeesStatus
|
|
|
|
|
.Where(x => employees.Contains(x.RollCallEmployeeId))
|
|
|
|
|
.Count(x => x.EndDate.Date == activeStatusDate.Date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (employeeCount > 0 && monthCounter > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
counter++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dailyWageYearlySalery = _context.YearlySalaries.Include(i => i.YearlySalaryItemsList).FirstOrDefault(x =>
|
|
|
|
|
x.StartDate.Date <= DateTime.Now.Date && x.EndDate >= DateTime.Now.Date);
|
|
|
|
|
var dailyWageYearlySalery = _context.YearlySalaries.Include(i => i.YearlySalaryItemsList)
|
|
|
|
|
.FirstOrDefault(x =>
|
|
|
|
|
x.StartDate.Date <= DateTime.Now.Date && x.EndDate >= DateTime.Now.Date);
|
|
|
|
|
|
|
|
|
|
var dailyWage = dailyWageYearlySalery.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه")
|
|
|
|
|
var dailyWage = dailyWageYearlySalery.YearlySalaryItemsList
|
|
|
|
|
.Where(x => x.ItemName == "مزد روزانه")
|
|
|
|
|
.Select(x => x.ItemValue).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
var planPercentage = _context.PlanPercentages.FirstOrDefault();
|
|
|
|
|
@@ -934,8 +950,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
var planByCountPerson = _context.InstitutionPlans
|
|
|
|
|
.FirstOrDefault(x => x.CountPerson == countPersonnel);
|
|
|
|
|
|
|
|
|
|
var amountForOneMonth =(((dailyWage * planPercentage.RollCallPercent) / 100) * planByCountPerson.CountPerson *
|
|
|
|
|
planByCountPerson.IncreasePercentage);
|
|
|
|
|
var amountForOneMonth = (((dailyWage * planPercentage.RollCallPercent) / 100) *
|
|
|
|
|
planByCountPerson.CountPerson *
|
|
|
|
|
planByCountPerson.IncreasePercentage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var amountWithoutTax = amountForOneMonth * monthCounter;
|
|
|
|
|
@@ -944,7 +961,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
var tenPercent = amountWithoutTax * 10 / 100;
|
|
|
|
|
var totalAmonut = amountWithoutTax + tenPercent;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine( counter + " - " + rollCallService.StartService.ToFarsi() + " - " + rollCallService.WorkshopId + " - " + monthCounter + " - " + employeeCount + $" - {amountWithoutTax}");
|
|
|
|
|
Console.WriteLine(counter + " - " + rollCallService.StartService.ToFarsi() + " - " +
|
|
|
|
|
rollCallService.WorkshopId + " - " + monthCounter + " - " + employeeCount +
|
|
|
|
|
$" - {amountWithoutTax}");
|
|
|
|
|
|
|
|
|
|
var financialStatment =
|
|
|
|
|
_context.FinancialStatments.FirstOrDefault(x =>
|
|
|
|
|
@@ -962,31 +981,32 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|
|
|
|
|
|
|
|
|
financialStatementId = statement.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var transaction = new FinancialTransaction(financialStatementId, endOfMonthGr, endOfMonth,
|
|
|
|
|
description,
|
|
|
|
|
"debt", "بابت سرویس حضور غیاب", totalAmonut, 0, 0);
|
|
|
|
|
"debt", "بابت سرویس حضور غیاب", totalAmonut, 0, 0);
|
|
|
|
|
_context.FinancialTransactions.Add(transaction);
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine(" number : " + counter + " - " + rollCallService.StartService.ToFarsi() + " - WorkshopId : " + rollCallService.WorkshopId + " - monthCount : " + monthCounter + " - employeeCount : " + employeeCount + $" - Amount : {amountWithoutTax.ToMoney()}" + $" - ten : {tenPercent.ToMoney()} total : {totalAmonut.ToMoney()}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<GetInstitutionContractListViewModel> GetList(InstitutionContractListSearchModel searchModel)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region CustomViewModels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class WorkshopsAndEmployeeViewModel
|
|
|
|
|
{
|
|
|
|
|
public List<WorkshopViewModel> WorkshopViewModels { get; set; }
|
|
|
|
|
|