Skip to content

Commit 5a649ff

Browse files
nielsdrost7claude
andcommitted
fix: restore develop's modal EditAction on the invoices table
The develop test suite asserts the modal edit flow on the list; the EditInvoice page stays reachable via its route and the copy/credit note redirects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b1c8c29 commit 5a649ff

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

Modules/Invoices/Filament/Company/Resources/Invoices/Tables/InvoicesTable.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,34 @@ public static function configure(Table $table): Table
7878
->recordActions([
7979
ActionGroup::make([
8080
EditAction::make()
81-
->visible(fn () => auth()->user()?->can(Permission::EDIT_INVOICES->value)),
81+
->visible(fn () => auth()->user()?->can(Permission::EDIT_INVOICES->value))
82+
->mutateDataUsing(function (array $data, Invoice $record) {
83+
$data['invoiceItems'] = $record->invoiceItems()->get()->map(function ($item) {
84+
$product = $item->product;
85+
86+
return [
87+
'id' => $item->id,
88+
'product_id' => $item->product_id,
89+
'product_name' => $product?->product_name ?? '',
90+
'item_name' => $item->item_name,
91+
'quantity' => $item->quantity,
92+
'price' => $item->price,
93+
'discount' => $item->discount,
94+
'subtotal' => $item->subtotal,
95+
'tax_1' => $item->tax_1,
96+
'tax_2' => $item->tax_2,
97+
'tax_rate_id' => $item->tax_rate_id,
98+
'tax_rate_2_id' => $item->tax_rate_2_id,
99+
'description' => $item->description,
100+
];
101+
})->toArray();
102+
103+
return $data;
104+
})
105+
->action(function (Invoice $record, array $data) {
106+
app(\Modules\Invoices\Services\InvoiceService::class)->updateInvoice($record, $data);
107+
})
108+
->modalWidth('full'),
82109
Action::make('download pdf')
83110
->visible(fn () => auth()->user()?->can(Permission::DOWNLOAD_INVOICES->value))
84111
->label(trans('ip.download_pdf'))

0 commit comments

Comments
 (0)