add workshops and plan amounts handling in InstitutionContractExtenstionTemp and update related services
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
@@ -23,6 +24,17 @@ public class InstitutionContractExtenstionTemp
|
||||
public string Province { get; set; }
|
||||
public List<EditContactInfo> ContactInfos { get; set; }
|
||||
|
||||
public List<InstitutionContractExtenstionTempWorkshop> Workshops { get; set; }
|
||||
|
||||
public InstitutionContractExtensionPlanDetail OneMonth { get; set; }
|
||||
public InstitutionContractExtensionPlanDetail ThreeMonths { get; set; }
|
||||
public InstitutionContractExtensionPlanDetail SixMonths { get; set; }
|
||||
public InstitutionContractExtensionPlanDetail TwelveMonths { get; set; }
|
||||
|
||||
public bool HasContractInPerson { get; set; }
|
||||
|
||||
public InstitutionContractDuration? Duration { get; set; }
|
||||
|
||||
public void SetContractingPartyInfos(string address, string city, string province, List<EditContactInfo> contactInfos)
|
||||
{
|
||||
Address = address;
|
||||
@@ -30,5 +42,108 @@ public class InstitutionContractExtenstionTemp
|
||||
Province = province;
|
||||
ContactInfos = contactInfos;
|
||||
}
|
||||
|
||||
public void SetWorkshopsAndPlanAmounts(List<InstitutionContractExtenstionTempWorkshop> workshops,
|
||||
InstitutionContractExtensionPlanDetail oneMonth,
|
||||
InstitutionContractExtensionPlanDetail threeMonth, InstitutionContractExtensionPlanDetail sixMonth,
|
||||
InstitutionContractExtensionPlanDetail twelveMonth, bool hasContractInPerson)
|
||||
{
|
||||
Workshops = workshops;
|
||||
OneMonth = oneMonth;
|
||||
ThreeMonths = threeMonth;
|
||||
SixMonths = sixMonth;
|
||||
TwelveMonths = twelveMonth;
|
||||
HasContractInPerson = hasContractInPerson;
|
||||
}
|
||||
}
|
||||
|
||||
public class InstitutionContractExtenstionTempPlan
|
||||
{
|
||||
public InstitutionContractExtenstionTempPlan(string contractStart, string contractEnd, string oneMonthPaymentDiscounted, string oneMonthDiscount, string oneMonthOriginalPayment, string totalPayment, string dailyCompenseation, string obligation)
|
||||
{
|
||||
ContractStart = contractStart;
|
||||
ContractEnd = contractEnd;
|
||||
OneMonthPaymentDiscounted = oneMonthPaymentDiscounted;
|
||||
OneMonthDiscount = oneMonthDiscount;
|
||||
OneMonthOriginalPayment = oneMonthOriginalPayment;
|
||||
TotalPayment = totalPayment;
|
||||
DailyCompenseation = dailyCompenseation;
|
||||
Obligation = obligation;
|
||||
}
|
||||
|
||||
public string ContractStart { get; set; }
|
||||
public string ContractEnd { get; set; }
|
||||
public string OneMonthPaymentDiscounted { get; set; }
|
||||
public string OneMonthDiscount { get; set; }
|
||||
public string OneMonthOriginalPayment { get; set; }
|
||||
public string TotalPayment { get; set; }
|
||||
public string DailyCompenseation { get; set; }
|
||||
public string Obligation { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractExtenstionTempWorkshop
|
||||
{
|
||||
public InstitutionContractExtenstionTempWorkshop(string workshopName, int countPerson, bool contractAndCheckout, bool contractAndCheckoutInPerson,
|
||||
bool insurance, bool insuranceInPerson,
|
||||
bool rollCall,bool rollCallInPerson, bool customizeCheckout)
|
||||
{
|
||||
WorkshopName = workshopName;
|
||||
CountPerson = countPerson;
|
||||
ContractAndCheckout = contractAndCheckout;
|
||||
Insurance = insurance;
|
||||
RollCall = rollCall;
|
||||
CustomizeCheckout = customizeCheckout;
|
||||
ContractAndCheckoutInPerson = contractAndCheckoutInPerson;
|
||||
InsuranceInPerson = insuranceInPerson;
|
||||
RollCallInPerson = rollCallInPerson;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نام کارگاه
|
||||
/// </summary>
|
||||
public string WorkshopName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعداد پرسنل
|
||||
/// </summary>
|
||||
public int CountPerson { get; private set; }
|
||||
|
||||
|
||||
#region ServiceSelection
|
||||
|
||||
/// <summary>
|
||||
/// قرارداد و تصفیه
|
||||
/// </summary>
|
||||
public bool ContractAndCheckout { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// بیمه
|
||||
/// </summary>
|
||||
public bool Insurance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// حضورغباب
|
||||
/// </summary>
|
||||
public bool RollCall { get; private set; }
|
||||
|
||||
public bool RollCallInPerson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فیش غیر رسمی
|
||||
/// </summary>
|
||||
public bool CustomizeCheckout { get;private set; }
|
||||
|
||||
/// <summary>
|
||||
/// خدمات حضوری قرداد و تصفیه
|
||||
/// </summary>
|
||||
public bool ContractAndCheckoutInPerson { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// خدمات حضوری بیمه
|
||||
/// </summary>
|
||||
public bool InsuranceInPerson { get; private set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class CreateWorkshopTemp
|
||||
/// حضورغباب
|
||||
/// </summary>
|
||||
public bool RollCall { get; set; }
|
||||
public bool RollCallInPerson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فیش غیر رسمی
|
||||
|
||||
@@ -16,6 +16,7 @@ using Company.Domain.FinancialStatmentAgg;
|
||||
using Company.Domain.FinancialTransactionAgg;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
using Company.Domain.InstitutionContractInsertTempAgg;
|
||||
using Company.Domain.InstitutionPlanAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
@@ -39,13 +40,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
private readonly IEmployerRepository _employerRepository;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
private readonly IMongoCollection<InstitutionContractExtenstionTemp> _institutionExtensionTemp;
|
||||
private readonly IPlanPercentageRepository _planPercentageRepository;
|
||||
|
||||
public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository,
|
||||
IWorkshopRepository workshopRepository, IMongoDatabase database) : base(context)
|
||||
IWorkshopRepository workshopRepository, IMongoDatabase database, IPlanPercentageRepository planPercentageRepository) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_employerRepository = employerRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
_planPercentageRepository = planPercentageRepository;
|
||||
_institutionExtensionTemp =
|
||||
database.GetCollection<InstitutionContractExtenstionTemp>("InstitutionContractExtenstionTemp");
|
||||
}
|
||||
@@ -1918,7 +1921,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
throw new BadRequestException("قرارداد مالی قبلی یافت نشد");
|
||||
}
|
||||
|
||||
|
||||
extenstionTemp.SetContractingPartyInfos(request.Address, request.City, request.Province, request.ContactInfos);
|
||||
await _institutionExtensionTemp.ReplaceOneAsync(
|
||||
x => x.Id == extenstionTemp.Id,
|
||||
@@ -1931,19 +1934,38 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
.Select(x =>
|
||||
{
|
||||
var workshop = workshops.FirstOrDefault(w=>w.id == x.WorkshopId);
|
||||
var service = x.Services;
|
||||
var price = x.Price;
|
||||
if (x.Price == 0)
|
||||
{
|
||||
var command = new WorkshopTempViewModel()
|
||||
{
|
||||
ContractAndCheckout = service.Contract,
|
||||
ContractAndCheckoutInPerson = service.ContractInPerson,
|
||||
CountPerson = x.PersonnelCount,
|
||||
CustomizeCheckout = service.CustomizeCheckout,
|
||||
Insurance = service.Insurance,
|
||||
InsuranceInPerson = service.InsuranceInPerson,
|
||||
RollCall = service.RollCall,
|
||||
WorkshopName = x.WorkshopName
|
||||
};
|
||||
var institutionPlanForWorkshop = _planPercentageRepository.GetInstitutionPlanForWorkshop(command);
|
||||
price = institutionPlanForWorkshop.OnlineAndInPersonSumAmountDouble;
|
||||
|
||||
}
|
||||
return new WorkshopTempViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractAndCheckout = x.Services.Contract,
|
||||
ContractAndCheckoutInPerson = x.Services.ContractInPerson,
|
||||
CustomizeCheckout = x.Services.ContractInPerson,
|
||||
ContractAndCheckout = service.Contract,
|
||||
ContractAndCheckoutInPerson = service.ContractInPerson,
|
||||
CustomizeCheckout = service.ContractInPerson,
|
||||
CountPerson = x.PersonnelCount,
|
||||
Insurance = x.Services.Insurance,
|
||||
InsuranceInPerson = x.Services.InsuranceInPerson,
|
||||
RollCall = x.Services.RollCall,
|
||||
Insurance = service.Insurance,
|
||||
InsuranceInPerson = service.InsuranceInPerson,
|
||||
RollCall = service.RollCall,
|
||||
WorkshopName = workshop?.WorkshopName??"فاقد کارگاه",
|
||||
WorkshopServicesAmount = x.Price,
|
||||
WorkshopServicesAmountStr = x.Price.ToMoney()
|
||||
WorkshopServicesAmount = price,
|
||||
WorkshopServicesAmountStr = price.ToMoney()
|
||||
};
|
||||
}).ToList();
|
||||
var res = new InstitutionContractExtensionWorkshopsResponse()
|
||||
@@ -1989,6 +2011,15 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
res.TwelveMonths= CalculateInstitutionPlan(InstitutionContractDuration.TwelveMonths,amount,false,newContractStart);
|
||||
}
|
||||
|
||||
var workshops = request.WorkshopTemps
|
||||
.Select(x => new InstitutionContractExtenstionTempWorkshop(x.WorkshopName,x.CountPerson,x.ContractAndCheckout,
|
||||
x.ContractAndCheckoutInPerson,x.Insurance,x.InsuranceInPerson,x.RollCall,x.RollCall,x.RollCallInPerson)).ToList();
|
||||
|
||||
institutionTemp.SetWorkshopsAndPlanAmounts(workshops,res.OneMonth,res.ThreeMonths,res.SixMonths,res.TwelveMonths, hasInPerson);
|
||||
|
||||
await _institutionExtensionTemp.ReplaceOneAsync(x=>x.Id == institutionTemp.Id, institutionTemp);
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user