feat: add contact info creation and account registration in institution contract process
This commit is contained in:
@@ -98,6 +98,7 @@ public class CreateInstitutionContractRequest
|
||||
/// مالیات ارزش افزوده
|
||||
/// </summary>
|
||||
public double TaxAmount { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// مدت زمان قرارداد نهاد
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Exceptions;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.empolyerAgg;
|
||||
@@ -18,6 +20,7 @@ using Company.Domain.TemporaryClientRegistrationAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.FinancialStatment;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||||
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
@@ -39,6 +42,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly IContractingPartyTempRepository _contractingPartyTempRepository;
|
||||
private readonly IFinancialStatmentRepository _financialStatmentRepository;
|
||||
private readonly IContactInfoApplication _contactInfoApplication;
|
||||
private readonly IAccountApplication _accountApplication;
|
||||
|
||||
|
||||
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
|
||||
@@ -46,7 +51,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
IRepresentativeRepository representativeRepository, IEmployerRepository employerRepository,
|
||||
IWorkshopRepository workshopRepository, ILeftWorkRepository leftWorkRepository,
|
||||
IFinancialStatmentApplication financialStatmentApplication, IWorkshopApplication workshopApplication,
|
||||
IContractingPartyTempRepository contractingPartyTempRepository, IFinancialStatmentRepository financialStatmentRepository)
|
||||
IContractingPartyTempRepository contractingPartyTempRepository,
|
||||
IFinancialStatmentRepository financialStatmentRepository, IContactInfoApplication contactInfoApplication,
|
||||
IAccountApplication accountApplication)
|
||||
{
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_contractingPartyRepository = contractingPartyRepository;
|
||||
@@ -58,6 +65,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
_workshopApplication = workshopApplication;
|
||||
_contractingPartyTempRepository = contractingPartyTempRepository;
|
||||
_financialStatmentRepository = financialStatmentRepository;
|
||||
_contactInfoApplication = contactInfoApplication;
|
||||
_accountApplication = accountApplication;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateInstitutionContract command)
|
||||
@@ -942,9 +951,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
|
||||
contractStartGr.AddMonthsFa((int)command.Duration, out var contractEndGr);
|
||||
contractEndGr = contractEndGr.ToFarsi().FindeEndOfMonth().ToGeorgianDateTime();
|
||||
|
||||
|
||||
var today = DateTime.Today;
|
||||
|
||||
|
||||
var contractDateGr = today;
|
||||
var contractDateFa = contractDateGr.ToFarsi();
|
||||
|
||||
@@ -967,33 +976,33 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
|
||||
var workshopDetails = command.Workshops.Select(x =>
|
||||
new InstitutionContractWorkshopDetail(x.WorkshopName, x.HasRollCallPlan, x.HasCustomizeCheckoutPlan,
|
||||
x.HasContractPlan, x.PersonnelCount,x.Price)).ToList();
|
||||
x.HasContractPlan, x.PersonnelCount, x.Price)).ToList();
|
||||
|
||||
var financialStatement = new FinancialStatment(contractingParty.id,contractingPartyFullName);
|
||||
var financialStatement = new FinancialStatment(contractingParty.id, contractingPartyFullName);
|
||||
|
||||
if (command.IsInstallment)
|
||||
{
|
||||
var installments =
|
||||
var installments =
|
||||
CalculateInstallment(command.TotalAmount, (int)command.Duration, command.ContractStartFa, true);
|
||||
|
||||
|
||||
// دریافت مبلغ اولین قسط
|
||||
//این کار برای این هست که اولین قسط باید با تاریخ امروز باشد و باید به وضعیت مالی بدهی ایجاد شود که یوزر اولین بدهی را وارد کند
|
||||
var firstInstallmentAmount = installments.First().Amount;
|
||||
|
||||
|
||||
// حذف اولین قسط
|
||||
installments.RemoveAt(0);
|
||||
|
||||
|
||||
// ایجاد قسط جدید با تاریخ امروز
|
||||
var todayInstallment = new InstitutionContractInstallment(DateTime.Today, firstInstallmentAmount, "");
|
||||
|
||||
var financialTransaction = new FinancialTransaction(0,today,today.ToFarsi(),
|
||||
"قسط اول سرویس", "debt","بابت خدمات",firstInstallmentAmount,0,0);
|
||||
|
||||
|
||||
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
|
||||
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
|
||||
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
|
||||
|
||||
// اضافه کردن قسط جدید به ابتدای لیست
|
||||
installments.Insert(0, todayInstallment);
|
||||
|
||||
|
||||
entity.SetInstallments(installments);
|
||||
}
|
||||
else
|
||||
@@ -1007,6 +1016,51 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
await _financialStatmentRepository.CreateAsync(financialStatement);
|
||||
await _institutionContractRepository.CreateAsync(entity);
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
|
||||
var mainContactInfo = new CreateContactInfo
|
||||
{
|
||||
InstitutionContractId = entity.id,
|
||||
PhoneType = "شماره همراه",
|
||||
Position = "طرف قرارداد",
|
||||
PhoneNumber = contractingParty.Phone,
|
||||
FnameLname = contractingPartyFullName,
|
||||
SendSms = true
|
||||
};
|
||||
_contactInfoApplication.Create(mainContactInfo);
|
||||
|
||||
foreach (var contactInfo in command.ContactInfos)
|
||||
{
|
||||
if (contactInfo.PhoneNumber != null)
|
||||
{
|
||||
var contactinfo = new CreateContactInfo
|
||||
{
|
||||
InstitutionContractId = entity.id,
|
||||
PhoneType = contactInfo.PhoneType,
|
||||
Position = contactInfo.Position,
|
||||
PhoneNumber = contactInfo.PhoneNumber,
|
||||
FnameLname = contactInfo.FnameLname,
|
||||
SendSms = contactInfo.SendSmsString == "true" ? true : false
|
||||
};
|
||||
_contactInfoApplication.Create(contactinfo);
|
||||
}
|
||||
}
|
||||
|
||||
var userPass = contractingParty.IsLegal == "حقیقی"
|
||||
? contractingParty.Nationalcode
|
||||
: contractingParty.NationalId;
|
||||
var createAcc = new RegisterAccount
|
||||
{
|
||||
Fullname = contractingParty.LName,
|
||||
Username = userPass,
|
||||
Password = userPass,
|
||||
Mobile = contractingParty.Phone,
|
||||
NationalCode = userPass
|
||||
};
|
||||
var res = _accountApplication.RegisterClient(createAcc);
|
||||
if (res.IsSuccedded)
|
||||
CreateContractingPartyAccount(contractingParty.id, res.SendId);
|
||||
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
await transaction.CommitAsync();
|
||||
return opration.Succcedded();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user