mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
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:
parent
4a3d37a42b
commit
7dd6f814ac
@ -31,10 +31,9 @@ class ApplyNumber
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function __invoke($invoice)
|
||||
{
|
||||
|
||||
if ($invoice->number != '')
|
||||
public function run($invoice)
|
||||
{
|
||||
if ($invoice->number != '')
|
||||
return $invoice;
|
||||
|
||||
switch ($this->client->getSetting('counter_number_applied')) {
|
||||
@ -46,12 +45,12 @@ class ApplyNumber
|
||||
$invoice->number = $this->getNextInvoiceNumber($this->client);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class ApplyPayment
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
public function __invoke($payment, $payment_amount)
|
||||
public function run($payment, $payment_amount)
|
||||
{
|
||||
|
||||
UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment_amount*-1), $payment->company);
|
||||
@ -55,7 +55,7 @@ class ApplyPayment
|
||||
} elseif($payment_amount < $this->invoice->balance) { //partial invoice payment made
|
||||
$this->invoice->service()->clearPartial()->updateBalance($payment_amount*-1);
|
||||
}
|
||||
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ class CreateInvitations
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// ..
|
||||
}
|
||||
|
||||
public function __invoke($invoice)
|
||||
public function run($invoice)
|
||||
{
|
||||
|
||||
$contacts = $invoice->client->contacts;
|
||||
@ -46,4 +47,4 @@ class CreateInvitations
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Storage;
|
||||
class GetInvoicePdf
|
||||
{
|
||||
|
||||
public function __invoke($invoice, $contact = null)
|
||||
public function run($invoice, $contact = null)
|
||||
{
|
||||
|
||||
if(!$contact)
|
||||
@ -33,7 +33,7 @@ class GetInvoicePdf
|
||||
|
||||
if(!$file)
|
||||
{
|
||||
|
||||
|
||||
$file_path = CreateInvoicePdf::dispatchNow($invoice, $invoice->company, $contact);
|
||||
|
||||
}
|
||||
|
@ -38,15 +38,15 @@ class InvoiceService
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks as invoice as paid
|
||||
* Marks as invoice as paid
|
||||
* and executes child sub functions
|
||||
* @return $this InvoiceService object
|
||||
*/
|
||||
public function markPaid()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
@ -59,7 +59,7 @@ class InvoiceService
|
||||
{
|
||||
$apply_number = new ApplyNumber($this->invoice->client);
|
||||
|
||||
$this->invoice = $apply_number($this->invoice);
|
||||
$this->invoice = $apply_number->run($this->invoice);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -74,7 +74,7 @@ class InvoiceService
|
||||
{
|
||||
$apply_payment = new ApplyPayment($this->invoice);
|
||||
|
||||
$this->invoice = $apply_payment($payment, $payment_amount);
|
||||
$this->invoice = $apply_payment->run($payment, $payment_amount);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -90,7 +90,7 @@ class InvoiceService
|
||||
{
|
||||
$update_balance = new UpdateBalance($this->invoice);
|
||||
|
||||
$this->invoice = $update_balance($balance_adjustment);
|
||||
$this->invoice = $update_balance->run($balance_adjustment);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -99,7 +99,7 @@ class InvoiceService
|
||||
{
|
||||
$create_invitation = new CreateInvitations();
|
||||
|
||||
$this->invoice = $create_invitation($this->invoice);
|
||||
$this->invoice = $create_invitation->run($this->invoice);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -108,7 +108,7 @@ class InvoiceService
|
||||
{
|
||||
$mark_sent = new MarkSent($this->invoice->client);
|
||||
|
||||
$this->invoice = $mark_sent($this->invoice);
|
||||
$this->invoice = $mark_sent->run($this->invoice);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -117,7 +117,7 @@ class InvoiceService
|
||||
{
|
||||
$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
|
||||
* @return Invoice object
|
||||
* @return Invoice object
|
||||
*/
|
||||
public function save() :?Invoice
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ class MarkPaid
|
||||
$this->client_service = $client_service;
|
||||
}
|
||||
|
||||
public function __invoke($invoice)
|
||||
public function run($invoice)
|
||||
{
|
||||
|
||||
if($invoice->status_id == Invoice::STATUS_DRAFT)
|
||||
@ -57,7 +57,7 @@ class MarkPaid
|
||||
event(new PaymentWasCreated($payment, $payment->company));
|
||||
|
||||
UpdateCompanyLedgerWithPayment::dispatchNow($payment, ($payment->amount*-1), $payment->company);
|
||||
|
||||
|
||||
$this->client_service
|
||||
->updateBalance($payment->amount*-1)
|
||||
->updatePaidToDate($payment->amount)
|
||||
|
@ -25,7 +25,7 @@ class MarkSent
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function __invoke($invoice)
|
||||
public function run($invoice)
|
||||
{
|
||||
|
||||
/* Return immediately if status is not draft */
|
||||
|
@ -24,7 +24,7 @@ class UpdateBalance
|
||||
}
|
||||
|
||||
|
||||
public function __invoke($balance_adjustment)
|
||||
public function run($balance_adjustment)
|
||||
{
|
||||
|
||||
if ($this->invoice->is_deleted) {
|
||||
@ -44,4 +44,4 @@ class UpdateBalance
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class ApplyNumber
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function __invoke($quote)
|
||||
public function run($quote)
|
||||
{
|
||||
|
||||
if ($quote->number != '')
|
||||
|
@ -20,7 +20,7 @@ class ConvertQuote
|
||||
* @param $quote
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke($quote)
|
||||
public function run($quote)
|
||||
{
|
||||
$invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id, $quote->company_id);
|
||||
$this->invoice_repo->save([], $invoice);
|
||||
|
@ -11,7 +11,7 @@ class CreateInvitations
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke($quote)
|
||||
public function run($quote)
|
||||
{
|
||||
|
||||
$contacts = $quote->client->contacts;
|
||||
|
@ -14,7 +14,7 @@ class MarkApproved
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function __invoke($quote)
|
||||
public function run($quote)
|
||||
{
|
||||
/* Return immediately if status is not draft */
|
||||
if ($quote->status_id != Quote::STATUS_SENT) {
|
||||
|
@ -14,7 +14,7 @@ class MarkSent
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function __invoke($quote)
|
||||
public function run($quote)
|
||||
{
|
||||
|
||||
/* Return immediately if status is not draft */
|
||||
|
@ -16,7 +16,7 @@ class QuoteService
|
||||
{
|
||||
$create_invitation = new CreateInvitations();
|
||||
|
||||
$this->quote = $create_invitation($this->quote);
|
||||
$this->quote = $create_invitation->run($this->quote);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -25,11 +25,11 @@ class QuoteService
|
||||
{
|
||||
$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) {
|
||||
$convert_quote = new ConvertQuote($this->quote->client);
|
||||
$this->quote = $convert_quote($this->quote);
|
||||
$this->quote = $convert_quote->run($this->quote);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -43,7 +43,7 @@ class QuoteService
|
||||
{
|
||||
$apply_number = new ApplyNumber($this->quote->client);
|
||||
|
||||
$this->quote = $apply_number($this->quote);
|
||||
$this->quote = $apply_number->run($this->quote);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -52,7 +52,7 @@ class QuoteService
|
||||
{
|
||||
$mark_sent = new MarkSent($this->quote->client);
|
||||
|
||||
$this->quote = $mark_sent($this->quote);
|
||||
$this->quote = $mark_sent->run($this->quote);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
@else
|
||||
<script>
|
||||
function gtag(){}
|
||||
</script>
|
||||
</script>
|
||||
@endif
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
Loading…
x
Reference in New Issue
Block a user