[CLAUDE] Domain: Plan B Chunk A1 — Contract +2 fields V2 (ApprovalWorkflowId + CurrentApprovalLevelOrder)

Mirror PE Mig 22-24 pattern. V1+V2 coexist (7 V1 contract giữ
WorkflowDefinitionId, V2 mới pin ApprovalWorkflowId).

Fields added:
- ApprovalWorkflowId Guid? — pin schema mới ApprovalWorkflowsV2
- CurrentApprovalLevelOrder int? — Cấp đang chờ duyệt (1/2/3) trong Step

Service ApproveV2Async branch (Chunk B) sẽ dispatch:
- if (contract.ApprovalWorkflowId is Guid awId) ApproveV2Async
- else ApproveV1Legacy (giữ behavior 7 V1 contract)

Verify:
- dotnet build SolutionErp.slnx PASS 0 err, 2 pre-existing DocxRenderer warn
- No migration (Chunk A2 sẽ scaffold Mig 32)

Plan B chain (6 chunks):
- A1 (this) Entity +2 fields (em main)
- A2 Mig 32 schema (Implementer Case 2 cookie-cutter)
- B Service ApproveV2Async branch (em main critical ~200 LOC)
- C Mig 33 ContractLevelOpinions (Implementer)
- D FE Workspace V2 (Implementer)
- E FE Section 5 LevelOpinionsV2 (Implementer)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-22 12:07:01 +07:00
parent 6eec8d78fb
commit 58898e8fbe

View File

@ -20,6 +20,7 @@ public class Contract : AuditableEntity
public string? NoiDung { get; set; }
public bool BypassProcurementAndCCM { get; set; } // HĐ Chủ đầu tư → skip CCM
public Guid? WorkflowDefinitionId { get; set; } // Pinned at creation — HĐ cũ chạy version cũ ngay cả khi admin active version mới
public Guid? ApprovalWorkflowId { get; set; } // [Plan B S29 2026-05-22 Mig 32] Pin schema mới ApprovalWorkflowsV2 — mirror PE Mig 23. V1+V2 coexist: 7 V1 contract giữ WorkflowDefinitionId; V2 mới pin ApprovalWorkflowId. Service ApproveV2Async branch theo field này.
public DateTime? SlaDeadline { get; set; } // Hết hạn phase hiện tại
public string? DraftData { get; set; } // JSON field values (render template)
public bool SlaWarningSent { get; set; } // Flag để không gửi warning 2 lần
@ -39,6 +40,11 @@ public class Contract : AuditableEntity
public int? CurrentWorkflowStepIndex { get; set; }
public int? RejectedAtStepIndex { get; set; }
// [Plan B S29 2026-05-22 Mig 32] V2 workflow tracking — mirror PE Mig 24.
// CurrentApprovalLevelOrder: Cấp đang chờ duyệt (1/2/3) trong Step hiện tại
// khi pin ApprovalWorkflowId. Null khi V1 legacy hoặc V2 terminal (DaPhatHanh).
public int? CurrentApprovalLevelOrder { get; set; }
public List<ContractApproval> Approvals { get; set; } = new();
public List<ContractComment> Comments { get; set; } = new();
public List<ContractAttachment> Attachments { get; set; } = new();