Skip to content

[Invoices]: Create a recurring invoice from an existing invoice (edit action) #586

Open

Description

@nielsdrost7

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 suggested start_at for monthly frequency, submit.

Assert

  • RecurringInvoice created: invoice_id = source, frequency monthly, start_at = invoice date + 1 month, numbering defaulted from the invoice.
  • 3 RecurringInvoiceItem rows 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_recurring action 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 RecurringInvoice linked 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

  1. nielsdrost7 commented on Jul 24, 2026

    @nielsdrost7
    CollaboratorAuthor

    SMART Plan — Recurring invoice creation from invoice edit page

    Context/Epic: Recurring-Invoices (#52)

    Confirmed: Modules/Invoices/Filament/Company/Resources/Invoices/Pages/EditInvoice.php lines 104-110 show create_recurring action is still a stub displaying "not yet implemented" toast.

    Supporting infrastructure in place:

    • RecurringInvoiceService::createRecurringInvoice() exists and is ready to use
    • RecurringInvoice model with frequency, start_at, end_at fields confirmed
    • copy_invoice action (lines 112-131) provides the exact pattern for item-copying logic (replicates invoice, then iterates invoiceItems to copy each one)
    • Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Resources/Schemas/RecurringInvoiceForm.php exists for the form schema

    Achievable implementation plan:

    1. Create a modal form action (similar to 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), optional end_at, numbering group (default: source invoice's group)
    2. On submit: call RecurringInvoiceService::createRecurringInvoice() to create the base record
    3. Copy invoice items: iterate $this->getRecord()->invoiceItems and create RecurringInvoiceItem rows matching the pattern from lines 122-128
    4. Redirect to the new recurring invoice's edit page + success toast with link
    5. Hide action if invoice already has an active schedule (check RecurringInvoice::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:

    • Action opens a form modal pre-filled with frequency/numbering from source invoice
    • Submitting creates RecurringInvoice + linked RecurringInvoiceItem rows matching source
    • Action is hidden for invoices with existing active schedule
    • Toast shows creation success + links to new recurring invoice
    • Changing frequency in modal live-updates suggested start_at
    • Test: EditInvoiceHeaderActionsTest.php (existing) covers the new action

    Time-bound: One sprint; independent of generation engine (CRUD only).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinedRefined with SMART plan / test suggestions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions