Repository navigation
[Invoices]: Create a recurring invoice from an existing invoice (edit action) #586
Description
The EditInvoice header action bar (Modules/Invoices/Filament/Company/Resources/Invoices/Pages/EditInvoice.php) has a create_recurring action that currently only shows a "not yet implemented" warning toast. It should create a RecurringInvoice record (see Modules/Invoices/Models/RecurringInvoice.php) seeded from the current invoice's line items and customer, then let the user manage/confirm the recurrence schedule.
Reopening: the create_recurring action is still the "not yet implemented" stub (Modules/Invoices/Filament/Company/Resources/Invoices/Pages/EditInvoice.php:104-110 on develop @ 9ad1b60) — no code path creates a RecurringInvoice from an invoice.
The EditInvoice header action bar (Modules/Invoices/Filament/Company/Resources/Invoices/Pages/EditInvoice.php) has a create_recurring action that currently only shows a "not yet implemented" warning toast (introduced as a stub in PR #575, feature/542-invoice-edit-page). It should create a RecurringInvoice seeded from the current invoice, then let the user manage the schedule. Part of Epic #52.
v1 spec: invoice view modal (application/modules/invoices/views/modal_create_recurring.php, opened from views/view.php:47, posting to application/modules/invoices/controllers/Ajax.php:491 create_recurring()), with start-date auto-suggest = invoice date + chosen frequency (Ajax.php:526 get_recur_start_date() → increment_user_date()).
Specific
Replace the stub with a modal form: frequency (preset/custom per the frequency-parity issue), start_at (default: invoice date advanced by one frequency step, live-updating when frequency changes — v1 get_recur_start_date), optional end_at, numbering group (default: invoice's group). On submit: create the RecurringInvoice for the current invoice's customer and copy the invoice's line items into RecurringInvoiceItem rows (name, description, qty, price, tax rates, discounts, display order), then redirect to the new recurring invoice's edit page.
Introduced as a stub in PR #575 (feature/542-invoice-edit-page).
Part of the broader #52 Epic Recurring-Invoices.
Measurable
- One click + confirm turns any invoice into a schedule in under 30 seconds with zero re-typing of items.
- The action is hidden when the invoice already has an active recurring schedule.
- Toast confirms creation and links to the new record.
Achievable
RecurringInvoiceService::createRecurringInvoice() already exists; add an item-copy step (source: invoice->invoiceItems) analogous to the working copy_invoice action in the same file (EditInvoice.php:112-131).
Relevant
Primary v1 entry point for recurring billing — users recur an invoice they already wrote; a standalone create form with a raw numeric invoice_id field (Schemas/RecurringInvoiceForm.php:17-19) is not a substitute.
Time-Bound
One sprint; independent of the generation engine (schedule CRUD suffices), part of Epic #52.
Arrange
- Invoice with 3 items (mixed tax rates, one discounted) for a customer; no existing schedule.
Act
- Open EditInvoice, trigger
create_recurring, accept suggestedstart_atfor monthly frequency, submit.
Assert
-
RecurringInvoicecreated:invoice_id= source, frequency monthly,start_at= invoice date + 1 month, numbering defaulted from the invoice. - 3
RecurringInvoiceItemrows match source items (name, qty, price, tax rates, discount, order). - Redirect lands on the recurring invoice edit page; success toast shown.
- Action hidden on an invoice that already has an active schedule.
- Changing frequency in the modal updates the suggested
start_at.
Acceptance criteria
-
create_recurringaction on the invoice edit page opens a form to configure recurrence (frequency, start date, end condition) pre-filled from the source invoice. - Submitting creates a
RecurringInvoicelinked to the source invoice's customer and item set. - Action is hidden/disabled for invoices that already have an active recurring invoice, if applicable.
- Toast confirms creation and links to the new recurring invoice.
Activity
nielsdrost7 commentedon Jul 24, 2026
SMART Plan — Recurring invoice creation from invoice edit page
Confirmed:
Modules/Invoices/Filament/Company/Resources/Invoices/Pages/EditInvoice.phplines 104-110 showcreate_recurringaction is still a stub displaying "not yet implemented" toast.Supporting infrastructure in place:
RecurringInvoiceService::createRecurringInvoice()exists and is ready to useRecurringInvoicemodel withfrequency,start_at,end_atfields confirmedcopy_invoiceaction (lines 112-131) provides the exact pattern for item-copying logic (replicates invoice, then iteratesinvoiceItemsto copy each one)Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Resources/Schemas/RecurringInvoiceForm.phpexists for the form schemaAchievable implementation plan:
create_credit_note, lines 67-94) that opens a form with: frequency selector (preset/custom),start_at(auto-calculated from invoice date + 1 frequency step), optionalend_at, numbering group (default: source invoice's group)RecurringInvoiceService::createRecurringInvoice()to create the base record$this->getRecord()->invoiceItemsand createRecurringInvoiceItemrows matching the pattern from lines 122-128RecurringInvoice::where('invoice_id', $this->getRecord()->id)->active()or similar scoping)v1 reference behavior (from issue): modal on invoice view → submit → start-date auto-suggestion based on frequency.
Measurable acceptance:
start_atEditInvoiceHeaderActionsTest.php(existing) covers the new actionTime-bound: One sprint; independent of generation engine (CRUD only).