Accounted rebrand + swarm-skill cleanup + bank-reconciliation fixes (#643)
* feat(reconciliation): close the bank-feed loop on voucher links and re-tag mis-typed opening balances
Two related fixes to bank reconciliation correctness:
1. Auto-reconcile on voucher link. Linking an invoice or supplier invoice to
an existing voucher previously advanced only the invoice — the bank
transaction that paid it kept sitting in the Transactions inbox with a null
journal_entry_id. linkInvoiceToVoucher / linkSupplierInvoiceToVoucher now
call autoReconcileTransactionForLinkedVoucher (lib/reconciliation), which
links the bank transaction to the same verifikat when exactly one unbooked
line matches it. Best-effort and post-commit: a failure here never fails the
link. The result surfaces reconciledTransactionId; the inbox row leaves the
list and the UI shows link_success_tx_reconciled.
2. Re-tag mis-typed opening balances. getReconciliationStatus and the GL-line
matching RPCs identify a cash account's ingående balans solely by
journal_entries.source_type='opening_balance'. Companies migrated from other
systems often booked the bank IB as an ordinary voucher (source_type
'import' or 'manual'), so it was never excluded and surfaced as a phantom
reconciliation difference equal to the opening balance. Adds:
- migration mark_entry_as_opening_balance: a GUC-gated carve-out in the
immutability trigger plus a SECURITY DEFINER RPC that validates the entry
(balance-sheet lines only, dated on a fiscal-period boundary), flips the
source_type, and writes an audit row — no blanket data sweep.
- POST /api/reconciliation/bank/mark-opening-balance + MarkOpeningBalanceSchema.
- BankReconciliationView action to trigger it from the IB diff.
The gnubok_create_voucher executor now accepts a typed is_opening_balance flag
and derives source_type='opening_balance' only after validating class 1/2 lines
on the period start, so new IBs land correctly typed.
Covered by lib/reconciliation auto-reconcile tests, voucher-executors tests,
and a mark-entry-as-opening-balance pg-real test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: rebrand gnubok → Accounted and prune swarm agent skills
Product rebrand and skills housekeeping. No runtime behaviour change.
Rebrand: replace user-visible "gnubok" with "Accounted" across docs, READMEs,
in-code comments, doc-site content, MCP skill/resource prose, and the
gnubok-mcp package description. The MCP resource URI scheme is moved gnubok://
→ Accounted:// consistently across resource registrations, the event-type
comment, and the resource/skill tests. Deliberately preserved as stable
identifiers (NOT rebranded): the gnubok-company-id cookie, gnubok_sk_ / gnubok_inv_
token prefixes, the gnubok-mcp npm bridge name, and the AGI <gem:Programnamn>
value (kept 'gnubok' per its source comment — it is the software identifier sent
to Skatteverket and must not churn across visual rebrands).
Skills: remove the 27 swarm-* agent SKILL.md atoms (no longer used; already
absent from the agent_atom_registry in prod), refresh the remaining skill docs,
add the .claude/rules/ path-scoped rule set, and regenerate the
seed_agent_atom_bodies migration + .skill-body-manifest.json via
`npm run skills:generate` so the DB-backed skill bodies match the trimmed set.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
331ae11867
commit
c74b19df1b
@@ -272,14 +272,14 @@ export function buildIdentityBlock(args: BuildArgs): string {
|
||||
// MCP catalog, and then claims access to tools that aren't in this
|
||||
// intent's whitelist. The tools-parameter the model receives via the
|
||||
// Anthropic API is the canonical source of truth — anything outside it
|
||||
// is reachable from *other* gnubok surfaces, not from here.
|
||||
// is reachable from *other* Accounted surfaces, not from here.
|
||||
lines.push('# Verktyg')
|
||||
lines.push('')
|
||||
lines.push('Verktygen du kan anropa just nu är EXAKT de som ligger i din tools-parameter — varken fler eller färre. Om du har sett andra verktygsnamn via gnubok_search_tools eller gnubok_list_skills så finns de i systemet, men de är inte anropbara från denna ingång. Påstå aldrig att du har ett verktyg som inte ligger i tools-parametern.')
|
||||
lines.push('')
|
||||
lines.push('När användaren frågar "vad kan du?" / "vilka verktyg har du?": svara i förmågor (vad du faktiskt kan hjälpa till med här), inte i API-namn. Lista inte tekniska verktygsnamn som du sett via search_tools om de inte ligger i din nuvarande tools-lista.')
|
||||
lines.push('')
|
||||
lines.push('När en uppgift kräver ett verktyg du inte har: hänvisa användaren till rätt vy i gnubok där motsvarande knapp har rätt verktyg inkopplat (t.ex. en transaktionsrad, /invoices/new, /bookkeeping/year-end). Säg vart de ska gå — försök inte fejka åtgärden.')
|
||||
lines.push('När en uppgift kräver ett verktyg du inte har: hänvisa användaren till rätt vy i Accounted där motsvarande knapp har rätt verktyg inkopplat (t.ex. en transaktionsrad, /invoices/new, /bookkeeping/year-end). Säg vart de ska gå — försök inte fejka åtgärden.')
|
||||
lines.push('')
|
||||
lines.push('När du HAR rätt verktyg — använd dem. Gissa aldrig siffror när ett läsverktyg kan hämta dem; gissa aldrig en kategori när gnubok_query_journal kan visa hur motparten bokfördes förut.')
|
||||
lines.push('')
|
||||
|
||||
@@ -214,7 +214,7 @@ function buildUserPrompt(inputs: ComposerInputs): string {
|
||||
const lines: string[] = []
|
||||
lines.push(`# Företag`)
|
||||
lines.push(`Namn: ${inputs.companyName}`)
|
||||
lines.push(`Juridisk form (gnubok): ${inputs.entityType}`)
|
||||
lines.push(`Juridisk form (Accounted): ${inputs.entityType}`)
|
||||
lines.push('')
|
||||
|
||||
const known = buildKnownFacts(inputs)
|
||||
|
||||
@@ -84,7 +84,7 @@ export async function loadCompanySettings(
|
||||
// ownership in the user's mouth.
|
||||
//
|
||||
// We match the user's enrichment row against this company's org_number.
|
||||
// `companyId` is the gnubok UUID — we need to read the orgnr from
|
||||
// `companyId` is the Accounted UUID — we need to read the orgnr from
|
||||
// `companies` to do the match. Cheap (single SELECT each) and only runs once
|
||||
// per agent build.
|
||||
//
|
||||
@@ -108,7 +108,7 @@ export async function loadUserDirectorship(
|
||||
companyId: string,
|
||||
): Promise<{ confirmedDirector: boolean }> {
|
||||
// Read this company's org_number — the BankID CompanyRoles row keys on
|
||||
// companyRegistrationNumber, not the gnubok company UUID.
|
||||
// companyRegistrationNumber, not the Accounted company UUID.
|
||||
const { data: companyRow } = await supabase
|
||||
.from('companies')
|
||||
.select('org_number')
|
||||
|
||||
Reference in New Issue
Block a user