feat: partial payment field + photo upload from dashboard

- WorkOrderResource: pay_status is now live(); added _partial_amount
  TextInput (visible only when pay_status=partial) that shows current
  paid amount and accepts a new total — dehydrated so it does not save
  directly; _achitat hidden when partial is selected to avoid confusion
- EditWorkOrder.afterSave: creates a Payment record for the difference
  when pay_status=partial and entered amount > existing paidAmount
- WorkOrderDashboard: WithFileUploads + uploadPhotos / deletePhoto
  methods using Spatie MediaLibrary
- Dashboard blade: Foto tab replaced with upload form + gallery with
  per-photo delete buttons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-08 08:16:21 +00:00
parent aa231f4b08
commit 1e7ca0fdfe
4 changed files with 83 additions and 4 deletions
@@ -31,6 +31,26 @@ class EditWorkOrder extends EditRecord
protected function afterSave(): void
{
$this->record->recalcTotal();
// Create payment for the difference when pay_status = partial
if ($this->record->pay_status === 'partial') {
$entered = (float) ($this->form->getState()['_partial_amount'] ?? 0);
$alreadyPaid = $this->record->paidAmount();
$diff = round($entered - $alreadyPaid, 2);
if ($diff > 0.005) {
\App\Models\Tenant\Payment::create([
'company_id' => $this->record->company_id,
'work_order_id' => $this->record->id,
'client_id' => $this->record->client_id,
'user_id' => auth()->id(),
'amount' => $diff,
'method' => 'cash',
'paid_at' => today(),
]);
$this->record->refresh();
}
}
$this->fillForm();
}