Andrew Wallo 4 个月前
父节点
当前提交
5dbc3695f9

+ 2
- 0
app/Filament/Actions/EditTransactionAction.php 查看文件

28
             };
28
             };
29
         });
29
         });
30
 
30
 
31
+        $this->slideOver();
32
+
31
         $this->visible(static fn (Transaction $transaction) => ! $transaction->transactionable_id);
33
         $this->visible(static fn (Transaction $transaction) => ! $transaction->transactionable_id);
32
 
34
 
33
         $this->modalWidth(function (): MaxWidth {
35
         $this->modalWidth(function (): MaxWidth {

+ 15
- 15
app/Filament/Company/Resources/Accounting/TransactionResource/Pages/ViewTransaction.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Resources\Accounting\TransactionResource\Pages;
3
 namespace App\Filament\Company\Resources\Accounting\TransactionResource\Pages;
4
 
4
 
5
-use App\Enums\Accounting\TransactionType;
6
 use App\Filament\Actions\EditTransactionAction;
5
 use App\Filament\Actions\EditTransactionAction;
7
 use App\Filament\Company\Resources\Accounting\TransactionResource;
6
 use App\Filament\Company\Resources\Accounting\TransactionResource;
8
 use App\Models\Accounting\JournalEntry;
7
 use App\Models\Accounting\JournalEntry;
12
 use Filament\Infolists\Components\TextEntry;
11
 use Filament\Infolists\Components\TextEntry;
13
 use Filament\Infolists\Infolist;
12
 use Filament\Infolists\Infolist;
14
 use Filament\Resources\Pages\ViewRecord;
13
 use Filament\Resources\Pages\ViewRecord;
15
-use Filament\Support\Enums\FontWeight;
16
 use Filament\Support\Enums\IconPosition;
14
 use Filament\Support\Enums\IconPosition;
17
 
15
 
18
 class ViewTransaction extends ViewRecord
16
 class ViewTransaction extends ViewRecord
71
                             ->date(),
69
                             ->date(),
72
                         TextEntry::make('type')
70
                         TextEntry::make('type')
73
                             ->badge(),
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
                         TextEntry::make('description')
78
                         TextEntry::make('description')
75
                             ->label('Description'),
79
                             ->label('Description'),
76
                         TextEntry::make('bankAccount.account.name')
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
                         TextEntry::make('account.name')
86
                         TextEntry::make('account.name')
79
                             ->label('Category')
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
                         TextEntry::make('amount')
89
                         TextEntry::make('amount')
83
                             ->label('Amount')
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
                         TextEntry::make('reviewed')
92
                         TextEntry::make('reviewed')
94
                             ->label('Status')
93
                             ->label('Status')
95
                             ->badge()
94
                             ->badge()
97
                             ->color(fn (bool $state): string => $state ? 'success' : 'warning'),
96
                             ->color(fn (bool $state): string => $state ? 'success' : 'warning'),
98
                         TextEntry::make('notes')
97
                         TextEntry::make('notes')
99
                             ->label('Notes')
98
                             ->label('Notes')
100
-                            ->columnSpanFull(),
99
+                            ->columnSpan(2)
100
+                            ->visible(fn (Transaction $record): bool => filled($record->notes)),
101
                     ]),
101
                     ]),
102
             ]);
102
             ]);
103
     }
103
     }

+ 0
- 10
app/Filament/Company/Resources/Accounting/TransactionResource/RelationManagers/JournalEntriesRelationManager.php 查看文件

41
                     ->weight(FontWeight::SemiBold)
41
                     ->weight(FontWeight::SemiBold)
42
                     ->sortable()
42
                     ->sortable()
43
                     ->currency(CurrencyAccessor::getDefaultCurrency()),
43
                     ->currency(CurrencyAccessor::getDefaultCurrency()),
44
-                Tables\Columns\TextColumn::make('created_at')
45
-                    ->label('Created at')
46
-                    ->dateTime()
47
-                    ->toggleable(isToggledHiddenByDefault: true)
48
-                    ->sortable(),
49
-                Tables\Columns\TextColumn::make('updated_at')
50
-                    ->label('Updated at')
51
-                    ->dateTime()
52
-                    ->toggleable(isToggledHiddenByDefault: true)
53
-                    ->sortable(),
54
             ])
44
             ])
55
             ->filters([
45
             ->filters([
56
                 //
46
                 //

+ 5
- 0
app/Models/Accounting/Transaction.php 查看文件

99
         return $this->journalEntries->contains(fn (JournalEntry $entry) => $entry->account->isUncategorized());
99
         return $this->journalEntries->contains(fn (JournalEntry $entry) => $entry->account->isUncategorized());
100
     }
100
     }
101
 
101
 
102
+    public function isPayment(): bool
103
+    {
104
+        return $this->is_payment;
105
+    }
106
+
102
     public function updateAmountIfBalanced(): void
107
     public function updateAmountIfBalanced(): void
103
     {
108
     {
104
         if ($this->journalEntries->areBalanced() && $this->journalEntries->sumDebits()->formatSimple() !== $this->getAttributeValue('amount')) {
109
         if ($this->journalEntries->areBalanced() && $this->journalEntries->sumDebits()->formatSimple() !== $this->getAttributeValue('amount')) {

正在加载...
取消
保存