Akaunting/app/Exports/Banking/Transactions.php

54 lines
1.4 KiB
PHP
Raw Normal View History

2019-11-16 07:21:14 +00:00
<?php
namespace App\Exports\Banking;
2020-01-19 23:05:40 +00:00
use App\Abstracts\Export;
2019-11-16 07:21:14 +00:00
use App\Models\Banking\Transaction as Model;
2021-02-15 19:58:58 +00:00
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
2019-11-16 07:21:14 +00:00
2021-02-15 19:58:58 +00:00
class Transactions extends Export implements WithColumnFormatting
2019-11-16 07:21:14 +00:00
{
public function collection()
{
2022-06-01 07:15:55 +00:00
return Model::with('account', 'category', 'contact', 'document')->isNotRecurring()->collectForExport($this->ids, ['paid_at' => 'desc']);
2020-01-21 06:10:12 +00:00
}
public function map($model): array
{
$model->account_name = $model->account->name;
$model->contact_email = $model->contact->email;
$model->category_name = $model->category->name;
2021-02-15 20:11:10 +00:00
$model->invoice_bill_number = $model->document->document_number ?? 0;
2020-01-21 06:10:12 +00:00
return parent::map($model);
2019-11-16 07:21:14 +00:00
}
2020-01-19 23:05:40 +00:00
public function fields(): array
2019-11-16 07:21:14 +00:00
{
return [
'type',
2022-06-01 07:15:55 +00:00
'number',
2019-11-16 07:21:14 +00:00
'paid_at',
'amount',
'currency_code',
'currency_rate',
2020-01-21 06:10:12 +00:00
'account_name',
'invoice_bill_number',
'contact_email',
'category_name',
2020-01-19 21:21:37 +00:00
'description',
2019-11-16 07:21:14 +00:00
'payment_method',
2020-01-19 21:21:37 +00:00
'reference',
2019-11-16 07:21:14 +00:00
'reconciled',
];
}
2021-02-15 19:58:58 +00:00
public function columnFormats(): array
{
return [
'B' => NumberFormat::FORMAT_DATE_YYYYMMDD,
];
}
2020-01-19 21:21:37 +00:00
}