Release transactions on failures

This commit is contained in:
David Bomba 2022-04-26 11:46:33 +10:00
parent bc76424fd7
commit 3a6258fd42
3 changed files with 6 additions and 2 deletions

View File

@ -309,6 +309,10 @@ class BaseImport
); );
} }
} catch (\Exception $ex) { } catch (\Exception $ex) {
if(\DB::connection(config('database.default'))->transactionLevel() > 0)
\DB::connection(config('database.default'))->rollBack();
if ($ex instanceof ImportException) { if ($ex instanceof ImportException) {
$message = $ex->getMessage(); $message = $ex->getMessage();
} else { } else {

View File

@ -445,7 +445,7 @@ class StripePaymentDriver extends BaseDriver
if(count($searchResults) == 1){ if(count($searchResults) == 1){
$customer = $searchResults->data[0]; $customer = $searchResults->data[0];
$this->updateStripeCustomer($customer); // $this->updateStripeCustomer($customer);
return $customer; return $customer;
} }

View File

@ -105,7 +105,7 @@ class MarkPaid extends AbstractService
/* Get the last record for the client and set the current balance*/ /* Get the last record for the client and set the current balance*/
$client = Client::where('id', $this->invoice->client_id)->lockForUpdate()->first(); $client = Client::where('id', $this->invoice->client_id)->lockForUpdate()->first();
$client->paid_to_date += $payment->amount; $client->paid_to_date += $payment->amount;
$client->balance += $payment->amount * -1; $client->balance -= $payment->amount;
$client->save(); $client->save();
}, 1); }, 1);