|
@@ -2,6 +2,7 @@
|
2
|
2
|
|
3
|
3
|
namespace App\Filament\Exports\Common;
|
4
|
4
|
|
|
5
|
+use App\Enums\Accounting\BillStatus;
|
5
|
6
|
use App\Models\Common\Vendor;
|
6
|
7
|
use Filament\Actions\Exports\ExportColumn;
|
7
|
8
|
use Filament\Actions\Exports\Exporter;
|
|
@@ -14,22 +15,60 @@ class VendorExporter extends Exporter
|
14
|
15
|
public static function getColumns(): array
|
15
|
16
|
{
|
16
|
17
|
return [
|
17
|
|
- ExportColumn::make('id')
|
18
|
|
- ->label('ID'),
|
19
|
|
- ExportColumn::make('company.name'),
|
20
|
18
|
ExportColumn::make('name'),
|
21
|
|
- ExportColumn::make('type'),
|
22
|
|
- ExportColumn::make('contractor_type'),
|
23
|
|
- ExportColumn::make('ssn'),
|
24
|
|
- ExportColumn::make('ein'),
|
25
|
|
- ExportColumn::make('currency_code'),
|
|
19
|
+ ExportColumn::make('type')
|
|
20
|
+ ->enum(),
|
|
21
|
+ ExportColumn::make('contractor_type')
|
|
22
|
+ ->enum(),
|
26
|
23
|
ExportColumn::make('account_number'),
|
27
|
|
- ExportColumn::make('website'),
|
28
|
|
- ExportColumn::make('notes'),
|
29
|
|
- ExportColumn::make('created_by'),
|
30
|
|
- ExportColumn::make('updated_by'),
|
31
|
|
- ExportColumn::make('created_at'),
|
32
|
|
- ExportColumn::make('updated_at'),
|
|
24
|
+ ExportColumn::make('contact.full_name')
|
|
25
|
+ ->label('Primary contact'),
|
|
26
|
+ ExportColumn::make('contact.email')
|
|
27
|
+ ->label('Email'),
|
|
28
|
+ ExportColumn::make('contact.first_available_phone')
|
|
29
|
+ ->label('Phone'),
|
|
30
|
+ ExportColumn::make('currency_code'),
|
|
31
|
+ ExportColumn::make('balance')
|
|
32
|
+ ->state(function (Vendor $record) {
|
|
33
|
+ return $record->bills()
|
|
34
|
+ ->unpaid()
|
|
35
|
+ ->get()
|
|
36
|
+ ->sumMoneyInDefaultCurrency('amount_due');
|
|
37
|
+ })
|
|
38
|
+ ->money(),
|
|
39
|
+ ExportColumn::make('overdue_amount')
|
|
40
|
+ ->state(function (Vendor $record) {
|
|
41
|
+ return $record->bills()
|
|
42
|
+ ->where('status', BillStatus::Overdue)
|
|
43
|
+ ->get()
|
|
44
|
+ ->sumMoneyInDefaultCurrency('amount_due');
|
|
45
|
+ })
|
|
46
|
+ ->money(),
|
|
47
|
+ ExportColumn::make('address.address_string')
|
|
48
|
+ ->label('Address')
|
|
49
|
+ ->enabledByDefault(false),
|
|
50
|
+ ExportColumn::make('address.address_line_1')
|
|
51
|
+ ->label('Address line 1'),
|
|
52
|
+ ExportColumn::make('address.address_line_2')
|
|
53
|
+ ->label('Address line 2'),
|
|
54
|
+ ExportColumn::make('address.city')
|
|
55
|
+ ->label('City'),
|
|
56
|
+ ExportColumn::make('address.state.name')
|
|
57
|
+ ->label('State'),
|
|
58
|
+ ExportColumn::make('address.postal_code')
|
|
59
|
+ ->label('Postal code'),
|
|
60
|
+ ExportColumn::make('address.country.name')
|
|
61
|
+ ->label('Country'),
|
|
62
|
+ ExportColumn::make('ssn')
|
|
63
|
+ ->label('SSN')
|
|
64
|
+ ->enabledByDefault(false),
|
|
65
|
+ ExportColumn::make('ein')
|
|
66
|
+ ->label('EIN')
|
|
67
|
+ ->enabledByDefault(false),
|
|
68
|
+ ExportColumn::make('website')
|
|
69
|
+ ->enabledByDefault(false),
|
|
70
|
+ ExportColumn::make('notes')
|
|
71
|
+ ->enabledByDefault(false),
|
33
|
72
|
];
|
34
|
73
|
}
|
35
|
74
|
|