From 0bf994ef47962f0bab06317269c3cc40c495bb40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=87ak=C4=B1rel?= Date: Wed, 21 Apr 2021 00:21:29 +0300 Subject: [PATCH] Send only invoice notification for customers --- app/Console/Commands/RecurringCheck.php | 7 +++++-- .../Document/SendDocumentRecurringNotification.php | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/RecurringCheck.php b/app/Console/Commands/RecurringCheck.php index d2644ca40..e19e44d79 100644 --- a/app/Console/Commands/RecurringCheck.php +++ b/app/Console/Commands/RecurringCheck.php @@ -10,7 +10,8 @@ use App\Models\Banking\Transaction; use App\Models\Common\Company; use App\Models\Common\Recurring; use App\Models\Document\Document; -use App\Notifications\Sale\Invoice as Notification; +use App\Notifications\Purchase\Bill as BillNotification; +use App\Notifications\Sale\Invoice as InvoiceNotification; use App\Utilities\Date; use Illuminate\Console\Command; @@ -133,7 +134,9 @@ class RecurringCheck extends Command event(new DocumentCreated($clone, request())); if ($clone->type === Document::INVOICE_TYPE) { - event(new DocumentRecurring($clone, Notification::class)); + event(new DocumentRecurring($clone, InvoiceNotification::class)); + } elseif ($clone->type === Document::BILL_TYPE) { + event(new DocumentRecurring($clone, BillNotification::class)); } break; diff --git a/app/Listeners/Document/SendDocumentRecurringNotification.php b/app/Listeners/Document/SendDocumentRecurringNotification.php index 77f3b5bf0..885e40686 100644 --- a/app/Listeners/Document/SendDocumentRecurringNotification.php +++ b/app/Listeners/Document/SendDocumentRecurringNotification.php @@ -3,6 +3,7 @@ namespace App\Listeners\Document; use App\Events\Document\DocumentRecurring as Event; +use App\Models\Document\Document; class SendDocumentRecurringNotification { @@ -18,7 +19,7 @@ class SendDocumentRecurringNotification $notification = $event->notification; // Notify the customer - if ($document->contact && !empty($document->contact_email)) { + if ($document->type === Document::INVOICE_TYPE && $document->contact && !empty($document->contact_email)) { $document->contact->notify(new $notification($document, "{$document->type}_recur_customer")); }