Fixes for db::raw queries

This commit is contained in:
David Bomba 2023-09-04 08:45:38 +10:00
parent 7c108c14f7
commit 62853c1dcb
2 changed files with 10 additions and 5 deletions

View File

@ -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()) {

View File

@ -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);
}