diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 138486fdaea8..684629c268d7 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -482,7 +482,7 @@ class CheckData extends Command payments.id = paymentables.payment_id WHERE paymentable_type = ? AND paymentables.deleted_at is NULL - AND payments.amount > 0 + AND paymentables.amount > 0 AND payments.is_deleted = 0 AND payments.client_id = ?; "), [App\Models\Credit::class, $client->id] ); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 482d9303d51d..0b0db9f7859a 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -396,8 +396,7 @@ class UserController extends BaseController UserEmailChanged::dispatch($new_user, json_decode($old_user), auth()->user()->company()); } - $user->company_users()->update(["permissions_updated_at" => now()]); - + $user->company_users()->update(["permissions_updated_at" => now()]); event(new UserWasUpdated($user, auth()->user(), auth()->user()->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 0e398c40ba80..105df50ec9ba 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -41,7 +41,6 @@ class QueryLogging $timeStart = microtime(true); DB::enableQueryLog(); - $response = $next($request); // hide requests made by debugbar if (strstr($request->url(), '_debugbar') === false) { @@ -73,6 +72,6 @@ class QueryLogging } - return $response; + return $next($request); } } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index dc6158ac6ff6..fe22bdb63591 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -66,9 +66,8 @@ class StartupCheck $this->buildTemplates(); } - $response = $next($request); + return $next($request); - return $response; } diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index f4f630bd701e..a4e12df0a285 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -138,8 +138,10 @@ class DeletePayment }); } - $this->payment - ->client + + $client = $this->payment->client->fresh(); + + $client ->service() ->updatePaidToDate(($this->payment->amount - $this->payment->refunded)*-1) ->save(); @@ -147,7 +149,7 @@ class DeletePayment $transaction = [ 'invoice' => [], 'payment' => [], - 'client' => $this->payment->client->transaction_event(), + 'client' => $client->transaction_event(), 'credit' => [], 'metadata' => [], ]; @@ -165,8 +167,8 @@ class DeletePayment $multiplier = 1; - if($paymentable_credit->pivot->amount < 0) - $multiplier = -1; + if($paymentable_credit->pivot->amount < 0) + $multiplier = -1; $paymentable_credit->service() ->updateBalance($paymentable_credit->pivot->amount*$multiplier*-1) @@ -174,18 +176,13 @@ class DeletePayment ->setStatus(Credit::STATUS_SENT) ->save(); - $this->payment - ->client - ->service() - ->updatePaidToDate(($paymentable_credit->pivot->amount)*-1) - ->save(); + $client = $this->payment->client->fresh(); + + $client + ->service() + ->updatePaidToDate(($paymentable_credit->pivot->amount)*-1) + ->save(); - //01-03-2022 - // $paymentable_credit->service() - // ->updateBalance($paymentable_credit->pivot->amount*$multiplier) - // ->updatePaidToDate($paymentable_credit->pivot->amount*-1) - // ->setStatus(Credit::STATUS_SENT) - // ->save(); }); }