Tax computation: store the reserves sort code (931) in the admin context instead of hard-coding it

Aperta
#5,137 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
40/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
graphql, postgresql, react, typescript
Ambito
api, backend, database

Direzione di ricerca

Start at packages/server/src/modules/reports/helpers/tax.helper.ts, where RESERVES_SORT_CODE = 931 gates the add-back and the researchAndDevelopmentForTax / calculateCumulativeRnDExpenses exclusions, and read its existing tests. Then follow the securitiesContext.sortCode precedent: the user_context migration named in the issue, the admin context GraphQL type and update input, and admin-context/helpers/admin-context.helper.ts for the SortCodesProvider.getSortCodesByIdLoader validation. Done means the constant is gone, an unset setting applies no reserves treatment, and tests cover a non-931 code plus the unset case alongside the unchanged-931 path.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

annual-audit-workflow enhancement

Priority: P3 — Low. Follow-up to #5088 / PR #5095. Part of #5085.
Effort: S · Area: server: admin-context, reports/helpers/tax.helper.ts; migrations; client admin settings

Problem

#5095 hard-codes the reserves sort code as RESERVES_SORT_CODE = 931 in packages/server/src/modules/reports/helpers/tax.helper.ts. It decides:

  • which entities get the reserves add-back (6111 line 150);
  • which R&D entities researchAndDevelopmentForTax keeps out of the yearly R&D add-back and the §20A three-year spread (tax report, tax-expense charge, 6111).

Sort codes are per-tenant (accounter_schema.sort_codes is keyed by key + owner_id). A tenant that books reserves under another key gets reserves treated as R&D — the double adjustment #5088 fixed.

Proposal

Store the reserves sort code in the admin context, following the securitiesContext.sortCode precedent (user_context.securities_context, migration 2026-10-11T12-00-00.add-securities-context-to-user-context.ts):

  1. DB: add a nullable reserves sort-code setting to the admin context (user_context). Migrate existing tenants to 931, so behaviour doesn't change.
  2. GraphQL: expose it on the admin context type and its update input. On update, validate it with SortCodesProvider.getSortCodesByIdLoader, as admin-context/helpers/admin-context.helper.ts does for the securities sort code.
  3. Tax helper:
    • read the value from getVerifiedAdminContext() in calculateTaxAmounts;
    • pass it into researchAndDevelopmentForTax and calculateCumulativeRnDExpenses (or resolve it in the callers: tax report, tax-expense ledger generator, 6111);
    • remove the constant;
    • when the setting is unset, apply no reserves treatment (no add-back, no exclusion). Don't fall back to 931 silently.
  4. Client: add the field to the admin context settings screen.

Out of scope

The P&L section ranges (800/810, 920–931, 990–992, …) and the other tax sort codes (922, 945, 990, 991) are hard-coded too. Track them separately if wanted.

Acceptance criteria

  • No hard-coded reserves code: 931 no longer appears as a reserves constant in the tax computation.
  • Configured code drives the tax treatment: with the setting on another sort code, that code gets the reserves add-back and is kept out of the §20A spread, and 931 is treated as ordinary R&D.
  • Existing tenants unchanged: after the migration, the tax report, the tax-expense charge and 6111 give the same results.
  • Tests: the tax.helper tests cover a non-931 configured code and the unset case.
Lingua principale
TypeScript
Stelle
30
Fork
10
Merge medio
2g 12h
PR unite (30g)
276

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Urigo/accounter-fullstack

Tutte le issue di Urigo/accounter-fullstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.