mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
add support for showing related entity documents on invoice
This commit is contained in:
parent
7051048fdf
commit
b3707967d8
@ -17,12 +17,15 @@ use App\Events\Invoice\InvoiceWasUpdated;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Presenters\InvoicePresenter;
|
||||
use App\Models\Task;
|
||||
use App\Services\Invoice\InvoiceService;
|
||||
use App\Services\Ledger\LedgerService;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Invoice\ActionsInvoice;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceValues;
|
||||
use App\Utils\Traits\MakesReminders;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
@ -562,6 +565,60 @@ class Invoice extends BaseModel
|
||||
];
|
||||
}
|
||||
|
||||
public function expense_documents()
|
||||
{
|
||||
|
||||
$line_items = $this->line_items;
|
||||
|
||||
$expense_ids = [];
|
||||
|
||||
foreach($line_items as $item)
|
||||
{
|
||||
|
||||
if(property_exists($item, 'expense_id'))
|
||||
{
|
||||
$expense_ids[] = $item->expense_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nlog($line_items);
|
||||
|
||||
return Expense::whereIn('id', $this->transformKeys($expense_ids))
|
||||
->where('invoice_documents', 1)
|
||||
->where('company_id', $this->company_id)
|
||||
->cursor();
|
||||
|
||||
}
|
||||
|
||||
public function task_documents()
|
||||
{
|
||||
|
||||
$line_items = $this->line_items;
|
||||
|
||||
$task_ids = [];
|
||||
|
||||
foreach($line_items as $item)
|
||||
{
|
||||
|
||||
if(property_exists($item, 'task_id'))
|
||||
{
|
||||
$task_ids[] = $item->task_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nlog($task_ids);
|
||||
|
||||
return Task::whereIn('id', $this->transformKeys($task_ids))
|
||||
->whereHas('company', function($query){
|
||||
$query->where('invoice_task_documents', 1);
|
||||
})
|
||||
->where('company_id', $this->company_id)
|
||||
->cursor();
|
||||
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.invoice');
|
||||
|
@ -42,45 +42,49 @@
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@if($entity->expense && $entity->expense->invoice_documents)
|
||||
@foreach ($entity->expense->documents as $document)
|
||||
<div class="inline-flex items-center space-x-1">
|
||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
||||
@if($entity instanceof App\Models\Invoice)
|
||||
@foreach ($entity->expense_documents() as $expense)
|
||||
@foreach($expense->documents as $document)
|
||||
<div class="inline-flex items-center space-x-1">
|
||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="text-primary h-6 w-4">
|
||||
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
|
||||
<polyline points="15 3 21 3 21 9"></polyline>
|
||||
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||
</svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="text-primary h-6 w-4">
|
||||
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
|
||||
<polyline points="15 3 21 3 21 9"></polyline>
|
||||
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||
</svg>
|
||||
|
||||
@if (!$loop->last)
|
||||
<span>—</span>
|
||||
@endif
|
||||
</div>
|
||||
@if (!$loop->last)
|
||||
<span>—</span>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
@if($entity->task && $entity->company->invoice_task_documents)
|
||||
@foreach ($entity->task->documents as $document)
|
||||
<div class="inline-flex items-center space-x-1">
|
||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
||||
@if($entity instanceof App\Models\Invoice)
|
||||
@foreach ($entity->task_documents() as $task)
|
||||
@foreach($task->documents as $document)
|
||||
<div class="inline-flex items-center space-x-1">
|
||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="text-primary h-6 w-4">
|
||||
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
|
||||
<polyline points="15 3 21 3 21 9"></polyline>
|
||||
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||
</svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="text-primary h-6 w-4">
|
||||
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
|
||||
<polyline points="15 3 21 3 21 9"></polyline>
|
||||
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||
</svg>
|
||||
|
||||
@if (!$loop->last)
|
||||
<span>—</span>
|
||||
@endif
|
||||
</div>
|
||||
@if (!$loop->last)
|
||||
<span>—</span>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user