Andrew Wallo 4 months ago
parent
commit
87ff7f2032

+ 6
- 6
app/Filament/Company/Pages/Reports/AccountTransactions.php View File

48
             $this->setFilterState('selectedAccount', 'all');
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
                 ])->extraFieldWrapperAttributes([
95
                 ])->extraFieldWrapperAttributes([
96
                     'class' => 'report-hidden-label',
96
                     'class' => 'report-hidden-label',
97
                 ]),
97
                 ]),
98
-                Select::make('selectedEntity')
99
-                    ->label('Entity')
98
+                Select::make('selectedPayee')
99
+                    ->label('Payee')
100
                     ->options($this->getEntityOptions())
100
                     ->options($this->getEntityOptions())
101
                     ->searchable()
101
                     ->searchable()
102
                     ->selectablePlaceholder(false),
102
                     ->selectablePlaceholder(false),
139
             ->toArray();
139
             ->toArray();
140
 
140
 
141
         $allEntitiesOption = [
141
         $allEntitiesOption = [
142
-            'All Entities' => ['all' => 'All Entities'],
142
+            'All Payees' => ['all' => 'All Payees'],
143
         ];
143
         ];
144
 
144
 
145
         return $allEntitiesOption + [
145
         return $allEntitiesOption + [
155
             endDate: $this->getFormattedEndDate(),
155
             endDate: $this->getFormattedEndDate(),
156
             columns: $columns,
156
             columns: $columns,
157
             accountId: $this->getFilterState('selectedAccount'),
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 View File

7
 use App\Models\Accounting\Bill;
7
 use App\Models\Accounting\Bill;
8
 use App\Models\Accounting\Invoice;
8
 use App\Models\Accounting\Invoice;
9
 use App\Models\Accounting\Transaction;
9
 use App\Models\Accounting\Transaction;
10
+use App\Models\Common\Client;
11
+use App\Models\Common\Vendor;
10
 use App\Repositories\Accounting\JournalEntryRepository;
12
 use App\Repositories\Accounting\JournalEntryRepository;
11
 use App\Utilities\Currency\CurrencyAccessor;
13
 use App\Utilities\Currency\CurrencyAccessor;
12
 use App\ValueObjects\Money;
14
 use App\ValueObjects\Money;
128
                 ->whereBetween('transactions.posted_at', [$startDate, $endDate])
130
                 ->whereBetween('transactions.posted_at', [$startDate, $endDate])
129
                 ->join('transactions', 'transactions.id', '=', 'journal_entries.transaction_id')
131
                 ->join('transactions', 'transactions.id', '=', 'journal_entries.transaction_id')
130
                 ->orderBy('transactions.posted_at')
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
             if ($entityId) {
135
             if ($entityId) {
134
                 $entityId = (int) $entityId;
136
                 $entityId = (int) $entityId;
135
                 if ($entityId < 0) {
137
                 if ($entityId < 0) {
136
                     $query->whereHas('transaction', function ($query) use ($entityId) {
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
                 } else {
142
                 } else {
142
                     $query->whereHas('transaction', function ($query) use ($entityId) {
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
             }

Loading…
Cancel
Save