diff --git a/app/BulkActions/Sales/Invoices.php b/app/BulkActions/Sales/Invoices.php
index e70a04b53..168eac93c 100644
--- a/app/BulkActions/Sales/Invoices.php
+++ b/app/BulkActions/Sales/Invoices.php
@@ -5,7 +5,7 @@ namespace App\BulkActions\Sales;
use App\Abstracts\BulkAction;
use App\Events\Document\DocumentCancelled;
use App\Events\Document\DocumentCreated;
-use App\Events\Document\DocumentSent;
+use App\Events\Document\DocumentMarkedSent;
use App\Events\Document\PaymentReceived;
use App\Exports\Sales\Invoices as Export;
use App\Jobs\Document\DeleteDocument;
@@ -58,7 +58,7 @@ class Invoices extends BulkAction
continue;
}
- event(new DocumentSent($invoice));
+ event(new DocumentMarkedSent($invoice));
}
}
diff --git a/app/Events/Document/DocumentMarkedSent.php b/app/Events/Document/DocumentMarkedSent.php
new file mode 100644
index 000000000..c79c1fe3f
--- /dev/null
+++ b/app/Events/Document/DocumentMarkedSent.php
@@ -0,0 +1,20 @@
+document = $document;
+ }
+}
diff --git a/app/Http/Controllers/Sales/Invoices.php b/app/Http/Controllers/Sales/Invoices.php
index e2521f12a..be3f68250 100644
--- a/app/Http/Controllers/Sales/Invoices.php
+++ b/app/Http/Controllers/Sales/Invoices.php
@@ -220,7 +220,7 @@ class Invoices extends Controller
*/
public function markSent(Document $invoice)
{
- event(new \App\Events\Document\DocumentSent($invoice));
+ event(new \App\Events\Document\DocumentMarkedSent($invoice));
$message = trans('documents.messages.marked_sent', ['type' => trans_choice('general.invoices', 1)]);
diff --git a/app/Listeners/Document/MarkDocumentSent.php b/app/Listeners/Document/MarkDocumentSent.php
index 266d623fa..70e944756 100644
--- a/app/Listeners/Document/MarkDocumentSent.php
+++ b/app/Listeners/Document/MarkDocumentSent.php
@@ -2,7 +2,8 @@
namespace App\Listeners\Document;
-use App\Events\Document\DocumentSent as Event;
+use App\Events\Document\DocumentMarkedSent;
+use App\Events\Document\DocumentSent;
use App\Jobs\Document\CreateDocumentHistory;
use App\Traits\Jobs;
@@ -10,13 +11,7 @@ class MarkDocumentSent
{
use Jobs;
- /**
- * Handle the event.
- *
- * @param $event
- * @return void
- */
- public function handle(Event $event)
+ public function handle(DocumentMarkedSent|DocumentSent $event): void
{
if ($event->document->status != 'partial') {
$event->document->status = 'sent';
@@ -24,6 +19,11 @@ class MarkDocumentSent
$event->document->save();
}
+ $this->dispatch(new CreateDocumentHistory($event->document, 0, $this->getDescription($event)));
+ }
+
+ public function getDescription(DocumentMarkedSent|DocumentSent $event): string
+ {
$type_text = '';
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
@@ -34,12 +34,8 @@ class MarkDocumentSent
$type = trans_choice($type_text, 1);
- $this->dispatch(
- new CreateDocumentHistory(
- $event->document,
- 0,
- trans('documents.messages.marked_sent', ['type' => $type])
- )
- );
+ $message = ($event instanceof DocumentMarkedSent) ? 'marked_sent' : 'email_sent';
+
+ return trans('documents.messages.' . $message, ['type' => $type]);
}
}
diff --git a/app/Providers/Event.php b/app/Providers/Event.php
index 198f1c903..832bae905 100644
--- a/app/Providers/Event.php
+++ b/app/Providers/Event.php
@@ -57,6 +57,9 @@ class Event extends Provider
'App\Listeners\Document\CreateDocumentTransaction',
'App\Listeners\Document\SendDocumentPaymentNotification',
],
+ 'App\Events\Document\DocumentMarkedSent' => [
+ 'App\Listeners\Document\MarkDocumentSent',
+ ],
'App\Events\Document\DocumentSent' => [
'App\Listeners\Document\MarkDocumentSent',
],
diff --git a/resources/lang/en-GB/documents.php b/resources/lang/en-GB/documents.php
index faee0a7d7..bb4170856 100644
--- a/resources/lang/en-GB/documents.php
+++ b/resources/lang/en-GB/documents.php
@@ -2,84 +2,80 @@
return [
- 'edit_columns' => 'Edit Columns',
- 'empty_items' => 'You have not added any items.',
+ 'edit_columns' => 'Edit Columns',
+ 'empty_items' => 'You have not added any items.',
+ 'grand_total' => 'Grand Total',
+ 'accept_payment_online' => 'Accept Payments Online',
+ 'transaction' => 'A payment for :amount was made using :account.',
+ 'billing' => 'Billing',
+ 'advanced' => 'Advanced',
- 'invoice_detail' => [
- 'marked' => ' You marked this invoice as',
- 'services' => 'Services',
- 'another_item' => 'Another Item',
- 'another_description' => 'and another description',
- 'more_item' => '+:count more item',
+ 'invoice_detail' => [
+ 'marked' => 'You marked this invoice as',
+ 'services' => 'Services',
+ 'another_item' => 'Another Item',
+ 'another_description' => 'and another description',
+ 'more_item' => '+:count more item',
],
- 'grand_total' => 'Grand Total',
-
- 'accept_payment_online' => 'Accept Payments Online',
-
- 'transaction' => 'A payment for :amount was made using :account.',
-
- 'billing' => 'Billing',
- 'advanced' => 'Advanced',
-
'statuses' => [
- 'draft' => 'Draft',
- 'sent' => 'Sent',
- 'expired' => 'Expired',
- 'viewed' => 'Viewed',
- 'approved' => 'Approved',
- 'received' => 'Received',
- 'refused' => 'Refused',
- 'restored' => 'Restored',
- 'reversed' => 'Reversed',
- 'partial' => 'Partial',
- 'paid' => 'Paid',
- 'pending' => 'Pending',
- 'invoiced' => 'Invoiced',
- 'overdue' => 'Overdue',
- 'unpaid' => 'Unpaid',
- 'cancelled' => 'Cancelled',
- 'voided' => 'Voided',
- 'completed' => 'Completed',
- 'shipped' => 'Shipped',
- 'refunded' => 'Refunded',
- 'failed' => 'Failed',
- 'denied' => 'Denied',
- 'processed' => 'Processed',
- 'open' => 'Open',
- 'closed' => 'Closed',
- 'billed' => 'Billed',
- 'delivered' => 'Delivered',
- 'returned' => 'Returned',
- 'drawn' => 'Drawn',
- 'not_billed' => 'Not Billed',
- 'issued' => 'Issued',
- 'not_invoiced' => 'Not Invoiced',
- 'confirmed' => 'Confirmed',
- 'not_confirmed' => 'Not Confirmed',
- 'active' => 'Active',
- 'ended' => 'Ended',
+ 'draft' => 'Draft',
+ 'sent' => 'Sent',
+ 'expired' => 'Expired',
+ 'viewed' => 'Viewed',
+ 'approved' => 'Approved',
+ 'received' => 'Received',
+ 'refused' => 'Refused',
+ 'restored' => 'Restored',
+ 'reversed' => 'Reversed',
+ 'partial' => 'Partial',
+ 'paid' => 'Paid',
+ 'pending' => 'Pending',
+ 'invoiced' => 'Invoiced',
+ 'overdue' => 'Overdue',
+ 'unpaid' => 'Unpaid',
+ 'cancelled' => 'Cancelled',
+ 'voided' => 'Voided',
+ 'completed' => 'Completed',
+ 'shipped' => 'Shipped',
+ 'refunded' => 'Refunded',
+ 'failed' => 'Failed',
+ 'denied' => 'Denied',
+ 'processed' => 'Processed',
+ 'open' => 'Open',
+ 'closed' => 'Closed',
+ 'billed' => 'Billed',
+ 'delivered' => 'Delivered',
+ 'returned' => 'Returned',
+ 'drawn' => 'Drawn',
+ 'not_billed' => 'Not Billed',
+ 'issued' => 'Issued',
+ 'not_invoiced' => 'Not Invoiced',
+ 'confirmed' => 'Confirmed',
+ 'not_confirmed' => 'Not Confirmed',
+ 'active' => 'Active',
+ 'ended' => 'Ended',
],
'form_description' => [
- 'companies' => 'Change the address, logo, and other information for your company.',
- 'billing' => 'Billing details appears in your document.',
- 'advanced' => 'Select the category, add or edit the footer, and add attachments to your :type.',
- 'attachment' => 'Download the files attached to this :type',
+ 'companies' => 'Change the address, logo, and other information for your company.',
+ 'billing' => 'Billing details appears in your document.',
+ 'advanced' => 'Select the category, add or edit the footer, and add attachments to your :type.',
+ 'attachment' => 'Download the files attached to this :type',
],
'messages' => [
- 'email_sent' => ':type email has been sent!',
- 'marked_as' => ':type marked as :status!',
- 'marked_sent' => ':type marked as sent!',
- 'marked_paid' => ':type marked as paid!',
- 'marked_viewed' => ':type marked as viewed!',
- 'marked_cancelled' => ':type marked as cancelled!',
- 'marked_received' => ':type marked as received!',
+ 'email_sent' => ':type email has been sent!',
+ 'marked_as' => ':type marked as :status!',
+ 'marked_sent' => ':type marked as sent!',
+ 'marked_paid' => ':type marked as paid!',
+ 'marked_viewed' => ':type marked as viewed!',
+ 'marked_cancelled' => ':type marked as cancelled!',
+ 'marked_received' => ':type marked as received!',
],
'recurring' => [
- 'auto_generated' => 'Auto-generated',
+ 'auto_generated' => 'Auto-generated',
'tooltip' => [
'document_date' => 'The :type date will be automatically assigned based on the :type schedule and frequency.',