Added transaction split events..
This commit is contained in:
parent
9ceae17f22
commit
32eb64a503
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class TransactionSplitted extends Event
|
||||
{
|
||||
public $request;
|
||||
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct($request, $transaction)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class TransactionSplitting extends Event
|
||||
{
|
||||
public $request;
|
||||
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct($request, $transaction)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue