From 32eb64a503b1955f018b3427b1dabd6b049e25ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 4 Oct 2024 15:02:30 +0100 Subject: [PATCH] Added transaction split events.. --- app/Events/Banking/TransactionSplitted.php | 23 +++++++++++++++++++ app/Events/Banking/TransactionSplitting.php | 23 +++++++++++++++++++ .../MatchBankingDocumentTransaction.php | 2 +- app/Jobs/Banking/SplitTransaction.php | 6 +++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 app/Events/Banking/TransactionSplitted.php create mode 100644 app/Events/Banking/TransactionSplitting.php diff --git a/app/Events/Banking/TransactionSplitted.php b/app/Events/Banking/TransactionSplitted.php new file mode 100644 index 000000000..032f88ab2 --- /dev/null +++ b/app/Events/Banking/TransactionSplitted.php @@ -0,0 +1,23 @@ +request = $request; + $this->transaction = $transaction; + } +} diff --git a/app/Events/Banking/TransactionSplitting.php b/app/Events/Banking/TransactionSplitting.php new file mode 100644 index 000000000..2d975713e --- /dev/null +++ b/app/Events/Banking/TransactionSplitting.php @@ -0,0 +1,23 @@ +request = $request; + $this->transaction = $transaction; + } +} diff --git a/app/Jobs/Banking/MatchBankingDocumentTransaction.php b/app/Jobs/Banking/MatchBankingDocumentTransaction.php index 129555ab6..373067a62 100644 --- a/app/Jobs/Banking/MatchBankingDocumentTransaction.php +++ b/app/Jobs/Banking/MatchBankingDocumentTransaction.php @@ -29,7 +29,7 @@ class MatchBankingDocumentTransaction extends Job \DB::transaction(function () { $this->transaction = $this->dispatch(new UpdateTransaction($this->transaction, [ 'document_id' => $this->model->id, - 'type' => $this->transaction->type, // Set missing type get default income typr for UpdateTransaction job. + 'type' => $this->transaction->type, // Set missing type get default income type for UpdateTransaction job. ])); $this->model->save(); diff --git a/app/Jobs/Banking/SplitTransaction.php b/app/Jobs/Banking/SplitTransaction.php index 67e0a0320..3975eb309 100644 --- a/app/Jobs/Banking/SplitTransaction.php +++ b/app/Jobs/Banking/SplitTransaction.php @@ -3,6 +3,8 @@ namespace App\Jobs\Banking; use App\Abstracts\Job; +use App\Events\Banking\TransactionSplitted; +use App\Events\Banking\TransactionSplitting; use App\Interfaces\Job\ShouldUpdate; use App\Models\Document\Document; use App\Traits\Transactions; @@ -17,6 +19,8 @@ class SplitTransaction extends Job implements ShouldUpdate { $this->checkAmount(); + event(new TransactionSplitting($this->request, $this->model)); + DB::transaction(function () { foreach ($this->request->items as $item) { $transaction = $this->model->duplicate(); @@ -44,6 +48,8 @@ class SplitTransaction extends Job implements ShouldUpdate $this->model->save(); }); + event(new TransactionSplitted($this->request, $this->model)); + return $this->request->items; }