[CLAUDE] PurchaseEvaluation: demo seed 4 phieu + MaPhieu atomic sequence + Pe_* perm defaults

Polish session tiep cua PE module skeleton (commit 2c6f0ca..3990066):
3 task A (MISSING in MVP) khac STATUS.md In Progress:

1. Demo PE data seed (SeedDemoPurchaseEvaluationsAsync)
   - 4 phieu varied A/B x phase: A-001 DangSoanThao (mo), A-002
     ChoCEODuyetNCC (winner+9 quotes), A-003 DaDuyet (chua tao HD,
     PaymentTerms JSON), B-001 ChoDuAn (5-step giua chung).
   - Idempotent: skip-if-[DEMO]-exists.
   - Approval history dung policy A (3-step) hoac B (5-step).

2. MaPhieu atomic sequence — Migration 13
   - Format PE/{YYYY}/{TypeLetter}/{Seq:D3} (vd PE/2026/A/001).
   - PurchaseEvaluationCodeSequence entity (Prefix PK).
   - IPurchaseEvaluationCodeGenerator + impl SERIALIZABLE
     transaction (mirror ContractCodeGenerator 1:1).
   - Replace Random.Shared trong CreatePurchaseEvaluationCommandHandler.
   - Migration AddPurchaseEvaluationCodeSequences (1 bang).

3. Pe_* permission defaults
   - SeedPurchaseEvaluationPermissionDefaultsAsync — 7 role business x 9 menu key.
   - Drafter/DeptManager/Procurement: R+C+U; CostControl/PM/Director/AuthorizedSigner: R+U.
   - DeptManager them Delete (xoa nhap).
   - Idempotent per-(roleId x menuKey).

Build: 0 error, 2 warning (pre-existing DocxRenderer).

Files: 4 new + 8 modified (1 migration + entity + generator + DI + 2 ctx + 2 features).

Resolves: STATUS.md In Progress §A — 3 item PE MISSING.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-04-24 10:41:17 +07:00
parent 0048a2e83a
commit c48ac2116d
16 changed files with 3621 additions and 24 deletions

View File

@ -1,19 +1,22 @@
# HANDOFF — Brief 5 phút cho session tiếp theo
**Last updated:** 2026-04-23 tối (Phase 6 — PE skeleton + G-084 hardening, **PE còn chỉnh nhiều**)
**Last updated:** 2026-04-24 sáng (Phase 6 — PE polish: demo seed + MaPhieu atomic + Pe_* perm defaults)
## TL;DR
**PE module skeleton E2E** — 2 quy trình A/B config được admin, 10 bảng, 17
endpoint, 3 page × 2 app + kế thừa HĐ 1-click. BE + FE + migration đã push
lên Gitea main (`2c6f0ca..3990066`, 6 commit). **CHƯA XONG — nhiều polish
+ feature thiếu cho session tiếp** (xem STATUS.md §🔥 In Progress đầy đủ).
lên Gitea main (`2c6f0ca..3990066`, 6+ commit). **Polish session 2026-04-24:**
demo seed 4 phiếu (`[DEMO] PE/.../A-001..A-003 + B-001`) + MaPhieu atomic
sequence (mirror ContractCodeSequences) + Pe_* permission defaults cho 7
role business → admin login thấy data ngay. Còn polish nhỏ (designer UI,
attachments, details mapping, export PDF) — xem STATUS.md §🔥 In Progress.
**G-084 hardening:** localhost → 127.0.0.1 trong scripts + skill, doc gotcha
#33 từ bài học VietReport (IPv4/IPv6 port hijack trên VPS shared).
**Tổng:** 46 DB tables, ~110 endpoints, 12 migrations, 33 gotchas. Blocker
user/ops cũ vẫn còn: UAT thật + SMTP + rotate creds + runner apply.
**Tổng:** 47 DB tables (+1 `PurchaseEvaluationCodeSequences`), ~110 endpoints,
13 migrations (+13 `AddPurchaseEvaluationCodeSequences`), 33 gotchas.
## ⚠️ CẢNH BÁO session tiếp
@ -110,9 +113,9 @@ Xem **STATUS.md §🔥 In Progress** đầy đủ (nhóm A/B/C/D). Tóm tắt nh
2. **PE Attachments upload** — copy pattern `ContractAttachmentFeatures.cs` + `ContractAttachmentsSection.tsx`. Entity + enum có sẵn.
3. **Ý kiến 4 phòng ban** (Phê duyệt / P.CCM / P.MuaHàng / SM-PM) — Excel form có, entity chưa map. Cần design: 4 text field + signoff date, hoặc dùng Approvals với role-kind.
4. **Payment terms tách field** từ JSON blob → 6 field riêng (Tạm ứng / TT tạm / Quyết toán / Bảo hành / Hạn mức / Đánh giá) theo Excel section D.
5. **Seed demo PE data** — 2-3 phiếu cho UAT + screenshot.
6. **Permission grant Pe_* cho non-admin role**`/system/permissions` tick `PurchaseEvaluations.Read` + CRUD cho role Drafter/PRO/CCM/BOD.
7. **MaPhieu format chính thức** — user confirm.
5. ~~Seed demo PE data~~ ✅ DONE (2026-04-24, 4 phiếu varied A/B × phase).
6. ~~Permission grant Pe_* defaults~~ ✅ DONE (2026-04-24, 7 role × 9 menu key).
7. ~~MaPhieu format chính thức~~ ✅ DONE (2026-04-24, atomic `PE/{YYYY}/{A\|B}/{Seq:D3}`).
8. **Export phiếu PDF/Excel** — tái dùng `IDocumentConverter` + template.
9. **Auto-map PE Details → Contract Details** khi gen HĐ (optional — nâng cấp).