diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 9dcf7cca26..b2be3f8c07 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -102,45 +102,12 @@ class ClientService $this->client->increment('balance', $balance); $this->client->increment('paid_to_date', $paid_to_date); - /* - try { - DB::connection(config('database.default'))->transaction(function () use ($balance, $paid_to_date) { - $this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); - $this->client->balance += $balance; - $this->client->paid_to_date += $paid_to_date; - $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(); - } - - } - */ return $this; } public function updatePaidToDate(float $amount) { - // 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(); - // } - - // } - - nlog("incrementing paid_to_date by {$amount}"); - $this->client->increment('paid_to_date', $amount); return $this; diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index 61daa74098..82d24f67b7 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -155,18 +155,16 @@ class DeletePayment } //sometimes the payment is NOT created properly, this catches the payment and prevents the paid to date reducing inappropriately. - if ($this->update_client_paid_to_date) { + // if ($this->update_client_paid_to_date) { - $reduced_paid_to_date = $this->payment->amount < 0 ? $this->payment->amount * -1 : min(0, ($this->payment->amount - $this->payment->refunded - $this->_paid_to_date_deleted) * -1); + // $reduced_paid_to_date = $this->payment->amount < 0 ? $this->payment->amount * -1 : min(0, ($this->payment->amount - $this->payment->refunded - $this->_paid_to_date_deleted) * -1); - // $reduced_paid_to_date = min(0, ($this->payment->amount - $this->payment->refunded - $this->_paid_to_date_deleted) * -1); - - $this->payment - ->client - ->service() - ->updatePaidToDate($reduced_paid_to_date) - ->save(); - } + // $this->payment + // ->client + // ->service() + // ->updatePaidToDate($reduced_paid_to_date) + // ->save(); + // } return $this; }