mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 02:44:35 -04:00
Invoice filters for expense
This commit is contained in:
parent
1ecce29e56
commit
356834b628
@ -109,7 +109,7 @@ class ExpenseFilters extends QueryFilters
|
|||||||
public function has_invoices(string $value = ''): Builder
|
public function has_invoices(string $value = ''): Builder
|
||||||
{
|
{
|
||||||
if ($value == 'true') {
|
if ($value == 'true') {
|
||||||
return $this->builder->whereNotNull('invoice_id')->select('expenses.invoice_id');
|
return $this->builder->whereNotNull('invoice_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
|
@ -225,6 +225,11 @@ class Expense extends BaseModel
|
|||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function invoice()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Invoice::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function vendor()
|
public function vendor()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Vendor::class);
|
return $this->belongsTo(Vendor::class);
|
||||||
|
@ -13,6 +13,7 @@ namespace App\Transformers;
|
|||||||
|
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
|
use App\Models\Invoice;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\ExpenseCategory;
|
use App\Models\ExpenseCategory;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -39,6 +40,7 @@ class ExpenseTransformer extends EntityTransformer
|
|||||||
'client',
|
'client',
|
||||||
'vendor',
|
'vendor',
|
||||||
'category',
|
'category',
|
||||||
|
'invoice',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeDocuments(Expense $expense)
|
public function includeDocuments(Expense $expense)
|
||||||
@ -59,6 +61,17 @@ class ExpenseTransformer extends EntityTransformer
|
|||||||
return $this->includeItem($expense->client, $transformer, Client::class);
|
return $this->includeItem($expense->client, $transformer, Client::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeInvoice(Expense $expense): ?Item
|
||||||
|
{
|
||||||
|
$transformer = new InvoiceTransformer($this->serializer);
|
||||||
|
|
||||||
|
if (!$expense->invoice) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->includeItem($expense->invoice, $transformer, Invoice::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeCategory(Expense $expense): ?Item
|
public function includeCategory(Expense $expense): ?Item
|
||||||
{
|
{
|
||||||
$transformer = new ExpenseCategoryTransformer($this->serializer);
|
$transformer = new ExpenseCategoryTransformer($this->serializer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user