Andrew Wallo 4 kuukautta sitten
vanhempi
commit
5dbc3695f9

+ 2
- 0
app/Filament/Actions/EditTransactionAction.php Näytä tiedosto

@@ -28,6 +28,8 @@ class EditTransactionAction extends EditAction
28 28
             };
29 29
         });
30 30
 
31
+        $this->slideOver();
32
+
31 33
         $this->visible(static fn (Transaction $transaction) => ! $transaction->transactionable_id);
32 34
 
33 35
         $this->modalWidth(function (): MaxWidth {

+ 15
- 15
app/Filament/Company/Resources/Accounting/TransactionResource/Pages/ViewTransaction.php Näytä tiedosto

@@ -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
     }

+ 0
- 10
app/Filament/Company/Resources/Accounting/TransactionResource/RelationManagers/JournalEntriesRelationManager.php Näytä tiedosto

@@ -41,16 +41,6 @@ class JournalEntriesRelationManager extends RelationManager
41 41
                     ->weight(FontWeight::SemiBold)
42 42
                     ->sortable()
43 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 45
             ->filters([
56 46
                 //

+ 5
- 0
app/Models/Accounting/Transaction.php Näytä tiedosto

@@ -99,6 +99,11 @@ class Transaction extends Model
99 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 107
     public function updateAmountIfBalanced(): void
103 108
     {
104 109
         if ($this->journalEntries->areBalanced() && $this->journalEntries->sumDebits()->formatSimple() !== $this->getAttributeValue('amount')) {

Loading…
Peruuta
Tallenna