Files
accounted/lib/providers/visma
Jakob Wennberg cadf02e407 fix(migration): derive Visma invoice payment state from PaymentStatus enum (#1462)
The eAccounting /supplierinvoices LIST payload omits RemainingAmount, and
reading the absence as 0 made every migrated supplier invoice fully paid
(ElvaSmultron: 290/290 imported as paid, including two open payables).
SupplierInvoiceApi has no IsCancelled/IsBooked/IsSent either, so the shared
status derivation could never produce an open supplier invoice.

- Supplier invoices: paid = PaymentStatus in (Paid=6, PaidInBank=9); bank
  in-flight states stay open; missing RemainingAmount now falls back to the
  invoice total instead of a settled-looking 0; lifecycle from Status
  (0=Draft, 2=Deleted) + overdue from PaymentStatus (4, 7).
- Sales invoices: paid = PaymentStatus 0 (enum: 0=Paid, 1=Unpaid, 2=Overdue)
  with the old RemainingAmount check as fallback only.
- IsCreditInvoice now maps to invoiceTypeCode '381' on both sides: credit
  notes have negative totals, could never satisfy 'remaining 0 && total > 0'
  and fell through to 'draft', surfacing on the dashboard as overdue unsent
  invoices.
- PaymentDate now feeds lastPaymentDate so paid_at is the real payment date
  rather than the invoice date.

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-08 14:26:34 +02:00
..
2026-04-07 10:30:20 +02:00
2026-05-21 01:25:18 +02:00