8e8b63a200
* fix(bookkeeping): honor underlag VAT via vat_amount override in categorize flow
The categorize flow always derived VAT as rate × gross/(1+rate) from the
transaction amount, with no way to use the underlag's actual moms. On e.g.
a restaurant receipt with dricks (no VAT on the tip), the agent could see
the document's correct VAT but the staged booking recomputed the wrong
rate-based amount on every attempt.
- buildMappingResultFromCategory: optional vatAmountOverride replaces the
rate-derived VAT line ("Ingående/Utgående moms (enligt underlag)"; 0 =
no VAT line). Rejects negatives, amounts above the 25%-extraction bound,
and combination with reverse_charge / VAT-less treatments / private.
- gnubok_categorize_transaction: new vat_amount input, threaded into the
staged preview and persisted in the operation params.
- commitCategorizeTransaction: reads params.vat_amount so the approved
posting matches the staged preview exactly.
- PATCH /api/pending-operations/[id]: accepts vat_amount (null clears);
preserves a staged override across category edits while the treatment
still carries rate-based VAT, drops it when it no longer does.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* review: guard order + agent guidance on vat_amount (PR #717 bots)
- Check treatment compatibility before the 25%-extraction bound so an
oversized override on reverse_charge reports the actual mistake (the
treatment), not the amount. Document why the typeof re-check stays:
commit-time params come from jsonb, so TS types don't hold at runtime.
- vat_amount property description now warns that foreign VAT is never
deductible as ingående moms and that a 0-moms document should use
vat_treatment="exempt" rather than vat_amount=0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mcp): tools/list payload budget + reject vat_amount 0
core-only failed: the verbose vat_amount descriptions pushed the projected
tools/list payload to 36,051 tokens (ceiling 36,000; main is at 35,862).
Per the guard's own guidance, trim descriptions instead of bumping:
now 35,943.
Folds in the Swedish review's round-2 point while trimming: vat_amount 0
is now rejected with a pointer to vat_treatment "exempt". A 0-moms
document is an exempt supply — "exempt" produces the identical expense
booking and the correct income account (3004), so 0 had no use case and
only created a silent momsdeklaration misclassification path. Schema
declares exclusiveMinimum: 0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(bookkeeping): use roundOre for vat_amount math (antipattern ratchet)
Second core-only failure: the naive-ore-round ratchet caught the new
Math.round(x*100)/100 lines (662 > baseline 661). Switch the override
path to roundOre from lib/money — including the pre-existing computed-VAT
line this PR touched — and ratchet the baseline down (659, raw-route-auth
168 locked in from main-side fixes).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
180 lines
8.9 KiB
JSON
180 lines
8.9 KiB
JSON
{
|
|
"_comment": "Ratchet baseline for scripts/checks/no-new-antipatterns.mjs. These counts may only decrease. Re-run with --update after a migration lowers them. Goal: both reach 0 (A1 route-auth campaign, D1 rounding codemod).",
|
|
"rawRouteAuth": {
|
|
"count": 168,
|
|
"files": [
|
|
"app/api/account/delete/route.ts",
|
|
"app/api/account/password/route.ts",
|
|
"app/api/agent/composer/route.ts",
|
|
"app/api/agent/conversations/[id]/route.ts",
|
|
"app/api/agent/conversations/route.ts",
|
|
"app/api/agent/invoke/route.ts",
|
|
"app/api/agent/memory/[id]/route.ts",
|
|
"app/api/agent/memory/route.ts",
|
|
"app/api/agent/onboarding/stream/route.ts",
|
|
"app/api/agent/profile/route.ts",
|
|
"app/api/agent/profile/verify/route.ts",
|
|
"app/api/agent/skills/route.ts",
|
|
"app/api/audit-trail/route.ts",
|
|
"app/api/bookkeeping/account-balances/route.ts",
|
|
"app/api/bookkeeping/account-totals/route.ts",
|
|
"app/api/bookkeeping/accounts/[number]/route.ts",
|
|
"app/api/bookkeeping/accounts/activate/route.ts",
|
|
"app/api/bookkeeping/accounts/bas-lookup/route.ts",
|
|
"app/api/bookkeeping/accounts/reference/route.ts",
|
|
"app/api/bookkeeping/accounts/route.ts",
|
|
"app/api/bookkeeping/fiscal-periods/[id]/close/route.ts",
|
|
"app/api/bookkeeping/fiscal-periods/[id]/entry-count/route.ts",
|
|
"app/api/bookkeeping/fiscal-periods/[id]/route.ts",
|
|
"app/api/bookkeeping/fiscal-periods/period-status/route.ts",
|
|
"app/api/bookkeeping/fiscal-periods/route.ts",
|
|
"app/api/bookkeeping/journal-entries/[id]/chain/route.ts",
|
|
"app/api/bookkeeping/journal-entries/[id]/no-document-required/route.ts",
|
|
"app/api/bookkeeping/journal-entries/[id]/notes/route.ts",
|
|
"app/api/bookkeeping/journal-entries/[id]/route.ts",
|
|
"app/api/bookkeeping/journal-entries/route.ts",
|
|
"app/api/bookkeeping/mapping-rules/evaluate/route.ts",
|
|
"app/api/bookkeeping/mapping-rules/route.ts",
|
|
"app/api/bookkeeping/no-doc-required/route.ts",
|
|
"app/api/bookkeeping/voucher-gaps/route.ts",
|
|
"app/api/calendar/feed/route.ts",
|
|
"app/api/cash-accounts/route.ts",
|
|
"app/api/company/current/route.ts",
|
|
"app/api/company/members/[id]/route.ts",
|
|
"app/api/company/members/invite/[id]/route.ts",
|
|
"app/api/company/members/invite/route.ts",
|
|
"app/api/company/members/route.ts",
|
|
"app/api/company/route.ts",
|
|
"app/api/currency/rate/route.ts",
|
|
"app/api/deadlines/[id]/complete/route.ts",
|
|
"app/api/deadlines/[id]/route.ts",
|
|
"app/api/deadlines/[id]/status/route.ts",
|
|
"app/api/deadlines/route.ts",
|
|
"app/api/documents/[id]/extraction-status/route.ts",
|
|
"app/api/documents/[id]/route.ts",
|
|
"app/api/documents/[id]/verify/route.ts",
|
|
"app/api/documents/[id]/versions/route.ts",
|
|
"app/api/documents/counts/route.ts",
|
|
"app/api/events/route.ts",
|
|
"app/api/extensions/[sector]/[slug]/data/route.ts",
|
|
"app/api/extensions/[sector]/[slug]/settings/route.ts",
|
|
"app/api/extensions/ext/[...path]/route.ts",
|
|
"app/api/extensions/skatteverket/skattekonto/drift/route.ts",
|
|
"app/api/import/sie/[id]/route.ts",
|
|
"app/api/import/sie/create-accounts/route.ts",
|
|
"app/api/import/sie/mappings/route.ts",
|
|
"app/api/import/sie/route.ts",
|
|
"app/api/invoices/[id]/convert/route.ts",
|
|
"app/api/invoices/[id]/mark-sent/route.ts",
|
|
"app/api/invoices/[id]/pdf/route.ts",
|
|
"app/api/invoices/[id]/route.ts",
|
|
"app/api/invoices/preview-pdf/route.ts",
|
|
"app/api/kpi/preferences/route.ts",
|
|
"app/api/mcp-oauth/authorize/route.ts",
|
|
"app/api/pending-operations/[id]/commit/route.ts",
|
|
"app/api/pending-operations/[id]/reject/route.ts",
|
|
"app/api/pending-operations/[id]/route.ts",
|
|
"app/api/pending-operations/bulk-commit/route.ts",
|
|
"app/api/pending-operations/route.ts",
|
|
"app/api/reconciliation/bank/link/route.ts",
|
|
"app/api/reconciliation/bank/mark-opening-balance/route.ts",
|
|
"app/api/reconciliation/bank/run/route.ts",
|
|
"app/api/reconciliation/bank/status/route.ts",
|
|
"app/api/reconciliation/bank/unlink/route.ts",
|
|
"app/api/reconciliation/bank/unmatched-entries/route.ts",
|
|
"app/api/reports/ar-ledger/customer/[customerId]/invoices/route.ts",
|
|
"app/api/reports/ar-ledger/route.ts",
|
|
"app/api/reports/ar-ledger/xlsx/route.ts",
|
|
"app/api/reports/audit-trail/route.ts",
|
|
"app/api/reports/avgifter-basis/route.ts",
|
|
"app/api/reports/balance-sheet/pdf/route.ts",
|
|
"app/api/reports/balance-sheet/xlsx/route.ts",
|
|
"app/api/reports/balansrapport/pdf/route.ts",
|
|
"app/api/reports/balansrapport/route.ts",
|
|
"app/api/reports/balansrapport/xlsx/route.ts",
|
|
"app/api/reports/continuity-check/route.ts",
|
|
"app/api/reports/full-archive/route.ts",
|
|
"app/api/reports/general-ledger/xlsx/route.ts",
|
|
"app/api/reports/income-statement/pdf/route.ts",
|
|
"app/api/reports/income-statement/xlsx/route.ts",
|
|
"app/api/reports/journal-register/route.ts",
|
|
"app/api/reports/journal-register/xlsx/route.ts",
|
|
"app/api/reports/kassaflodesanalys/pdf/route.ts",
|
|
"app/api/reports/kassaflodesanalys/route.ts",
|
|
"app/api/reports/kpi/route.ts",
|
|
"app/api/reports/kpi/xlsx/route.ts",
|
|
"app/api/reports/monthly-breakdown/route.ts",
|
|
"app/api/reports/monthly-breakdown/xlsx/route.ts",
|
|
"app/api/reports/resultatrapport/pdf/route.ts",
|
|
"app/api/reports/resultatrapport/route.ts",
|
|
"app/api/reports/resultatrapport/xlsx/route.ts",
|
|
"app/api/reports/salary-journal/route.ts",
|
|
"app/api/reports/salary-journal/xlsx/route.ts",
|
|
"app/api/reports/supplier-ledger/route.ts",
|
|
"app/api/reports/supplier-ledger/supplier/[supplierId]/invoices/route.ts",
|
|
"app/api/reports/supplier-ledger/xlsx/route.ts",
|
|
"app/api/reports/trial-balance/account/[accountNumber]/sources/route.ts",
|
|
"app/api/reports/trial-balance/route.ts",
|
|
"app/api/reports/trial-balance/xlsx/route.ts",
|
|
"app/api/reports/vacation-liability/route.ts",
|
|
"app/api/reports/vat-declaration/ruta/[ruta]/sources/route.ts",
|
|
"app/api/reports/vat-declaration/xlsx/route.ts",
|
|
"app/api/salary/employees/[id]/absence/route.ts",
|
|
"app/api/salary/employees/[id]/benefits/[benefitId]/route.ts",
|
|
"app/api/salary/employees/[id]/benefits/route.ts",
|
|
"app/api/salary/employees/[id]/route.ts",
|
|
"app/api/salary/employees/[id]/worked-hours/batch/route.ts",
|
|
"app/api/salary/employees/[id]/worked-hours/route.ts",
|
|
"app/api/salary/employees/route.ts",
|
|
"app/api/salary/ku/[year]/route.ts",
|
|
"app/api/salary/payroll-config/[year]/route.ts",
|
|
"app/api/salary/runs/[id]/agi/submit/route.ts",
|
|
"app/api/salary/runs/[id]/agi/xml/route.ts",
|
|
"app/api/salary/runs/[id]/correct/route.ts",
|
|
"app/api/salary/runs/[id]/employees/[employeeId]/route.ts",
|
|
"app/api/salary/runs/[id]/employees/route.ts",
|
|
"app/api/salary/runs/[id]/lines/[lineId]/route.ts",
|
|
"app/api/salary/runs/[id]/lines/route.ts",
|
|
"app/api/salary/runs/[id]/payment/bg-lb/route.ts",
|
|
"app/api/salary/runs/[id]/payment/pain001/route.ts",
|
|
"app/api/salary/runs/[id]/payslips/[employeeId]/pdf/route.ts",
|
|
"app/api/salary/runs/[id]/payslips/send/route.ts",
|
|
"app/api/salary/runs/[id]/preview/route.ts",
|
|
"app/api/salary/runs/[id]/review/route.ts",
|
|
"app/api/salary/tax-tables/lookup/route.ts",
|
|
"app/api/salary/tax-tables/status/route.ts",
|
|
"app/api/settings/api-keys/[id]/route.ts",
|
|
"app/api/settings/booking-templates/[id]/route.ts",
|
|
"app/api/settings/booking-templates/[id]/touch/route.ts",
|
|
"app/api/settings/booking-templates/export/route.ts",
|
|
"app/api/settings/booking-templates/import/route.ts",
|
|
"app/api/settings/booking-templates/route.ts",
|
|
"app/api/settings/counterparty-templates/route.ts",
|
|
"app/api/settings/logo/route.ts",
|
|
"app/api/settings/oauth-clients/[id]/route.ts",
|
|
"app/api/settings/oauth-clients/route.ts",
|
|
"app/api/settings/route.ts",
|
|
"app/api/skatteverket/tax-payments/[period]/mark-paid/route.ts",
|
|
"app/api/skatteverket/tax-payments/[period]/payment-file/route.ts",
|
|
"app/api/skatteverket/tax-payments/[period]/route.ts",
|
|
"app/api/supplier-invoices/[id]/route.ts",
|
|
"app/api/supplier-invoices/[id]/uncredit/route.ts",
|
|
"app/api/support/contact/route.ts",
|
|
"app/api/tax-deadlines/generate/route.ts",
|
|
"app/api/team/accept/route.ts",
|
|
"app/api/team/members/route.ts",
|
|
"app/api/transactions/[id]/attach-document/route.ts",
|
|
"app/api/transactions/[id]/book/route.ts",
|
|
"app/api/transactions/[id]/ignore/route.ts",
|
|
"app/api/transactions/[id]/uncategorize/route.ts",
|
|
"app/api/transactions/batch-match-invoices/route.ts",
|
|
"app/api/transactions/create-from-document/route.ts",
|
|
"app/api/transactions/suggest-categories/route.ts",
|
|
"app/api/vat/validate/route.ts"
|
|
]
|
|
},
|
|
"naiveOreRound": {
|
|
"count": 659
|
|
}
|
|
}
|