Tax computation: encode the loss-offset order between preferred-rate and sort-991 income
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- graphql, typescript
Research direction
Start with packages/server/src/modules/reports/helpers/tax.helper.ts, especially computeCurrentTax, and read the linked follow-up issues #5105 and #5088 for context. The accountant must first decide how losses offset income across rate buckets and what carries forward; then update the helper, its tests, the tax report, and the 6111 line 510 calculation. Done when the decisions are documented and both mixed cases, reporting, and 6111 use the confirmed split.
Written by the indexing model from the issue text.
Description
Follow-up to #5086, fixed in #5096 (epic #5085). Related: #5105 (loss carry-forward) and #5088 (sort code 931, which also changes calculateTaxAmounts). Links point to main at 4d5ba86.
Background
calculateTaxAmounts builds two taxable-income figures:
taxableIncomeAmount(L130-L140): profit before tax plus adjustments, minus sort-code-991 income. It is taxed attaxRate, the company's own and possibly preferred rate (corporate_tax_variables.tax_rate).specialTaxableIncome.amount: the ledger amount on sort code 991. It is taxed atspecialTaxRate, the regular corporate rate (L144,corporate_tax_variables.original_tax_rate, default 23, added in this migration).
computeCurrentTax then computes:
annualTaxExpenseAmount = taxableIncomeAmount * taxRate + specialTaxableIncomeAmount * specialTaxRate
currentTaxExpense = max(0, annualTaxExpenseAmount)
taxableLoss = max(0, -(taxableIncomeAmount + specialTaxableIncomeAmount))
mixedRateLoss = the two incomes are non-zero with opposite signs
Problem
When the two incomes have opposite signs, the formula nets a loss against a profit at different rates. A loss should offset income before any rate is applied. Example at 12% / 23%:
| Case | preferred-rate | sort 991 | Formula today | If the loss offsets the other income first |
|---|---|---|---|---|
| A | −100,000 | +300,000 | −12,000 + 69,000 = 57,000 | (300,000 − 100,000) × 23% = 46,000 |
| B | +300,000 | −100,000 | 36,000 − 23,000 = 13,000 | (300,000 − 100,000) × 12% = 24,000 |
The order and the rules (can a 991 loss offset preferred-rate income at all?) must come from the company's accountant. Until they do, #5096 only flags the case:
TaxReportYear.mixedRateLoss: schema, resolver.- The tax report shows a yellow warning banner: client.
- The ledger (
tax-expenses-ledger-generation.resolver.ts) still booksmax(0, netted).
To do
- Ask the accountant, and write the answers in this issue:
- Preferred-rate loss with sort-991 profit: does the loss offset the 991 income? At which rate is the rest taxed?
- Sort-991 loss with preferred-rate profit: the same questions.
- What carries forward afterwards, and at which "rate bucket"? This feeds #5105.
- Change
computeCurrentTaxto offset first, then apply the rates. Return each rate's taxable amount and tax plus the remaining loss, not just the net. Keep the signature pure: it is the single place both the ledger and the report get the tax from. - Callers (they all read from
calculateTaxAmounts):- ledger:
tax-expenses-ledger-generation.resolver.tsbookscurrentTaxExpense; no change expected; - tax report: show the split if useful, and remove the
mixedRateLosswarning or downgrade it to an informational note; - 6111:
buildTaxAdjustmentEntriessets line 510 (income at the special rate) fromtaxableIncome. Check it against the new split (shaam6111.helper.ts L243-L266).
- ledger:
- Tests: extend tax.helper.test.ts. The two "flags a ..." cases already exist; update their expected amounts to the confirmed rules and add cases A and B from the table.
How to run
yarn vitest run --project unit packages/server/src/modules/reports/helpers/__tests__/tax.helper.test.ts
After changing the GraphQL schema, run yarn generate.
Done when
- The accountant's answer is recorded here and in a doc comment on
computeCurrentTax. - Both mixed cases produce the confirmed tax and loss, and tests cover them.
- The tax report no longer flags these cases as unresolved, and 6111 line 510 is consistent.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Urigo/accounter-fullstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Urigo/accounter-fullstack#5302 ·
Maintainers usually reply within 2 days
-
1214 annual-audit-workflow
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Urigo/accounter-fullstack#5257 ·
Maintainers usually reply within 2 days
-
1214 annual-audit-workflow
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Urigo/accounter-fullstack#5256 ·
Maintainers usually reply within 2 days
-
annual-audit-workflow
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
Urigo/accounter-fullstack#5252 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Urigo/accounter-fullstack#4919 ·
Maintainers usually reply within 2 days
All issues in Urigo/accounter-fullstack
Similar issues
-
area: integrations documentation priority: P2 size: XS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eddiejaoude/StackDash#798 ·
Maintainers usually reply within 1 day
-
bot:ai-assisted component:midnight-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
midnightntwrk/midnight-js#1790 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
area:vscode bug has repro platform:macos platform:vscode regression
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anthropics/claude-code#113502 ·
-
Add: Rajdhani TV HDOpencheck:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 77/100
Maintainers usually reply within 1 day