Files
solution-erp/docs/STATUS.md
pqhuy1987 3c4931687a
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m15s
[CLAUDE] App+Api+Docs: Chunk E1 — List endpoint + Bypass-review + Notify TPB + chốt session 8
3 endpoint mới + Notify TPB + Docs update để chốt session 8.

Application:
- PurchaseEvaluationDepartmentApprovalFeatures.cs (NEW):
  * ListPeDepartmentApprovalsQuery + DTO PeDepartmentApprovalDto
  * Join Departments (lấy Name) + lookup Users.FullName denorm cho FE timeline
- UserFeatures.cs: SetUserBypassReviewCommand + Handler dùng UserManager.UpdateAsync
- IApplicationDbContext: thêm DbSet<User> Users + DbSet<Role> Roles (cần cho lookup)

Api:
- PurchaseEvaluationsController: GET /api/purchase-evaluations/{id}/department-approvals
- UsersController: PATCH /api/users/{id}/bypass-review (Authorize Users.Update)

Infra:
- PurchaseEvaluationWorkflowService: notify TPB cùng dept khi NV review.
  Query db.Users.Where(DeptId match + IsActive) → UserManager.GetRolesAsync
  filter DeptManager → notifications.NotifyAsync. Best effort fail non-critical.

Docs:
- STATUS.md: Recently Done thêm row session 8 + Phase header update
  count 52→55 tables, 15→16 migrations, 128→131 endpoints
- HANDOFF.md: TL;DR session 8 + 8 cảnh báo session 9 (FE chưa làm,
  test flow anh Kiệt, smart reject test, lock edit test, ...)
- migration-todos.md: Phase 9 done section đầy đủ 3 ràng buộc + pending Chunk E-bis
- CLAUDE.md: count 52→55 + migration 16 description
- session log: 2026-05-04-1230-chot-session-8-2-stage-dept-approval.md (full report)

Verify final:
- Build pass 0 warning 0 error
- 77 unit test pass (54 Domain + 23 Infra)
- Migration 16 applied LocalDB OK + schema verified

Total session 8 cumulative: 5 commit per-chunk:
- 5fe61cc (A: Migration 16 schema)
- 14f3c9f (B: Lock edit guards 17 handler)
- 9747f8c (C: Smart reject + Resume 3 module)
- a532ba6 (D: PE 2-stage logic)
- (current E1: List + Notify + Bypass + Docs)

Pending Chunk E-bis (defer cho session 9 sau UAT PE):
- FE Workflow Panel hiển thị 2-stage timeline
- FE UserManager toggle CanBypassReview
- HĐ + Budget 2-stage extension
- Tests Phase 3 mini cho 2-stage Service-layer logic

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 12:42:47 +07:00

18 KiB
Raw Blame History

STATUS — Snapshot hiện tại

Update rule: trước khi bắt đầu 1 task → ghi row vào 🔥 In Progress. Xong → chuyển sang ✅ Recently Done.

Last updated: 2026-05-04 (Session 8 — 2-stage department approval + smart reject + lock edit guards (Migration 16). Đóng bug anh Kiệt báo: NV duyệt được hết phase PE workflow.)

📍 Phase hiện tại: Phase 9 active — UAT + Ops + 2-stage dept approval55 DB tables (52+3), 16 migrations, ~131 API endpoints (+3 dept-approvals/bypass-review), 31 FE pages (FE 2-stage chưa update). 77 unit test pass (54 Domain + 23 Infra). 41 gotcha. 30 demo user. 6 skill.

🌐 Production URLs

🔥 In Progress — Session 7+ (Phase 9 active)

A. Hard blockers (chờ user / ops)

  • UAT thật 1 tuần với 2-3 user (Drafter / CCM / BOD) — hard requirement Phase 5 roadmap
  • SMTP config → Email outbox (BLOCKED chờ user cấp host/user/pass)
  • Rotate creds — admin + 30 demo + SA + vrapp + JWT secret + Gitea runner token
  • Schedule SQL backup dailyscripts/backup-sql.ps1 đã sẵn, chưa schedule Task Scheduler
  • Remove binding cũ .huypham.vn sau verify stable: ssh vietreport-vps ; .\migrate-domains.ps1 -RemoveOld -SkipCert
  • win-acme scheduled task "unhealthy" — auto-renew fix trước 2026-06-18

B. Carry over feature gap

  • Export phiếu PDF/Excel PE — tái dùng IDocumentConverter + template PE-TrinhDuyet.docx (user pending — không quan trọng lắm)

C. Optional polish (khi UAT phát sinh bug)

  • Budget MaNganSach atomic sequence (hiện Random.Shared → migration AddBudgetCodeSequences)
  • Budget versioned workflow (admin config UI thay hardcoded BudgetPolicy.Default)
  • Payment terms PE tách field (JSON blob → 6 column riêng)
  • Auto-map PE Details → Contract per-type Details khi gen HĐ
  • Matrix Quotes bulk paste từ Excel
  • fe-user Inbox thêm section "Phiếu Duyệt NCC chờ tôi"

D. Tests Phase 3-5 (làm khi gặp bug recurring để justify ROI — rule §7)

  • Phase 3 full — Application handler tests cần UserManager DI helper (PE Opinion Upsert, Budget validate, CreateContractFromEvaluation BudgetId carry) ~15 test
  • Phase 4 — API smoke tests qua WebApplicationFactory ~7 test
  • Phase 5 — FE Vitest cho lib utility (queryMatches, fmtMoney) ~10 test

E. 2-stage dept approval — Chunk E-bis (FE + extend)

  • FE Workflow Panel update (cả fe-admin + fe-user) — hiển thị progress 2-stage timeline per phase × dept. Dùng endpoint GET /pe/{id}/department-approvals.
  • FE UserManager toggle CanBypassReview checkbox per user. Endpoint PATCH /users/{id}/bypass-review đã sẵn.
  • HĐ 2-stage mở rộng: ContractWorkflowService.TransitionAsync thêm 2-stage logic + endpoint List ContractDepartmentApprovals (sau verify PE OK).
  • Budget 2-stage mở rộng tương tự (low priority, ít user duyệt budget per dept).
  • Tests Phase 3 mini cho 2-stage logic ở PurchaseEvaluationWorkflowService (cần UserManager DI helper).

F. Audit định kỳ (cron tự fire)

  • 2026-05-01 (đã quá hạn 3 ngày, cần manual trigger hoặc recreate cron) — solution-erp-skill-audit-monthly Combined audit theo §6.4 + §9.4. Log → docs/changelog/skill-audit-2026-05.md

Recently Done (newest on top)

Ngày Ai Task Commit
2026-05-04 Claude Session 8 — Migration 16: 2-stage dept approval + smart reject + lock edit (đóng bug anh Kiệt) — Anh Kiệt báo: NV.PRO tạo phiếu PE → duyệt được hết phase = phân quyền sai. Schema mới: 3 bảng *DepartmentApprovals (Contract/PE/Budget) UNIQUE (TargetId, Phase, Dept, Stage). 4 cột mới: Users.CanBypassReview bit + 3 RejectedFromPhase int. Logic 2-stage trong PurchaseEvaluationWorkflowService.TransitionAsync: user.DepartmentId != null → DeptManager (TPB) Stage=Confirm; CanBypassReview=true → Stage=Confirm+IsBypassed; else NV → Stage=Review only, BLOCK transition cho đến khi TPB confirm. Smart reject: Decision=Reject → set RejectedFromPhase, force về DangSoanThao. Resume sau reject: Drafter trình lại từ DangSoanThao + RejectedFromPhase != null → jump straight tới phase đã reject (skip phase trung gian). Lock edit: 17 handler thêm guard Phase != DangSoanThao (Contract Detail × 15, PE Detail × 5, Budget Detail × 3). 3 endpoint mới: GET /pe/{id}/department-approvals (FE Workflow Panel hiển thị progress) + PATCH /users/{id}/bypass-review (admin toggle) + Notify TPB cùng dept khi NV review. HĐ + Budget 2-stage scope defer (chỉ PE first đóng bug). FE update + Tests defer Chunk E-bis. 5fe61cc (A) · 14f3c9f (B) · 9747f8c (C) · a532ba6 (D) · (current)
2026-04-30 Claude Session 6 — MD audit + compact + 3 skill refresh + 2 rule mới — Compact 3 file core (-288 dòng): STATUS -27%, HANDOFF -32%, migration-todos -35%. Archive 51 row Recently Done Phase 0-7 → changelog/recently-done-archive-2026-04.md. Refresh 3 skill stale: form-engine (Phase 2 MVP → Tier 3 feature-complete + bỏ section duplicate gen mã HĐ), permission-matrix (12 menu → ~60 menu key + Bg_/Pe_/PeWf_* + inheritance roots), ef-core-migration (24 DbSet → 52 bảng + ERD update). Rule mới rules.md §7 Khi nào viết test — timing rule (5-row table compact, sau khi rút gọn từ 70 dòng overkill). Rule mới rules.md §6.4 Audit + compact MD định kỳ (cadence + checklist + anti-pattern, KHÔNG rewrite toàn bộ). rules.md §9.4 Skill audit mở rộng cross-ref §6.4. (current)
2026-04-29 Claude Tests Phase 3 mini + 3 gotcha CI mới (#39 #40 #41)tests/.../Application/PeWorkflowAdminTests.cs 6 test versioning logic (CreatePeWorkflowDefinition: first version IsActive=true, second deactivates first, different EvaluationType independent, persists steps ordered + approvers per step, third version increments to v3). Total 77 test (54 Domain + 17 Infra + 6 PE WF Application). Gotcha #39 act_runner github.com TCP timeout 21s + manual checkout fix. #40 npm junction cache fail tsc not found rolled back. #41 paths-ignore behavior + workflow file exclusion. b874743
2026-04-29 Claude CI Path filter docs-only skip livepaths-ignore trong on:push lookup docs/**/**/*.md/.claude/skills/**/.gitignore. Commit chỉ touch docs SKIP CI hoàn toàn (saving ~196s/commit, ~30% commit thuộc loại này). Verify 512880c (docs-only) → Gitea NO trigger run #113. 29eb5d9 · a21790d · 512880c
2026-04-29 Claude CI manual checkout bypass github.com (fix #108/#109) — Run #108/#109 fail TCP timeout 21s khi act_runner fetch actions/checkout@v4 từ github.com. Replace uses: actions/checkout@v4 + actions/upload-artifact@v4 bằng manual git init + git fetch từ Gitea internal. Token ${{ github.token }} auth tự sẵn per-job. Fetch by ref + depth=30. Run #110 pass 3m16s. 14b7d18 · 26075c4
2026-04-29 Claude Tests Phase 2 — Code generator format + sequence (SQLite in-memory)tests/SolutionErp.Infrastructure.Tests/ xUnit + EF SQLite 10. SqliteDbFixture + TestApplicationDbContext subclass override nvarchar(max) → TEXT (SQLite không support max). 17 test: ContractCodeGenerator (format RG-001 5 type + Framework year scope vs Project scope + sequence per prefix + year boundary reset + persistence verify) + PurchaseEvaluationCodeGenerator (format A/B + 3-digit pad + independent A/B sequences + year boundary). CI gate +1 step. Total 71 test pass / 2.1s. df5988b
2026-04-29 Claude Tests Phase 1 — Domain unit tests + CI gatetests/SolutionErp.Domain.Tests/ xUnit 2.9 + FluentAssertions 7.2 (pin trước v8 commercial). 54 test pure function (no DB/IO): WorkflowPolicy (Standard 9-phase + SkipCcm 7-phase + Registry per ContractType + FromDefinition versioned + UserKindApprover) / PEPolicy (NccOnly 3-step + NccWithPlan 5-step + reject paths) / BudgetPolicy (Default 3-step + terminals + SLA spec). .gitea/workflows/deploy.yml thêm step "Run unit tests" trước build, fail → exit $LASTEXITCODE → no deploy. SolutionErp.slnx + folder /tests/. d3f9346
2026-04-29 Claude PE Workflow designer admin UI + Ý kiến 4 phòng ban — Migration 15 AddPurchaseEvaluationDepartmentOpinions (UNIQUE PEId+Kind, 1 row/phòng/phiếu). Domain PurchaseEvaluationDepartmentOpinion + enum PeDepartmentKind (PheDuyet/Ccm/MuaHang/SmPm). BE: PeWorkflowAdminFeatures.cs ~250 LOC mirror Contract pattern (GetOverview + Create version, deactivate cũ atomic) + PeWorkflowsController 2 endpoint reuse policy Workflows.*. PeDepartmentOpinionFeatures.cs Upsert (sign=true→set SignedAt+UserId, sign=false giữ chữ ký cũ) + Delete + 2 endpoint. FE: PeWorkflowsPage.tsx ~500 LOC + designer dialog (clone version + add/remove steps + +Role/+User approvers). Section "5. Ý kiến 4 phòng ban (sign-off)" 2x2 grid OpinionBox (read mode chữ ký vs edit textarea + 2 button Lưu/Lưu&Ký). 5d94bb4
2026-04-29 Claude PE Detail UI restructure theo spec form PHIẾU TRÌNH KÝ — 4 section đánh số match form chính thức: "1. Thông tin gói thầu" (a/b chỉ Tên + Dự án) / "2. Chọn NCC/TP" (a NCC chọn / b Ngân sách / c Giá chào thầu auto-compute từ winner quotes / d Bản so sánh embed GeneralAttachments) / "3. NCC/TP tham gia" / "4. Hạng mục + Báo giá". FormRow helper (label 176px + value flex) thay cho dl grid 2-col cũ. 7e36241
2026-04-29 Claude PE/Contract → Budget integration + cột "So với ngân sách" — BE: BudgetSummaryDto shared (PE & Contract DetailBundle), Create/Update PE+Contract commands + BudgetId? validate cùng Project + Phase=DaDuyet. CreateContractFromEvaluation carry forward pe.BudgetId → contract.BudgetId. FE: PE & Contract Create form + Select "Ngân sách" filter Phase=DaDuyet + Project match. PE InfoTab + Contract Edit display Budget link clickable. PE ItemsTab matrix + cột "NS link · Δ" — match per-row qua key groupCode|itemCode, fetch /budgets/{id} riêng + footer aggregate (xanh dưới / đỏ vượt / xám khớp). 61e5d4d
2026-04-29 Claude Budget FE 3-panel pages cả 2 apptypes/budget.ts (BudgetPhase 5-state enum + DTO) + BudgetsListPage 3-panel [340px_1fr_360px] + filter Phase + Năm + alias ?phase=Pending + readOnly mode menu Duyệt + BudgetCreatePage form Header + BudgetDetailTabs flat (Section Thông tin Header + Section Hạng mục table CRUD inline auto-compute ThanhTien=KL×ĐG) + BudgetWorkflowPanel Panel 3 timeline + dialog comment + Approvals/Changelog. Mirror fe-user. App.tsx 3 route + Layout resolver Bg_*. TS build pass cả 2 app. df12fb1

51 row Phase 0-7 (2026-04-21..28) đã archive → changelog/recently-done-archive-2026-04.md

Session logs: P0 · P1f · P1.2 · P2 · P3 · P4 · P5prep · Tier 3 · Skill gov · Toolkit+4-bảng+Roles VN · Roles+Demo+Pending · PE polish iter 2 + rebrand · Budget BE + 14 Solutions users · Budget FE + PE/HD-Budget + PE WF Designer + Tests Phase 1-2

Docs entry points:

🎯 Next up

Hard blockers (chờ user / ops)

  • UAT 1 tuần 2-3 user thật — hard requirement từ roadmap Phase 5
  • Email outbox — MailKit + SMTP (BLOCKED chờ user cấp SMTP host/user/pass)
  • Rotate credentials — SA, vrapp, JWT secret, runner token (đã post chat)
  • SQL backup daily — Task Scheduler (script scripts/backup-sql.ps1 đã có, chưa schedule)

Optional polish (khi rảnh / UAT phát sinh)

  • Roles CRUD — admin tạo custom role ngoài 12 hardcoded (schema sẵn, chỉ cần CQRS + FE)
  • User-level approver targeting runtime — data model đã có (WorkflowStepApprover.Kind=User), chỉ cần wire User-kind vào ContractWorkflowService.TransitionAsync guard
  • PermissionsPage: grant Workflows.Read cho non-admin role → menu Wf_* visible
  • Warning notification khi còn 20% SLA (SlaWarningSent flag đã có, chỉ thiếu job emit)
  • E2E test reject → quay về DangSoanThao (multi-role)
  • Dependencies scan CI (dotnet list package --vulnerable, npm audit)

Tier 3 ERP roadmap ✓ (close)

  • Attachment upload BE + FE ✓
  • SignalR real-time push ✓
  • Form template builder CRUD + DynamicForm ✓
  • PDF export qua LibreOffice headless ✓
  • .doc/.xls → .docx/.xlsx auto-conversion ✓
  • Dynamic workflow policy per ContractType ✓
  • Versioned workflow (WorkflowDefinition pinned per Contract)
  • Admin workflow designer UI (per-type, per-step approvers)
  • Nested sidebar menu per ContractType (fe-user) + menu split admin/user
  • PermissionsPage 3-panel layout
  • Email outbox for Notification (blocked — SMTP config)

📊 Thông số cumulative

P0 P1f P1.2 P2 P3 P4 P5prep Tier3 +Toolkit +RolesPg+Demo +PE module +PE polish +Budget+30 users +Session 5
BE LOC 0 ~400 ~1500 ~1900 ~2700 ~3100 ~3300 ~4800 ~7800 ~8800 ~11100 ~11400 ~11750 ~13050 (+1300 PE WF Designer + Opinion + Budget integration)
DB tables 0 7 12 14 19 19 19 24 36 36 46 47 51 52 (+1 PEDepartmentOpinions)
API endpoints 0 4 20 23 31 33 35 ~50 ~80 ~93 ~110 ~113 ~124 ~128 (+2 PE WF + 2 Opinion)
Migrations 0 1 3 4 5 5 5 8 11 11 12 13 14 15 (AddPEDepartmentOpinions)
FE pages 0 2 6 7 14 16 16 ~20 ~22 ~23 ~26 ~26 ~26 ~31 (+5 Budget × 2 app + PeWorkflowsPage)
FE components many many+ +EditRowDialog +PE 5-tab +Compare section +Budget tabs/panel + PE OpinionBox + PE 4-section restructure
Scripts PS 0 0 0 1 1 1 3 4 4 5 5 6 6 6
CI/CD workflow 0 0 0 0 0 0 1 1 1 1 1 1 1 1+test gate+path filter+manual checkout
Tests 0 0 0 0 0 0 0 0 0 0 0 0 0 77 (54 Domain + 17 Infra + 6 PE WF Application)
Docs 10 13 14 24 26 30 35 ~40 ~42 ~44 ~46 ~48 ~50 ~52 (+session log + Test plan)
Demo data 0 0 empty 0 0 0 0 0 5+3 15+8+7+13+4 +PE 4 phiếu +rebrand email 30 user 30 user
Commits 1 2 3 5 6 7 8 ~25 ~47 ~52 ~63 ~70 ~75 ~82 (+6 session 5)

🚨 Blockers / risks

  • ⚠️ Email SMTP chưa có — blocker cho notification outbound
  • ⚠️ UAT real user chưa chạy — risk phát sinh bug edge-case quan trọng
  • ⚠️ Credentials leaked trong chat — cần rotate trước go-live thật
  • ⚠️ SQL backup không auto — risk data loss nếu VPS crash
  • ⚠️ Permission Workflows.Read cho non-admin — cần grant để họ thấy menu Wf_* (hiện chỉ admin thấy)
  • ⚠️ User-kind approver chưa enable runtime — designer cho chọn User nhưng guard fall back DeptManager

Credentials + URLs

admin@solutionerp.local / Admin@123456