2019-11-16 10:21:14 +03:00
|
|
|
<?php
|
|
|
|
|
2020-12-25 19:25:38 +03:00
|
|
|
namespace App\Exports\Sales\Sheets;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
use App\Abstracts\Export;
|
2020-12-24 01:28:38 +03:00
|
|
|
use App\Models\Document\Document as Model;
|
2021-01-27 23:13:56 +03:00
|
|
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
2020-11-13 03:07:30 +03:00
|
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2021-01-27 23:13:56 +03:00
|
|
|
class Invoices extends Export implements WithColumnFormatting
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
public function collection()
|
|
|
|
{
|
2022-06-05 03:33:26 +03:00
|
|
|
return Model::with('category')->invoice()->collectForExport($this->ids, ['document_number' => 'desc']);
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
|
2020-01-20 22:58:49 +03:00
|
|
|
public function map($model): array
|
|
|
|
{
|
|
|
|
$model->category_name = $model->category->name;
|
2020-12-25 19:25:38 +03:00
|
|
|
$model->invoice_number = $model->document_number;
|
|
|
|
$model->invoiced_at = $model->issued_at;
|
2021-11-08 02:40:40 +03:00
|
|
|
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2020-01-20 22:58:49 +03:00
|
|
|
return parent::map($model);
|
|
|
|
}
|
|
|
|
|
2020-01-20 02:05:40 +03:00
|
|
|
public function fields(): array
|
2019-11-16 10:21:14 +03:00
|
|
|
{
|
|
|
|
return [
|
2020-12-25 19:25:38 +03:00
|
|
|
'invoice_number',
|
2019-11-16 10:21:14 +03:00
|
|
|
'order_number',
|
2020-01-11 16:57:32 +03:00
|
|
|
'status',
|
2020-12-25 19:25:38 +03:00
|
|
|
'invoiced_at',
|
2019-11-16 10:21:14 +03:00
|
|
|
'due_at',
|
|
|
|
'amount',
|
|
|
|
'currency_code',
|
|
|
|
'currency_rate',
|
2020-01-20 22:58:49 +03:00
|
|
|
'category_name',
|
2019-11-16 10:21:14 +03:00
|
|
|
'contact_name',
|
|
|
|
'contact_email',
|
|
|
|
'contact_tax_number',
|
2020-01-06 13:49:23 +03:00
|
|
|
'contact_phone',
|
2019-11-16 10:21:14 +03:00
|
|
|
'contact_address',
|
2021-11-08 02:40:40 +03:00
|
|
|
'contact_country',
|
|
|
|
'contact_state',
|
|
|
|
'contact_zip_code',
|
|
|
|
'contact_city',
|
2019-11-16 10:21:14 +03:00
|
|
|
'notes',
|
|
|
|
'footer',
|
|
|
|
];
|
|
|
|
}
|
2020-11-13 03:07:30 +03:00
|
|
|
|
|
|
|
public function columnFormats(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'D' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
|
|
|
'E' => NumberFormat::FORMAT_DATE_YYYYMMDD,
|
|
|
|
];
|
|
|
|
}
|
2020-01-06 13:49:23 +03:00
|
|
|
}
|