mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Hide draft invoices from the client portal
This commit is contained in:
parent
ad07599e92
commit
78a2a66729
@ -58,7 +58,7 @@ class SendRecurringInvoices extends Command
|
||||
$today = new DateTime();
|
||||
|
||||
$invoices = Invoice::with('account.timezone', 'invoice_items', 'client', 'user')
|
||||
->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND frequency_id > 0 AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', [$today, $today])
|
||||
->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND is_public IS TRUE AND frequency_id > 0 AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', [$today, $today])
|
||||
->orderBy('id', 'asc')
|
||||
->get();
|
||||
$this->info(count($invoices).' recurring invoice(s) found');
|
||||
@ -81,7 +81,7 @@ class SendRecurringInvoices extends Command
|
||||
}
|
||||
|
||||
$delayedAutoBillInvoices = Invoice::with('account.timezone', 'recurring_invoice', 'invoice_items', 'client', 'user')
|
||||
->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS FALSE
|
||||
->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS FALSE AND is_public IS TRUE
|
||||
AND balance > 0 AND due_date = ? AND recurring_invoice_id IS NOT NULL',
|
||||
[$today->format('Y-m-d')])
|
||||
->orderBy('invoices.id', 'asc')
|
||||
|
@ -141,7 +141,7 @@ class InvoiceController extends BaseController
|
||||
$actions[] = ['url' => URL::to("quotes/{$invoice->quote_id}/edit"), 'label' => trans('texts.view_quote')];
|
||||
}
|
||||
|
||||
if (!$invoice->is_recurring && $invoice->balance > 0) {
|
||||
if (!$invoice->is_recurring && $invoice->balance > 0 && $invoice->is_public) {
|
||||
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
|
||||
}
|
||||
|
||||
|
@ -83,8 +83,8 @@ class PaymentController extends BaseController
|
||||
public function create(PaymentRequest $request)
|
||||
{
|
||||
$invoices = Invoice::scope()
|
||||
->invoiceType(INVOICE_TYPE_STANDARD)
|
||||
->where('is_recurring', '=', false)
|
||||
->invoices()
|
||||
->whereIsPublic(true)
|
||||
->where('invoices.balance', '>', 0)
|
||||
->with('client', 'invoice_status')
|
||||
->orderBy('invoice_number')->get();
|
||||
@ -128,8 +128,11 @@ class PaymentController extends BaseController
|
||||
$data = [
|
||||
'client' => null,
|
||||
'invoice' => null,
|
||||
'invoices' => Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->where('is_recurring', '=', false)
|
||||
->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
|
||||
'invoices' => Invoice::scope()
|
||||
->invoices()
|
||||
->whereIsPublic(true)
|
||||
->with('client', 'invoice_status')
|
||||
->orderBy('invoice_number')->get(),
|
||||
'payment' => $payment,
|
||||
'entity' => $payment,
|
||||
'method' => 'PUT',
|
||||
@ -161,7 +164,7 @@ class PaymentController extends BaseController
|
||||
Session::flash('message', trans('texts.created_payment'));
|
||||
}
|
||||
|
||||
return redirect()->to($payment->client->getRoute());
|
||||
return redirect()->to($payment->client->getRoute() . '#payments');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,7 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
||||
|
||||
$invoice = Invoice::scope($this->invoice_id)
|
||||
->invoices()
|
||||
->whereIsPublic(true)
|
||||
->firstOrFail();
|
||||
|
||||
$this->merge([
|
||||
|
@ -24,6 +24,7 @@ class CreatePaymentRequest extends PaymentRequest
|
||||
$input = $this->input();
|
||||
$invoice = Invoice::scope($input['invoice'])
|
||||
->invoices()
|
||||
->whereIsPublic(true)
|
||||
->firstOrFail();
|
||||
|
||||
$rules = [
|
||||
|
@ -45,7 +45,7 @@ class ClientPortalHeaderComposer
|
||||
->join('documents', 'documents.invoice_id', '=', 'invoices.id')
|
||||
->count();
|
||||
|
||||
$view->with('hasQuotes', $client->quotes->count());
|
||||
$view->with('hasQuotes', $client->publicQuotes->count());
|
||||
$view->with('hasCredits', $client->creditsWithBalance->count());
|
||||
$view->with('hasDocuments', $hasDocuments);
|
||||
}
|
||||
|
@ -173,6 +173,14 @@ class Client extends EntityModel
|
||||
return $this->hasMany('App\Models\Invoice')->where('invoice_type_id', '=', INVOICE_TYPE_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function publicQuotes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Invoice')->where('invoice_type_id', '=', INVOICE_TYPE_QUOTE)->whereIsPublic(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
@ -280,6 +280,7 @@ class AccountRepository
|
||||
$lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first();
|
||||
$publicId = $lastInvoice ? ($lastInvoice->public_id + 1) : 1;
|
||||
$invoice = new Invoice();
|
||||
$invoice->is_public = true;
|
||||
$invoice->account_id = $account->id;
|
||||
$invoice->user_id = $account->users()->first()->id;
|
||||
$invoice->public_id = $publicId;
|
||||
|
@ -179,6 +179,7 @@ class InvoiceRepository extends BaseRepository
|
||||
->where('invoices.is_deleted', '=', false)
|
||||
->where('clients.deleted_at', '=', null)
|
||||
->where('invoices.is_recurring', '=', true)
|
||||
->where('invoices.is_public', '=', true)
|
||||
->whereIn('invoices.auto_bill', [AUTO_BILL_OPT_IN, AUTO_BILL_OPT_OUT])
|
||||
//->where('invoices.start_date', '>=', date('Y-m-d H:i:s'))
|
||||
->select(
|
||||
@ -693,6 +694,10 @@ class InvoiceRepository extends BaseRepository
|
||||
if ($account->invoice_terms) {
|
||||
$clone->terms = $account->invoice_terms;
|
||||
}
|
||||
if ($account->auto_convert_quote) {
|
||||
$clone->is_public = true;
|
||||
$clone->invoice_status_id = INVOICE_STATUS_SENT;
|
||||
}
|
||||
}
|
||||
|
||||
$clone->save();
|
||||
@ -822,6 +827,7 @@ class InvoiceRepository extends BaseRepository
|
||||
}
|
||||
|
||||
$invoice = Invoice::createNew($recurInvoice);
|
||||
$invoice->is_public = true;
|
||||
$invoice->invoice_type_id = INVOICE_TYPE_STANDARD;
|
||||
$invoice->client_id = $recurInvoice->client_id;
|
||||
$invoice->recurring_invoice_id = $recurInvoice->id;
|
||||
|
@ -557,7 +557,7 @@
|
||||
@if ($invoice->isSent())
|
||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||
@else
|
||||
{!! Button::normal(trans("texts.save_draft"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||
{!! Button::normal(trans("texts.save_draft"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveDraftClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||
{!! Button::success(trans("texts.mark_sent"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onMarkSentClick()'))->appendIcon(Icon::create('globe')) !!}
|
||||
@endif
|
||||
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
||||
@ -1291,23 +1291,27 @@
|
||||
}, getSendToEmails());
|
||||
}
|
||||
|
||||
function onMarkSentClick() {
|
||||
model.invoice().is_public(true);
|
||||
function onSaveDraftClick() {
|
||||
model.invoice().is_public(false);
|
||||
onSaveClick();
|
||||
}
|
||||
|
||||
function onMarkSentClick() {
|
||||
if (model.invoice().is_recurring()) {
|
||||
// warn invoice will be emailed when saving new recurring invoice
|
||||
var text = getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}";
|
||||
var title = "{!! trans("texts.confirm_recurring_email_$entityType") !!}";
|
||||
sweetConfirm(function() {
|
||||
model.invoice().is_public(true);
|
||||
submitAction('');
|
||||
}, text, title);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function onSaveClick() {
|
||||
if (model.invoice().is_recurring()) {
|
||||
// warn invoice will be emailed when saving new recurring invoice
|
||||
if ({{ $invoice->exists ? 'false' : 'true' }}) {
|
||||
var text = getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}";
|
||||
var title = "{!! trans("texts.confirm_recurring_email_$entityType") !!}";
|
||||
sweetConfirm(function() {
|
||||
submitAction('');
|
||||
}, text, title);
|
||||
return;
|
||||
// warn invoice will be emailed again if start date is changed
|
||||
} else if (model.invoice().start_date() != model.invoice().start_date_orig()) {
|
||||
if (model.invoice().start_date() != model.invoice().start_date_orig()) {
|
||||
var text = "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
|
||||
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date();
|
||||
var title = "{!! trans("texts.warn_start_date_changed") !!}";
|
||||
|
Loading…
Reference in New Issue
Block a user