From f314be1db3aa861163969e1bd39bbcbd7650c135 Mon Sep 17 00:00:00 2001 From: Frank Steiler Date: Mon, 15 Jun 2026 21:29:50 +0200 Subject: [PATCH] fix(e2e): correct Scenario 25 invoice amount to account for VAT gross-up (#1591) The variance computation in AutoItemizePage sums effectiveLineAmount() which grosses up net (includesVat:false) amounts by 1.19. THREE_LINES has all three lines as net: 900+680+120 net = 1071+809.20+142.80 = 2023 gross. The test was using invoice amount=1700 (raw net sum), causing an immediate ~19% variance on page load and deterministic varianceMatch assertion failure. Fix: set invoice amount=2023 (gross total) so the initial state is a genuine 0% match, then editing line 0 to 500 net (=595 gross) produces a new gross total of 1547 vs 2023 = ~23.5% > 5% = varianceDanger as expected. Co-Authored-By: Claude e2e-test-engineer (Sonnet 4.5) --- .../invoices/invoice-auto-itemize-page.spec.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/e2e/tests/invoices/invoice-auto-itemize-page.spec.ts b/e2e/tests/invoices/invoice-auto-itemize-page.spec.ts index 1acc519fa..f6b738dac 100644 --- a/e2e/tests/invoices/invoice-auto-itemize-page.spec.ts +++ b/e2e/tests/invoices/invoice-auto-itemize-page.spec.ts @@ -2005,10 +2005,12 @@ test.describe('Scenario 25 — Variance indicator recomputes on totalAmount edit let invoiceId = ''; try { - // Invoice amount = 1700, extracted total = 900+680+120 = 1700 → 0% variance → match state + // All THREE_LINES are includesVat:false (net), so effectiveLineAmount grosses up by 1.19: + // 900x1.19=1071.00 + 680x1.19=809.20 + 120x1.19=142.80 = 2023.00 gross total + // Invoice amount = 2023 to match gross total -> 0% variance -> match state vendorId = await createVendorViaApi(page, `${testPrefix} AI-Variance Vendor`); invoiceId = await createInvoiceViaApi(page, vendorId, { - amount: 1700, + amount: 2023, date: '2026-06-01', }); @@ -2019,14 +2021,15 @@ test.describe('Scenario 25 — Variance indicator recomputes on totalAmount edit await autoItemizePage.goto(invoiceId, docId); await autoItemizePage.waitForAnalyzingDone(); - // ── Initial state: invoice=1700, lines total=1700 → varianceMatch ──────── + // Initial state: invoice=2023, gross total=2023 -> 0% variance -> varianceMatch const indicator = autoItemizePage.getVarianceIndicator(); await expect(indicator).toBeVisible(); - // Initial: ≤1% → varianceMatch CSS class + // Initial: 0% variance -> varianceMatch CSS class await expect(indicator).toHaveClass(/varianceMatch/); - // ── Edit first line totalAmount to 500 (total becomes 500+680+120=1300) ── - // Variance = |1300-1700|/1700 ≈ 23.5% → > 5% → varianceDanger + // Edit first line totalAmount to 500 (net -> grossed to 500x1.19=595.00) + // New gross total = 595.00+809.20+142.80 = 1547.00 + // Variance = |1547-2023|/2023 = 476/2023 ~23.5% -> > 5% -> varianceDanger const totalInput = autoItemizePage.getLineCardTotalAmountInput(0); await totalInput.fill('500'); // Trigger change event by tabbing away