[CLAUDE] Domain+Infra: 7 ContractType-specific Details + ContractChangelog (migration 9)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m37s

User decision: Option B — bảng riêng cho mỗi loại HĐ (chuẩn nhất, schema
chuyên biệt). Plus: ContractChangelog audit log thống nhất Header /
Detail / Workflow / Comment / Attachment.

## 8 entities mới

### Details (7) — Domain/Contracts/Details/

| Bảng | Loại HĐ | Field đặc trưng |
|---|---|---|
| ThauPhuDetails | 1 (Thầu phụ) | HangMuc, KhoiLuong, DonGia, ThoiGianHoanThanh |
| GiaoKhoanDetails | 2 (Giao khoán) | MaCongViec, KhoiLuong, YeuCauKyThuat |
| NhaCungCapDetails | 3 (NCC) | MaSP, ThongSoKyThuat, SoLuong, ThoiGianGiao, XuatXu |
| DichVuDetails | 4 (Dịch vụ) | MaDichVu, ThoiGian, TuNgay/DenNgay |
| MuaBanDetails | 5 (Mua bán) | MaSP, SoLuong, DonGia, ThueVAT (%), XuatXu |
| NguyenTacNccDetails | 6 (Nguyên tắc NCC) | NhomSP, DonGiaToiThieu/ToiDa, DieuKienGiaoHang |
| NguyenTacDvDetails | 7 (Nguyên tắc DV) | LoaiDichVu, DonGiaToiThieu/ToiDa, PhamViDichVu, SLA |

Common base `ContractDetailBase`: ContractId FK + Order + ThanhTien
decimal(18,2) + GhiChu nvarchar(1000) + audit (BaseEntity).

### ContractChangelog (1) — Domain/Contracts/

Unified audit log. Khác ContractApprovals (workflow-only, dùng cho guard
logic) — Changelog là VIEW LAYER cho user đọc lịch sử thao tác:
- EntityType enum: Contract | Detail | Workflow | Comment | Attachment
- Action enum: Insert | Update | Delete | Transition
- PhaseAtChange snapshot
- UserId + UserName denormalize (log readable)
- Summary human-readable + FieldChangesJson [{Field, Old, New}]
- ContextNote (comment kèm theo)

## EF Configurations

ContractDetailsConfiguration.cs (1 file gộp 7 IEntityTypeConfiguration):
- ToTable + HasMaxLength + HasPrecision per type
- HasOne(Contract).WithMany(<TypeDetails>) cascade delete
- IX (ContractId, Order) cho load timeline

ContractChangelogConfiguration.cs:
- Cascade delete khi Contract xóa
- IX (ContractId, CreatedAt) timeline + IX (ContractId, EntityType) filter

## DbContext + IApplicationDbContext

+ 8 DbSet mới (7 Details + ContractChangelogs).

## Migration 9: AddContractDetailsAndChangelog

3-file rule (gotcha #17): .cs + .Designer.cs + ApplicationDbContextModel
Snapshot.cs đầy đủ. Applied LocalDB SolutionErp_Dev OK — 24 + 8 = 32 bảng
total.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-04-23 10:08:42 +07:00
parent d326e80082
commit 70810e1b34
17 changed files with 3327 additions and 0 deletions

View File

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using SolutionErp.Domain.Contracts;
using SolutionErp.Domain.Contracts.Details;
using SolutionErp.Domain.Forms;
using SolutionErp.Domain.Identity;
using SolutionErp.Domain.Master;
@ -21,11 +22,21 @@ public interface IApplicationDbContext
DbSet<ContractComment> ContractComments { get; }
DbSet<ContractAttachment> ContractAttachments { get; }
DbSet<ContractCodeSequence> ContractCodeSequences { get; }
DbSet<ContractChangelog> ContractChangelogs { get; }
DbSet<Notification> Notifications { get; }
DbSet<WorkflowTypeAssignment> WorkflowTypeAssignments { get; }
DbSet<WorkflowDefinition> WorkflowDefinitions { get; }
DbSet<WorkflowStep> WorkflowSteps { get; }
DbSet<WorkflowStepApprover> WorkflowStepApprovers { get; }
// Per-type Details DbSets (Option B — bảng riêng từng loại HĐ)
DbSet<ThauPhuDetail> ThauPhuDetails { get; }
DbSet<GiaoKhoanDetail> GiaoKhoanDetails { get; }
DbSet<NhaCungCapDetail> NhaCungCapDetails { get; }
DbSet<DichVuDetail> DichVuDetails { get; }
DbSet<MuaBanDetail> MuaBanDetails { get; }
DbSet<NguyenTacNccDetail> NguyenTacNccDetails { get; }
DbSet<NguyenTacDvDetail> NguyenTacDvDetails { get; }
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}

View File

@ -1,4 +1,5 @@
using SolutionErp.Domain.Common;
using SolutionErp.Domain.Contracts.Details;
namespace SolutionErp.Domain.Contracts;
@ -26,4 +27,16 @@ public class Contract : AuditableEntity
public List<ContractApproval> Approvals { get; set; } = new();
public List<ContractComment> Comments { get; set; } = new();
public List<ContractAttachment> Attachments { get; set; } = new();
public List<ContractChangelog> Changelogs { get; set; } = new();
// Per-type details — chỉ 1 collection có data tương ứng với Type. Backend
// logic dispatch theo Contract.Type để load đúng bảng. KHÔNG load eager
// tất cả 7 — overhead. CQRS handler tự chọn DbSet theo Type.
public List<ThauPhuDetail> ThauPhuDetails { get; set; } = new();
public List<GiaoKhoanDetail> GiaoKhoanDetails { get; set; } = new();
public List<NhaCungCapDetail> NhaCungCapDetails { get; set; } = new();
public List<DichVuDetail> DichVuDetails { get; set; } = new();
public List<MuaBanDetail> MuaBanDetails { get; set; } = new();
public List<NguyenTacNccDetail> NguyenTacNccDetails { get; set; } = new();
public List<NguyenTacDvDetail> NguyenTacDvDetails { get; set; } = new();
}

View File

@ -0,0 +1,44 @@
using SolutionErp.Domain.Common;
namespace SolutionErp.Domain.Contracts;
// Audit log thống nhất cho mọi thay đổi liên quan HĐ — Header / Details /
// Workflow transition / Comment / Attachment. Khác `ContractApprovals` (chỉ
// log workflow transitions, dùng cho guard logic) — Changelog là VIEW LAYER
// cho user đọc lịch sử thao tác.
//
// Populate qua MediatR `AuditBehavior` interceptor — auto từ Insert/Update/
// Delete commands trên Contract + Details (xem Application/Common/Behaviors/
// AuditBehavior.cs).
public class ContractChangelog : BaseEntity
{
public Guid ContractId { get; set; }
public Contract? Contract { get; set; }
public ChangelogEntityType EntityType { get; set; } // Contract | Detail | Workflow | Comment | Attachment
public Guid? EntityId { get; set; } // PK của child entity (null nếu là Contract header)
public ChangelogAction Action { get; set; } // Insert | Update | Delete | Transition
public ContractPhase? PhaseAtChange { get; set; } // Snapshot phase tại thời điểm change
public Guid? UserId { get; set; } // Null = system (vd SLA auto-approve)
public string? UserName { get; set; } // Denormalize cho log readable
public string? Summary { get; set; } // Human-readable: "Đổi giá trị 100M → 150M"
public string? FieldChangesJson { get; set; } // JSON [{Field, OldValue, NewValue}] cho update
public string? ContextNote { get; set; } // Comment khi user kèm theo thay đổi
}
public enum ChangelogEntityType
{
Contract = 1,
Detail = 2,
Workflow = 3,
Comment = 4,
Attachment = 5,
}
public enum ChangelogAction
{
Insert = 1,
Update = 2,
Delete = 3,
Transition = 4, // Riêng cho workflow phase change
}

View File

@ -0,0 +1,18 @@
using SolutionErp.Domain.Common;
namespace SolutionErp.Domain.Contracts.Details;
// Base cho 7 ContractType Details. Mỗi loại HĐ có 1 bảng riêng (Option B
// theo user decision) — schema đặc thù từng loại nhưng share common fields:
// ContractId FK + Order + ThanhTien + GhiChu + audit (CreatedAt/By).
//
// Không dùng EF TPH/TPT inheritance (mỗi subclass là 1 bảng độc lập, không
// chung type discriminator) — mỗi subclass tự khai báo entity ToTable riêng.
public abstract class ContractDetailBase : BaseEntity
{
public Guid ContractId { get; set; }
public int Order { get; set; } // Thứ tự dòng trong HĐ (1, 2, 3...)
public decimal ThanhTien { get; set; } // Computed/manual entered
public string? GhiChu { get; set; }
public Contract? Contract { get; set; }
}

View File

@ -0,0 +1,14 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Dịch vụ (Type=4) — gói dịch vụ thuê (vd thuê thiết bị, tư vấn).
public class DichVuDetail : ContractDetailBase
{
public string MaDichVu { get; set; } = "";
public string TenDichVu { get; set; } = "";
public string? MoTa { get; set; }
public string DonViTinh { get; set; } = ""; // Giờ, ngày, tháng, gói
public decimal ThoiGian { get; set; } // Số đơn vị (vd 30 ngày)
public decimal DonGia { get; set; } // Đơn giá / đơn vị
public DateTime? TuNgay { get; set; }
public DateTime? DenNgay { get; set; }
}

View File

@ -0,0 +1,13 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Giao khoán (Type=2) — gói công việc giao khoán cho tổ đội.
public class GiaoKhoanDetail : ContractDetailBase
{
public string MaCongViec { get; set; } = ""; // Mã định danh công việc
public string TenCongViec { get; set; } = "";
public string DonViTinh { get; set; } = "";
public decimal KhoiLuong { get; set; }
public decimal DonGia { get; set; }
public DateTime? ThoiGianHoanThanh { get; set; }
public string? YeuCauKyThuat { get; set; } // Spec yêu cầu
}

View File

@ -0,0 +1,15 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Mua bán (Type=5) — danh mục sản phẩm mua bán + thuế VAT.
public class MuaBanDetail : ContractDetailBase
{
public string MaSP { get; set; } = "";
public string TenSP { get; set; } = "";
public string? MoTa { get; set; }
public string DonViTinh { get; set; } = "";
public decimal SoLuong { get; set; }
public decimal DonGia { get; set; } // Chưa VAT
public decimal ThueVAT { get; set; } // % (vd 10 = 10%)
// ThanhTien (base class) = SoLuong * DonGia * (1 + ThueVAT/100)
public string? XuatXu { get; set; }
}

View File

@ -0,0 +1,13 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Nguyên tắc Dịch vụ (Type=7) — framework agreement cho dịch vụ.
public class NguyenTacDvDetail : ContractDetailBase
{
public string LoaiDichVu { get; set; } = ""; // Phân loại (vd: "Vận chuyển", "Bảo trì")
public string TenDichVu { get; set; } = "";
public string DonViTinh { get; set; } = "";
public decimal DonGiaToiThieu { get; set; }
public decimal DonGiaToiDa { get; set; }
public string? PhamViDichVu { get; set; } // Scope of service
public string? SLA { get; set; } // SLA cam kết (vd "24h response")
}

View File

@ -0,0 +1,15 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Nguyên tắc NCC (Type=6) — framework agreement, không cố định
// số lượng, chỉ liệt kê nhóm SP + price range. ThanhTien base class = 0
// (không cố định), phục vụ tham chiếu khi tạo PO sau này.
public class NguyenTacNccDetail : ContractDetailBase
{
public string NhomSP { get; set; } = ""; // Nhóm sản phẩm (vd: "Vật tư xây dựng")
public string TenSP { get; set; } = "";
public string DonViTinh { get; set; } = "";
public decimal DonGiaToiThieu { get; set; }
public decimal DonGiaToiDa { get; set; }
public string? DieuKienGiaoHang { get; set; }
public string? DieuKienThanhToan { get; set; }
}

View File

@ -0,0 +1,14 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Nhà cung cấp (Type=3) — danh mục sản phẩm mua từ NCC.
public class NhaCungCapDetail : ContractDetailBase
{
public string MaSP { get; set; } = ""; // Mã sản phẩm
public string TenSP { get; set; } = "";
public string? ThongSoKyThuat { get; set; } // Specification
public string DonViTinh { get; set; } = "";
public decimal SoLuong { get; set; }
public decimal DonGia { get; set; }
public DateTime? ThoiGianGiao { get; set; } // Lead time
public string? XuatXu { get; set; } // Origin country
}

View File

@ -0,0 +1,12 @@
namespace SolutionErp.Domain.Contracts.Details;
// Chi tiết HĐ Thầu phụ (Type=1) — line item theo hạng mục công việc thầu phụ.
public class ThauPhuDetail : ContractDetailBase
{
public string HangMuc { get; set; } = ""; // Tên hạng mục công việc
public string DonViTinh { get; set; } = ""; // m2, m3, kg, ngày công, ...
public decimal KhoiLuong { get; set; } // 4 chữ số thập phân (decimal 18,4)
public decimal DonGia { get; set; } // VND
// ThanhTien = KhoiLuong * DonGia (FE/BE compute, không trigger DB)
public DateTime? ThoiGianHoanThanh { get; set; }
}

View File

@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using SolutionErp.Application.Common.Interfaces;
using SolutionErp.Domain.Contracts;
using SolutionErp.Domain.Contracts.Details;
using SolutionErp.Domain.Forms;
using SolutionErp.Domain.Identity;
using SolutionErp.Domain.Master;
@ -26,11 +27,19 @@ public class ApplicationDbContext
public DbSet<ContractComment> ContractComments => Set<ContractComment>();
public DbSet<ContractAttachment> ContractAttachments => Set<ContractAttachment>();
public DbSet<ContractCodeSequence> ContractCodeSequences => Set<ContractCodeSequence>();
public DbSet<ContractChangelog> ContractChangelogs => Set<ContractChangelog>();
public DbSet<Notification> Notifications => Set<Notification>();
public DbSet<WorkflowTypeAssignment> WorkflowTypeAssignments => Set<WorkflowTypeAssignment>();
public DbSet<WorkflowDefinition> WorkflowDefinitions => Set<WorkflowDefinition>();
public DbSet<WorkflowStep> WorkflowSteps => Set<WorkflowStep>();
public DbSet<WorkflowStepApprover> WorkflowStepApprovers => Set<WorkflowStepApprover>();
public DbSet<ThauPhuDetail> ThauPhuDetails => Set<ThauPhuDetail>();
public DbSet<GiaoKhoanDetail> GiaoKhoanDetails => Set<GiaoKhoanDetail>();
public DbSet<NhaCungCapDetail> NhaCungCapDetails => Set<NhaCungCapDetail>();
public DbSet<DichVuDetail> DichVuDetails => Set<DichVuDetail>();
public DbSet<MuaBanDetail> MuaBanDetails => Set<MuaBanDetail>();
public DbSet<NguyenTacNccDetail> NguyenTacNccDetails => Set<NguyenTacNccDetail>();
public DbSet<NguyenTacDvDetail> NguyenTacDvDetails => Set<NguyenTacDvDetail>();
protected override void OnModelCreating(ModelBuilder builder)
{

View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Contracts;
namespace SolutionErp.Infrastructure.Persistence.Configurations;
public class ContractChangelogConfiguration : IEntityTypeConfiguration<ContractChangelog>
{
public void Configure(EntityTypeBuilder<ContractChangelog> b)
{
b.ToTable("ContractChangelogs");
b.HasKey(x => x.Id);
b.Property(x => x.EntityType).HasConversion<int>();
b.Property(x => x.Action).HasConversion<int>();
b.Property(x => x.PhaseAtChange).HasConversion<int?>();
b.Property(x => x.UserName).HasMaxLength(200);
b.Property(x => x.Summary).HasMaxLength(500);
b.Property(x => x.FieldChangesJson).HasColumnType("nvarchar(max)");
b.Property(x => x.ContextNote).HasMaxLength(2000);
b.HasOne(x => x.Contract)
.WithMany(c => c.Changelogs)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
// Common queries: all changes của 1 HĐ ordered timeline
b.HasIndex(x => new { x.ContractId, x.CreatedAt });
// Filter theo entity type (chỉ xem header changes / chỉ workflow / etc.)
b.HasIndex(x => new { x.ContractId, x.EntityType });
}
}

View File

@ -0,0 +1,187 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Contracts.Details;
namespace SolutionErp.Infrastructure.Persistence.Configurations;
// EF config cho 7 ContractType-specific Details bảng + 1 base abstract.
// Common pattern: ContractId FK Cascade, Order int, ThanhTien decimal(18,2),
// GhiChu nvarchar(1000), index theo (ContractId, Order).
public class ThauPhuDetailConfiguration : IEntityTypeConfiguration<ThauPhuDetail>
{
public void Configure(EntityTypeBuilder<ThauPhuDetail> b)
{
b.ToTable("ThauPhuDetails");
b.HasKey(x => x.Id);
b.Property(x => x.HangMuc).HasMaxLength(500).IsRequired();
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.KhoiLuong).HasPrecision(18, 4);
b.Property(x => x.DonGia).HasPrecision(18, 2);
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.HasOne(x => x.Contract)
.WithMany(c => c.ThauPhuDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}
public class GiaoKhoanDetailConfiguration : IEntityTypeConfiguration<GiaoKhoanDetail>
{
public void Configure(EntityTypeBuilder<GiaoKhoanDetail> b)
{
b.ToTable("GiaoKhoanDetails");
b.HasKey(x => x.Id);
b.Property(x => x.MaCongViec).HasMaxLength(100).IsRequired();
b.Property(x => x.TenCongViec).HasMaxLength(500).IsRequired();
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.KhoiLuong).HasPrecision(18, 4);
b.Property(x => x.DonGia).HasPrecision(18, 2);
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.Property(x => x.YeuCauKyThuat).HasMaxLength(2000);
b.HasOne(x => x.Contract)
.WithMany(c => c.GiaoKhoanDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}
public class NhaCungCapDetailConfiguration : IEntityTypeConfiguration<NhaCungCapDetail>
{
public void Configure(EntityTypeBuilder<NhaCungCapDetail> b)
{
b.ToTable("NhaCungCapDetails");
b.HasKey(x => x.Id);
b.Property(x => x.MaSP).HasMaxLength(100).IsRequired();
b.Property(x => x.TenSP).HasMaxLength(500).IsRequired();
b.Property(x => x.ThongSoKyThuat).HasMaxLength(2000);
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.SoLuong).HasPrecision(18, 4);
b.Property(x => x.DonGia).HasPrecision(18, 2);
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.Property(x => x.XuatXu).HasMaxLength(100);
b.HasOne(x => x.Contract)
.WithMany(c => c.NhaCungCapDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}
public class DichVuDetailConfiguration : IEntityTypeConfiguration<DichVuDetail>
{
public void Configure(EntityTypeBuilder<DichVuDetail> b)
{
b.ToTable("DichVuDetails");
b.HasKey(x => x.Id);
b.Property(x => x.MaDichVu).HasMaxLength(100).IsRequired();
b.Property(x => x.TenDichVu).HasMaxLength(500).IsRequired();
b.Property(x => x.MoTa).HasMaxLength(2000);
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.ThoiGian).HasPrecision(18, 4);
b.Property(x => x.DonGia).HasPrecision(18, 2);
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.HasOne(x => x.Contract)
.WithMany(c => c.DichVuDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}
public class MuaBanDetailConfiguration : IEntityTypeConfiguration<MuaBanDetail>
{
public void Configure(EntityTypeBuilder<MuaBanDetail> b)
{
b.ToTable("MuaBanDetails");
b.HasKey(x => x.Id);
b.Property(x => x.MaSP).HasMaxLength(100).IsRequired();
b.Property(x => x.TenSP).HasMaxLength(500).IsRequired();
b.Property(x => x.MoTa).HasMaxLength(2000);
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.SoLuong).HasPrecision(18, 4);
b.Property(x => x.DonGia).HasPrecision(18, 2);
b.Property(x => x.ThueVAT).HasPrecision(5, 2); // %
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.Property(x => x.XuatXu).HasMaxLength(100);
b.HasOne(x => x.Contract)
.WithMany(c => c.MuaBanDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}
public class NguyenTacNccDetailConfiguration : IEntityTypeConfiguration<NguyenTacNccDetail>
{
public void Configure(EntityTypeBuilder<NguyenTacNccDetail> b)
{
b.ToTable("NguyenTacNccDetails");
b.HasKey(x => x.Id);
b.Property(x => x.NhomSP).HasMaxLength(200).IsRequired();
b.Property(x => x.TenSP).HasMaxLength(500).IsRequired();
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.DonGiaToiThieu).HasPrecision(18, 2);
b.Property(x => x.DonGiaToiDa).HasPrecision(18, 2);
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.DieuKienGiaoHang).HasMaxLength(1000);
b.Property(x => x.DieuKienThanhToan).HasMaxLength(1000);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.HasOne(x => x.Contract)
.WithMany(c => c.NguyenTacNccDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}
public class NguyenTacDvDetailConfiguration : IEntityTypeConfiguration<NguyenTacDvDetail>
{
public void Configure(EntityTypeBuilder<NguyenTacDvDetail> b)
{
b.ToTable("NguyenTacDvDetails");
b.HasKey(x => x.Id);
b.Property(x => x.LoaiDichVu).HasMaxLength(200).IsRequired();
b.Property(x => x.TenDichVu).HasMaxLength(500).IsRequired();
b.Property(x => x.DonViTinh).HasMaxLength(50).IsRequired();
b.Property(x => x.DonGiaToiThieu).HasPrecision(18, 2);
b.Property(x => x.DonGiaToiDa).HasPrecision(18, 2);
b.Property(x => x.ThanhTien).HasPrecision(18, 2);
b.Property(x => x.PhamViDichVu).HasMaxLength(1000);
b.Property(x => x.SLA).HasMaxLength(500);
b.Property(x => x.GhiChu).HasMaxLength(1000);
b.HasOne(x => x.Contract)
.WithMany(c => c.NguyenTacDvDetails)
.HasForeignKey(x => x.ContractId)
.OnDelete(DeleteBehavior.Cascade);
b.HasIndex(x => new { x.ContractId, x.Order });
}
}

View File

@ -0,0 +1,344 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SolutionErp.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddContractDetailsAndChangelog : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ContractChangelogs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EntityType = table.Column<int>(type: "int", nullable: false),
EntityId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Action = table.Column<int>(type: "int", nullable: false),
PhaseAtChange = table.Column<int>(type: "int", nullable: true),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UserName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
Summary = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
FieldChangesJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
ContextNote = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ContractChangelogs", x => x.Id);
table.ForeignKey(
name: "FK_ContractChangelogs_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DichVuDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
MaDichVu = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
TenDichVu = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
MoTa = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
ThoiGian = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
DonGia = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
TuNgay = table.Column<DateTime>(type: "datetime2", nullable: true),
DenNgay = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DichVuDetails", x => x.Id);
table.ForeignKey(
name: "FK_DichVuDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GiaoKhoanDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
MaCongViec = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
TenCongViec = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
KhoiLuong = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
DonGia = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
ThoiGianHoanThanh = table.Column<DateTime>(type: "datetime2", nullable: true),
YeuCauKyThuat = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GiaoKhoanDetails", x => x.Id);
table.ForeignKey(
name: "FK_GiaoKhoanDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MuaBanDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
MaSP = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
TenSP = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
MoTa = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
SoLuong = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
DonGia = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
ThueVAT = table.Column<decimal>(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false),
XuatXu = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MuaBanDetails", x => x.Id);
table.ForeignKey(
name: "FK_MuaBanDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "NguyenTacDvDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LoaiDichVu = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
TenDichVu = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
DonGiaToiThieu = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
DonGiaToiDa = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
PhamViDichVu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
SLA = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_NguyenTacDvDetails", x => x.Id);
table.ForeignKey(
name: "FK_NguyenTacDvDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "NguyenTacNccDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
NhomSP = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
TenSP = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
DonGiaToiThieu = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
DonGiaToiDa = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
DieuKienGiaoHang = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
DieuKienThanhToan = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_NguyenTacNccDetails", x => x.Id);
table.ForeignKey(
name: "FK_NguyenTacNccDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "NhaCungCapDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
MaSP = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
TenSP = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
ThongSoKyThuat = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
SoLuong = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
DonGia = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
ThoiGianGiao = table.Column<DateTime>(type: "datetime2", nullable: true),
XuatXu = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_NhaCungCapDetails", x => x.Id);
table.ForeignKey(
name: "FK_NhaCungCapDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ThauPhuDetails",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
HangMuc = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
DonViTinh = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
KhoiLuong = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
DonGia = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
ThoiGianHoanThanh = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UpdatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ContractId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
ThanhTien = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
GhiChu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ThauPhuDetails", x => x.Id);
table.ForeignKey(
name: "FK_ThauPhuDetails_Contracts_ContractId",
column: x => x.ContractId,
principalTable: "Contracts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ContractChangelogs_ContractId_CreatedAt",
table: "ContractChangelogs",
columns: new[] { "ContractId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_ContractChangelogs_ContractId_EntityType",
table: "ContractChangelogs",
columns: new[] { "ContractId", "EntityType" });
migrationBuilder.CreateIndex(
name: "IX_DichVuDetails_ContractId_Order",
table: "DichVuDetails",
columns: new[] { "ContractId", "Order" });
migrationBuilder.CreateIndex(
name: "IX_GiaoKhoanDetails_ContractId_Order",
table: "GiaoKhoanDetails",
columns: new[] { "ContractId", "Order" });
migrationBuilder.CreateIndex(
name: "IX_MuaBanDetails_ContractId_Order",
table: "MuaBanDetails",
columns: new[] { "ContractId", "Order" });
migrationBuilder.CreateIndex(
name: "IX_NguyenTacDvDetails_ContractId_Order",
table: "NguyenTacDvDetails",
columns: new[] { "ContractId", "Order" });
migrationBuilder.CreateIndex(
name: "IX_NguyenTacNccDetails_ContractId_Order",
table: "NguyenTacNccDetails",
columns: new[] { "ContractId", "Order" });
migrationBuilder.CreateIndex(
name: "IX_NhaCungCapDetails_ContractId_Order",
table: "NhaCungCapDetails",
columns: new[] { "ContractId", "Order" });
migrationBuilder.CreateIndex(
name: "IX_ThauPhuDetails_ContractId_Order",
table: "ThauPhuDetails",
columns: new[] { "ContractId", "Order" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ContractChangelogs");
migrationBuilder.DropTable(
name: "DichVuDetails");
migrationBuilder.DropTable(
name: "GiaoKhoanDetails");
migrationBuilder.DropTable(
name: "MuaBanDetails");
migrationBuilder.DropTable(
name: "NguyenTacDvDetails");
migrationBuilder.DropTable(
name: "NguyenTacNccDetails");
migrationBuilder.DropTable(
name: "NhaCungCapDetails");
migrationBuilder.DropTable(
name: "ThauPhuDetails");
}
}
}

View File

@ -321,6 +321,66 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
b.ToTable("ContractAttachments", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.ContractChangelog", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("Action")
.HasColumnType("int");
b.Property<string>("ContextNote")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("EntityId")
.HasColumnType("uniqueidentifier");
b.Property<int>("EntityType")
.HasColumnType("int");
b.Property<string>("FieldChangesJson")
.HasColumnType("nvarchar(max)");
b.Property<int?>("PhaseAtChange")
.HasColumnType("int");
b.Property<string>("Summary")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<string>("UserName")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("Id");
b.HasIndex("ContractId", "CreatedAt");
b.HasIndex("ContractId", "EntityType");
b.ToTable("ContractChangelogs", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.ContractCodeSequence", b =>
{
b.Property<string>("Prefix")
@ -377,6 +437,494 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
b.ToTable("ContractComments", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.DichVuDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DenNgay")
.HasColumnType("datetime2");
b.Property<decimal>("DonGia")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("MaDichVu")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("MoTa")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("TenDichVu")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<decimal>("ThoiGian")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<DateTime?>("TuNgay")
.HasColumnType("datetime2");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("DichVuDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.GiaoKhoanDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("DonGia")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<decimal>("KhoiLuong")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<string>("MaCongViec")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("TenCongViec")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<DateTime?>("ThoiGianHoanThanh")
.HasColumnType("datetime2");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.Property<string>("YeuCauKyThuat")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("GiaoKhoanDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.MuaBanDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("DonGia")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("MaSP")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("MoTa")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<decimal>("SoLuong")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<string>("TenSP")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<decimal>("ThueVAT")
.HasPrecision(5, 2)
.HasColumnType("decimal(5,2)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.Property<string>("XuatXu")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("MuaBanDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.NguyenTacDvDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("DonGiaToiDa")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<decimal>("DonGiaToiThieu")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("LoaiDichVu")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("PhamViDichVu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("SLA")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<string>("TenDichVu")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("NguyenTacDvDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.NguyenTacNccDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<string>("DieuKienGiaoHang")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("DieuKienThanhToan")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<decimal>("DonGiaToiDa")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<decimal>("DonGiaToiThieu")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("NhomSP")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("TenSP")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("NguyenTacNccDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.NhaCungCapDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("DonGia")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("MaSP")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<decimal>("SoLuong")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<string>("TenSP")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<DateTime?>("ThoiGianGiao")
.HasColumnType("datetime2");
b.Property<string>("ThongSoKyThuat")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.Property<string>("XuatXu")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("NhaCungCapDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.ThauPhuDetail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("ContractId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatedBy")
.HasColumnType("uniqueidentifier");
b.Property<decimal>("DonGia")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<string>("DonViTinh")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("GhiChu")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property<string>("HangMuc")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property<decimal>("KhoiLuong")
.HasPrecision(18, 4)
.HasColumnType("decimal(18,4)");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<decimal>("ThanhTien")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");
b.Property<DateTime?>("ThoiGianHoanThanh")
.HasColumnType("datetime2");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime2");
b.Property<Guid?>("UpdatedBy")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("ContractId", "Order");
b.ToTable("ThauPhuDetails", (string)null);
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.WorkflowDefinition", b =>
{
b.Property<Guid>("Id")
@ -1173,6 +1721,17 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.ContractChangelog", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("Changelogs")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.ContractComment", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
@ -1184,6 +1743,83 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.DichVuDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("DichVuDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.GiaoKhoanDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("GiaoKhoanDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.MuaBanDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("MuaBanDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.NguyenTacDvDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("NguyenTacDvDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.NguyenTacNccDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("NguyenTacNccDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.NhaCungCapDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("NhaCungCapDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.Details.ThauPhuDetail", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.Contract", "Contract")
.WithMany("ThauPhuDetails")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.WorkflowStep", b =>
{
b.HasOne("SolutionErp.Domain.Contracts.WorkflowDefinition", "WorkflowDefinition")
@ -1241,7 +1877,23 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
b.Navigation("Attachments");
b.Navigation("Changelogs");
b.Navigation("Comments");
b.Navigation("DichVuDetails");
b.Navigation("GiaoKhoanDetails");
b.Navigation("MuaBanDetails");
b.Navigation("NguyenTacDvDetails");
b.Navigation("NguyenTacNccDetails");
b.Navigation("NhaCungCapDetails");
b.Navigation("ThauPhuDetails");
});
modelBuilder.Entity("SolutionErp.Domain.Contracts.WorkflowDefinition", b =>