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

Open
#5,105 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
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
graphql, postgresql, typescript
Domain
backend, databases

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
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.