diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 96878cd2480e..8aabdbcbf487 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -44,6 +44,19 @@ class ClientService }, 2); } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); + DB::connection(config('database.default'))->rollBack(); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + + } catch(\Exception $exception){ + nlog("DB ERROR " . $exception->getMessage()); + DB::connection(config('database.default'))->rollBack(); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } } return $this; @@ -60,6 +73,17 @@ class ClientService }, 2); } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + + } catch(\Exception $exception){ + nlog("DB ERROR " . $exception->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } } return $this; @@ -67,11 +91,27 @@ class ClientService public function updatePaidToDate(float $amount) { - DB::connection(config('database.default'))->transaction(function () use ($amount) { - $this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); - $this->client->paid_to_date += $amount; - $this->client->saveQuietly(); - }, 2); + try { + DB::connection(config('database.default'))->transaction(function () use ($amount) { + $this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); + $this->client->paid_to_date += $amount; + $this->client->saveQuietly(); + }, 2); + } + catch (\Throwable $throwable) { + nlog("DB ERROR " . $throwable->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + + } catch(\Exception $exception){ + nlog("DB ERROR " . $exception->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + } return $this; } diff --git a/lang/en/texts.php b/lang/en/texts.php index a1c32b256f7c..49eb412a6202 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5179,6 +5179,7 @@ $LANG = array( 'stock_quantity_number' => 'Stock :quantity', 'upcoming' => 'Upcoming', 'client_contact' => 'Client Contact', + 'uncategorized' => 'Uncategorized', ); return $LANG;