Enable viewing draft invoices with link

This commit is contained in:
Hillel Coren 2017-01-08 21:45:42 +02:00
parent b34c5724de
commit 854b13de19
4 changed files with 6 additions and 4 deletions

View File

@ -194,7 +194,7 @@ class InvoiceController extends BaseController
} }
// Set the invitation data on the client's contacts // Set the invitation data on the client's contacts
if ($invoice->is_public && ! $clone) { if ( ! $clone) {
$clients = $data['clients']; $clients = $data['clients'];
foreach ($clients as $client) { foreach ($clients as $client) {
if ($client->id != $invoice->client->id) { if ($client->id != $invoice->client->id) {

View File

@ -196,7 +196,7 @@ class Invoice extends EntityModel implements BalanceAffecting
if ($this->getRawAdjustment() != 0) { if ($this->getRawAdjustment() != 0) {
return true; return true;
} }
foreach ([ foreach ([
'invoice_number', 'invoice_number',
'po_number', 'po_number',
@ -566,7 +566,7 @@ class Invoice extends EntityModel implements BalanceAffecting
public function canBePaid() public function canBePaid()
{ {
return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice(); return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice() && $this->is_public;
} }
public static function calcStatusLabel($status, $class, $entityType, $quoteInvoiceId) public static function calcStatusLabel($status, $class, $entityType, $quoteInvoiceId)

View File

@ -797,7 +797,7 @@ class InvoiceRepository extends BaseRepository
} }
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
if (!$invoice || $invoice->is_deleted || ! $invoice->is_public) { if (!$invoice || $invoice->is_deleted) {
return false; return false;
} }

View File

@ -116,6 +116,8 @@
@if ($showApprove) @if ($showApprove)
{!! Button::success(trans('texts.approve'))->asLinkTo(URL::to('/approve/' . $invitation->invitation_key))->large() !!} {!! Button::success(trans('texts.approve'))->asLinkTo(URL::to('/approve/' . $invitation->invitation_key))->large() !!}
@endif @endif
@elseif ( ! $invoice->canBePaid())
{!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}
@elseif ($invoice->client->account->isGatewayConfigured() && floatval($invoice->balance) && !$invoice->is_recurring) @elseif ($invoice->client->account->isGatewayConfigured() && floatval($invoice->balance) && !$invoice->is_recurring)
{!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}   {!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}  
@if (count($paymentTypes) > 1) @if (count($paymentTypes) > 1)