Change 'Quote' & 'Invoice' service implementation (#3327)

* Change '__invoke' to 'run' for Invoice services

*  Change '__invoke' to 'run' for Quote services
This commit is contained in:
Benjamin Beganović 2020-02-14 04:32:22 +01:00 committed by GitHub
parent 4a3d37a42b
commit 7dd6f814ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 41 additions and 41 deletions

View File

@ -31,10 +31,9 @@ class ApplyNumber
$this->client = $client; $this->client = $client;
} }
public function __invoke($invoice) public function run($invoice)
{ {
if ($invoice->number != '')
if ($invoice->number != '')
return $invoice; return $invoice;
switch ($this->client->getSetting('counter_number_applied')) { switch ($this->client->getSetting('counter_number_applied')) {
@ -46,12 +45,12 @@ class ApplyNumber
$invoice->number = $this->getNextInvoiceNumber($this->client); $invoice->number = $this->getNextInvoiceNumber($this->client);
} }
break; break;
default: default:
# code... # code...
break; break;
} }
return $invoice; return $invoice;
} }
} }

View File

@ -26,7 +26,7 @@ class ApplyPayment
$this->invoice = $invoice; $this->invoice = $invoice;
} }
public function __invoke($payment, $payment_amount) public function run($payment, $payment_amount)
{ {
UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment_amount*-1), $payment->company); UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment_amount*-1), $payment->company);
@ -55,7 +55,7 @@ class ApplyPayment
} elseif($payment_amount < $this->invoice->balance) { //partial invoice payment made } elseif($payment_amount < $this->invoice->balance) { //partial invoice payment made
$this->invoice->service()->clearPartial()->updateBalance($payment_amount*-1); $this->invoice->service()->clearPartial()->updateBalance($payment_amount*-1);
} }
return $this->invoice; return $this->invoice;
} }
} }

View File

@ -21,9 +21,10 @@ class CreateInvitations
public function __construct() public function __construct()
{ {
// ..
} }
public function __invoke($invoice) public function run($invoice)
{ {
$contacts = $invoice->client->contacts; $contacts = $invoice->client->contacts;
@ -46,4 +47,4 @@ class CreateInvitations
return $invoice; return $invoice;
} }
} }

View File

@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Storage;
class GetInvoicePdf class GetInvoicePdf
{ {
public function __invoke($invoice, $contact = null) public function run($invoice, $contact = null)
{ {
if(!$contact) if(!$contact)
@ -33,7 +33,7 @@ class GetInvoicePdf
if(!$file) if(!$file)
{ {
$file_path = CreateInvoicePdf::dispatchNow($invoice, $invoice->company, $contact); $file_path = CreateInvoicePdf::dispatchNow($invoice, $invoice->company, $contact);
} }

View File

@ -38,15 +38,15 @@ class InvoiceService
} }
/** /**
* Marks as invoice as paid * Marks as invoice as paid
* and executes child sub functions * and executes child sub functions
* @return $this InvoiceService object * @return $this InvoiceService object
*/ */
public function markPaid() public function markPaid()
{ {
$mark_invoice_paid = new MarkPaid($this->client_service); $mark_invoice_paid = new MarkPaid($this->client_service);
$this->invoice = $mark_invoice_paid($this->invoice); $this->invoice = $mark_invoice_paid->run($this->invoice);
return $this; return $this;
} }
@ -59,7 +59,7 @@ class InvoiceService
{ {
$apply_number = new ApplyNumber($this->invoice->client); $apply_number = new ApplyNumber($this->invoice->client);
$this->invoice = $apply_number($this->invoice); $this->invoice = $apply_number->run($this->invoice);
return $this; return $this;
} }
@ -74,7 +74,7 @@ class InvoiceService
{ {
$apply_payment = new ApplyPayment($this->invoice); $apply_payment = new ApplyPayment($this->invoice);
$this->invoice = $apply_payment($payment, $payment_amount); $this->invoice = $apply_payment->run($payment, $payment_amount);
return $this; return $this;
} }
@ -90,7 +90,7 @@ class InvoiceService
{ {
$update_balance = new UpdateBalance($this->invoice); $update_balance = new UpdateBalance($this->invoice);
$this->invoice = $update_balance($balance_adjustment); $this->invoice = $update_balance->run($balance_adjustment);
return $this; return $this;
} }
@ -99,7 +99,7 @@ class InvoiceService
{ {
$create_invitation = new CreateInvitations(); $create_invitation = new CreateInvitations();
$this->invoice = $create_invitation($this->invoice); $this->invoice = $create_invitation->run($this->invoice);
return $this; return $this;
} }
@ -108,7 +108,7 @@ class InvoiceService
{ {
$mark_sent = new MarkSent($this->invoice->client); $mark_sent = new MarkSent($this->invoice->client);
$this->invoice = $mark_sent($this->invoice); $this->invoice = $mark_sent->run($this->invoice);
return $this; return $this;
} }
@ -117,7 +117,7 @@ class InvoiceService
{ {
$get_invoice_pdf = new GetInvoicePdf(); $get_invoice_pdf = new GetInvoicePdf();
return $get_invoice_pdf($this->invoice, $contact); return $get_invoice_pdf->run($this->invoice, $contact);
} }
@ -178,7 +178,7 @@ class InvoiceService
/** /**
* Saves the invoice * Saves the invoice
* @return Invoice object * @return Invoice object
*/ */
public function save() :?Invoice public function save() :?Invoice
{ {

View File

@ -28,7 +28,7 @@ class MarkPaid
$this->client_service = $client_service; $this->client_service = $client_service;
} }
public function __invoke($invoice) public function run($invoice)
{ {
if($invoice->status_id == Invoice::STATUS_DRAFT) if($invoice->status_id == Invoice::STATUS_DRAFT)
@ -57,7 +57,7 @@ class MarkPaid
event(new PaymentWasCreated($payment, $payment->company)); event(new PaymentWasCreated($payment, $payment->company));
UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment->amount*-1), $payment->company); UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment->amount*-1), $payment->company);
$this->client_service $this->client_service
->updateBalance($payment->amount*-1) ->updateBalance($payment->amount*-1)
->updatePaidToDate($payment->amount) ->updatePaidToDate($payment->amount)

View File

@ -25,7 +25,7 @@ class MarkSent
$this->client = $client; $this->client = $client;
} }
public function __invoke($invoice) public function run($invoice)
{ {
/* Return immediately if status is not draft */ /* Return immediately if status is not draft */

View File

@ -24,7 +24,7 @@ class UpdateBalance
} }
public function __invoke($balance_adjustment) public function run($balance_adjustment)
{ {
if ($this->invoice->is_deleted) { if ($this->invoice->is_deleted) {
@ -44,4 +44,4 @@ class UpdateBalance
return $this->invoice; return $this->invoice;
} }
} }

View File

@ -15,7 +15,7 @@ class ApplyNumber
$this->client = $client; $this->client = $client;
} }
public function __invoke($quote) public function run($quote)
{ {
if ($quote->number != '') if ($quote->number != '')

View File

@ -20,7 +20,7 @@ class ConvertQuote
* @param $quote * @param $quote
* @return mixed * @return mixed
*/ */
public function __invoke($quote) public function run($quote)
{ {
$invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id, $quote->company_id); $invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id, $quote->company_id);
$this->invoice_repo->save([], $invoice); $this->invoice_repo->save([], $invoice);

View File

@ -11,7 +11,7 @@ class CreateInvitations
{ {
} }
public function __invoke($quote) public function run($quote)
{ {
$contacts = $quote->client->contacts; $contacts = $quote->client->contacts;

View File

@ -14,7 +14,7 @@ class MarkApproved
$this->client = $client; $this->client = $client;
} }
public function __invoke($quote) public function run($quote)
{ {
/* Return immediately if status is not draft */ /* Return immediately if status is not draft */
if ($quote->status_id != Quote::STATUS_SENT) { if ($quote->status_id != Quote::STATUS_SENT) {

View File

@ -14,7 +14,7 @@ class MarkSent
$this->client = $client; $this->client = $client;
} }
public function __invoke($quote) public function run($quote)
{ {
/* Return immediately if status is not draft */ /* Return immediately if status is not draft */

View File

@ -16,7 +16,7 @@ class QuoteService
{ {
$create_invitation = new CreateInvitations(); $create_invitation = new CreateInvitations();
$this->quote = $create_invitation($this->quote); $this->quote = $create_invitation->run($this->quote);
return $this; return $this;
} }
@ -25,11 +25,11 @@ class QuoteService
{ {
$mark_approved = new MarkApproved($this->quote->client); $mark_approved = new MarkApproved($this->quote->client);
$this->quote = $mark_approved($this->quote); $this->quote = $mark_approved->run($this->quote);
if($this->quote->client->getSetting('auto_convert_quote') === true) { if($this->quote->client->getSetting('auto_convert_quote') === true) {
$convert_quote = new ConvertQuote($this->quote->client); $convert_quote = new ConvertQuote($this->quote->client);
$this->quote = $convert_quote($this->quote); $this->quote = $convert_quote->run($this->quote);
} }
return $this; return $this;
@ -43,7 +43,7 @@ class QuoteService
{ {
$apply_number = new ApplyNumber($this->quote->client); $apply_number = new ApplyNumber($this->quote->client);
$this->quote = $apply_number($this->quote); $this->quote = $apply_number->run($this->quote);
return $this; return $this;
} }
@ -52,7 +52,7 @@ class QuoteService
{ {
$mark_sent = new MarkSent($this->quote->client); $mark_sent = new MarkSent($this->quote->client);
$this->quote = $mark_sent($this->quote); $this->quote = $mark_sent->run($this->quote);
return $this; return $this;
} }

View File

@ -22,7 +22,7 @@
@else @else
<script> <script>
function gtag(){} function gtag(){}
</script> </script>
@endif @endif
<meta charset="utf-8"> <meta charset="utf-8">