diff --git a/app/Listeners/Document/MarkDocumentReceived.php b/app/Listeners/Document/MarkDocumentReceived.php index e1d8d1d3e..eba419f48 100644 --- a/app/Listeners/Document/MarkDocumentReceived.php +++ b/app/Listeners/Document/MarkDocumentReceived.php @@ -18,7 +18,7 @@ class MarkDocumentReceived */ public function handle(Event $event) { - if ($event->document->status != 'partial') { + if (! in_array($event->document->status, ['partial', 'paid'])) { $event->document->status = 'received'; $event->document->save(); diff --git a/app/Listeners/Document/SendDocumentRecurringNotification.php b/app/Listeners/Document/SendDocumentRecurringNotification.php index 6725f8512..0934861a9 100644 --- a/app/Listeners/Document/SendDocumentRecurringNotification.php +++ b/app/Listeners/Document/SendDocumentRecurringNotification.php @@ -36,7 +36,9 @@ class SendDocumentRecurringNotification $document->contact->notify(new $notification($document, "{$document->type}_recur_customer")); } - event(new DocumentSent($document)); + $sent = config('type.document.' . $document->type . '.auto_send', DocumentSent::class); + + event(new $sent($document)); // Check if should notify users if (! $config['notify_user']) { diff --git a/config/type.php b/config/type.php index 189a94808..1c65e8940 100644 --- a/config/type.php +++ b/config/type.php @@ -143,6 +143,7 @@ return [ 'notify_contact' => true, 'notify_user' => true, ], + 'auto_send' => 'App\Events\Document\DocumentSent', 'script' => [ 'folder' => 'common', 'file' => 'documents', @@ -192,6 +193,7 @@ return [ 'notification' => [ ], + 'auto_send' => 'App\Events\Document\DocumentSent', 'image_empty_page' => 'public/img/empty_pages/recurring_templates.png', 'script' => [ 'folder' => 'common', @@ -244,6 +246,7 @@ return [ 'notify_contact' => false, 'notify_user' => true, ], + 'auto_send' => 'App\Events\Document\DocumentReceived', 'script' => [ 'folder' => 'common', 'file' => 'documents', @@ -291,6 +294,7 @@ return [ 'notification' => [ ], + 'auto_send' => 'App\Events\Document\DocumentReceived', 'image_empty_page' => 'public/img/empty_pages/recurring_templates.png', 'script' => [ 'folder' => 'common',