mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 06:34:34 -04:00
Change the order we check a payment deleted status
This commit is contained in:
parent
6541bb2bfe
commit
9de6ee1d2a
@ -257,7 +257,8 @@ class PaymentRepository extends BaseRepository {
|
|||||||
|
|
||||||
$payment = $payment->service()->deletePayment();
|
$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;
|
return $payment;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class ClientService
|
|||||||
$this->client->balance += $amount;
|
$this->client->balance += $amount;
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
}, 2);
|
}, 1);
|
||||||
}
|
}
|
||||||
catch (\Throwable $throwable) {
|
catch (\Throwable $throwable) {
|
||||||
nlog("DB ERROR " . $throwable->getMessage());
|
nlog("DB ERROR " . $throwable->getMessage());
|
||||||
@ -58,7 +58,7 @@ class ClientService
|
|||||||
$this->client->paid_to_date += $paid_to_date;
|
$this->client->paid_to_date += $paid_to_date;
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
}, 2);
|
}, 1);
|
||||||
}
|
}
|
||||||
catch (\Throwable $throwable) {
|
catch (\Throwable $throwable) {
|
||||||
nlog("DB ERROR " . $throwable->getMessage());
|
nlog("DB ERROR " . $throwable->getMessage());
|
||||||
@ -79,7 +79,7 @@ class ClientService
|
|||||||
$this->client->paid_to_date += $amount;
|
$this->client->paid_to_date += $amount;
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
}, 2);
|
}, 1);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -38,22 +38,21 @@ class DeletePayment
|
|||||||
|
|
||||||
\DB::connection(config('database.default'))->transaction(function () {
|
\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->payment = Payment::withTrashed()->where('id', $this->payment->id)->lockForUpdate()->first();
|
||||||
|
|
||||||
$this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
|
if (!$this->payment->is_deleted) {
|
||||||
->updateCreditables() //return the credits first
|
|
||||||
->adjustInvoices()
|
$this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
|
||||||
->deletePaymentables()
|
->updateCreditables() //return the credits first
|
||||||
->cleanupPayment()
|
->adjustInvoices()
|
||||||
->save();
|
->deletePaymentables()
|
||||||
|
->cleanupPayment()
|
||||||
|
->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}, 2);
|
}, 1);
|
||||||
|
|
||||||
return $this->payment;
|
return $this->payment;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user