Epic: Annual audit — fix wrong numbers and broken controls (FY2025 close review, section A)

Open
#5,085 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Read docs/annual-audit-workflow/fy2025-close-review.md section 2.A and the listed entry points: packages/server/src/modules/reports/helpers/tax.helper.ts, the financial ledger generation resolvers, packages/server/src/modules/ledger/resolvers/ledger.resolver.ts, and the annual audit workflow step files. Work through sub-issues #5086–#5092 in the suggested order; use their tests and verify regenerated FY2025 charges leave no pending ledger changes. Done when all sub-issues are closed and the FY2025 review document is updated.

Written by the indexing model from the issue text.

Description

annual-audit-workflow

Goal

Fix the calculations and controls in the annual-audit workflow (/workflows/annual-audit/:year) that put wrong numbers into the annual statements and the tax return, or let closed figures change after the close.

Background

These items come from the FY2025 close review: docs/annual-audit-workflow/fy2025-close-review.md, section 2.A, based on main at 85507ae.

This epic covers only the findings that affect the numbers or the close control. Other findings in the review are out of scope here:

  • missing filings;
  • reconciliations;
  • step-status issues.
How the pieces fit (read before picking up a sub-issue)
  • Year-end charges (workflow step 4).
    • packages/client/src/components/screens/operations/annual-audit/step-04-financial-charges/index.tsx calls the generate*Charge mutations in packages/server/src/modules/charges/resolvers/financial-charges.resolver.ts.
    • Each mutation creates a FINANCIAL charge tagged with a tax category (generateAndTagCharge). The charge's description carries the year, e.g. Tax expenses charge for 2025.
    • generateLedgerRecordsForFinancialCharge (packages/server/src/modules/ledger/resolvers/ledger-generation/financial-ledger-generation.resolver.ts) then dispatches on the charge's tax category to a per-type generator under .../financial-ledger-generation/.
    • The generators recompute their amounts every time the ledger is regenerated.
  • Ledger-drift detection (steps 2 and 7). chargesWithLedgerChanges (packages/server/src/modules/ledger/resolvers/ledger.resolver.ts) regenerates every charge of the year and diffs it against the stored ledger.
    • After a generator fix, existing year-end charges show up as "pending ledger changes" until they are regenerated.
    • That is the migration path for existing data. The calculation fixes need no SQL migration.
  • Tax computation. calculateTaxAmounts (packages/server/src/modules/reports/helpers/tax.helper.ts) is shared by the tax report (step 13), the tax-expense charge (step 4) and SHAAM 6111 (step 16). A change there affects all three.
  • Ledger lock (step 8). lockLedgerRecords sets admin_context.ledger_lock and marks ledger records locked.

Priority scale

Grade Meaning
P0 — Critical Puts wrong numbers into the FY2025 statements or tax return in the common case. Fix before closing 2025, or apply the workaround.
P1 — High Wrong in specific but realistic cases, or breaks a control the close relies on. Fix before filing.
P2 — Medium Misleading output with a simple workaround. Fix in the next cycle.
P3 — Low Polish.

Effort: S is about a day, M is 2–4 days, L is 1–2 weeks.

Sub-issues

Review item Issue Priority Effort FY2025 workaround
A2 #5087 Vacation reserve is overstated, and decreases are booked as increases P0 M Compute the reserve from the December payslips and book the correct change manually
A1 #5086 Tax-expense charge books a loss year's negative tax as an expense P1 (P0 if FY2025 is a tax-loss year) S–M In a loss year, don't generate the tax-expense charge (or delete it) and record tax 0
A3 #5088 Sort code 931 goes through both the R&D §20A adjustment and the reserves add-back P1 S Correct the 2025 taxable income by −⅔·X₂₀₂₅ + ⅓·X₂₀₂₄ + ⅓·X₂₀₂₃
A4 #5090 Ledger lock: year-end charges still post into a locked year; locked records can't be reopened P1 M–L Don't lock until the auditor's adjustments and the tax true-up are posted
A5 #5091 SHAAM 6111: hard-coded header; tax-adjustment lines never filled P1 (tasks P1–P3) L Use the app's file as a draft; finish it in the CPA's software or the Tax Authority's online form
A6 #5092 Step 10 exports the year's movements instead of a year-end trial balance P2 M Export the trial balance from inception to 31/12/2025

In the workaround for #5088, X is the sort-code-931 amount for each year.

Suggested order

  1. The numbers: #5087, #5086 and #5088.
    • #5086 and #5088 both change calculateTaxAmounts and the tax-expense generator. Land them in sequence, or in one PR.
    • Regenerate the tax expense after #5087, because the reserves change profit before tax.
  2. The lock: #5090, before anyone locks FY2025.
  3. 6111 content: #5091, after #5086 and #5088, which feed lines 5600, 9980, 150 and 400.
  4. Trial balance export: #5092.

Definition of done

  • All sub-issues closed.
  • FY2025 year-end charges regenerated (steps 2 and 7 show no pending ledger changes) and re-approved.
  • The FY2025 close review doc updated.

Related

  • #5083: the 1214 package in the workflow (steps 6 and 18).
  • #4544: dynamic report approvals in the annual audit flow.
  • #1981, #1883, #1844: earlier ledger-lock issues; see #5090.
  • #1147: partial-tax recognition. A tax-computation gap, not in this epic.
Dominant language
TypeScript
Stars
30
Forks
10
Avg merge
2d 12h
Merged PRs (30d)
276

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Urigo/accounter-fullstack

All issues in Urigo/accounter-fullstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.