Merge branch 'Feature/InstitutionContract/add-registration-style' into Main
# Conflicts: # CompanyManagment.EFCore/Repository/PersonalContractingPartyRepository.cs
This commit is contained in:
@@ -930,59 +930,87 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
var syear = command.ContractStartFa.Substring(0, 4);
|
||||
var smonth = command.ContractStartFa.Substring(5, 2);
|
||||
var sday = command.ContractStartFa.Substring(8, 2);
|
||||
|
||||
|
||||
var transaction = await _contractingPartyRepository.BeginTransactionAsync();
|
||||
|
||||
|
||||
if (command.ContractStartFa.TryToGeorgianDateTime(out var contractStartGr) == false)
|
||||
return opration.Failed("تاریخ شروع قرارداد معتبر نیست");
|
||||
|
||||
contractStartGr.AddMonthsFa((int)command.Duration, out var contractEndGr);
|
||||
contractEndGr = contractEndGr.ToFarsi().FindeEndOfMonth().ToGeorgianDateTime();
|
||||
|
||||
|
||||
PersonalContractingParty existingContractingParty = null;
|
||||
if (command.ContractingPartyLegalType == LegalType.Legal)
|
||||
{
|
||||
existingContractingParty =
|
||||
await _contractingPartyRepository.GetByRegisterId(command.LegalParty.RegisterId);
|
||||
if (_contractingPartyRepository.Exists(x =>
|
||||
x.LName == command.LegalParty.CompanyName && x.RegisterId == command.LegalParty.RegisterId) &&
|
||||
_institutionContractRepository.Exists(x=> x.IsActiveString =="true" &&
|
||||
x.ContractStartGr < contractEndGr && contractStartGr < x.ContractEndGr))
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
x.LName == command.LegalParty.CompanyName && x.RegisterId == command.LegalParty.RegisterId))
|
||||
{
|
||||
if (_institutionContractRepository.Exists(x => x.ContractStartGr < contractEndGr
|
||||
&& contractStartGr < x.ContractEndGr
|
||||
&& x.ContractingPartyId == existingContractingParty.id
|
||||
&& x.IsActiveString == "true"))
|
||||
{
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(command.ContractingPartyLegalType == LegalType.Real)
|
||||
else if (command.ContractingPartyLegalType == LegalType.Real)
|
||||
{
|
||||
existingContractingParty =
|
||||
await _contractingPartyRepository.GetByNationalCode(command.RealParty.NationalCode);
|
||||
if (_contractingPartyRepository.Exists(x =>
|
||||
x.LName == command.RealParty.LName && x.Nationalcode == command.RealParty.NationalCode)&&
|
||||
_institutionContractRepository.Exists(x=> x.IsActiveString =="true" &&
|
||||
x.ContractStartGr < contractEndGr && contractStartGr < x.ContractEndGr))
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
x.LName == command.RealParty.LName && x.Nationalcode == command.RealParty.NationalCode))
|
||||
{
|
||||
if (_institutionContractRepository.Exists(x => x.ContractStartGr < contractEndGr
|
||||
&& contractStartGr < x.ContractEndGr
|
||||
&& x.ContractingPartyId == existingContractingParty.id
|
||||
&& x.IsActiveString == "true"))
|
||||
{
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
}
|
||||
}
|
||||
}
|
||||
OperationResult<PersonalContractingParty> contractingPartyResult = command.ContractingPartyLegalType switch
|
||||
|
||||
PersonalContractingParty contractingParty;
|
||||
if (existingContractingParty != null)
|
||||
{
|
||||
LegalType.Legal => await CreateLegalContractingPartyEntity(command.LegalParty, command.RepresentativeId,command.Address,
|
||||
command.City,command.Province),
|
||||
LegalType.Real => await CreateRealContractingPartyEntity(command.RealParty, command.RepresentativeId,command.Address,
|
||||
command.City,command.Province),
|
||||
_ => throw new BadRequestException("نوع طرف قرارداد مشخص نشده است")
|
||||
};
|
||||
contractingParty = existingContractingParty;
|
||||
}
|
||||
else
|
||||
{
|
||||
OperationResult<PersonalContractingParty> contractingPartyResult = command.ContractingPartyLegalType switch
|
||||
{
|
||||
LegalType.Legal => await CreateLegalContractingPartyEntity(command.LegalParty, command.RepresentativeId,
|
||||
command.Address,
|
||||
command.City, command.Province),
|
||||
LegalType.Real => await CreateRealContractingPartyEntity(command.RealParty, command.RepresentativeId,
|
||||
command.Address,
|
||||
command.City, command.Province),
|
||||
_ => throw new BadRequestException("نوع طرف قرارداد مشخص نشده است")
|
||||
};
|
||||
|
||||
if (!contractingPartyResult.IsSuccedded)
|
||||
return opration.Failed(contractingPartyResult.Message);
|
||||
if (!contractingPartyResult.IsSuccedded)
|
||||
return opration.Failed(contractingPartyResult.Message);
|
||||
|
||||
var contractingParty = contractingPartyResult.Data;
|
||||
contractingParty = contractingPartyResult.Data;
|
||||
}
|
||||
|
||||
|
||||
var contractNo = $"{syear}{smonth}{sday}/{contractingParty.ArchiveCode}/0";
|
||||
|
||||
var representative = _representativeRepository.Get(command.RepresentativeId);
|
||||
if (representative == null)
|
||||
return opration.Failed("معرف مورد نظر یافت نشد");
|
||||
|
||||
|
||||
if (command.IsInstallment &&
|
||||
!command.Workshops.Any(x => x.HasContractPlanInPerson || x.HasInsurancePlanInPerson))
|
||||
{
|
||||
return opration.Failed("برای قراردادهای اقساطی حداقل یک کارگاه باید دارای طرح حضوری باشد");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var today = DateTime.Today;
|
||||
|
||||
@@ -1004,14 +1032,25 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
contractingParty.id,
|
||||
contractingPartyFullName, contractDateGr, contractDateFa, command.Province, command.City, command.Address,
|
||||
contractStartGr,
|
||||
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(), command.OneMonthAmount, command.DailyCompensation,
|
||||
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(), command.OneMonthAmount,
|
||||
command.DailyCompensation,
|
||||
command.Obligation, command.TotalAmount, 0,
|
||||
command.Workshops.Count.ToString(),
|
||||
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
|
||||
"NotOfficial", "JobRelation", hasValueAddedTax,
|
||||
command.TaxAmount, workshopDetails);
|
||||
|
||||
var financialStatement = new FinancialStatment(contractingParty.id, contractingPartyFullName);
|
||||
|
||||
FinancialStatment financialStatement;
|
||||
if (_financialStatmentRepository.Exists(x=>x.ContractingPartyId == contractingParty.id))
|
||||
{
|
||||
financialStatement = await _financialStatmentRepository.GetByContractingPartyId(contractingParty.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
financialStatement = new FinancialStatment(contractingParty.id, contractingPartyFullName);
|
||||
await _financialStatmentRepository.CreateAsync(financialStatement);
|
||||
}
|
||||
|
||||
if (command.IsInstallment)
|
||||
{
|
||||
@@ -1045,7 +1084,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
}
|
||||
|
||||
await _financialStatmentRepository.CreateAsync(financialStatement);
|
||||
|
||||
await _institutionContractRepository.CreateAsync(entity);
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
|
||||
@@ -1094,7 +1133,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
|
||||
_smsService.VerifySend(contractingParty.Phone, entity.id.ToString());
|
||||
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||
entity.PublicId);
|
||||
|
||||
|
||||
await transaction.CommitAsync();
|
||||
@@ -1146,8 +1186,10 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
throw new BadRequestException("کد تایید قبلی هنوز منقضی نشده است",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "expireTime", (int)institutionContract.ReSendTime.TotalSeconds -
|
||||
(int)(DateTime.Now - institutionContract.VerifyCodeCreation).TotalSeconds }
|
||||
{
|
||||
"expireTime", (int)institutionContract.ReSendTime.TotalSeconds -
|
||||
(int)(DateTime.Now - institutionContract.VerifyCodeCreation).TotalSeconds
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1211,7 +1253,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
|
||||
public async Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId)
|
||||
{
|
||||
var details =await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(workshopDetailsId);
|
||||
var details = await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(workshopDetailsId);
|
||||
var services = details.Services;
|
||||
|
||||
var res = new InstitutionContractWorkshopDetailViewModel()
|
||||
@@ -1231,10 +1273,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
|
||||
CreateInstitutionContractLegalPartyRequest request, long representativeId,string address,string city,string state)
|
||||
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,
|
||||
string state)
|
||||
{
|
||||
var opration = new OperationResult<PersonalContractingParty>();
|
||||
|
||||
|
||||
|
||||
if (representativeId < 1)
|
||||
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||
@@ -1262,7 +1305,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
var legalContractingParty = new PersonalContractingParty("*", request.CompanyName,
|
||||
"*", "*", request.RegisterId, request.NationalId,
|
||||
"حقوقی",
|
||||
request.PhoneNumber, request.PhoneNumber,address, representativeId, representative.FullName,
|
||||
request.PhoneNumber, request.PhoneNumber, address, representativeId, representative.FullName,
|
||||
archiveCode, state, city, null, null, request.FName, request.LName, request.Position);
|
||||
|
||||
|
||||
@@ -1273,11 +1316,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateRealContractingPartyEntity(
|
||||
CreateInstitutionContractRealPartyRequest request, long representativeId,string address,
|
||||
string city,string province)
|
||||
CreateInstitutionContractRealPartyRequest request, long representativeId, string address,
|
||||
string city, string province)
|
||||
{
|
||||
var operation = new OperationResult<PersonalContractingParty>();
|
||||
|
||||
|
||||
|
||||
if (representativeId < 1)
|
||||
return operation.Failed("لطفا معرف را انتخاب کنید");
|
||||
|
||||
@@ -105,6 +105,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
result.FatherName = contractingParty.FatherName;
|
||||
result.IdNumberSerial = contractingParty.IdNumberSerial;
|
||||
result.IdNumber = contractingParty.IdNumber;
|
||||
result.NationalCode = contractingParty.Nationalcode;
|
||||
|
||||
if (contractingParty.DateOfBirth != null &&contractingParty.DateOfBirth != dateOfBirthGr)
|
||||
return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
@@ -219,6 +220,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
result.FatherName = createTemp.FatherName;
|
||||
result.IdNumberSerial = createTemp.IdNumberSerial;
|
||||
result.IdNumber = idNumber;
|
||||
result.NationalCode = createTemp.NationalCode;
|
||||
|
||||
|
||||
return op.Succcedded(result);
|
||||
|
||||
Reference in New Issue
Block a user