From 62853c1dcb823608b8078e734321ef0306764696 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Sep 2023 08:45:38 +1000 Subject: [PATCH] Fixes for db::raw queries --- app/Console/Commands/CheckData.php | 2 +- app/Services/Invoice/HandleRestore.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 89e4ba69f17d..6609752411d6 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -961,7 +961,7 @@ class CheckData extends Command } $records = DB::table($table) ->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id") - ->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id")->getValue(DB::connection()->getQueryGrammar())) + ->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id")) ->get(["{$table}.id"]); if ($records->count()) { diff --git a/app/Services/Invoice/HandleRestore.php b/app/Services/Invoice/HandleRestore.php index d2a4eeb1e1cc..d5edaa339c19 100644 --- a/app/Services/Invoice/HandleRestore.php +++ b/app/Services/Invoice/HandleRestore.php @@ -96,17 +96,22 @@ class HandleRestore extends AbstractService $this->adjustment_amount += $payment->paymentables ->where('paymentable_type', '=', 'invoices') ->where('paymentable_id', $this->invoice->id) - ->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar())); - + ->sum('amount'); + // ->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar())); +nlog($this->adjustment_amount); $this->adjustment_amount += $payment->paymentables ->where('paymentable_type', '=', 'invoices') ->where('paymentable_id', $this->invoice->id) - ->sum(DB::raw('refunded')->getValue(DB::connection()->getQueryGrammar())); + ->sum('amount'); + // ->sum(DB::raw('refunded')->getValue(DB::connection()->getQueryGrammar())); +nlog($this->adjustment_amount); //14/07/2023 - do not include credits in the payment amount $this->adjustment_amount -= $payment->paymentables ->where('paymentable_type', '=', 'App\Models\Credit') - ->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar())); + ->sum('amount'); + // ->sum(DB::raw('amount')->getValue(DB::connection()->getQueryGrammar())); +nlog($this->adjustment_amount); }