Tax: loss carry-forward (form 1344, 6111 line 480)

Aperta
#5,105 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à
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
graphql, postgresql, typescript
Ambito
backend, databases

Direzione di ricerca

Start with packages/server/src/modules/reports/helpers/tax.helper.ts and the existing R&D spreading calculation to understand how yearly tax amounts are computed. Review the corporate taxes provider and packages/server/src/__tests__/shaam6111.integration.test.ts for data and report patterns; the issue calls for a migration if storage is added. Done means loss balances roll forward from entered opening amounts, reduce later taxable income, appear in the tax report and 6111 line 480, and are covered by the described tests; deferred tax also needs a decision.

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

Descrizione

annual-audit-workflow

Follow-up to #5086 (out of scope there; epic #5085). Depends on #5104 (loss-offset order between preferred-rate and sort-991 income). Related: #5091 (other 6111 tax-adjustment lines that are never filled). Links point to main at 4d5ba86.

Background

Since #5096, a year with a taxable loss books current tax 0, and the loss is reported as TaxReportYear.taxableLoss:

After that, the loss goes nowhere:

  • No data: nothing stores losses carried forward. The tax inputs per year are only corporate_tax_variables (tax_rate, original_tax_rate), read through CorporateTaxesProvider.
  • Full tax on the next profit: calculateTaxAmounts (L17-L171) looks at a single year. A profitable year after a loss year is taxed in full.
  • 6111 line 480 is never filled: the form computes 500 = 400 − 430 − 480 + 490 (formula), but buildTaxAdjustmentEntries never sets 480. No form 1344 support exists either.

Proposed design (refine before building)

  1. Data: where the opening balance comes from.

    • Computed: roll forward from each year's taxableLoss and the amount used. This works only for years the app has full books for.
    • Entered: an opening balance per business (and per rate bucket, depending on #5104). This covers the years before the app's data.

    Likely both: a computed roll-forward seeded by an entered opening balance. A small table such as tax_loss_carry_forward (owner_id, year, opening_balance, source) and a provider in the corporate-taxes module would fit the existing pattern (@Injectable provider + DataLoader; SQL types from yarn generate).

  2. Tax calculation. In calculateTaxAmounts / computeCurrentTax:

    • offset the year's positive taxable income by the losses carried in, applying the #5104 order;
    • expose lossCarriedForwardUsed and lossCarriedForwardClosing.

    R&D spreading already works across three years (calculateCumulativeRnDExpenses, same file); follow its pattern if computing on the fly.

  3. Ledger. No new mechanism: generateLedgerRecordsForTaxExpenses books currentTaxExpense, which will already be reduced.

  4. Reports.

    • Tax report: add rows for losses carried in, used and carried out.
    • 6111: pass the amount used into Shaam6111TaxAdjustmentInputs and set line 480 (call site). Check 500 against the tax report afterwards (the existing integration test does this: shaam6111.integration.test.ts L452).
  5. Deferred tax (a deferred-tax asset for the loss) is a separate accounting decision: under Israeli GAAP it is booked only when using the loss is probable. Decide whether it belongs here or in its own issue.

Tests

  • Unit: tax calculation for a loss year followed by a profit year (fully absorbed, partly absorbed), plus an entered opening balance.
  • Integration: extend shaam6111.integration.test.ts with a loss year followed by a profit year. Assert that 480 is filled and that 500 matches the tax report.

How to run

yarn generate
yarn vitest run --project unit packages/server/src/modules/reports/helpers
yarn vitest run --project integration packages/server/src/__tests__/shaam6111.integration.test.ts

For a schema change, add a migration under packages/migrations/src/actions/ and register it in run-pg-migrations.ts, then run yarn migration:check-conflicts. Make sure POSTGRES_* points at a local DB.

Done when

  • A loss year's taxable loss carries into the next year's balance; an opening balance can be entered for years before the app's data.
  • A profit year after a loss year is taxed on income net of the losses carried forward, and tests cover it.
  • The tax report shows the carry-forward, 6111 line 480 is filled, and 500 still matches the tax report.
  • Deferred tax is decided: done here or tracked in its own issue.
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.