Andrew Wallo 4 miesięcy temu
rodzic
commit
87ff7f2032

+ 6
- 6
app/Filament/Company/Pages/Reports/AccountTransactions.php Wyświetl plik

@@ -48,8 +48,8 @@ class AccountTransactions extends BaseReportPage
48 48
             $this->setFilterState('selectedAccount', 'all');
49 49
         }
50 50
 
51
-        if (empty($this->getFilterState('selectedEntity'))) {
52
-            $this->setFilterState('selectedEntity', 'all');
51
+        if (empty($this->getFilterState('selectedPayee'))) {
52
+            $this->setFilterState('selectedPayee', 'all');
53 53
         }
54 54
     }
55 55
 
@@ -95,8 +95,8 @@ class AccountTransactions extends BaseReportPage
95 95
                 ])->extraFieldWrapperAttributes([
96 96
                     'class' => 'report-hidden-label',
97 97
                 ]),
98
-                Select::make('selectedEntity')
99
-                    ->label('Entity')
98
+                Select::make('selectedPayee')
99
+                    ->label('Payee')
100 100
                     ->options($this->getEntityOptions())
101 101
                     ->searchable()
102 102
                     ->selectablePlaceholder(false),
@@ -139,7 +139,7 @@ class AccountTransactions extends BaseReportPage
139 139
             ->toArray();
140 140
 
141 141
         $allEntitiesOption = [
142
-            'All Entities' => ['all' => 'All Entities'],
142
+            'All Payees' => ['all' => 'All Payees'],
143 143
         ];
144 144
 
145 145
         return $allEntitiesOption + [
@@ -155,7 +155,7 @@ class AccountTransactions extends BaseReportPage
155 155
             endDate: $this->getFormattedEndDate(),
156 156
             columns: $columns,
157 157
             accountId: $this->getFilterState('selectedAccount'),
158
-            entityId: $this->getFilterState('selectedEntity'),
158
+            entityId: $this->getFilterState('selectedPayee'),
159 159
         );
160 160
     }
161 161
 

+ 7
- 7
app/Services/AccountService.php Wyświetl plik

@@ -7,6 +7,8 @@ use App\Models\Accounting\Account;
7 7
 use App\Models\Accounting\Bill;
8 8
 use App\Models\Accounting\Invoice;
9 9
 use App\Models\Accounting\Transaction;
10
+use App\Models\Common\Client;
11
+use App\Models\Common\Vendor;
10 12
 use App\Repositories\Accounting\JournalEntryRepository;
11 13
 use App\Utilities\Currency\CurrencyAccessor;
12 14
 use App\ValueObjects\Money;
@@ -128,21 +130,19 @@ class AccountService
128 130
                 ->whereBetween('transactions.posted_at', [$startDate, $endDate])
129 131
                 ->join('transactions', 'transactions.id', '=', 'journal_entries.transaction_id')
130 132
                 ->orderBy('transactions.posted_at')
131
-                ->with('transaction:id,type,description,posted_at,is_payment,transactionable_id,transactionable_type');
133
+                ->with('transaction:id,type,description,posted_at,is_payment,payeeable_id,payeeable_type');
132 134
 
133 135
             if ($entityId) {
134 136
                 $entityId = (int) $entityId;
135 137
                 if ($entityId < 0) {
136 138
                     $query->whereHas('transaction', function ($query) use ($entityId) {
137
-                        $query->whereHasMorph('transactionable', [Bill::class], function ($query) use ($entityId) {
138
-                            $query->where('vendor_id', abs($entityId));
139
-                        });
139
+                        $query->where('payeeable_type', Vendor::class)
140
+                            ->where('payeeable_id', abs($entityId));
140 141
                     });
141 142
                 } else {
142 143
                     $query->whereHas('transaction', function ($query) use ($entityId) {
143
-                        $query->whereHasMorph('transactionable', [Invoice::class], function ($query) use ($entityId) {
144
-                            $query->where('client_id', $entityId);
145
-                        });
144
+                        $query->where('payeeable_type', Client::class)
145
+                            ->where('payeeable_id', $entityId);
146 146
                     });
147 147
                 }
148 148
             }

Ładowanie…
Anuluj
Zapisz