Send only invoice notification for customers

This commit is contained in:
Burak Çakırel 2021-04-21 00:21:29 +03:00
parent 96f9a99077
commit 0bf994ef47
No known key found for this signature in database
GPG Key ID: 48FFBB7771B99C7C
2 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -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"));
}