mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Place checks on quote 'isConvertable()'
This commit is contained in:
parent
c72d38ca4f
commit
41b19c20c1
@ -534,7 +534,7 @@ class QuoteController extends BaseController
|
||||
$this->entity_transformer = InvoiceTransformer::class;
|
||||
|
||||
$invoices = $quotes->map(function ($quote, $key) use ($action) {
|
||||
if (auth()->user()->can('edit', $quote)) {
|
||||
if (auth()->user()->can('edit', $quote) && $quote->service()->isConvertable()) {
|
||||
$invoice = $quote->service()->convertToInvoice();
|
||||
return $invoice->id;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class QuoteService
|
||||
return $this;
|
||||
|
||||
$convert_quote = new ConvertQuote($this->quote->client);
|
||||
|
||||
$this->invoice = $convert_quote->run($this->quote);
|
||||
|
||||
$this->quote->fresh();
|
||||
@ -125,7 +126,7 @@ class QuoteService
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function convertToInvoice() :Invoice
|
||||
public function convertToInvoice()
|
||||
{
|
||||
|
||||
//to prevent circular references we need to explicit call this here.
|
||||
@ -137,6 +138,17 @@ class QuoteService
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
public function isConvertable() :bool
|
||||
{
|
||||
if($this->quote->invoice_id)
|
||||
return false;
|
||||
|
||||
if($this->quote->status_id == Quote::STATUS_EXPIRED)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the quote
|
||||
* @return Quote|null
|
||||
|
Loading…
x
Reference in New Issue
Block a user