--- name: bookkeep description: Clear the bookkeeping inbox, categorize bank transactions and receipts into correct vouchers. Use when the user says "bokfor", "bokfora", "book this", "categorize my transactions", "osorterade transaktioner", "kvitton", or wants daily bookkeeping done. argument-hint: [period or counterparty] --- # Bookkeep Work through unbooked bank transactions and receipts and stage correct vouchers. This is the highest-frequency flow; accuracy comes from the company's own history, not from guessing. ## Flow 1. If not already done this session, call `accounted_get_agent_briefing` (accounting method changes how income is booked: faktureringsmetoden credits 1510 via invoices, kontantmetoden books on payment). 2. Find what is unbooked: start from `Accounted://attention` (for a company other than the default: `Accounted://company/{company_id}/attention`), then discover the listing and categorization tools with `accounted_search_tools` (for example "uncategorized transactions", "categorize", "upload receipt"). 3. For each item, decide the posting in this order of authority: 1. Explicit mapping rules the company has configured. 2. Observed history in `Accounted://ledger/context`: how THIS company booked this counterparty before (dominant account, VAT treatment, frequency as evidence). Prefer these over textbook answers, but frequency is not permission to auto-post. 3. Only then general knowledge, and for VAT treatment always load it: `accounted_load_skill("horizontal/swedish-vat")` for deductibility edge cases (representation caps, EU trade, reverse charge). Never answer Swedish VAT from memory. 4. Stage the categorizations, grouped by counterparty so the user can approve in coherent batches. Present each preview with account, VAT treatment, and why. Approve only what the user confirms, via `accounted_approve_pending_operation`. If that tool is not among your tools, the connection has no Approve permission: tell the user the proposals wait under Att göra › Rutin (`/pending`). 5. If a tool response carries `period_status` locked or closed, stop that item and explain; never work around a period lock. 6. Finish with a short summary in the user's language: booked, skipped and why, what remains, and the next relevant deadline. ## Rules - Evidence over guesses: ledger context and mapping rules outrank general knowledge. - Every write stages a pending operation; the user approves before anything is booked. - Amounts are SEK with ore precision; never round away balance. - Company context: if the working directory (or a parent, nearest wins) contains `.accounted.json` with `{ "company_id": "", "name": "" }`, pass that `company_id` on every company-scoped call and say the company name once at the start. Otherwise, if `accounted_list_companies` is among your tools, the account reaches several companies: call it and ask once which company the task concerns (or whether it spans all of them) before any write, never write to a company the user did not name, and read back the `company: { company_id, name, is_default }` block that opens every result whenever it is not the company they named. If `accounted_list_companies` is not among your tools, the account has one company: results carry no company block and none of this applies.