mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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 $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
|
* @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);
|
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'),
|
trans('texts.view_invoice'),
|
||||||
function ($model) {
|
function ($model) {
|
||||||
|
@ -235,8 +235,8 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
$actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans('texts.convert_to_invoice')];
|
$actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans('texts.convert_to_invoice')];
|
||||||
}
|
}
|
||||||
} elseif ($entityType == ENTITY_INVOICE) {
|
} elseif ($entityType == ENTITY_INVOICE) {
|
||||||
if ($invoice->quote_id) {
|
if ($invoice->quote) {
|
||||||
$actions[] = ['url' => url("quotes/{$invoice->quote_id}/edit"), 'label' => trans('texts.view_quote')];
|
$actions[] = ['url' => url("quotes/{$invoice->quote->public_id}/edit"), 'label' => trans('texts.view_quote')];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($invoice->canBePaid()) {
|
if ($invoice->canBePaid()) {
|
||||||
|
@ -815,11 +815,11 @@ class InvoiceRepository extends BaseRepository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Invoice $invoice
|
* @param Invoice $invoice
|
||||||
* @param null $quotePublicId
|
* @param null $quoteId
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function cloneInvoice(Invoice $invoice, $quotePublicId = null)
|
public function cloneInvoice(Invoice $invoice, $quoteId = null)
|
||||||
{
|
{
|
||||||
$invoice->load('invitations', 'invoice_items');
|
$invoice->load('invitations', 'invoice_items');
|
||||||
$account = $invoice->account;
|
$account = $invoice->account;
|
||||||
@ -873,9 +873,9 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$clone->$field = $invoice->$field;
|
$clone->$field = $invoice->$field;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($quotePublicId) {
|
if ($quoteId) {
|
||||||
$clone->invoice_type_id = INVOICE_TYPE_STANDARD;
|
$clone->invoice_type_id = INVOICE_TYPE_STANDARD;
|
||||||
$clone->quote_id = $quotePublicId;
|
$clone->quote_id = $quoteId;
|
||||||
if ($account->invoice_terms) {
|
if ($account->invoice_terms) {
|
||||||
$clone->terms = $account->invoice_terms;
|
$clone->terms = $account->invoice_terms;
|
||||||
}
|
}
|
||||||
@ -890,7 +890,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$clone->due_date = $account->defaultDueDate($invoice->client);
|
$clone->due_date = $account->defaultDueDate($invoice->client);
|
||||||
$clone->save();
|
$clone->save();
|
||||||
|
|
||||||
if ($quotePublicId) {
|
if ($quoteId) {
|
||||||
$invoice->quote_invoice_id = $clone->public_id;
|
$invoice->quote_invoice_id = $clone->public_id;
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user