From beade697a87b5ccd54381e932278d04328a63d4d Mon Sep 17 00:00:00 2001 From: Daniel Stock Date: Wed, 22 Oct 2025 16:13:01 +0200 Subject: [PATCH] FIX: saving new invoices was broken because changing a customer would only store billingData, but not a customerId --- .../migrations/2025_09_18_190049_create_invoices_table.php | 2 +- resources/js/pages/Invoices.vue | 2 +- resources/views/invoice.blade.php | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/database/migrations/2025_09_18_190049_create_invoices_table.php b/database/migrations/2025_09_18_190049_create_invoices_table.php index c3f666d..e0d7dd8 100644 --- a/database/migrations/2025_09_18_190049_create_invoices_table.php +++ b/database/migrations/2025_09_18_190049_create_invoices_table.php @@ -20,7 +20,7 @@ public function up(): void $table->date('service_end_date')->nullable(); $table->boolean('is_recurring')->default(false); $table->boolean('is_partial_service')->default(false); - $table->foreignId('customer_id')->constrained()->onDelete('cascade'); + $table->foreignId('customer_id')->nullable()->constrained()->onDelete('cascade'); $table->string('payment_status')->default('draft'); $table->decimal('total_amount', 10, 2); $table->text('title')->nullable(); diff --git a/resources/js/pages/Invoices.vue b/resources/js/pages/Invoices.vue index 5bb2566..57e51a4 100644 --- a/resources/js/pages/Invoices.vue +++ b/resources/js/pages/Invoices.vue @@ -111,7 +111,7 @@ const saveInvoice = async (updatedInvoice: Invoice) => { totalAmount: updatedInvoice.totalAmount, title: updatedInvoice.title, text: updatedInvoice.text, - customer: updatedInvoice.customer, + customerId: updatedInvoice.customer ? updatedInvoice.customer.id : null, billingData: { companyName: updatedInvoice.billingData?.companyName, vatId: updatedInvoice.billingData?.vatId, diff --git a/resources/views/invoice.blade.php b/resources/views/invoice.blade.php index 40b31a7..3c2e233 100644 --- a/resources/views/invoice.blade.php +++ b/resources/views/invoice.blade.php @@ -77,7 +77,11 @@ Rechnungs-Nr. + @if($invoice['paymentStatus'] == 'draft') + Entwurf + @else {{ $invoice['nr'] }} + @endif @if($invoice['customer']['customerNr']) @@ -127,7 +131,7 @@ @if($invoice['text'])
- {{ $invoice['text'] }} + {!! nl2br(e($invoice['text'])) !!}
@endif