-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Transactions.php
55 lines (48 loc) · 1.46 KB
/
Transactions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace App\Exports\Banking;
use App\Abstracts\Export;
use App\Models\Banking\Transaction as Model;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
class Transactions extends Export implements WithColumnFormatting
{
public function collection()
{
return Model::with('account', 'category', 'contact', 'document')->collectForExport($this->ids, ['paid_at' => 'desc']);
}
public function map($model): array
{
$model->account_name = $model->account->name;
$model->contact_email = $model->contact->email;
$model->category_name = $model->category->name;
$model->invoice_bill_number = $model->document->document_number ?? 0;
$model->parent_number = Model::isRecurring()->find($model->parent_id)?->number;
return parent::map($model);
}
public function fields(): array
{
return [
'type',
'number',
'paid_at',
'amount',
'currency_code',
'currency_rate',
'account_name',
'invoice_bill_number',
'contact_email',
'category_name',
'description',
'payment_method',
'reference',
'reconciled',
'parent_number',
];
}
public function columnFormats(): array
{
return [
'C' => NumberFormat::FORMAT_DATE_YYYYMMDD,
];
}
}