diff --git a/app/Listeners/Document/SendDocumentPaymentNotification.php b/app/Listeners/Document/SendDocumentPaymentNotification.php index 5a842743a..ee378ed35 100644 --- a/app/Listeners/Document/SendDocumentPaymentNotification.php +++ b/app/Listeners/Document/SendDocumentPaymentNotification.php @@ -11,10 +11,14 @@ class SendDocumentPaymentNotification * Handle the event. * * @param $event - * @return array + * @return void */ public function handle(Event $event) { + if ($event->request['type'] !== 'income') { + return; + } + $document = $event->document; $transaction = $document->transactions()->latest()->first(); diff --git a/config/type.php b/config/type.php index bcda981ba..920ce1c4a 100644 --- a/config/type.php +++ b/config/type.php @@ -24,6 +24,7 @@ return [ 'due_at' => 'invoices.due_date', ], 'category_type' => 'income', + 'transaction_type' => 'income', 'contact_type' => 'customer', // use contact type 'hide' => [], // for document items 'class' => [], @@ -47,6 +48,7 @@ return [ 'due_at' => 'bills.due_date', ], 'category_type' => 'expense', + 'transaction_type' => 'expense', 'contact_type' => 'vendor', 'hide' => [], ], diff --git a/database/factories/Document.php b/database/factories/Document.php index 6a0123f3f..6ecb0e5b0 100644 --- a/database/factories/Document.php +++ b/database/factories/Document.php @@ -327,7 +327,7 @@ class Document extends AbstractFactory case 'paid': $payment_request = [ 'paid_at' => $updated_document->due_at, - 'type' => 'income', + 'type' => config('type.' . $document->type . '.transaction_type'), ]; if ($init_status === 'partial') {