fix(import): let a skattekontoutdrag that does not sum through a confirm gate (#1675)

* fix(import): let a skattekontoutdrag that does not sum through a confirm gate

The skattekonto file parser refused any statement where ingående saldo plus
händelser did not equal utgående saldo with a bare 400 and no figures. A
real export hit it on 2026-08-18 and the user had no way forward, and the
logs carried nothing to diagnose it with. Nothing is booked at import and
the dedup contract makes a later complete re-import safe, so refusing the
file only blocked the rows that WERE readable.

- Parser: report events_sum / sum_difference / unreadable_amount_rows
  instead of just a boolean; reduce several marker pairs to the earliest
  opening and latest closing (per-year sections, newest-first files); read
  a marker saldo from a trailing running-saldo column when the belopp cell
  is empty; accept U+2212 and dash lookalikes as minus and a leading plus.
- Route: no longer 400s on sum_valid=false; logs the figures (amounts and
  counts, never row text) so the next report is diagnosable. Zero readable
  rows still refuses. SKATTEKONTO_FILE_SUM_MISMATCH removed (unused).
- Preview: an "Utdraget summerar inte" card with ingående, händelser,
  ingående+händelser, utgående and differens plus a confirm checkbox that
  gates the import button, mirroring the orgnr-mismatch gate. A one-line
  note explains that nothing is booked at import and that events already
  carrying a 1630 verifikat are offered as a link, not a second booking.

Verified end to end in the sandbox: gate renders, import proceeds after
confirmation, rows land on /skattekonto with Matcha/Bokför.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(import): round the derived händelser total and fall back to the date cell for an invalid marker date

Review nits on #1675.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-08-18 10:33:51 +02:00
committed by GitHub
co-authored by Claude Fable 5 Jakob Wennberg
parent 2b5b813b7a
commit 387e1fb7f1
10 changed files with 314 additions and 42 deletions
+11
View File
@@ -7116,6 +7116,17 @@
"skattekonto_org_mismatch_title": "The statement belongs to another company",
"skattekonto_org_mismatch_body": "The file is a statement for {companyName} ({orgNumber}), which does not match the active company's organisation number. Make sure you have the right company selected before importing.",
"skattekonto_org_mismatch_confirm": "I am sure this statement belongs to the active company",
"skattekonto_sum_gap_title": "The statement does not sum",
"skattekonto_sum_gap_opening": "Opening balance",
"skattekonto_sum_gap_events": "Events in the file",
"skattekonto_sum_gap_expected": "Opening balance + events",
"skattekonto_sum_gap_closing": "Closing balance per the file",
"skattekonto_sum_gap_difference": "Difference",
"skattekonto_sum_gap_no_saldo": "The file has no readable opening or closing balance, so the statement cannot be reconciled.",
"skattekonto_sum_gap_body": "Events are missing from the file: it may have been downloaded with a filter, cut off or edited. You can still import the events that are in it; nothing is booked automatically, and importing a complete statement later fills the gap without duplicates.",
"skattekonto_sum_gap_body_unreadable": "{count, plural, one {1 dated row has an amount we could not read and is missing from the sum.} other {# dated rows have amounts we could not read and are missing from the sum.}} You can still import the readable events; nothing is booked automatically. Send us the file and we will teach the import to read it.",
"skattekonto_sum_gap_confirm": "I understand the statement is incomplete and want to import the events it contains",
"skattekonto_after_import_note": "Nothing is booked at import. The events land on the tax account page; those that already have a voucher on 1630 (for example deposits you booked from the bank side) are flagged as possible duplicates and linked to that voucher instead of being booked again.",
"skattekonto_duplicates_note": "{count, plural, one {1 event already exists on the tax account and will be skipped.} other {# events already exist on the tax account and will be skipped.}}",
"skattekonto_issues_title": "{count, plural, one {1 row could not be fully read} other {# rows could not be fully read}}",
"skattekonto_issue_row": "Row {row}",
+11
View File
@@ -7116,6 +7116,17 @@
"skattekonto_org_mismatch_title": "Utdraget gäller ett annat företag",
"skattekonto_org_mismatch_body": "Filen är ett kontoutdrag för {companyName} ({orgNumber}), vilket inte matchar det aktiva företagets organisationsnummer. Kontrollera att du valt rätt företag innan du importerar.",
"skattekonto_org_mismatch_confirm": "Jag är säker på att utdraget hör till det aktiva företaget",
"skattekonto_sum_gap_title": "Utdraget summerar inte",
"skattekonto_sum_gap_opening": "Ingående saldo",
"skattekonto_sum_gap_events": "Händelser i filen",
"skattekonto_sum_gap_expected": "Ingående saldo + händelser",
"skattekonto_sum_gap_closing": "Utgående saldo enligt filen",
"skattekonto_sum_gap_difference": "Differens",
"skattekonto_sum_gap_no_saldo": "Filen saknar ett läsbart ingående eller utgående saldo, så utdraget kan inte stämmas av.",
"skattekonto_sum_gap_body": "Händelser saknas i filen: den kan vara nedladdad med ett filter, avklippt eller redigerad. Du kan importera händelserna som finns med ändå; inget bokförs automatiskt, och en senare import av ett komplett utdrag fyller på det som fattas utan dubbletter.",
"skattekonto_sum_gap_body_unreadable": "{count, plural, one {En rad med datum har ett belopp som inte gick att läsa och saknas därför i summan.} other {# rader med datum har belopp som inte gick att läsa och saknas därför i summan.}} Du kan importera de läsbara händelserna ändå; inget bokförs automatiskt. Skicka gärna filen till oss så lär vi importen läsa den.",
"skattekonto_sum_gap_confirm": "Jag förstår att utdraget är ofullständigt och vill importera händelserna som finns",
"skattekonto_after_import_note": "Inget bokförs vid importen. Händelserna hamnar på skattekontosidan; de som redan har ett verifikat på 1630 (till exempel insättningar du bokfört från banken) markeras som möjlig dubblett och kopplas till det verifikatet i stället för att bokföras en gång till.",
"skattekonto_duplicates_note": "{count, plural, one {En händelse finns redan på skattekontot och hoppas över.} other {# händelser finns redan på skattekontot och hoppas över.}}",
"skattekonto_issues_title": "{count, plural, one {En rad kunde inte läsas fullt ut} other {# rader kunde inte läsas fullt ut}}",
"skattekonto_issue_row": "Rad {row}",