Repository navigation
[Invoices]: Stop a recurring invoice from the list #643
Description
v1 lets users stop a recurring schedule without deleting it: application/modules/invoices/controllers/Recurring.php:51-59 → Mdl_invoices_recurring::stop() (application/modules/invoices/models/Mdl_invoices_recurring.php:120-129) sets recur_end_date = today and recur_next_date = NULL; the list then shows it as "inactive" (computed recur_status, Mdl_invoices_recurring.php:61). v2's RecurringInvoicesTable (Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Tables/RecurringInvoicesTable.php) offers only Edit and Delete — the only way to end a schedule is destroying it (losing history) or hand-editing end_at.
Depends on the next_run_at column from the generation-engine issue (Epic #52). Reactivation is tracked separately in #362.
Specific
Add a stop record action (icon ban, requires confirmation, permission EDIT_INVOICES) to RecurringInvoicesTable that calls RecurringInvoiceService::stop(RecurringInvoice $r): set end_at = today, next_run_at = null. Visible only while the schedule is active (next_run_at not null). The status column shows "stopped"/"inactive" afterwards.
Measurable
- A stopped schedule is never selected by the engine's due query again.
- The row remains in the list with its history (generated invoices keep their
recurring_invoice_idlink). - Action hidden on already-stopped rows; Delete remains available for both states.
Achievable
One Filament Action + one 3-line service method + visibility closure; mirrors the existing permission-gated actions in the same table (RecurringInvoicesTable.php:45-58).
Relevant
Core lifecycle operation (epic #52: "Pausing stops generation without deleting history"); v1 parity; prerequisite for #362 (reactivate).
Time-Bound
Half a sprint alongside the engine schema; part of Epic #52.
Arrange
- Active monthly schedule with
next_run_at = today, one previously generated invoice linked to it.
Act
- Trigger the
stoptable action as a user withEDIT_INVOICES; then run the generation engine.
Assert
-
end_at = today,next_run_at = null; status column shows stopped/inactive. - Engine run generates nothing for this schedule.
- Previously generated invoice still exists and still references the schedule.
-
stophidden on the stopped row; hidden entirely for users withoutEDIT_INVOICES.
Activity