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:
parent
7768f714e1
commit
1720baccc8
@ -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 */
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user