Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions e2e/tests/invoices/invoice-auto-itemize-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});

Expand All @@ -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
Expand Down