1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Change the order we check a payment deleted status

This commit is contained in:
David Bomba 2023-01-14 16:22:26 +11:00
parent 6541bb2bfe
commit 9de6ee1d2a
3 changed files with 16 additions and 16 deletions

View File

@ -257,7 +257,8 @@ class PaymentRepository extends BaseRepository {
$payment = $payment->service()->deletePayment();
event(new PaymentWasDeleted($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
if($payment)
event(new PaymentWasDeleted($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
return $payment;

View File

@ -37,7 +37,7 @@ class ClientService
$this->client->balance += $amount;
$this->client->save();
}, 2);
}, 1);
}
catch (\Throwable $throwable) {
nlog("DB ERROR " . $throwable->getMessage());
@ -58,7 +58,7 @@ class ClientService
$this->client->paid_to_date += $paid_to_date;
$this->client->save();
}, 2);
}, 1);
}
catch (\Throwable $throwable) {
nlog("DB ERROR " . $throwable->getMessage());
@ -79,7 +79,7 @@ class ClientService
$this->client->paid_to_date += $amount;
$this->client->save();
}, 2);
}, 1);
return $this;
}

View File

@ -38,22 +38,21 @@ class DeletePayment
\DB::connection(config('database.default'))->transaction(function () {
if ($this->payment->is_deleted) {
return $this->payment;
}
$this->payment = Payment::withTrashed()->where('id', $this->payment->id)->lockForUpdate()->first();
$this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
->updateCreditables() //return the credits first
->adjustInvoices()
->deletePaymentables()
->cleanupPayment()
->save();
if (!$this->payment->is_deleted) {
$this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
->updateCreditables() //return the credits first
->adjustInvoices()
->deletePaymentables()
->cleanupPayment()
->save();
}
}, 2);
}, 1);
return $this->payment;