2020-12-24 01:28:38 +03:00
|
|
|
<?php
|
|
|
|
|
2023-08-14 17:21:40 +03:00
|
|
|
namespace App\Exports\Purchases\RecurringBills\Sheets;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
use App\Abstracts\Export;
|
|
|
|
use App\Models\Document\DocumentItem as Model;
|
|
|
|
|
2023-08-14 17:21:40 +03:00
|
|
|
class RecurringBillItems extends Export
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
|
|
|
public function collection()
|
|
|
|
{
|
2023-08-14 17:21:40 +03:00
|
|
|
return Model::with('document', 'item')->billRecurring()->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->bill_number = $document->document_number;
|
2020-12-24 01:28:38 +03:00
|
|
|
$model->item_name = $model->item->name;
|
2023-03-09 16:45:20 +03:00
|
|
|
$model->item_description = $model->item->description;
|
2023-03-03 22:08:09 +03:00
|
|
|
$model->item_type = $model->item->type;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
return parent::map($model);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fields(): array
|
|
|
|
{
|
|
|
|
return [
|
2020-12-25 19:25:38 +03:00
|
|
|
'bill_number',
|
2020-12-24 01:28:38 +03:00
|
|
|
'item_name',
|
2023-03-09 16:45:20 +03:00
|
|
|
'item_description',
|
2023-03-09 16:47:15 +03:00
|
|
|
'item_type',
|
2020-12-24 01:28:38 +03:00
|
|
|
'quantity',
|
|
|
|
'price',
|
|
|
|
'total',
|
|
|
|
'tax',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|