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