mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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\InvoiceSum;
|
||||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||||
use App\Jobs\Entity\CreateEntityPdf;
|
use App\Jobs\Entity\CreateEntityPdf;
|
||||||
|
use App\Models\Expense;
|
||||||
use App\Models\Presenters\InvoicePresenter;
|
use App\Models\Presenters\InvoicePresenter;
|
||||||
|
use App\Models\Task;
|
||||||
use App\Services\Invoice\InvoiceService;
|
use App\Services\Invoice\InvoiceService;
|
||||||
use App\Services\Ledger\LedgerService;
|
use App\Services\Ledger\LedgerService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\Invoice\ActionsInvoice;
|
use App\Utils\Traits\Invoice\ActionsInvoice;
|
||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\MakesInvoiceValues;
|
use App\Utils\Traits\MakesInvoiceValues;
|
||||||
use App\Utils\Traits\MakesReminders;
|
use App\Utils\Traits\MakesReminders;
|
||||||
use App\Utils\Traits\NumberFormatter;
|
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()
|
public function translate_entity()
|
||||||
{
|
{
|
||||||
return ctrans('texts.invoice');
|
return ctrans('texts.invoice');
|
||||||
|
@ -42,45 +42,49 @@
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
@if($entity->expense && $entity->expense->invoice_documents)
|
@if($entity instanceof App\Models\Invoice)
|
||||||
@foreach ($entity->expense->documents as $document)
|
@foreach ($entity->expense_documents() as $expense)
|
||||||
<div class="inline-flex items-center space-x-1">
|
@foreach($expense->documents as $document)
|
||||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
<div class="inline-flex items-center space-x-1">
|
||||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
<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"
|
<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"
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||||
class="text-primary h-6 w-4">
|
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>
|
<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>
|
<polyline points="15 3 21 3 21 9"></polyline>
|
||||||
<line x1="10" y1="14" x2="21" y2="3"></line>
|
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
@if (!$loop->last)
|
@if (!$loop->last)
|
||||||
<span>—</span>
|
<span>—</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($entity->task && $entity->company->invoice_task_documents)
|
@if($entity instanceof App\Models\Invoice)
|
||||||
@foreach ($entity->task->documents as $document)
|
@foreach ($entity->task_documents() as $task)
|
||||||
<div class="inline-flex items-center space-x-1">
|
@foreach($task->documents as $document)
|
||||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
<div class="inline-flex items-center space-x-1">
|
||||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
<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"
|
<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"
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||||
class="text-primary h-6 w-4">
|
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>
|
<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>
|
<polyline points="15 3 21 3 21 9"></polyline>
|
||||||
<line x1="10" y1="14" x2="21" y2="3"></line>
|
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
@if (!$loop->last)
|
@if (!$loop->last)
|
||||||
<span>—</span>
|
<span>—</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user