[CLAUDE] PurchaseEvaluation: endsBeforeCeo theo RUNTIME (Mig 60 EndedByLevelFinalize) — phiếu lên CEO hết báo sai "không qua CEO" (anh Kiệt FDC UAT)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m21s

- Bug: phiếu có cấp AllowApproverFinalize nhưng approver opt-out → lên CEO thật + CEO duyệt, nhưng sơ đồ báo sai "kết thúc tại CCM, không qua CEO" + làm mờ Bước CEO (endsBeforeCeo tính theo CONFIG workflow)
- Fix: +field runtime EndedByLevelFinalize (set true CHỈ ở nhánh level-finalize service) → EndsBeforeCeo cho phiếu DaDuyet đọc runtime thay config; ChoDuyet giữ heads-up config
- BE: entity + EF config + service + 4 projection (detail/List/Inbox/ListApproved) runtime-aware
- Mig 60 AddPeEndedByLevelFinalize + backfill (dò marker "Duyệt KẾT THÚC tại" set phiếu finalize-sớm cũ; ccm-delegation không match → giữ false)
- FE: gate làm-mờ finalizeFlowStep theo endsBeforeCeo (2 app SHA-mirror b7abbc2f)
- Test 440 PASS (repro peFinButWentCeo: config-finalize + EndedByLevelFinalize=false → false) + reviewer PASS 0-issue

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-07-01 19:23:03 +07:00
parent 051d0493ae
commit 8037fa01d1
12 changed files with 6423 additions and 28 deletions

View File

@ -38,6 +38,8 @@ public class PurchaseEvaluationConfiguration : IEntityTypeConfiguration<Purchase
// nullable, KHÔNG index (free-text). Mirror HoSoLink + PeWorkItemBudget.CcmNote.
b.Property(x => x.ProSuggestedPriceNote).HasMaxLength(1000);
b.Property(x => x.CcmSuggestedPriceNote).HasMaxLength(1000);
// [S97 2026-07-01] Runtime finalize-fact — bit NOT NULL default false (mirror IsUrgent* bool).
b.Property(x => x.EndedByLevelFinalize).HasDefaultValue(false);
b.HasIndex(x => x.MaPhieu).IsUnique().HasFilter("[MaPhieu] IS NOT NULL");
b.HasIndex(x => new { x.Phase, x.IsDeleted });

View File

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SolutionErp.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddPeEndedByLevelFinalize : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "EndedByLevelFinalize",
table: "PurchaseEvaluations",
type: "bit",
nullable: false,
defaultValue: false);
// [S97 anh Kiệt FDC] Backfill: phiếu DaDuyet (Phase=7) đã kết thúc SỚM bằng level-finalize
// để lại marker "[Duyệt KẾT THÚC tại ...]" trong LogTransition comment → set =1. Phiếu đi
// HẾT lên CEO (không marker) giữ default 0 → EndsBeforeCeo hiện đúng "qua CEO". SQL-Server-only
// (Dev/prod migrations); tests dùng EnsureCreated KHÔNG replay migration (gotcha #63).
migrationBuilder.Sql(@"
UPDATE pe SET EndedByLevelFinalize = 1
FROM PurchaseEvaluations pe
WHERE pe.Phase = 7
AND EXISTS (
SELECT 1 FROM PurchaseEvaluationApprovals a
WHERE a.PurchaseEvaluationId = pe.Id
AND a.Comment LIKE N'%Duyệt KẾT THÚC tại%');");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EndedByLevelFinalize",
table: "PurchaseEvaluations");
}
}
}

View File

@ -4653,6 +4653,11 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
b.Property<Guid?>("DrafterUserId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("EndedByLevelFinalize")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<decimal?>("ExpectedRemainingAmount")
.HasPrecision(18, 2)
.HasColumnType("decimal(18,2)");