|
@@ -35,7 +35,7 @@ class TransactionObserver
|
35
|
35
|
{
|
36
|
36
|
$this->transactionService->createJournalEntries($transaction);
|
37
|
37
|
|
38
|
|
- if (! $transaction->is_payment) {
|
|
38
|
+ if (! $transaction->transactionable) {
|
39
|
39
|
return;
|
40
|
40
|
}
|
41
|
41
|
|
|
@@ -57,7 +57,7 @@ class TransactionObserver
|
57
|
57
|
|
58
|
58
|
$this->transactionService->updateJournalEntries($transaction);
|
59
|
59
|
|
60
|
|
- if (! $transaction->is_payment) {
|
|
60
|
+ if (! $transaction->transactionable) {
|
61
|
61
|
return;
|
62
|
62
|
}
|
63
|
63
|
|
|
@@ -78,7 +78,7 @@ class TransactionObserver
|
78
|
78
|
DB::transaction(function () use ($transaction) {
|
79
|
79
|
$this->transactionService->deleteJournalEntries($transaction);
|
80
|
80
|
|
81
|
|
- if (! $transaction->is_payment) {
|
|
81
|
+ if (! $transaction->transactionable) {
|
82
|
82
|
return;
|
83
|
83
|
}
|
84
|
84
|
|
|
@@ -103,6 +103,10 @@ class TransactionObserver
|
103
|
103
|
|
104
|
104
|
protected function updateInvoiceTotals(Invoice $invoice, ?Transaction $excludedTransaction = null): void
|
105
|
105
|
{
|
|
106
|
+ if (! $invoice->hasPayments()) {
|
|
107
|
+ return;
|
|
108
|
+ }
|
|
109
|
+
|
106
|
110
|
$depositTotal = (int) $invoice->deposits()
|
107
|
111
|
->when($excludedTransaction, fn (Builder $query) => $query->whereKeyNot($excludedTransaction->getKey()))
|
108
|
112
|
->sum('amount');
|
|
@@ -138,6 +142,10 @@ class TransactionObserver
|
138
|
142
|
|
139
|
143
|
protected function updateBillTotals(Bill $bill, ?Transaction $excludedTransaction = null): void
|
140
|
144
|
{
|
|
145
|
+ if (! $bill->hasPayments()) {
|
|
146
|
+ return;
|
|
147
|
+ }
|
|
148
|
+
|
141
|
149
|
$withdrawalTotal = (int) $bill->withdrawals()
|
142
|
150
|
->when($excludedTransaction, fn (Builder $query) => $query->whereKeyNot($excludedTransaction->getKey()))
|
143
|
151
|
->sum('amount');
|