diff --git a/resources/views/components/⚡create-payment.blade.php b/resources/views/components/⚡create-payment.blade.php new file mode 100644 index 0000000..87d89a7 --- /dev/null +++ b/resources/views/components/⚡create-payment.blade.php @@ -0,0 +1,135 @@ +with('client')->get()->sortBy('client.abbreviation'); + } + + #[Computed] + public function contacts() + { + if (!$this->invoice_id) { + return collect(); + } + $invoice = Invoice::find($this->invoice_id); + return $invoice?->client?->contacts ?? collect(); + } + + public function updatedInvoiceId(): void + { + $this->contact_id = null; // Reset when invoice changes + } + + + public function mount(?int $invoice_id = null): void + { + $this->invoice_id = $invoice_id; + $this->payment_date = now()->local()->format('Y-m-d'); + } + + public function save() + { + $this->validate(); + Payment::create([ + 'invoice_id' => $this->invoice_id, + 'contact_id'=> $this->contact_id, + 'payment_date' => $this->payment_date, + 'status' => $this->status, + 'payment_method' => $this->payment_method, + 'reference' => $this->reference, + 'amount' => $this->amount, + 'notes' => $this->notes, + ]); + + $this->reset(); + Flux::modal('create-payment')->close(); + $this->dispatch('payment-created'); + } + + +}; +?> + +