refactor: streamline sales and expenses management in client resource

- Move create/edit logic from relation managers to dedicated resource pages
- Add transaction handling with proper rollback in sale create/update
- Fix expense transaction creation by using correct array access
- Set default client from query parameter in sale/expense forms
- Exclude 'type' field from balance creation to prevent errors
This commit is contained in:
Jp
2026-02-10 15:05:36 +08:00
parent 0e4da559d6
commit 0131193b8d
8 changed files with 123 additions and 426 deletions

View File

@@ -28,7 +28,7 @@ class CreateExpense extends CreateRecord
protected function afterCreate(): void
{
$transactions = Arr::only($this->form->getState(), ['transactions']);
$transactions = $this->form->getState()['transactions'] ?? [];
try {
$branch = $this->getRecord()->branch;
@@ -38,7 +38,7 @@ class CreateExpense extends CreateRecord
$data = [
'branch_id' => $branch->id,
'happened_on' => $this->getRecord()->happened_on,
...Arr::first($transaction),
...$transaction,
];
$payload = new CreateTransactionDTO(data: $data, transactionable: $this->getRecord());