Files
accounted/extensions/general/mcp-server/skills/month-end-close.ts
T
Jakob WennbergandClaude Sonnet 5 ec27228a8e style: remove em/en dashes repo-wide, add CLAUDE.md rule against them (#890)
Em dashes (—) and en dashes (–) had spread across comments, docs, tests,
and a few UI strings, reading as AI-generated boilerplate rather than
house style. Replaced each with punctuation matching its context: colon
for explanatory clauses, comma for asides, plain hyphen for numeric/legal
ranges (e.g. "21-23§"), "to"/"till" for date ranges, parentheses for
paired-dash asides. messages/en.json and messages/sv.json were fixed by
hand together to keep sv/en in sync.

Left untouched where the dash is the functional subject rather than
decorative punctuation: date-range-parser.ts's separator regex,
charset-repair.ts's CP1252 byte-mapping table (and its test), the SIE
encoding mojibake docs, generic-csv.ts's minus-sign normalizer, the
agent system-prompt files that already instruct against em dashes, and
a golden iXBRL test fixture compared byte-for-byte.

Also fixes two bugs surfaced along the way: an off-by-one in
ApiKeysPanel's scope-label split (a leftover from an earlier partial
pass), and a charset-repair test that had lost the literal en-dash it
exists to verify.

Regenerated the agent atom seed migration (skills:generate) since 27
SKILL.md files changed. Added a CLAUDE.md rule against em/en dashes,
with an explicit carve-out for the functional-dash cases above.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 15:58:06 +02:00

87 lines
4.5 KiB
TypeScript

import type { Skill } from './types'
const body = `# Month-End Close: Accounted
Run this at the end of each calendar month to ensure books are clean before locking the period.
## When to use
Trigger this workflow when the user says any of:
- "Close out [month]"
- "Stäng [månad]"
- "Month-end close"
- "Lock [period]"
Run it on the **last business day** of the month (or first business day of the next month). Locking too early prevents legitimate late entries; locking too late risks period-skew on VAT filings.
## Workflow
### Step 1: Book every business transaction
Goal: zero uncategorized business transactions inside the period.
1. Call \`gnubok_list_uncategorized_transactions\` to see what's outstanding.
2. For each, call \`gnubok_suggest_categories\` (batches of up to 20) to get high-confidence proposals.
3. Stage categorizations via \`gnubok_categorize_transaction\` (or, for income that matches an invoice, \`gnubok_match_transaction_to_invoice\`).
4. The user approves each in the web app: staging is non-negotiable for legal compliance (BFL 5 kap.).
If a transaction is genuinely private, mark it as \`category: 'private'\`: no journal entry will be created.
### Step 2: Reconcile bank
Run \`gnubok_get_reconciliation_status\` for the month's date range. The result includes \`bank_balance\`, \`ledger_balance\`, and \`difference\`. Any non-zero difference means unmatched transactions or missing JEs: investigate before locking.
### Step 3: Check voucher gaps
Run \`gnubok_list_voucher_gaps\` for the fiscal period. **Every gap must have an explanation** per BFNAR 2013:2. Use \`gnubok_explain_voucher_gap\` to document each one (e.g., "Voucher number reserved but not used because invoice was cancelled before posting").
### Step 4: Run VAT report (monthly filers)
If the company files VAT monthly (beskattningsunderlag > 40M SEK, or voluntarily), run \`gnubok_get_vat_report\` with \`period_type: 'monthly'\`. Sanity-check ruta49 ("att betala/återfå"). Use \`gnubok_vat_review_widget\` for a visual review.
If quarterly or annual filer: skip: VAT happens on its own cadence (see the quarterly-vat-review skill).
### Step 5: Lock the period
Stage the lock via \`gnubok_lock_period(fiscal_period_id)\`. The tool refuses if any business transactions remain unbooked. After user approval, no new entries can be posted into the period: late corrections must use \`gnubok_unlock_period\` (also high-risk, also staged).
## Critical rules
- **Never delete journal entries.** Use \`gnubok_uncategorize_transaction\` (storno reversal) to undo. DB triggers enforce this: direct deletes will fail.
- **Posted entries are immutable.** Once a JE is posted, even amounts are locked. Use \`correctEntry\` (web app) for corrections.
- **Money math:** \`Math.round(x * 100) / 100\`, never \`toFixed()\`. The categorize tool handles this; if you compute manually, follow the same pattern.
- **Locking ≠ closing.** Locking blocks new entries; closing (after year-end) is irreversible. This skill stops at locking.
## Common errors
- **"Period must be locked before closing"**: \`gnubok_close_period\` requires \`gnubok_lock_period\` first AND the year-end closing entry. Don't try to close mid-year periods.
- **"Cannot lock period: N business transactions unbooked"**: Step 1 wasn't complete. Re-run \`gnubok_list_uncategorized_transactions\`.
## Tools
- \`gnubok_list_uncategorized_transactions\`: find unbooked transactions
- \`gnubok_suggest_categories\`: get categorization proposals (batch of 20)
- \`gnubok_categorize_transaction\`: stage a single categorization
- \`gnubok_match_transaction_to_invoice\`: apply income to a customer invoice
- \`gnubok_get_reconciliation_status\`: bank vs ledger balance
- \`gnubok_list_voucher_gaps\`: BFNAR 2013:2 audit check
- \`gnubok_explain_voucher_gap\`: document a gap
- \`gnubok_get_vat_report\`: momsdeklaration data
- \`gnubok_vat_review_widget\`: interactive VAT review
- \`gnubok_lock_period\`: stage period lock
- \`gnubok_uncategorize_transaction\`: undo a categorization (storno)
`
export const monthEndCloseSkill: Skill = {
slug: 'month-end-close',
name: 'Month-End Close',
summary: 'End-of-month workflow: book transactions, reconcile bank, verify voucher gaps, file VAT (monthly filers), lock period.',
tags: ['monthly', 'close', 'reconciliation', 'vat'],
body,
tier: 'workflow',
// Universal: both AB and EF run a monthly close. VAT step is conditional
// inside the body so non-VAT-registered companies aren't blocked.
applicability: { entity_type: 'both' },
}