add amendment mapping in InstitutionContract
This commit is contained in:
@@ -53,4 +53,5 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
Task<InstitutionContract> GetIncludeWorkshopDetailsAsync(long institutionContractId);
|
||||
void UpdateStatusIfNeeded(long institutionContractId);
|
||||
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
|
||||
Task<InstitutionContract> GetByPublicIdAsync(Guid id);
|
||||
}
|
||||
@@ -112,11 +112,14 @@ public class InstitutionContract : EntityBase
|
||||
|
||||
public string TypeOfContract { get; private set; }
|
||||
|
||||
public string HasValueAddedTax { get; set; }
|
||||
public string HasValueAddedTax { get; private set; }
|
||||
|
||||
public double ValueAddedTax { get; set; }
|
||||
public double ValueAddedTax { get; private set; }
|
||||
|
||||
public Guid PublicId { get; private set; }
|
||||
|
||||
public Guid PublicId { get; set; }
|
||||
public string VerifyCode { get; private set; }
|
||||
public DateTime VerifyCodeCreation { get; private set; }
|
||||
|
||||
public InstitutionContractVerificationStatus VerificationStatus { get; private set; }
|
||||
|
||||
@@ -208,9 +211,12 @@ public class InstitutionContract : EntityBase
|
||||
public class InstitutionContractAmendment : EntityBase
|
||||
{
|
||||
public long InstitutionContractId { get; set; }
|
||||
public InstitutionContract InstitutionContract { get; set; }
|
||||
public List<InstitutionContractInstallment> Installments { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public bool HasInstallment { get; set; }
|
||||
public string VerifyCode { get; set; }
|
||||
public DateTime VerificationCreation { get; set; }
|
||||
public List<InstitutionContractAmendmentChange> AmendmentChanges { get; set; }
|
||||
}
|
||||
|
||||
@@ -260,6 +266,8 @@ public class InstitutionContractAmendmentChange : EntityBase
|
||||
/// تعداد کارگاه
|
||||
/// </summary>
|
||||
public long? WorkshopDetailsId { get; private set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum InstitutionContractAmendmentChangeType
|
||||
|
||||
@@ -210,8 +210,9 @@ public interface IInstitutionContractApplication
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
|
||||
Task<OperationResult> Verify(Guid id, string code);
|
||||
}
|
||||
|
||||
public class GetInstitutionVerificationDetailsViewModel
|
||||
|
||||
@@ -1101,6 +1101,28 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
return await _institutionContractRepository.GetVerificationDetails(id);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Verify(Guid id, string code)
|
||||
{
|
||||
var institutionContract = await _institutionContractRepository.GetByPublicIdAsync(id);
|
||||
if (institutionContract == null)
|
||||
{
|
||||
throw new NotFoundException("رکورد مورد نظر یافت نشد");
|
||||
}
|
||||
|
||||
if (institutionContract.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
|
||||
throw new BadRequestException("تاییدیه این قرارداد مالی منقضی شده است");
|
||||
|
||||
if (institutionContract.VerifyCodeCreation.AddDays(1)< DateTime.Now)
|
||||
throw new BadRequestException("تاییدیه این قرارداد مالی منقضی شده است");
|
||||
|
||||
if (institutionContract.VerifyCode != code)
|
||||
throw new BadRequestException("کد وارد شده صحیح نمی باشد");
|
||||
|
||||
institutionContract.Verified();
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
return new OperationResult().Succcedded();
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
|
||||
CreateInstitutionContractLegalPartyRequest request, long representativeId)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping;
|
||||
|
||||
public class InstitutionContractAmendmentMapping:IEntityTypeConfiguration<InstitutionContractAmendment>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<InstitutionContractAmendment> builder)
|
||||
{
|
||||
builder.ToTable("InstitutionContractAmendments");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.VerifyCode).HasMaxLength(10);
|
||||
|
||||
builder.HasOne(x => x.InstitutionContract)
|
||||
.WithMany(x => x.Amendments)
|
||||
.HasForeignKey(x => x.InstitutionContractId);
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,10 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
|
||||
builder.Property(x => x.TypeOfContract).HasMaxLength(30);
|
||||
builder.Property(x => x.HasValueAddedTax).HasMaxLength(10);
|
||||
|
||||
builder.Property(x => x.VerifyCode).HasMaxLength(20);
|
||||
|
||||
builder.Property(x => x.VerificationStatus).HasConversion<string>().HasMaxLength(122);
|
||||
|
||||
|
||||
builder.HasMany(x => x.Installments)
|
||||
.WithOne(x => x.InstitutionContract)
|
||||
.HasForeignKey(x => x.InstitutionContractId);
|
||||
@@ -38,5 +40,8 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
|
||||
builder.HasMany(x => x.ContactInfoList)
|
||||
.WithOne(x => x.InstitutionContracts)
|
||||
.HasForeignKey(x => x.InstitutionContractId);
|
||||
|
||||
builder.HasMany(x => x.Amendments).WithOne(x => x.InstitutionContract)
|
||||
.HasForeignKey(x => x.InstitutionContractId);
|
||||
}
|
||||
}
|
||||
10803
CompanyManagment.EFCore/Migrations/20250923152422_Add amendment in institutioncontract.Designer.cs
generated
Normal file
10803
CompanyManagment.EFCore/Migrations/20250923152422_Add amendment in institutioncontract.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Addamendmentininstitutioncontract : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InstitutionContractAmendment_InstitutionContracts_InstitutionContractId",
|
||||
table: "InstitutionContractAmendment");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InstitutionContractAmendmentChange_InstitutionContractAmendment_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractAmendmentChange");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InstitutionContractInstallments_InstitutionContractAmendment_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractInstallments");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_InstitutionContractAmendment",
|
||||
table: "InstitutionContractAmendment");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "InstitutionContractAmendment",
|
||||
newName: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_InstitutionContractAmendment_InstitutionContractId",
|
||||
table: "InstitutionContractAmendments",
|
||||
newName: "IX_InstitutionContractAmendments_InstitutionContractId");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "VerifyCode",
|
||||
table: "InstitutionContracts",
|
||||
type: "nvarchar(20)",
|
||||
maxLength: 20,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "VerifyCodeCreation",
|
||||
table: "InstitutionContracts",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "VerificationCreation",
|
||||
table: "InstitutionContractAmendments",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "VerifyCode",
|
||||
table: "InstitutionContractAmendments",
|
||||
type: "nvarchar(10)",
|
||||
maxLength: 10,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_InstitutionContractAmendments",
|
||||
table: "InstitutionContractAmendments",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InstitutionContractAmendmentChange_InstitutionContractAmendments_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractAmendmentChange",
|
||||
column: "InstitutionContractAmendmentId",
|
||||
principalTable: "InstitutionContractAmendments",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InstitutionContractAmendments_InstitutionContracts_InstitutionContractId",
|
||||
table: "InstitutionContractAmendments",
|
||||
column: "InstitutionContractId",
|
||||
principalTable: "InstitutionContracts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InstitutionContractInstallments_InstitutionContractAmendments_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractInstallments",
|
||||
column: "InstitutionContractAmendmentId",
|
||||
principalTable: "InstitutionContractAmendments",
|
||||
principalColumn: "id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InstitutionContractAmendmentChange_InstitutionContractAmendments_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractAmendmentChange");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InstitutionContractAmendments_InstitutionContracts_InstitutionContractId",
|
||||
table: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_InstitutionContractInstallments_InstitutionContractAmendments_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractInstallments");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_InstitutionContractAmendments",
|
||||
table: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifyCode",
|
||||
table: "InstitutionContracts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifyCodeCreation",
|
||||
table: "InstitutionContracts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerificationCreation",
|
||||
table: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerifyCode",
|
||||
table: "InstitutionContractAmendments");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "InstitutionContractAmendments",
|
||||
newName: "InstitutionContractAmendment");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_InstitutionContractAmendments_InstitutionContractId",
|
||||
table: "InstitutionContractAmendment",
|
||||
newName: "IX_InstitutionContractAmendment_InstitutionContractId");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_InstitutionContractAmendment",
|
||||
table: "InstitutionContractAmendment",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InstitutionContractAmendment_InstitutionContracts_InstitutionContractId",
|
||||
table: "InstitutionContractAmendment",
|
||||
column: "InstitutionContractId",
|
||||
principalTable: "InstitutionContracts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InstitutionContractAmendmentChange_InstitutionContractAmendment_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractAmendmentChange",
|
||||
column: "InstitutionContractAmendmentId",
|
||||
principalTable: "InstitutionContractAmendment",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_InstitutionContractInstallments_InstitutionContractAmendment_InstitutionContractAmendmentId",
|
||||
table: "InstitutionContractInstallments",
|
||||
column: "InstitutionContractAmendmentId",
|
||||
principalTable: "InstitutionContractAmendment",
|
||||
principalColumn: "id");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3142,6 +3142,13 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(122)
|
||||
.HasColumnType("nvarchar(122)");
|
||||
|
||||
b.Property<string>("VerifyCode")
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.Property<DateTime>("VerifyCodeCreation")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("WorkshopManualCount")
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("nvarchar(5)");
|
||||
@@ -3171,11 +3178,18 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<long>("InstitutionContractId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime>("VerificationCreation")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("VerifyCode")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("InstitutionContractId");
|
||||
|
||||
b.ToTable("InstitutionContractAmendment");
|
||||
b.ToTable("InstitutionContractAmendments", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendmentChange", b =>
|
||||
@@ -9765,11 +9779,13 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendment", b =>
|
||||
{
|
||||
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContract", null)
|
||||
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContract", "InstitutionContract")
|
||||
.WithMany("Amendments")
|
||||
.HasForeignKey("InstitutionContractId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("InstitutionContract");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendmentChange", b =>
|
||||
|
||||
@@ -1726,6 +1726,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<InstitutionContract> GetByPublicIdAsync(Guid id)
|
||||
{
|
||||
return await _context.InstitutionContractSet.FirstOrDefaultAsync(x=>x.PublicId == id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -707,9 +707,23 @@ public class institutionContractController : AdminBaseController
|
||||
{
|
||||
return await _institutionContractApplication.GetVerificationDetails(id);
|
||||
}
|
||||
|
||||
[HttpPost("/institutionContract/Verification")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<OperationResult>> Verify([FromBody] InstitutionVerificationRequest command)
|
||||
{
|
||||
var res = await _institutionContractApplication.Verify(command.Id, command.Code);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class InstitutionVerificationRequest
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionPlanCalculatorResponse
|
||||
{
|
||||
public string TotalAmountWithTax { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user