mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Attach expense documents to invoices
This commit is contained in:
parent
f59a7653ff
commit
8ef12f2ce9
@ -14,14 +14,18 @@ namespace App\Mail\Engine;
|
|||||||
use App\DataMapper\EmailTemplateDefaults;
|
use App\DataMapper\EmailTemplateDefaults;
|
||||||
use App\Jobs\Entity\CreateEntityPdf;
|
use App\Jobs\Entity\CreateEntityPdf;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
|
use App\Models\Expense;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Lang;
|
use Illuminate\Support\Facades\Lang;
|
||||||
|
|
||||||
class InvoiceEmailEngine extends BaseEmailEngine
|
class InvoiceEmailEngine extends BaseEmailEngine
|
||||||
{
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
public $invitation;
|
public $invitation;
|
||||||
|
|
||||||
public $client;
|
public $client;
|
||||||
@ -146,6 +150,32 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
|||||||
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
|
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$line_items = $this->invoice->line_items;
|
||||||
|
|
||||||
|
$expense_ids = [];
|
||||||
|
|
||||||
|
foreach($line_items as $item)
|
||||||
|
{
|
||||||
|
if(property_exists($item, 'expense_id'))
|
||||||
|
{
|
||||||
|
$expense_ids[] = $item->expense_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($expense_ids) > 0){
|
||||||
|
$expenses = Expense::whereIn('id', $this->transformKeys($expense_ids))
|
||||||
|
->where('invoice_documents', 1)
|
||||||
|
->cursor()
|
||||||
|
->each(function ($expense){
|
||||||
|
|
||||||
|
foreach($expense->documents as $document)
|
||||||
|
{
|
||||||
|
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => $document->type]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user