mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 22:14:33 -04:00
Option to include expense documents with invoice #1442
This commit is contained in:
parent
81d9e4994c
commit
d1e77f877b
@ -651,8 +651,10 @@ class ClientPortalController extends BaseController
|
|||||||
$documents = $invoice->documents;
|
$documents = $invoice->documents;
|
||||||
|
|
||||||
foreach ($invoice->expenses as $expense) {
|
foreach ($invoice->expenses as $expense) {
|
||||||
|
if ($expense->invoice_documents) {
|
||||||
$documents = $documents->merge($expense->documents);
|
$documents = $documents->merge($expense->documents);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$documents = $documents->sortBy('size');
|
$documents = $documents->sortBy('size');
|
||||||
|
|
||||||
@ -740,7 +742,7 @@ class ClientPortalController extends BaseController
|
|||||||
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
||||||
|
|
||||||
$authorized = false;
|
$authorized = false;
|
||||||
if ($document->expense && $document->expense->client_id == $invitation->invoice->client_id) {
|
if ($document->expense && $document->expense->invoice_documents && $document->expense->client_id == $invitation->invoice->client_id) {
|
||||||
$authorized = true;
|
$authorized = true;
|
||||||
} elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) {
|
} elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) {
|
||||||
$authorized = true;
|
$authorized = true;
|
||||||
|
@ -50,6 +50,7 @@ class Expense extends EntityModel
|
|||||||
'payment_date',
|
'payment_date',
|
||||||
'payment_type_id',
|
'payment_type_id',
|
||||||
'transaction_reference',
|
'transaction_reference',
|
||||||
|
'invoice_documents',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function getImportColumns()
|
public static function getImportColumns()
|
||||||
|
@ -1405,6 +1405,22 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
$taxes[$key]['paid'] += $paid;
|
$taxes[$key]['paid'] += $paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function countDocuments()
|
||||||
|
{
|
||||||
|
$count = count($this->documents);
|
||||||
|
|
||||||
|
foreach ($this->expenses as $expense) {
|
||||||
|
if ($expense->invoice_documents) {
|
||||||
|
$count += count($expense->documents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -1423,7 +1439,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
public function hasExpenseDocuments()
|
public function hasExpenseDocuments()
|
||||||
{
|
{
|
||||||
foreach ($this->expenses as $expense) {
|
foreach ($this->expenses as $expense) {
|
||||||
if (count($expense->documents)) {
|
if ($expense->invoice_documents && count($expense->documents)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ class AddCustomContactFields extends Migration
|
|||||||
$table->date('payment_date')->nullable();
|
$table->date('payment_date')->nullable();
|
||||||
$table->string('transaction_reference')->nullable();
|
$table->string('transaction_reference')->nullable();
|
||||||
$table->foreign('payment_type_id')->references('id')->on('payment_types');
|
$table->foreign('payment_type_id')->references('id')->on('payment_types');
|
||||||
|
$table->boolean('invoice_documents')->default(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove duplicate annual frequency
|
// remove duplicate annual frequency
|
||||||
@ -76,6 +77,7 @@ class AddCustomContactFields extends Migration
|
|||||||
$table->dropColumn('payment_type_id');
|
$table->dropColumn('payment_type_id');
|
||||||
$table->dropColumn('payment_date');
|
$table->dropColumn('payment_date');
|
||||||
$table->dropColumn('transaction_reference');
|
$table->dropColumn('transaction_reference');
|
||||||
|
$table->dropColumn('invoice_documents');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2481,7 +2481,7 @@ $LANG = array(
|
|||||||
'custom_contact_fields_help' => 'Add a field when creating a contact and display the label and value on the PDF.',
|
'custom_contact_fields_help' => 'Add a field when creating a contact and display the label and value on the PDF.',
|
||||||
'datatable_info' => 'Showing :start to :end of :total entries',
|
'datatable_info' => 'Showing :start to :end of :total entries',
|
||||||
'credit_total' => 'Credit Total',
|
'credit_total' => 'Credit Total',
|
||||||
'mark_billable' => 'Mark Billable',
|
'mark_billable' => 'Mark billable',
|
||||||
'billed' => 'Billed',
|
'billed' => 'Billed',
|
||||||
'company_variables' => 'Company Variables',
|
'company_variables' => 'Company Variables',
|
||||||
'client_variables' => 'Client Variables',
|
'client_variables' => 'Client Variables',
|
||||||
@ -2489,6 +2489,8 @@ $LANG = array(
|
|||||||
'navigation_variables' => 'Navigation Variables',
|
'navigation_variables' => 'Navigation Variables',
|
||||||
'custom_variables' => 'Custom Variables',
|
'custom_variables' => 'Custom Variables',
|
||||||
'invalid_file' => 'Invalid file type',
|
'invalid_file' => 'Invalid file type',
|
||||||
|
'add_documents_to_invoice' => 'Add documents to invoice',
|
||||||
|
'mark_expense_paid' => 'Mark paid',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
@if (! $expense || ! $expense->isPaid())
|
@if (! $expense || ! $expense->isPaid())
|
||||||
{!! Former::checkbox('mark_paid')
|
{!! Former::checkbox('mark_paid')
|
||||||
->data_bind('checked: mark_paid')
|
->data_bind('checked: mark_paid')
|
||||||
->text(trans('texts.mark_paid'))
|
->text(trans('texts.mark_expense_paid'))
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->value(1) !!}
|
->value(1) !!}
|
||||||
@endif
|
@endif
|
||||||
@ -181,6 +181,15 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if ($account->hasFeature(FEATURE_DOCUMENTS))
|
||||||
|
{!! Former::checkbox('invoice_documents')
|
||||||
|
->text(trans('texts.add_documents_to_invoice'))
|
||||||
|
->onchange('onInvoiceDocumentsChange()')
|
||||||
|
->data_bind('checked: invoice_documents')
|
||||||
|
->label(' ')
|
||||||
|
->value(1) !!}
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
@ -452,6 +461,12 @@
|
|||||||
self.convert_currency = ko.observable({{ ($expense && $expense->isExchanged()) ? 'true' : 'false' }});
|
self.convert_currency = ko.observable({{ ($expense && $expense->isExchanged()) ? 'true' : 'false' }});
|
||||||
self.apply_taxes = ko.observable({{ ($expense && ($expense->tax_name1 || $expense->tax_name2)) ? 'true' : 'false' }});
|
self.apply_taxes = ko.observable({{ ($expense && ($expense->tax_name1 || $expense->tax_name2)) ? 'true' : 'false' }});
|
||||||
|
|
||||||
|
var invoiceDocuments = false;
|
||||||
|
if (isStorageSupported()) {
|
||||||
|
invoiceDocuments = localStorage.getItem('last:invoice_documents');
|
||||||
|
}
|
||||||
|
self.invoice_documents = ko.observable({{ $expense ? $expense->invoice_documents : 'invoiceDocuments' }});
|
||||||
|
|
||||||
self.mapping = {
|
self.mapping = {
|
||||||
'documents': {
|
'documents': {
|
||||||
create: function(options) {
|
create: function(options) {
|
||||||
@ -611,6 +626,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onInvoiceDocumentsChange()
|
||||||
|
{
|
||||||
|
if (isStorageSupported()) {
|
||||||
|
var checked = $('#invoice_documents').is(':checked');
|
||||||
|
localStorage.setItem('last:invoice_documents', checked || '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
@ -346,8 +346,8 @@
|
|||||||
@if ($account->hasFeature(FEATURE_DOCUMENTS))
|
@if ($account->hasFeature(FEATURE_DOCUMENTS))
|
||||||
<li role="presentation"><a href="#attached-documents" aria-controls="attached-documents" role="tab" data-toggle="tab">
|
<li role="presentation"><a href="#attached-documents" aria-controls="attached-documents" role="tab" data-toggle="tab">
|
||||||
{{ trans("texts.invoice_documents") }}
|
{{ trans("texts.invoice_documents") }}
|
||||||
@if (count($invoice->documents))
|
@if ($count = $invoice->countDocuments())
|
||||||
({{ count($invoice->documents) }})
|
({{ $count }})
|
||||||
@endif
|
@endif
|
||||||
</a></li>
|
</a></li>
|
||||||
@endif
|
@endif
|
||||||
@ -393,9 +393,11 @@
|
|||||||
@if ($invoice->hasExpenseDocuments())
|
@if ($invoice->hasExpenseDocuments())
|
||||||
<h4>{{trans('texts.documents_from_expenses')}}</h4>
|
<h4>{{trans('texts.documents_from_expenses')}}</h4>
|
||||||
@foreach($invoice->expenses as $expense)
|
@foreach($invoice->expenses as $expense)
|
||||||
|
@if ($expense->invoice_documents)
|
||||||
@foreach($expense->documents as $document)
|
@foreach($expense->documents as $document)
|
||||||
<div>{{$document->name}}</div>
|
<div>{{$document->name}}</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@ -151,7 +151,9 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@foreach ($invoice->expenses as $expense)
|
@foreach ($invoice->expenses as $expense)
|
||||||
@foreach ($expense->documents as $document)
|
@foreach ($expense->documents as $document)
|
||||||
|
@if ($expense->invoice_documents)
|
||||||
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
|
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user