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