|
@@ -2,7 +2,6 @@
|
2
|
2
|
|
3
|
3
|
namespace App\Filament\Company\Resources\Accounting\TransactionResource\Pages;
|
4
|
4
|
|
5
|
|
-use App\Enums\Accounting\TransactionType;
|
6
|
5
|
use App\Filament\Actions\EditTransactionAction;
|
7
|
6
|
use App\Filament\Company\Resources\Accounting\TransactionResource;
|
8
|
7
|
use App\Models\Accounting\JournalEntry;
|
|
@@ -12,7 +11,6 @@ use Filament\Infolists\Components\Section;
|
12
|
11
|
use Filament\Infolists\Components\TextEntry;
|
13
|
12
|
use Filament\Infolists\Infolist;
|
14
|
13
|
use Filament\Resources\Pages\ViewRecord;
|
15
|
|
-use Filament\Support\Enums\FontWeight;
|
16
|
14
|
use Filament\Support\Enums\IconPosition;
|
17
|
15
|
|
18
|
16
|
class ViewTransaction extends ViewRecord
|
|
@@ -71,25 +69,26 @@ class ViewTransaction extends ViewRecord
|
71
|
69
|
->date(),
|
72
|
70
|
TextEntry::make('type')
|
73
|
71
|
->badge(),
|
|
72
|
+ TextEntry::make('is_payment')
|
|
73
|
+ ->label('Payment')
|
|
74
|
+ ->badge()
|
|
75
|
+ ->formatStateUsing(fn (bool $state): string => $state ? 'Yes' : 'No')
|
|
76
|
+ ->color(fn (bool $state): string => $state ? 'info' : 'gray')
|
|
77
|
+ ->visible(fn (Transaction $record): bool => $record->isPayment()),
|
74
|
78
|
TextEntry::make('description')
|
75
|
79
|
->label('Description'),
|
76
|
80
|
TextEntry::make('bankAccount.account.name')
|
77
|
|
- ->label('Account'),
|
|
81
|
+ ->label('Bank Account')
|
|
82
|
+ ->visible(fn (Transaction $record): bool => $record->bankAccount !== null),
|
|
83
|
+ TextEntry::make('payeeable.name')
|
|
84
|
+ ->label('Payee')
|
|
85
|
+ ->visible(fn (Transaction $record): bool => $record->payeeable !== null),
|
78
|
86
|
TextEntry::make('account.name')
|
79
|
87
|
->label('Category')
|
80
|
|
- ->prefix(fn (Transaction $record) => $record->type->isTransfer() ? 'Transfer to ' : null)
|
81
|
|
- ->state(fn (Transaction $record) => $record->account->name ?? 'Journal Entry'),
|
|
88
|
+ ->visible(fn (Transaction $record): bool => $record->account !== null),
|
82
|
89
|
TextEntry::make('amount')
|
83
|
90
|
->label('Amount')
|
84
|
|
- ->weight(fn (Transaction $record) => $record->reviewed ? null : FontWeight::SemiBold)
|
85
|
|
- ->color(
|
86
|
|
- fn (Transaction $record) => match ($record->type) {
|
87
|
|
- TransactionType::Deposit => 'success',
|
88
|
|
- TransactionType::Journal => 'primary',
|
89
|
|
- default => null,
|
90
|
|
- }
|
91
|
|
- )
|
92
|
|
- ->currency(fn (Transaction $record) => $record->bankAccount?->account->currency_code),
|
|
91
|
+ ->currency(fn (Transaction $record) => $record->bankAccount?->account->currency_code ?? 'USD'),
|
93
|
92
|
TextEntry::make('reviewed')
|
94
|
93
|
->label('Status')
|
95
|
94
|
->badge()
|
|
@@ -97,7 +96,8 @@ class ViewTransaction extends ViewRecord
|
97
|
96
|
->color(fn (bool $state): string => $state ? 'success' : 'warning'),
|
98
|
97
|
TextEntry::make('notes')
|
99
|
98
|
->label('Notes')
|
100
|
|
- ->columnSpanFull(),
|
|
99
|
+ ->columnSpan(2)
|
|
100
|
+ ->visible(fn (Transaction $record): bool => filled($record->notes)),
|
101
|
101
|
]),
|
102
|
102
|
]);
|
103
|
103
|
}
|