mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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();
|
$today = new DateTime();
|
||||||
|
|
||||||
$invoices = Invoice::with('account.timezone', 'invoice_items', 'client', 'user')
|
$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')
|
->orderBy('id', 'asc')
|
||||||
->get();
|
->get();
|
||||||
$this->info(count($invoices).' recurring invoice(s) found');
|
$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')
|
$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',
|
AND balance > 0 AND due_date = ? AND recurring_invoice_id IS NOT NULL',
|
||||||
[$today->format('Y-m-d')])
|
[$today->format('Y-m-d')])
|
||||||
->orderBy('invoices.id', 'asc')
|
->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')];
|
$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')];
|
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ class PaymentController extends BaseController
|
|||||||
public function create(PaymentRequest $request)
|
public function create(PaymentRequest $request)
|
||||||
{
|
{
|
||||||
$invoices = Invoice::scope()
|
$invoices = Invoice::scope()
|
||||||
->invoiceType(INVOICE_TYPE_STANDARD)
|
->invoices()
|
||||||
->where('is_recurring', '=', false)
|
->whereIsPublic(true)
|
||||||
->where('invoices.balance', '>', 0)
|
->where('invoices.balance', '>', 0)
|
||||||
->with('client', 'invoice_status')
|
->with('client', 'invoice_status')
|
||||||
->orderBy('invoice_number')->get();
|
->orderBy('invoice_number')->get();
|
||||||
@ -128,8 +128,11 @@ class PaymentController extends BaseController
|
|||||||
$data = [
|
$data = [
|
||||||
'client' => null,
|
'client' => null,
|
||||||
'invoice' => null,
|
'invoice' => null,
|
||||||
'invoices' => Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->where('is_recurring', '=', false)
|
'invoices' => Invoice::scope()
|
||||||
->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
|
->invoices()
|
||||||
|
->whereIsPublic(true)
|
||||||
|
->with('client', 'invoice_status')
|
||||||
|
->orderBy('invoice_number')->get(),
|
||||||
'payment' => $payment,
|
'payment' => $payment,
|
||||||
'entity' => $payment,
|
'entity' => $payment,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
@ -161,7 +164,7 @@ class PaymentController extends BaseController
|
|||||||
Session::flash('message', trans('texts.created_payment'));
|
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)
|
$invoice = Invoice::scope($this->invoice_id)
|
||||||
->invoices()
|
->invoices()
|
||||||
|
->whereIsPublic(true)
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
$this->merge([
|
$this->merge([
|
||||||
|
@ -24,6 +24,7 @@ class CreatePaymentRequest extends PaymentRequest
|
|||||||
$input = $this->input();
|
$input = $this->input();
|
||||||
$invoice = Invoice::scope($input['invoice'])
|
$invoice = Invoice::scope($input['invoice'])
|
||||||
->invoices()
|
->invoices()
|
||||||
|
->whereIsPublic(true)
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
|
@ -45,7 +45,7 @@ class ClientPortalHeaderComposer
|
|||||||
->join('documents', 'documents.invoice_id', '=', 'invoices.id')
|
->join('documents', 'documents.invoice_id', '=', 'invoices.id')
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$view->with('hasQuotes', $client->quotes->count());
|
$view->with('hasQuotes', $client->publicQuotes->count());
|
||||||
$view->with('hasCredits', $client->creditsWithBalance->count());
|
$view->with('hasCredits', $client->creditsWithBalance->count());
|
||||||
$view->with('hasDocuments', $hasDocuments);
|
$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 $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
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
*/
|
*/
|
||||||
|
@ -280,6 +280,7 @@ class AccountRepository
|
|||||||
$lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first();
|
$lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first();
|
||||||
$publicId = $lastInvoice ? ($lastInvoice->public_id + 1) : 1;
|
$publicId = $lastInvoice ? ($lastInvoice->public_id + 1) : 1;
|
||||||
$invoice = new Invoice();
|
$invoice = new Invoice();
|
||||||
|
$invoice->is_public = true;
|
||||||
$invoice->account_id = $account->id;
|
$invoice->account_id = $account->id;
|
||||||
$invoice->user_id = $account->users()->first()->id;
|
$invoice->user_id = $account->users()->first()->id;
|
||||||
$invoice->public_id = $publicId;
|
$invoice->public_id = $publicId;
|
||||||
|
@ -179,6 +179,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
->where('invoices.is_deleted', '=', false)
|
->where('invoices.is_deleted', '=', false)
|
||||||
->where('clients.deleted_at', '=', null)
|
->where('clients.deleted_at', '=', null)
|
||||||
->where('invoices.is_recurring', '=', true)
|
->where('invoices.is_recurring', '=', true)
|
||||||
|
->where('invoices.is_public', '=', true)
|
||||||
->whereIn('invoices.auto_bill', [AUTO_BILL_OPT_IN, AUTO_BILL_OPT_OUT])
|
->whereIn('invoices.auto_bill', [AUTO_BILL_OPT_IN, AUTO_BILL_OPT_OUT])
|
||||||
//->where('invoices.start_date', '>=', date('Y-m-d H:i:s'))
|
//->where('invoices.start_date', '>=', date('Y-m-d H:i:s'))
|
||||||
->select(
|
->select(
|
||||||
@ -693,6 +694,10 @@ class InvoiceRepository extends BaseRepository
|
|||||||
if ($account->invoice_terms) {
|
if ($account->invoice_terms) {
|
||||||
$clone->terms = $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();
|
$clone->save();
|
||||||
@ -822,6 +827,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$invoice = Invoice::createNew($recurInvoice);
|
$invoice = Invoice::createNew($recurInvoice);
|
||||||
|
$invoice->is_public = true;
|
||||||
$invoice->invoice_type_id = INVOICE_TYPE_STANDARD;
|
$invoice->invoice_type_id = INVOICE_TYPE_STANDARD;
|
||||||
$invoice->client_id = $recurInvoice->client_id;
|
$invoice->client_id = $recurInvoice->client_id;
|
||||||
$invoice->recurring_invoice_id = $recurInvoice->id;
|
$invoice->recurring_invoice_id = $recurInvoice->id;
|
||||||
|
@ -557,7 +557,7 @@
|
|||||||
@if ($invoice->isSent())
|
@if ($invoice->isSent())
|
||||||
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
||||||
@else
|
@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')) !!}
|
{!! Button::success(trans("texts.mark_sent"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onMarkSentClick()'))->appendIcon(Icon::create('globe')) !!}
|
||||||
@endif
|
@endif
|
||||||
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
||||||
@ -1291,23 +1291,27 @@
|
|||||||
}, getSendToEmails());
|
}, getSendToEmails());
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMarkSentClick() {
|
function onSaveDraftClick() {
|
||||||
model.invoice().is_public(true);
|
model.invoice().is_public(false);
|
||||||
onSaveClick();
|
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() {
|
function onSaveClick() {
|
||||||
if (model.invoice().is_recurring()) {
|
if (model.invoice().is_recurring()) {
|
||||||
// warn invoice will be emailed when saving new recurring invoice
|
if (model.invoice().start_date() != model.invoice().start_date_orig()) {
|
||||||
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()) {
|
|
||||||
var text = "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
|
var text = "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
|
||||||
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date();
|
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date();
|
||||||
var title = "{!! trans("texts.warn_start_date_changed") !!}";
|
var title = "{!! trans("texts.warn_start_date_changed") !!}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user