mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-07-16 13:55:21 +00:00
27 lines
714 B
PHP
27 lines
714 B
PHP
<?php
|
|
|
|
namespace App\Exports\Concerns;
|
|
|
|
use App\Exports\Support\ExportFormatter;
|
|
use App\Models\EstimateItem;
|
|
use App\Models\InvoiceItem;
|
|
|
|
trait MapsLineTaxes
|
|
{
|
|
/**
|
|
* @return array<int, array<string, mixed>>
|
|
*/
|
|
protected static function lineTaxes(InvoiceItem|EstimateItem $item): array
|
|
{
|
|
return $item->taxes
|
|
->map(fn ($tax) => array_filter([
|
|
'tax_type_id' => $tax->tax_type_id,
|
|
'name' => $tax->taxType?->name ?? $tax->name ?? null,
|
|
'percent' => $tax->percent ?: null,
|
|
'amount' => $tax->amount ? ExportFormatter::money($tax->amount) : null,
|
|
]))
|
|
->values()
|
|
->all();
|
|
}
|
|
}
|