T1 Electrical SolutionsT1 Platform Docs
Allowance Matrix

Lifecycle and Recalculation

Lifecycle and Recalculation

Allowance lines are recalculated automatically during Doctrine flushes and manually through a console command.

Automatic recalculation

TimesheetAllowanceCalculationSubscriber listens to Doctrine onFlush.

It collects affected timesheets when scheduled insertions, updates, or deletions include:

  • Timesheet
  • TimeEntry
  • Project
  • ClientAllowance

For project changes, it finds submitted, accepted, or approved timesheets for that project. For client allowance changes, it finds submitted, accepted, or approved timesheets for the allowance's client.

It then refreshes allowance lines only for timesheets in these statuses:

  • submitted
  • accepted
  • approved

The subscriber has an isRefreshing guard to avoid recursive recalculation.

Deleted allowance behavior

If a ClientAllowance is deleted, the subscriber tracks it and removes any calculated lines linked to that deleted object. New recalculation then produces any remaining valid lines from the current rule set.

Manual recalculation command

Command:

php bin/console app:allowances:recalculate-timesheets --force

Options:

OptionMeaning
--forcePersist recalculated lines. Without it, the command only reports how many timesheets would be recalculated.
--limit=NProcess a limited number of timesheets, ordered by updated date descending.
--id=UUIDRecalculate one specific timesheet.

The command targets submitted, accepted, and approved timesheets.

Recalculation order with award snapshots

Allowance recalculation and award recalculation are separate subscribers. Award calculation listens for TimesheetAllowanceLine changes as well as timesheet/time-entry/client-allowance changes, then queues a post-flush award snapshot. This lets award snapshots include current allowance lines.

On this page