Merge branch 'Feature/InstitutionContract/print-api' into Feature/InstitutionContract/upgrade
# Conflicts: # Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs # CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs # CompanyManagment.Application/InstitutionContractApplication.cs # CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs
This commit is contained in:
@@ -75,5 +75,6 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
#endregion
|
||||
|
||||
Task<List<InstitutionContractSelectListViewModel>> GetInstitutionContractSelectList(string search, string selected);
|
||||
Task<List<InstitutionContractPrintViewModel>> PrintAllAsync(List<long> ids);
|
||||
Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request);
|
||||
}
|
||||
@@ -125,6 +125,8 @@ public class InstitutionContract : EntityBase
|
||||
|
||||
public string VerifyCode { get; private set; }
|
||||
public DateTime VerifyCodeCreation { get; private set; }
|
||||
public string VerifierFullName { get; private set; }
|
||||
public string VerifierPhoneNumber { get; private set; }
|
||||
|
||||
[NotMapped] public bool VerifyCodeExpired => VerifyCodeCreation.Add(ExpireTime) <= DateTime.Now;
|
||||
|
||||
@@ -225,10 +227,12 @@ public class InstitutionContract : EntityBase
|
||||
}
|
||||
|
||||
|
||||
public void SetVerifyCode(string code)
|
||||
public void SetVerifyCode(string code,string verifierFullName, string verifierPhoneNumber)
|
||||
{
|
||||
VerifyCode = code;
|
||||
VerifyCodeCreation = DateTime.Now;
|
||||
VerifierFullName = verifierFullName;
|
||||
VerifierPhoneNumber = verifierPhoneNumber;
|
||||
}
|
||||
|
||||
public void SetWorkshopGroup(InstitutionContractWorkshopGroup workshopGroup)
|
||||
@@ -281,11 +285,19 @@ public class InstitutionContractAmendment : EntityBase
|
||||
|
||||
public long LawId { get; set; }
|
||||
|
||||
public void SetVerifyCode(string code)
|
||||
public void SetVerifyCode(string code,string verifierFullName, string verifierPhoneNumber)
|
||||
{
|
||||
VerifyCode = code;
|
||||
VerificationCreation = DateTime.Now;
|
||||
VerifyCodeCreation = DateTime.Now;
|
||||
VerifierFullName = verifierFullName;
|
||||
VerifierPhoneNumber = verifierPhoneNumber;
|
||||
}
|
||||
|
||||
public string VerifierPhoneNumber { get; private set; }
|
||||
|
||||
public string VerifierFullName { get; private set; }
|
||||
|
||||
public DateTime VerifyCodeCreation { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractAmendmentChange : EntityBase
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Law;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.WorkshopPlan;
|
||||
@@ -77,6 +78,8 @@ public interface IInstitutionContractApplication
|
||||
/// <returns>لیست قراردادها برای چاپ</returns>
|
||||
List<InstitutionContractViewModel> PrintAll(List<long> id);
|
||||
|
||||
|
||||
[Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")]
|
||||
/// <summary>
|
||||
/// چاپ یک قرارداد
|
||||
/// </summary>
|
||||
@@ -242,6 +245,12 @@ public interface IInstitutionContractApplication
|
||||
|
||||
Task<OperationResult> ResendVerifyLink(long institutionContractId);
|
||||
Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request);
|
||||
/// <summary>
|
||||
/// دیتای پرینت قرارداد مالی
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
|
||||
}
|
||||
|
||||
public class InstitutionContractAmendmentCompleteRequest
|
||||
@@ -249,6 +258,28 @@ public class InstitutionContractAmendmentCompleteRequest
|
||||
public Guid TempId { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
public long LawId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class InstitutionContractPrintViewModel
|
||||
{
|
||||
public InstitutionContratVerificationParty FirstParty { get; set; }
|
||||
public InstitutionContratVerificationParty SecondParty { get; set; }
|
||||
public string ContractNo { get; set; }
|
||||
public string CreationDate { get; set; }
|
||||
public string ContractStart { get; set; }
|
||||
public string ContractEnd { get; set; }
|
||||
public List<GetInstitutionVerificationDetailsWorkshopsViewModel> Workshops { get; set; }
|
||||
public string TotalPrice { get; set; }
|
||||
public string TaxPrice { get; set; }
|
||||
public string PaymentPrice { get; set; }
|
||||
public string VerifyCode { get; set; }
|
||||
public string VerifyDateTime { get; set; }
|
||||
public string VerifierFullName { get; set; }
|
||||
public string VerifierPhoneNumber { get; set; }
|
||||
public LawViewModel LawViewModel { get; set; }
|
||||
public string Obligation { get; set; }
|
||||
}
|
||||
|
||||
public class InsertAmendmentTempWorkshopResponse
|
||||
|
||||
@@ -1203,7 +1203,12 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
throw new NotFoundException("طرف قرارداد یافت نشد");
|
||||
|
||||
var code = new Random().Next(1000, 9999).ToString();
|
||||
institutionContract.SetVerifyCode(code);
|
||||
|
||||
var contractingPartyFullName = contractingParty.IsLegal == "حقیقی"
|
||||
? contractingParty.FName + " " + contractingParty.LName
|
||||
: contractingParty.CeoFName + " " + contractingParty.CeoLName;
|
||||
|
||||
institutionContract.SetVerifyCode(code,contractingPartyFullName ,contractingParty.Phone);
|
||||
|
||||
var transaction = await _institutionContractRepository.BeginTransactionAsync();
|
||||
try
|
||||
@@ -1377,6 +1382,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return new OperationResult().Succcedded();
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractPrintViewModel> PrintOneAsync(long id)
|
||||
{
|
||||
return (await _institutionContractRepository.PrintAllAsync([id])).FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request)
|
||||
{
|
||||
await _institutionContractRepository.AmendmentComplete(request);
|
||||
|
||||
@@ -12,6 +12,8 @@ public class InstitutionContractAmendmentMapping:IEntityTypeConfiguration<Instit
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.VerifyCode).HasMaxLength(10);
|
||||
builder.Property(x => x.VerifierFullName).HasMaxLength(100);
|
||||
builder.Property(x => x.VerifierPhoneNumber).HasMaxLength(20);
|
||||
|
||||
builder.HasOne(x => x.InstitutionContract)
|
||||
.WithMany(x => x.Amendments)
|
||||
|
||||
@@ -30,6 +30,8 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
|
||||
builder.Property(x => x.HasValueAddedTax).HasMaxLength(10);
|
||||
|
||||
builder.Property(x => x.VerifyCode).HasMaxLength(20);
|
||||
builder.Property(x => x.VerifierFullName).HasMaxLength(100);
|
||||
builder.Property(x => x.VerifierPhoneNumber).HasMaxLength(20);
|
||||
|
||||
builder.Property(x => x.VerificationStatus).HasConversion<string>().HasMaxLength(122);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddVerifierdetailsininstituioncontractandamendment : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "VerifierFullName",
|
||||
table: "InstitutionContracts",
|
||||
type: "nvarchar(100)",
|
||||
maxLength: 100,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "VerifierPhoneNumber",
|
||||
table: "InstitutionContracts",
|
||||
type: "nvarchar(20)",
|
||||
maxLength: 20,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "VerifierFullName",
|
||||
table: "InstitutionContractAmendments",
|
||||
type: "nvarchar(100)",
|
||||
maxLength: 100,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "VerifierPhoneNumber",
|
||||
table: "InstitutionContractAmendments",
|
||||
type: "nvarchar(20)",
|
||||
maxLength: 20,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "VerifyCodeCreation",
|
||||
table: "InstitutionContractAmendments",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifierFullName",
|
||||
table: "InstitutionContracts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifierPhoneNumber",
|
||||
table: "InstitutionContracts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifierFullName",
|
||||
table: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifierPhoneNumber",
|
||||
table: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifyCodeCreation",
|
||||
table: "InstitutionContractAmendments");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3205,6 +3205,14 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(122)
|
||||
.HasColumnType("nvarchar(122)");
|
||||
|
||||
b.Property<string>("VerifierFullName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("VerifierPhoneNumber")
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<string>("VerifyCode")
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
@@ -3247,10 +3255,21 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<DateTime>("VerificationCreation")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("VerifierFullName")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("VerifierPhoneNumber")
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<string>("VerifyCode")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.Property<DateTime>("VerifyCodeCreation")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("InstitutionContractId");
|
||||
|
||||
@@ -25,6 +25,7 @@ using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
|
||||
using CompanyManagment.App.Contracts.Law;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.WorkshopPlan;
|
||||
@@ -48,6 +49,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
private readonly IPlanPercentageRepository _planPercentageRepository;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
private readonly InstitutionContratVerificationParty _firstParty = new()
|
||||
{
|
||||
Address = "رشت - خیابان حاجی آیاد - کوچه سپهدار - ساختمان داماش - واحد 17",
|
||||
PhoneNumber = "09111485044",
|
||||
CeoName = "سید حسن مصباح",
|
||||
CompanyNameOrFullName = "نور داد مهر گستر کاسپین",
|
||||
NationalCodeOrNationalId = "14009970584",
|
||||
LegalType = LegalType.Legal
|
||||
};
|
||||
|
||||
public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository,
|
||||
IWorkshopRepository workshopRepository, IMongoDatabase database,
|
||||
IPlanPercentageRepository planPercentageRepository, ISmsService smsService) : base(context)
|
||||
@@ -1799,15 +1810,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
query.party.IsLegal == "حقیقی" ? query.party.Nationalcode : query.party.NationalId,
|
||||
LegalType = query.party.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
|
||||
},
|
||||
FirstParty = new InstitutionContratVerificationParty()
|
||||
{
|
||||
Address = "رشت - خیابان حاجی آیاد - کوچه سپهدار - ساختمان داماش - واحد 17",
|
||||
PhoneNumber = "09111111111",
|
||||
CeoName = "سید حسن مصباح",
|
||||
CompanyNameOrFullName = "نور داد مهر گستر کاسپین",
|
||||
NationalCodeOrNationalId = "1111111111",
|
||||
LegalType = LegalType.Legal
|
||||
}
|
||||
FirstParty =_firstParty
|
||||
};
|
||||
|
||||
return res;
|
||||
@@ -2663,6 +2666,112 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<InstitutionContractPrintViewModel>> PrintAllAsync(List<long> ids)
|
||||
{
|
||||
var query =_context.InstitutionContractSet
|
||||
.Include(x=>x.WorkshopGroup)
|
||||
.ThenInclude(x=>x.InitialWorkshops)
|
||||
.Include(x=>x.WorkshopGroup)
|
||||
.ThenInclude(x=>x.CurrentWorkshops)
|
||||
.Where(x=>ids.Contains(x.id));
|
||||
|
||||
var contractingPartyIds = query.Select(x => x.ContractingPartyId).ToList();
|
||||
var contractingParties = await _context.PersonalContractingParties
|
||||
.Where(x => contractingPartyIds.Contains(x.id))
|
||||
.ToListAsync();
|
||||
|
||||
var list = query.ToList();
|
||||
|
||||
if (list.Count == 0)
|
||||
throw new NotFoundException("قرارداد مؤسسه یافت نشد");
|
||||
|
||||
var res = new List<InstitutionContractPrintViewModel>();
|
||||
foreach (var institution in list)
|
||||
{
|
||||
var contractingParty = contractingParties.FirstOrDefault(x => x.id == institution.ContractingPartyId);
|
||||
|
||||
if (contractingParty == null)
|
||||
{
|
||||
throw new NotFoundException("طرف حساب یافت نشد");
|
||||
}
|
||||
|
||||
var law = await _context.Laws
|
||||
.FirstOrDefaultAsync(x => x.id == institution.LawId);
|
||||
|
||||
|
||||
var secondParty = new InstitutionContratVerificationParty()
|
||||
{
|
||||
Address = contractingParty.Address,
|
||||
PhoneNumber = contractingParty.Phone,
|
||||
CeoName = contractingParty.IsLegal == "حقیقی"
|
||||
? $"{contractingParty.FName} {contractingParty.LName}"
|
||||
: $"{contractingParty.CeoFName} {contractingParty.CeoLName}",
|
||||
CompanyNameOrFullName = contractingParty.IsLegal == "حقیقی"
|
||||
? $"{contractingParty.FName} {contractingParty.LName}"
|
||||
: contractingParty.LName,
|
||||
NationalCodeOrNationalId =
|
||||
contractingParty.IsLegal == "حقیقی" ? contractingParty.Nationalcode : contractingParty.NationalId,
|
||||
LegalType = contractingParty.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
|
||||
};
|
||||
|
||||
var lawViewModel = new LawViewModel()
|
||||
{
|
||||
Id = law.id,
|
||||
CreatedAt = law.CreationDate,
|
||||
HeadTitle = law.HeadTitle,
|
||||
IsActive = law.IsActive,
|
||||
Items = law.Items.Select(x => new LawItemViewModel()
|
||||
{
|
||||
Details = x.Details,
|
||||
Header = x.Header
|
||||
}).ToList(),
|
||||
Notifications = law.Notifications,
|
||||
Title = law.Title,
|
||||
Type = law.Type,
|
||||
Version = law.Version
|
||||
};
|
||||
|
||||
var item = new InstitutionContractPrintViewModel()
|
||||
{
|
||||
ContractStart = institution.ContractStartFa,
|
||||
ContractEnd = institution.ContractEndFa,
|
||||
ContractNo = institution.ContractNo,
|
||||
CreationDate = institution.CreationDate.ToFarsi(),
|
||||
FirstParty = _firstParty,
|
||||
SecondParty = secondParty,
|
||||
LawViewModel = lawViewModel,
|
||||
Obligation = institution.Obligation.ToMoney(),
|
||||
PaymentPrice = institution.TotalAmount.ToMoney(),
|
||||
TotalPrice = (institution.TotalAmount - institution.ValueAddedTax).ToMoney(),
|
||||
TaxPrice = institution.ValueAddedTax.ToMoney(),
|
||||
VerifierFullName = institution.VerifierFullName,
|
||||
VerifierPhoneNumber = institution.VerifierPhoneNumber,
|
||||
VerifyCode = institution.VerifyCode,
|
||||
VerifyDateTime = institution.VerifyCodeCreation.ToFarsi(),
|
||||
Workshops = institution.WorkshopGroup.CurrentWorkshops
|
||||
.Select(x => new GetInstitutionVerificationDetailsWorkshopsViewModel()
|
||||
{
|
||||
Name = x.WorkshopName,
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Services = new WorkshopServicesViewModel()
|
||||
{
|
||||
Contract = x.Services.Contract,
|
||||
ContractInPerson = x.Services.ContractInPerson,
|
||||
CustomizeCheckout = x.Services.CustomizeCheckout,
|
||||
Insurance = x.Services.Insurance,
|
||||
InsuranceInPerson = x.Services.InsuranceInPerson,
|
||||
RollCall = x.Services.RollCall,
|
||||
RollCallInPerson = x.Services.RollCallInPerson
|
||||
},
|
||||
Price = x.Price.ToMoney()
|
||||
}).ToList()
|
||||
};
|
||||
res.Add(item);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request)
|
||||
{
|
||||
var amendmentTemp = await _institutionAmendmentTemp
|
||||
|
||||
@@ -756,6 +756,12 @@ public class institutionContractController : AdminBaseController
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet("print/{id}")]
|
||||
public async Task<ActionResult<InstitutionContractPrintViewModel>> PrintOne(long id)
|
||||
{
|
||||
var res =await _institutionContractApplication.PrintOneAsync(id);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user