From 9ea62be6a72c383e816ab48da4371ea610d195de Mon Sep 17 00:00:00 2001 From: pqhuy1987 Date: Tue, 19 May 2026 12:32:53 +0700 Subject: [PATCH] =?UTF-8?q?[CLAUDE]=20PurchaseEvaluation:=20Plan=20AE=20?= =?UTF-8?q?=E2=80=94=20fix=20Changelog=20UserName=209=20sites=20(Budget=20?= =?UTF-8?q?Adjust=20+=208=20preventive)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bro UAT 2026-05-19 post-S25 Plan AD: "Điều chỉnh ngân sách" entry trong Lịch sử thay đổi show "Hệ thống" thay vì tên user thật (Phan Văn Chương / NV CCM). Audit phát hiện systemic bug — 9 Changelog.Add sites trong PE features MISSING UserName field, FE fallback "Hệ thống" toàn bộ. Fix Plan AE — preventive batch (8 sites khác chắc chắn bro sẽ phát hiện sau): PurchaseEvaluationFeatures.cs (4 sites): - line 120 Tạo phiếu - line 149 Hạng mục mặc định - line 228 Cập nhật thông tin phiếu (UpdateDraft) - line 379 Điều chỉnh ngân sách (Budget Adjust) — bro feedback chính PurchaseEvaluationDetailFeatures.cs (5 sites): - line 167 Thêm hạng mục (Detail Insert) - line 225 Cập nhật hạng mục (Detail Update) - line 257 Xóa hạng mục (Detail Delete) - line 317 Cập nhật báo giá (Quote Update — inside if block, 16-space indent) - line 342 Thêm báo giá (Quote Insert) - line 377 Xóa báo giá (Quote Delete) - line 416 Chọn NCC trúng thầu (Select Winner) Pattern: `UserName = currentUser.FullName ?? currentUser.Email` — ICurrentUser đã có FullName + Email từ JWT claims, KHÔNG cần inject userManager mới. Verify: - dotnet build clean 0 err 2 warn (pre-existing DocxRenderer) - dotnet test 111/111 PASS Co-Authored-By: Claude Opus 4.7 (1M context) --- .../PurchaseEvaluationDetailFeatures.cs | 7 +++++++ .../PurchaseEvaluations/PurchaseEvaluationFeatures.cs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationDetailFeatures.cs b/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationDetailFeatures.cs index 3f6e261..02a7560 100644 --- a/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationDetailFeatures.cs +++ b/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationDetailFeatures.cs @@ -165,6 +165,7 @@ public class AddPurchaseEvaluationDetailCommandHandler( Action = ChangelogAction.Insert, PhaseAtChange = evaluation.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Thêm hạng mục {request.GroupCode} — {request.NoiDung}", }); @@ -222,6 +223,7 @@ public class UpdatePurchaseEvaluationDetailCommandHandler( Action = ChangelogAction.Update, PhaseAtChange = evaluation.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Cập nhật hạng mục {request.GroupCode} — {request.NoiDung}{approverNote}", }); @@ -253,6 +255,7 @@ public class DeletePurchaseEvaluationDetailCommandHandler( Action = ChangelogAction.Delete, PhaseAtChange = evaluation.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Xóa hạng mục {entity.GroupCode} — {entity.NoiDung}{approverNote}", }); @@ -312,6 +315,7 @@ public class UpsertPurchaseEvaluationQuoteCommandHandler( Action = ChangelogAction.Update, PhaseAtChange = evaluation.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Cập nhật báo giá cho hạng mục {detail.GroupCode}{approverNote}", }); await db.SaveChangesAsync(ct); @@ -337,6 +341,7 @@ public class UpsertPurchaseEvaluationQuoteCommandHandler( Action = ChangelogAction.Insert, PhaseAtChange = evaluation.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Thêm báo giá cho hạng mục {detail.GroupCode}{approverNote}", }); await db.SaveChangesAsync(ct); @@ -371,6 +376,7 @@ public class DeletePurchaseEvaluationQuoteCommandHandler( Action = ChangelogAction.Delete, PhaseAtChange = evaluation.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Xóa báo giá{approverNote}", }); @@ -409,6 +415,7 @@ public class SelectPurchaseEvaluationWinnerCommandHandler( Action = ChangelogAction.Update, PhaseAtChange = entity.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = "Chọn NCC trúng thầu", }); diff --git a/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationFeatures.cs b/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationFeatures.cs index f0cdb4a..888f72b 100644 --- a/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationFeatures.cs +++ b/src/Backend/SolutionErp.Application/PurchaseEvaluations/PurchaseEvaluationFeatures.cs @@ -124,6 +124,7 @@ public class CreatePurchaseEvaluationCommandHandler( Action = ChangelogAction.Insert, PhaseAtChange = entity.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Tạo phiếu {entity.MaPhieu} — {entity.TenGoiThau}", }); @@ -154,6 +155,7 @@ public class CreatePurchaseEvaluationCommandHandler( Action = ChangelogAction.Insert, PhaseAtChange = entity.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Hạng mục mặc định — {defaultDetail.NoiDung}", }); @@ -232,6 +234,7 @@ public class UpdatePurchaseEvaluationDraftCommandHandler( Action = ChangelogAction.Update, PhaseAtChange = entity.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = "Cập nhật thông tin phiếu", }); @@ -376,6 +379,8 @@ public class AdjustPurchaseEvaluationBudgetCommandHandler( } var diffSummary = parts.Count == 0 ? "không đổi" : string.Join(", ", parts); + // Plan AE S25 — set UserName để FE hiện đúng tên user thay vì "Hệ thống" + // fallback. ICurrentUser đã có FullName + Email sẵn từ JWT claims. db.PurchaseEvaluationChangelogs.Add(new PurchaseEvaluationChangelog { PurchaseEvaluationId = entity.Id, @@ -383,6 +388,7 @@ public class AdjustPurchaseEvaluationBudgetCommandHandler( Action = ChangelogAction.Update, PhaseAtChange = entity.Phase, UserId = currentUser.UserId, + UserName = currentUser.FullName ?? currentUser.Email, Summary = $"Điều chỉnh ngân sách: {diffSummary} {actorTag}", });