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

Checks inside transactions

This commit is contained in:
David Bomba 2023-01-15 14:59:42 +11:00
parent 7768f714e1
commit 1720baccc8
2 changed files with 13 additions and 10 deletions

View File

@ -57,16 +57,19 @@ class MarkPaid extends AbstractService
$this->invoice = Invoice::withTrashed()->where('id', $this->invoice->id)->lockForUpdate()->first();
$this->payable_balance = $this->invoice->balance;
$this->invoice
->service()
->setExchangeRate()
->updateBalance($this->payable_balance * -1)
->updatePaidToDate($this->payable_balance)
->setStatus(Invoice::STATUS_PAID)
->save();
if($this->invoice)
{
$this->payable_balance = $this->invoice->balance;
$this->invoice
->service()
->setExchangeRate()
->updateBalance($this->payable_balance * -1)
->updatePaidToDate($this->payable_balance)
->setStatus(Invoice::STATUS_PAID)
->save();
}
}, 1);
/* Create Payment */

View File

@ -40,7 +40,7 @@ class DeletePayment
$this->payment = Payment::withTrashed()->where('id', $this->payment->id)->lockForUpdate()->first();
if (!$this->payment->is_deleted) {
if ($this->payment && !$this->payment->is_deleted) {
$this->setStatus(Payment::STATUS_CANCELLED) //sets status of payment
->updateCreditables() //return the credits first