diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php index 6d29ac9b68..eb99c2b3cd 100644 --- a/app/Console/Commands/VerifyDatabase.php +++ b/app/Console/Commands/VerifyDatabase.php @@ -197,7 +197,7 @@ class VerifyDatabase extends Command $date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at; $this->error( 'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' . - ' Find it in the table called `accounts` and change the `deleted_at` field to: "' . $date . '"' + ' Find it in the table called "accounts" and change the "deleted_at" field to: "' . $date . '"' ); } } @@ -224,7 +224,7 @@ class VerifyDatabase extends Command foreach ($set as $entry) { $this->error( 'Error: Transaction #' . $entry->transaction_id . ' should have been deleted, but has not.' . - ' Find it in the table called `transactions` and change the `deleted_at` field to: "' . $entry->journal_deleted . '"' + ' Find it in the table called "transactions" and change the "deleted_at" field to: "' . $entry->journal_deleted . '"' ); } } @@ -242,7 +242,7 @@ class VerifyDatabase extends Command foreach ($set as $entry) { $this->error( - 'Error: Journal #' . $entry->id . ' has zero transactions. Open table `transaction_journals` and delete the entry with id #' . $entry->id + 'Error: Journal #' . $entry->id . ' has zero transactions. Open table "transaction_journals" and delete the entry with id #' . $entry->id ); } @@ -303,7 +303,7 @@ class VerifyDatabase extends Command foreach ($set as $entry) { $this->error( 'Error: Transaction journal #' . $entry->journal_id . ' should have been deleted, but has not.' . - ' Find it in the table called `transaction_journals` and change the `deleted_at` field to: "' . $entry->transaction_deleted . '"' + ' Find it in the table called "transaction_journals" and change the "deleted_at" field to: "' . $entry->transaction_deleted . '"' ); } } diff --git a/app/Helpers/Report/AccountReportHelper.php b/app/Helpers/Report/AccountReportHelper.php index c5ecb3b155..fdb5539ed9 100644 --- a/app/Helpers/Report/AccountReportHelper.php +++ b/app/Helpers/Report/AccountReportHelper.php @@ -139,6 +139,6 @@ class AccountReportHelper implements AccountReportHelperInterface ->whereNull('transactions.deleted_at') ->where('transaction_journals.date', '<=', $date->format('Y-m-d')) ->groupBy('accounts.id') - ->get(['accounts.id', DB::raw('SUM(`transactions`.`amount`) as `balance`')]); + ->get(['accounts.id', DB::raw('SUM(transactions.amount) AS balance')]); } } diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php index 781191b576..4210cc66fe 100644 --- a/app/Helpers/Report/BalanceReportHelper.php +++ b/app/Helpers/Report/BalanceReportHelper.php @@ -128,7 +128,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface ->get( [ 't_destination.account_id', - DB::raw('SUM(`t_destination`.`amount`) as `sum`'), + DB::raw('SUM(t_destination.amount) AS sum'), ] ); diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index b333b26cf1..2e12076d10 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -106,7 +106,7 @@ class BillRepository implements BillRepositoryInterface ->get( [ 'bills.*', - DB::raw('((`bills`.`amount_min` + `bills`.`amount_max`) / 2) as `expectedAmount`'), + DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'), ] )->sortBy('name'); @@ -141,7 +141,7 @@ class BillRepository implements BillRepositoryInterface [ 'transaction_journals.bill_id', 'transaction_journals.id', - DB::raw('SUM(`transactions`.`amount`) as `journalAmount`'), + DB::raw('SUM(transactions.amount) AS journalAmount'), ] ); @@ -247,7 +247,7 @@ class BillRepository implements BillRepositoryInterface $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0); } ) - ->first([DB::raw('SUM(`transactions`.`amount`) as `sum_amount`')]); + ->first([DB::raw('SUM(transactions.amount) AS sum_amount')]); $sumAmount = $paid->sum_amount ?? '0'; $amount = bcadd($amount, $sumAmount); } @@ -282,7 +282,7 @@ class BillRepository implements BillRepositoryInterface $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0); } ) - ->first([DB::raw('SUM(`transactions`.`amount`) as `sum_amount`')]); + ->first([DB::raw('SUM(transactions.amount) AS sum_amount')]); $sumAmount = $paid->sum_amount ?? '0'; $paidBill = bcadd($sumAmount, $paidBill); } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 404e5e4f21..fce3033619 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -229,7 +229,7 @@ class JournalRepository implements JournalRepositoryInterface $transactions = new Collection; $fields = ['transactions.id', 'transactions.created_at', 'transactions.updated_at', 'transactions.deleted_at', 'transactions.account_id', 'transactions.transaction_journal_id', 'transactions.description', 'transactions.amount', - DB::raw('SUM(`transactions`.`amount`) as `sum`')]; + DB::raw('SUM(transactions.amount) AS sum')]; $groupBy = ['transactions.id', 'transactions.created_at', 'transactions.updated_at', 'transactions.deleted_at', 'transactions.account_id', 'transactions.transaction_journal_id', 'transactions.description', 'transactions.amount']; switch ($journal->transactionType->type) { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 15cf25c94a..d94b7af230 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -124,7 +124,7 @@ class Steam ->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->groupBy('transaction_journals.date') - ->get(['transaction_journals.date', DB::raw('SUM(`transactions`.`amount`) as `modified`')]); + ->get(['transaction_journals.date', DB::raw('SUM(transactions.amount) AS modified')]); $currentBalance = $startBalance; foreach ($set as $entry) { $modified = is_null($entry->modified) ? '0' : strval($entry->modified); @@ -164,7 +164,7 @@ class Steam ->where('transaction_journals.date', '<=', $date->format('Y-m-d')) ->groupBy('transactions.account_id') ->whereIn('transactions.account_id', $ids) - ->get(['transactions.account_id', DB::raw('sum(`transactions`.`amount`) as aggregate')]); + ->get(['transactions.account_id', DB::raw('sum(transactions.amount) AS aggregate')]); $result = []; foreach ($balances as $entry) { @@ -191,7 +191,7 @@ class Steam $set = auth()->user()->transactions() ->whereIn('transactions.account_id', $accounts) ->groupBy(['transactions.account_id', 'transaction_journals.user_id']) - ->get(['transactions.account_id', DB::raw('MAX(`transaction_journals`.`date`) as `max_date`')]); + ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]); foreach ($set as $entry) { $list[intval($entry->account_id)] = new Carbon($entry->max_date);