[CLAUDE] Domain+Infra: PurchaseEvaluation module — 10 bảng + 2 workflow seed (migration 12)

Module Duyệt NCC (tiền-HĐ): phiếu trình duyệt so sánh giá N NCC × M hạng
mục trước khi ký HĐ. 2 quy trình: A DuyetNcc (3-step: Purchasing→CCM→CEO),
B DuyetNccPhuongAn (5-step: Purchasing→DựÁn→CCM→CEO PA→CEO NCC).

Domain (7 core + 3 workflow admin):
 - PurchaseEvaluation (header, AuditableEntity, pin WorkflowDefinitionId,
   SelectedSupplierId, PaymentTerms JSON, ContractId? FK kế thừa)
 - PurchaseEvaluationSupplier (N:M Phiếu × Supplier + contact + payment term)
 - PurchaseEvaluationDetail (hạng mục + ngân sách, group A.I/A.II/...)
 - PurchaseEvaluationQuote (báo giá per NCC per hạng mục + IsSelected)
 - PurchaseEvaluationApproval (workflow history, reuse ApprovalDecision)
 - PurchaseEvaluationChangelog (audit log, reuse ChangelogAction)
 - PurchaseEvaluationAttachment (file upload — báo giá NCC + spec...)
 - PurchaseEvaluationWorkflowDefinition/Step/StepApprover (config y như HĐ,
   tách table riêng vì Phase là PurchaseEvaluationPhase enum riêng)

Policy:
 - PurchaseEvaluationPolicy record + PurchaseEvaluationPolicies.NccOnly/
   NccWithPlan (default hardcoded) + FromDefinition(def) build runtime policy
   từ DB admin-authored. Default SLA: soạn 3d, step 1-2d, CEO 1d.

EF: 10 configurations với index phase+isDeleted, SupplierId, ProjectId,
SlaDeadline, WorkflowDefinitionId, ContractId. UX index (PeId, SupplierId)
+ (DetailId, SupplierId). HasQueryFilter soft delete cho header.

Migration 12 AddPurchaseEvaluations tạo 10 bảng. Idempotent seed:
 - SeedMenuTreeAsync +13 menu item (Pe_* root + 2 group + 6 action leaf
   + PeWorkflows root + 2 admin leaf)
 - SeedPurchaseEvaluationWorkflowsAsync seed QT-DN-A-v01 + QT-DN-B-v01
This commit is contained in:
pqhuy1987
2026-04-23 16:37:55 +07:00
parent a7ea6ad3d6
commit 2c6f0cabfb
19 changed files with 4884 additions and 1 deletions

View File

@ -6,6 +6,7 @@ using SolutionErp.Domain.Identity;
using SolutionErp.Domain.Master;
using SolutionErp.Domain.Master.Catalogs;
using SolutionErp.Domain.Notifications;
using SolutionErp.Domain.PurchaseEvaluations;
namespace SolutionErp.Application.Common.Interfaces;
@ -44,5 +45,17 @@ public interface IApplicationDbContext
DbSet<NguyenTacNccDetail> NguyenTacNccDetails { get; }
DbSet<NguyenTacDvDetail> NguyenTacDvDetails { get; }
// Module Duyệt NCC (tiền-HĐ) — 7 core + 3 workflow config
DbSet<PurchaseEvaluation> PurchaseEvaluations { get; }
DbSet<PurchaseEvaluationSupplier> PurchaseEvaluationSuppliers { get; }
DbSet<PurchaseEvaluationDetail> PurchaseEvaluationDetails { get; }
DbSet<PurchaseEvaluationQuote> PurchaseEvaluationQuotes { get; }
DbSet<PurchaseEvaluationApproval> PurchaseEvaluationApprovals { get; }
DbSet<PurchaseEvaluationChangelog> PurchaseEvaluationChangelogs { get; }
DbSet<PurchaseEvaluationAttachment> PurchaseEvaluationAttachments { get; }
DbSet<PurchaseEvaluationWorkflowDefinition> PurchaseEvaluationWorkflowDefinitions { get; }
DbSet<PurchaseEvaluationWorkflowStep> PurchaseEvaluationWorkflowSteps { get; }
DbSet<PurchaseEvaluationWorkflowStepApprover> PurchaseEvaluationWorkflowStepApprovers { get; }
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}