Files
accounted/lib/bokslut/arsredovisning/__tests__/soliditet.test.ts
T
Mattsson 466e55a015 Fix/invoice delivery and payment accounts (#1116)
* fix: reconcile annual reports with final closing entries

* test: cover annual report depreciation and VAT balances

* Merge remote-tracking branch 'origin/main' into fix/usr-fdbck-ch

* fix: show exact invoice delivery details

* fix: use currency account in invoice emails

* fix: address invoice delivery review feedback

* fix: harden invoice delivery and payment accounts

* test: assert RLS-denied zero-row updates

* fix: close remaining invoice compliance gaps

* fix: harden invoice archive authorization

* fix: close invoice delivery review findings

* fix: verify delivery finalization results

* fix: cap combined invoice email recipients

* fix: close final invoice compliance findings

* fix: prevent stale payment account saves

* test: prove invoice delivery isolation

* fix: close invoice privacy review findings

* test: normalize delivery retention dates
2026-07-23 09:54:02 +02:00

51 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { mapTrialBalancesToK2, type TrialBalanceRowLike } from '../../ixbrl/k2-mapper'
import { calculateSoliditet } from '../build-data'
function row(
account: string,
debit: number,
credit: number,
): TrialBalanceRowLike {
return {
account_number: account,
account_name: `Account ${account}`,
closing_debit: debit,
closing_credit: credit,
}
}
describe('calculateSoliditet', () => {
it('returns null when total assets are non-positive', () => {
const mapping = mapTrialBalancesToK2({ full: [], preClosing: [] }, null)
expect(calculateSoliditet(mapping)).toBeNull()
})
it('uses adjusted equity and the sign-reclassified balance-sheet total', () => {
const full = [
row('1630', 0, 22_985),
row('1930', 17_428.36, 0),
row('1940', 749_306.35, 0),
row('2081', 0, 25_000),
row('2099', 0, 469_542.21),
row('2125', 0, 197_574),
row('2512', 0, 123_180),
row('2518', 101_970, 0),
row('2641', 1_387.5, 0),
row('2891', 0, 23_223),
row('2893', 0, 8_588),
]
const mapping = mapTrialBalancesToK2({ full, preClosing: full }, null)
expect(mapping.br['OvrigaFordringarKortfristiga'].current).toBe(1_387)
expect(mapping.br['KassaBankExklRedovisningsmedel'].current).toBe(766_735)
expect(mapping.br['Skatteskulder'].current).toBe(44_195)
expect(mapping.br['OvrigaKortfristigaSkulder'].current).toBe(31_811)
expect(mapping.br['Periodiseringsfonder'].current).toBe(197_574)
expect(mapping.totals.tillgangar.current).toBe(768_122)
expect(mapping.totals.egetKapitalSkulder.current).toBe(768_122)
expect(calculateSoliditet(mapping)).toBe(84.8)
})
})