From fc8420cf02930e63b57243b3eb295debef4b85b1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 3 Jun 2023 22:49:48 +1000 Subject: [PATCH] Code cleanup --- app/Services/Invoice/ApplyPayment.php | 12 +----------- app/Services/Invoice/CreateInvitations.php | 5 +---- app/Services/Invoice/GenerateDeliveryNote.php | 16 +--------------- app/Services/Invoice/HandleCancellation.php | 7 +------ app/Services/Invoice/HandleRestore.php | 5 +---- app/Services/Invoice/HandleReversal.php | 5 +---- app/Services/Invoice/MarkInvoiceDeleted.php | 5 +---- app/Services/Invoice/SendEmail.php | 13 +------------ app/Services/Invoice/TriggeredActions.php | 9 +-------- app/Services/Invoice/UpdateReminder.php | 7 +------ 10 files changed, 10 insertions(+), 74 deletions(-) diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index dd43a7dc7288..63763dfa58ef 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -11,25 +11,15 @@ namespace App\Services\Invoice; -use App\Jobs\Ninja\TransactionLog; use App\Models\Invoice; use App\Models\Payment; -use App\Models\TransactionEvent; use App\Services\AbstractService; class ApplyPayment extends AbstractService { - private $invoice; - private $payment; - - private $payment_amount; - - public function __construct($invoice, $payment, $payment_amount) + public function __construct(private Invoice $invoice, private Payment $payment, private float $payment_amount) { - $this->invoice = $invoice; - $this->payment = $payment; - $this->payment_amount = $payment_amount; } /* Apply payment to a single invoice */ diff --git a/app/Services/Invoice/CreateInvitations.php b/app/Services/Invoice/CreateInvitations.php index 1b352caf6f5a..5261df58f1b3 100644 --- a/app/Services/Invoice/CreateInvitations.php +++ b/app/Services/Invoice/CreateInvitations.php @@ -23,11 +23,8 @@ class CreateInvitations extends AbstractService { use MakesHash; - private $invoice; - - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 5c369a9a5c05..86ba365545c5 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -28,27 +28,13 @@ class GenerateDeliveryNote { use MakesHash, PdfMaker; - /** - * @var \App\Models\Invoice - */ - private $invoice; - - /** - * @var \App\Models\ClientContact - */ - private $contact; - /** * @var mixed */ private $disk; - public function __construct(Invoice $invoice, ClientContact $contact = null, $disk = null) + public function __construct(private Invoice $invoice, private ?ClientContact $contact = null, $disk = null) { - $this->invoice = $invoice; - - $this->contact = $contact; - $this->disk = $disk ?? config('filesystems.default'); } diff --git a/app/Services/Invoice/HandleCancellation.php b/app/Services/Invoice/HandleCancellation.php index 7cf689a30a42..fe83909e3e36 100644 --- a/app/Services/Invoice/HandleCancellation.php +++ b/app/Services/Invoice/HandleCancellation.php @@ -12,10 +12,7 @@ namespace App\Services\Invoice; use App\Events\Invoice\InvoiceWasCancelled; -use App\Jobs\Ninja\TransactionLog; -use App\Models\Client; use App\Models\Invoice; -use App\Models\TransactionEvent; use App\Services\AbstractService; use App\Utils\Ninja; use App\Utils\Traits\GeneratesCounter; @@ -25,9 +22,7 @@ class HandleCancellation extends AbstractService { use GeneratesCounter; - private $invoice; - - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { $this->invoice = $invoice; } diff --git a/app/Services/Invoice/HandleRestore.php b/app/Services/Invoice/HandleRestore.php index b2878a38b56b..18502189f485 100644 --- a/app/Services/Invoice/HandleRestore.php +++ b/app/Services/Invoice/HandleRestore.php @@ -23,17 +23,14 @@ class HandleRestore extends AbstractService { use GeneratesCounter; - private $invoice; - private $payment_total = 0; private $total_payments = 0; private $adjustment_amount = 0; - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/HandleReversal.php b/app/Services/Invoice/HandleReversal.php index 008fd44534af..58d566e51ce0 100644 --- a/app/Services/Invoice/HandleReversal.php +++ b/app/Services/Invoice/HandleReversal.php @@ -23,11 +23,8 @@ class HandleReversal extends AbstractService { use GeneratesCounter; - private $invoice; - - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index d3ed85a2808e..27291123d56e 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -21,17 +21,14 @@ class MarkInvoiceDeleted extends AbstractService { use GeneratesCounter; - public $invoice; - private $adjustment_amount = 0; private $total_payments = 0; private $balance_adjustment = 0; - public function __construct(Invoice $invoice) + public function __construct(public Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/SendEmail.php b/app/Services/Invoice/SendEmail.php index b71677457307..5cf05dd6a3d9 100644 --- a/app/Services/Invoice/SendEmail.php +++ b/app/Services/Invoice/SendEmail.php @@ -18,19 +18,8 @@ use App\Services\AbstractService; class SendEmail extends AbstractService { - protected $invoice; - - protected $reminder_template; - - protected $contact; - - public function __construct(Invoice $invoice, $reminder_template = null, ClientContact $contact = null) + public function __construct(protected Invoice $invoice, protected $reminder_template = null, protected ?ClientContact $contact = null) { - $this->invoice = $invoice; - - $this->reminder_template = $reminder_template; - - $this->contact = $contact; } /** diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index 4fb1342391ae..7c6e7c4f6ad9 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -23,17 +23,10 @@ class TriggeredActions extends AbstractService { use GeneratesCounter; - private $request; - - private $invoice; - private bool $updated = false; - public function __construct(Invoice $invoice, Request $request) + public function __construct(private Invoice $invoice, private Request $request) { - $this->request = $request; - - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/UpdateReminder.php b/app/Services/Invoice/UpdateReminder.php index cba87bacdf84..f552fb141e85 100644 --- a/app/Services/Invoice/UpdateReminder.php +++ b/app/Services/Invoice/UpdateReminder.php @@ -18,14 +18,9 @@ use Carbon\Carbon; class UpdateReminder extends AbstractService { - public $invoice; - public $settings; - - public function __construct(Invoice $invoice, $settings = null) + public function __construct(public Invoice $invoice, public mixed $settings = null) { - $this->invoice = $invoice; - $this->settings = $settings; } /* We only support setting reminders based on the due date, not the partial due date */