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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user