Fix/bank sync bas (#1284)
* fix(year-end): stop revaluing FX items that were not on the balance sheet The year-end close ran currency revaluation as an unconditional step before the irreversible close, and the revaluation queried LIVE open invoices with no date scoping. An invoice issued after balansdagen, settled before it, or never booked at all was therefore revalued into the year being closed, writing down a 1510/2440 that stood at zero. Because the entry lands inside the same run that closes the period, the only remedy left was a rattelse in the following year. The population is now measured as of balansdagen, reusing the reconstruction the reskontra reports already use (fetchPaymentsAsOf / outstandingAsOf): the invoice_date ceiling is unconditional (post-dated invoices make the bug reachable for a current period too) and the widening to 'paid' applies only to a historical date, where a since-settled invoice was still open then. Rows that carry no balance-sheet exposure are skipped per row rather than per company: an unbooked registration is not on 1510/2440. Deliberately NOT keyed on accounting_method, since BFL 5 kap 2 § 3 st requires kontantmetoden companies to book their outstanding fordringar/skulder at balansdagen, and those converted rows are genuine exposure that ARL 4 kap. 13 § must value. The readiness warning stays ungated on purpose: an unbooked FX row is exactly what deserves a warning, because /book still posts it into the year about to close and lockPeriod/closePeriod then removes that remedy for good. The wizard preview now lists the per-invoice revaluation rows it will post instead of three aggregate numbers, so the user approves line-level content before the close. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(bookkeeping): reach accounts outside BAS 2026 from a verifikat rattelse A user could not move a verifikat line to konto 8022: the picker reported no such account and offered no way forward. 8022 was dropped from BAS 2026 (it is in BAS 2018), so it is a legitimate company-specific underkonto rather than a catalog gap. Verified against the official bas.se kontoplan that our BAS reference already matches BAS 2026, so 8022 is deliberately NOT added to it: seeding a retired account would push it onto every company. StrikeLinesDialog and CorrectionEntryDialog were the only account pickers in the app that never passed onCreateAccount, so their combobox rendered a dead empty state. Both now open AddAccountDialog prefilled, then refetch the chart and select the new account on the initiating line, leaving the half-finished rattelse intact. AccountCombobox closed its dropdown on the fourth digit of any committed number, which hid the empty state before it was ever painted and made the create affordance unreachable for exactly the numbers that need it. It now closes only when the number matches something, so focus still advances to the belopp field for real accounts. No change to posting rules: correct_entry_lines_inline validates chart membership, not BAS membership, and account creation already required the same write role. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(vacation): adjust vacation accrual calculations for mid-year hires and update related logic --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
108f348c84
commit
3bbf2a051b
@@ -884,9 +884,17 @@ function hasUsableFxRate(rate: number | string | null | undefined): boolean {
|
||||
* cannot be dated, so its live outstanding is assumed to have stood at
|
||||
* balansdagen; and an invoice cancelled or credited since is treated as never
|
||||
* having been open, because neither event carries a reliable date. The status
|
||||
* population is kept identical to what the revaluation engine actually acts on
|
||||
* (`getOpenForeignCurrencyReceivables` / `...Payables`), so the warning never
|
||||
* points at rows for which no remedy exists.
|
||||
* population, date scoping and outstanding reconstruction are kept identical
|
||||
* to what the revaluation engine acts on (`getOpenForeignCurrencyReceivables`
|
||||
* / `...Payables` with the same as-of date).
|
||||
*
|
||||
* Deliberately NOT gated by `fxExposureScope`, unlike the revaluation itself.
|
||||
* An unbooked FX row is exactly the case worth warning about: it is not on
|
||||
* 1510/2440 yet, so the revaluation skips it, but POST /api/invoices/[id]/book
|
||||
* still books it at its own invoice_date, i.e. into the year about to close.
|
||||
* Once step 7/8 lock and close the period that remedy is gone for good, so
|
||||
* suppressing the warning here would convert a recoverable state into a
|
||||
* permanent misstatement.
|
||||
*/
|
||||
async function countOpenFxItemsAtBalansdagen(
|
||||
supabase: SupabaseClient,
|
||||
|
||||
Reference in New Issue
Block a user