fix(copy): make K3 and year-end claims match what the code actually does (#1431)
* fix(copy): make K3, leasing and year-end claims match what the code does
Follow-up to the batch that removed the uppskjuten-skatt posting on
obeskattade reserver (K3 29.37 gross in juridisk person) and added the K2
asset-account gate. Six user-facing strings still described the old
behaviour or made claims the code cannot support.
1. Arsredovisning page: the K3 explainer promised an uppskjuten skatt-not
and a materiella anlaggningstillgangar-not in every K3 document. Both
are conditional (a 2240/8940 balance, assets in the register) and the
first is now absent in the normal case. The kassaflodesanalys is
dropped with a warning when it cannot be generated, so it is named
only when the document actually carries one.
2. Regelverk settings: kassaflodesanalys was presented as following from
K3. It follows from being ett storre foretag
(swedish-year-end-closing/references/reporting-and-filing.md:10,
legal-framework.md:42); the copy now says the product includes one and
states the storre-foretag rule separately. Komponentavskrivning was
presented as optional under K3; it is mandatory where component useful
lives differ materially (k2-vs-k3.md:5, asset-accounting
references/depreciation.md:33).
3. Note 1 and the Uppskjutna skatter-not no longer claim the 2240 balance
is hanforlig till obeskattade reserver. deriveLatentTaxMovement reads
the 2240/8940 balances only, and under K3 that account carries deferred
tax on all temporary differences (k2-vs-k3.md:11-13).
4. The deferredTax 'unknown' branch emitted the gross-reserve statement,
which is the denial phrased positively: the same affirmative claim
about books that could not be read. It now emits no deferred-tax
paragraph at all; build-data already warns on that path.
5. Capitalized-lease detection looked at 1260/1269 only. On the shipped
BAS 2026 chart 1260 is a free inventarier account and 1269 is ack.
avskrivningar pa datorer, so owned computers were reported as leased,
while 1217/1227 (finansiellt leasade) were missed. Detection now reads
the company's own account names in kontogrupp 12, which is where BAS
keeps capitalized leases (leasing-and-disposal.md:28) and which owned
inventarier on 1220 never matches. 1720 forutbetalda leasingavgifter
stays out: that is the operational treatment.
6a. gnubok_year_end_readiness listed FX revaluation as a blocker (it is a
warning) and omitted UNBOOKED_TRANSACTIONS, the common one. The
description now names every actionable blocker kind, within the
280-char budget, and a test pins it against YEAR_END_BLOCKER_KIND.
6b. companies.accounting_framework defaults to 'k2', so every enskild
firma hit the K2 asset gate and was handed a BFNAR 2016:10 punkt 10.4
citation plus a K3 remedy it cannot take: a sole trader prepares ett
forenklat arsbokslut, not an arsredovisning (legal-framework.md:29,
:48). entity_type now rides along on the companies read the routes
already do, and non-AB entities get wording with no citation and no
K3, keeping the 1090 remedy. The K1 counterpart of punkt 10.4 is not
sourced in the repo skills, so nothing was invented in its place.
* fix(copy): close the review findings on the copy-truth sweep
Three follow-ups from the source and code reviews. (1) The K2/K3 help text had upgraded a vague sentence into a definite boundary claim ('gransen gar vid <trosklar>'), which excludes the other routes into mandatory K3 that are live right now for this control's audience: noterade vardepapper, and from fiscal years starting after 2025-12-31 also utlandsk filial, kryptotillgangar, aktierelaterade ersattningar and fastighetsbolag. An AB in one of those categories would have read the sentence and stayed on a regelverk it may no longer use. (2) hasCapitalizedLeaseAsset compared per-side cumulative totals, so a lease acquired earlier and disposed this year still claimed the balance sheet carries a leased asset; it now compares the net balance. (3) The K3 warning enumerated a kassaflodesanalys the document may not contain, contradicting the newly conditional page copy on the same screen.
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:
co-authored by
Claude Fable 5
Jakob Wennberg
parent
a5c10e441a
commit
5b0ca3d874
@@ -7,7 +7,7 @@
|
||||
* lib/core/bookkeeping tests + the manual MCP smoke test.
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { tools } from '../server'
|
||||
import { tools, YEAR_END_BLOCKER_KIND } from '../server'
|
||||
import { TOOL_SCOPE_MAP } from '@/lib/auth/api-keys'
|
||||
|
||||
vi.mock('@/lib/core/bookkeeping/year-end-service', () => ({
|
||||
@@ -47,6 +47,48 @@ describe('gnubok_year_end_readiness: registration', () => {
|
||||
it('is mapped to reports:read scope', () => {
|
||||
expect(TOOL_SCOPE_MAP.gnubok_year_end_readiness).toBe('reports:read')
|
||||
})
|
||||
|
||||
// The description is the only thing an agent reads before deciding what to
|
||||
// pre-check, and the 280-char budget does not fit all eleven kinds. It must
|
||||
// therefore name every kind the caller can DO something about ahead of time;
|
||||
// the four period-state kinds are summarized, since nothing can be
|
||||
// pre-checked about them.
|
||||
const PERIOD_STATE_KINDS = new Set([
|
||||
'period_not_found',
|
||||
'period_not_ended',
|
||||
'period_already_closed',
|
||||
'closing_entry_exists',
|
||||
])
|
||||
|
||||
it('names every actionable blocker kind the tool can emit', () => {
|
||||
const tool = tools.find((t) => t.name === 'gnubok_year_end_readiness')!
|
||||
const actionable = [...new Set(Object.values(YEAR_END_BLOCKER_KIND))].filter(
|
||||
(kind) => !PERIOD_STATE_KINDS.has(kind),
|
||||
)
|
||||
// Guards the summarizing itself: if a kind stops being period-state, or a
|
||||
// new one appears, it has to show up in the description.
|
||||
expect(actionable.length).toBe(7)
|
||||
for (const kind of actionable) {
|
||||
expect(tool.description, `blocker kind ${kind} missing from description`).toContain(kind)
|
||||
}
|
||||
expect(tool.description).toContain('period-state')
|
||||
})
|
||||
|
||||
it('names unbooked transactions as the most common blocker', () => {
|
||||
// The omission that sent agents pre-checking the wrong things: this is the
|
||||
// blocker a real close trips on, and the description never mentioned it.
|
||||
const tool = tools.find((t) => t.name === 'gnubok_year_end_readiness')!
|
||||
expect(tool.description).toMatch(/unbooked_transactions \(most common\)/)
|
||||
})
|
||||
|
||||
it('does not present open foreign-currency items as a blocker', () => {
|
||||
// validateYearEndReadiness pushes those onto `warnings`, never `blockers`:
|
||||
// executeYearEndClosing runs the revaluation itself, so escalating would
|
||||
// block a close that the very next step performs.
|
||||
const tool = tools.find((t) => t.name === 'gnubok_year_end_readiness')!
|
||||
expect(tool.description).toMatch(/FX = warning, never blocker/)
|
||||
expect(tool.description).not.toMatch(/[Bb]lockers[^.]*revaluation/)
|
||||
})
|
||||
})
|
||||
|
||||
function makeMockSupabase(period: Record<string, unknown> | null) {
|
||||
|
||||
@@ -1722,8 +1722,13 @@ const RC_COMPLETENESS_CODES = new Set<VatDeclarationCheck['code']>([
|
||||
* UNBOOKED_CHECK_FAILED shares 'unbooked_transactions' with the real count:
|
||||
* the fail-closed variant means "we could not tell", and an agent should react
|
||||
* to it the same way (go look at the transactions, then re-run readiness).
|
||||
*
|
||||
* Exported so the tool-description test can assert that every kind an agent
|
||||
* can receive is actually named in the description it plans against: the
|
||||
* description drifted once already (it advertised FX revaluation, a WARNING,
|
||||
* as a blocker and never mentioned unbooked transactions, the common one).
|
||||
*/
|
||||
const YEAR_END_BLOCKER_KIND: Record<YearEndBlockerCode, string> = {
|
||||
export const YEAR_END_BLOCKER_KIND: Record<YearEndBlockerCode, string> = {
|
||||
PERIOD_NOT_FOUND: 'period_not_found',
|
||||
PERIOD_NOT_ENDED: 'period_not_ended',
|
||||
PERIOD_ALREADY_CLOSED: 'period_already_closed',
|
||||
@@ -12780,7 +12785,14 @@ export const tools: McpTool[] = [
|
||||
{
|
||||
name: 'gnubok_year_end_readiness',
|
||||
title: 'Year-End Readiness Check',
|
||||
description: "Pre-flight before irreversible gnubok_run_year_end. Returns ready (bool) + ordered blockers (drafts, voucher gaps, sequence mismatches, unbalanced TB, FX revaluation) + optional closing-entry preview.",
|
||||
// Budget: 280 chars (output-schema.test.ts). Spend it on the blockers an
|
||||
// agent can act on BEFORE calling, in likelihood order. The four
|
||||
// period-state kinds (period_not_found / _not_ended / _already_closed /
|
||||
// closing_entry_exists) collapse into "period-state": nothing to pre-check
|
||||
// there, the period either is closable or is not. Open items in foreign
|
||||
// currency are warnings, never blockers, because executeYearEndClosing
|
||||
// revalues them in step 2 (lib/core/bookkeeping/year-end-service.ts).
|
||||
description: "Pre-flight for irreversible gnubok_run_year_end. Blockers: unbooked_transactions (most common), draft_entries, unexplained_voucher_gap, sequence_mismatch, trial_balance_unbalanced, opening_balance_continuity, next_period_ib_posted, period-state. FX = warning, never blocker.",
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
|
||||
Reference in New Issue
Block a user