mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fix 'View quote' link
This commit is contained in:
parent
050df75868
commit
5f6f3851d8
@ -361,6 +361,14 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this->belongsTo('App\Models\Invoice');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function quote()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Invoice');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -141,15 +141,6 @@ class InvoiceDatatable extends EntityDatatable
|
||||
return $entityType == ENTITY_INVOICE && $model->invoice_status_id != INVOICE_STATUS_PAID && Auth::user()->can('create', ENTITY_PAYMENT);
|
||||
},
|
||||
],
|
||||
[
|
||||
trans('texts.view_quote'),
|
||||
function ($model) {
|
||||
return URL::to("quotes/{$model->quote_id}/edit");
|
||||
},
|
||||
function ($model) use ($entityType) {
|
||||
return $entityType == ENTITY_INVOICE && $model->quote_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||
},
|
||||
],
|
||||
[
|
||||
trans('texts.view_invoice'),
|
||||
function ($model) {
|
||||
|
@ -235,8 +235,8 @@ class InvoicePresenter extends EntityPresenter
|
||||
$actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans('texts.convert_to_invoice')];
|
||||
}
|
||||
} elseif ($entityType == ENTITY_INVOICE) {
|
||||
if ($invoice->quote_id) {
|
||||
$actions[] = ['url' => url("quotes/{$invoice->quote_id}/edit"), 'label' => trans('texts.view_quote')];
|
||||
if ($invoice->quote) {
|
||||
$actions[] = ['url' => url("quotes/{$invoice->quote->public_id}/edit"), 'label' => trans('texts.view_quote')];
|
||||
}
|
||||
|
||||
if ($invoice->canBePaid()) {
|
||||
|
@ -815,11 +815,11 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
* @param null $quotePublicId
|
||||
* @param null $quoteId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function cloneInvoice(Invoice $invoice, $quotePublicId = null)
|
||||
public function cloneInvoice(Invoice $invoice, $quoteId = null)
|
||||
{
|
||||
$invoice->load('invitations', 'invoice_items');
|
||||
$account = $invoice->account;
|
||||
@ -873,9 +873,9 @@ class InvoiceRepository extends BaseRepository
|
||||
$clone->$field = $invoice->$field;
|
||||
}
|
||||
|
||||
if ($quotePublicId) {
|
||||
if ($quoteId) {
|
||||
$clone->invoice_type_id = INVOICE_TYPE_STANDARD;
|
||||
$clone->quote_id = $quotePublicId;
|
||||
$clone->quote_id = $quoteId;
|
||||
if ($account->invoice_terms) {
|
||||
$clone->terms = $account->invoice_terms;
|
||||
}
|
||||
@ -890,7 +890,7 @@ class InvoiceRepository extends BaseRepository
|
||||
$clone->due_date = $account->defaultDueDate($invoice->client);
|
||||
$clone->save();
|
||||
|
||||
if ($quotePublicId) {
|
||||
if ($quoteId) {
|
||||
$invoice->quote_invoice_id = $clone->public_id;
|
||||
$invoice->save();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user