Tax computation: encode the loss-offset order between preferred-rate and sort-991 income
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- graphql, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Urigo/accounter-fullstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
Urigo/accounter-fullstack#5302 ·
I maintainer di solito rispondono entro 2 giorni
-
1214 annual-audit-workflow
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Urigo/accounter-fullstack#5257 ·
I maintainer di solito rispondono entro 2 giorni
-
1214 annual-audit-workflow
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Urigo/accounter-fullstack#5256 ·
I maintainer di solito rispondono entro 2 giorni
-
annual-audit-workflow
Difficoltà 1/5 1-3 ore Idoneità per principianti 87/100
Urigo/accounter-fullstack#5252 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Urigo/accounter-fullstack#4919 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di Urigo/accounter-fullstack
Issue simili
-
area: integrations documentation priority: P2 size: XS
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eddiejaoude/StackDash#798 ·
I maintainer di solito rispondono entro 1 giorno
-
bot:ai-assisted component:midnight-js status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
midnightntwrk/midnight-js#1790 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
area:vscode bug has repro platform:macos platform:vscode regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
anthropics/claude-code#113502 ·
-
Add: Rajdhani TV HDApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno