[CLAUDE] FE-Admin FE-User: Chunk L2 — Fix F4 BudgetAdjustSection bypass readOnly khi Approver scope (menu Duyệt)
Some checks failed
Deploy SOLUTION_ERP / build-deploy (push) Failing after 1m1s

Bro UAT S23 t2 catch: "Đã stick cho edit trong luồng duyệt nhưng trong menu
duyệt -> vẫn không edit đc ngân sách". Investigator audit root cause:
- BudgetAdjustSection canAdjust = !readOnly && (...) — `!readOnly` short-circuit
  block F4 logic
- Menu Duyệt route truyền readOnly=true xuống PeDetailTabs → button "Điều chỉnh"
  hidden dù admin đã tick AllowApproverEditBudget cho slot + actor match
- F3 wire ItemsTab ĐÚNG via `itemsReadOnly = readOnly && !approverEditMode`
  pattern bypass — F4 không follow same pattern

Refactor canAdjust × 2 app (rule §3.9 mirror):
```
- canAdjust = !readOnly && (isAdmin || (isDrafter && isDrafterPhase) || isApproverChoDuyet)
+ canAdjust = isAdmin
+   || (!readOnly && isDrafter && isDrafterPhase)
+   || isApproverChoDuyet
```

→ F4 Approver scope (Mig 30) BYPASS readOnly:
- Admin: bypass readOnly (full quyền)
- Drafter (Nháp/TraLai): chỉ Workspace (readOnly=false)
- Approver ChoDuyet + flag tick + actor match: bypass readOnly → button "Điều chỉnh"
  visible trong menu Duyệt

Mirror F3 pattern (itemsReadOnly line 118). F4 wire S22+5 ban đầu miss BYPASS
pattern — fixed S23 t2.

Verify:
- npm run build × 2 app pass (0 TS err, bundle hash rotated)
- Bro UAT verify: tick F4 → vào menu Duyệt → click "Điều chỉnh ngân sách"
  → modal open editable

Pattern lesson saved memory: per-NV admin opt-in flag wire RULE — FE bypass
readOnly khi flag tick + actor match + phase match (mirror F3 itemsReadOnly).
F4 BudgetAdjustSection retroactive fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-15 01:39:21 +07:00
parent f3db9e6cc0
commit 10ddc8761b
2 changed files with 14 additions and 2 deletions

View File

@ -970,7 +970,13 @@ function BudgetAdjustSection({ ev, readOnly }: { ev: PeDetailBundle; readOnly: b
&& actorInCurrentLevel
&& approverEditBudgetAllowed
const canAdjust = !readOnly && (isAdmin || (isDrafter && isDrafterPhase) || isApproverChoDuyet)
// S23 t2 bug fix: F4 Approver scope BYPASS readOnly (mirror F3 itemsReadOnly
// pattern line 118). Khi admin tick AllowApproverEditBudget cho slot + actor
// match + Phase=ChoDuyet → button "Điều chỉnh" enable trong menu Duyệt (readOnly=true)
// dù chế độ chỉ-đọc. Drafter + Admin vẫn cần !readOnly (chỉ active từ Workspace).
const canAdjust = isAdmin
|| (!readOnly && isDrafter && isDrafterPhase)
|| isApproverChoDuyet
const initialManual = (ev.budgetManualName !== null || ev.budgetManualAmount !== null) && !ev.budgetId
const [manualMode, setManualMode] = useState(initialManual)