2020-12-24 01:28:38 +03:00
|
|
|
<?php
|
|
|
|
|
2020-12-25 19:25:38 +03:00
|
|
|
namespace App\Exports\Sales\Sheets;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
use App\Abstracts\Export;
|
|
|
|
use App\Models\Document\DocumentItemTax as Model;
|
|
|
|
|
2020-12-25 19:25:38 +03:00
|
|
|
class InvoiceItemTaxes extends Export
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
|
|
|
public function collection()
|
|
|
|
{
|
2021-06-27 11:40:46 +03:00
|
|
|
return Model::with('document', 'item', 'tax')->invoice()->collectForExport($this->ids, null, 'document_id');
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function map($model): array
|
|
|
|
{
|
|
|
|
$document = $model->document;
|
|
|
|
|
|
|
|
if (empty($document)) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-12-25 19:25:38 +03:00
|
|
|
$model->invoice_number = $document->document_number;
|
2020-12-24 01:28:38 +03:00
|
|
|
$model->item_name = $model->item->name;
|
|
|
|
$model->tax_rate = $model->tax->rate;
|
|
|
|
|
|
|
|
return parent::map($model);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fields(): array
|
|
|
|
{
|
|
|
|
return [
|
2020-12-25 19:25:38 +03:00
|
|
|
'invoice_number',
|
2020-12-24 01:28:38 +03:00
|
|
|
'item_name',
|
|
|
|
'tax_rate',
|
|
|
|
'amount',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|