This commit is contained in:
James Cole 2016-10-06 05:26:38 +02:00
parent 5540697dbd
commit 9920504232
6 changed files with 14 additions and 14 deletions

View File

@ -197,7 +197,7 @@ class VerifyDatabase extends Command
$date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at; $date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at;
$this->error( $this->error(
'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' . '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) { foreach ($set as $entry) {
$this->error( $this->error(
'Error: Transaction #' . $entry->transaction_id . ' should have been deleted, but has not.' . '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) { foreach ($set as $entry) {
$this->error( $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) { foreach ($set as $entry) {
$this->error( $this->error(
'Error: Transaction journal #' . $entry->journal_id . ' should have been deleted, but has not.' . '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 . '"'
); );
} }
} }

View File

@ -139,6 +139,6 @@ class AccountReportHelper implements AccountReportHelperInterface
->whereNull('transactions.deleted_at') ->whereNull('transactions.deleted_at')
->where('transaction_journals.date', '<=', $date->format('Y-m-d')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
->groupBy('accounts.id') ->groupBy('accounts.id')
->get(['accounts.id', DB::raw('SUM(`transactions`.`amount`) as `balance`')]); ->get(['accounts.id', DB::raw('SUM(transactions.amount) AS balance')]);
} }
} }

View File

@ -128,7 +128,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
->get( ->get(
[ [
't_destination.account_id', 't_destination.account_id',
DB::raw('SUM(`t_destination`.`amount`) as `sum`'), DB::raw('SUM(t_destination.amount) AS sum'),
] ]
); );

View File

@ -106,7 +106,7 @@ class BillRepository implements BillRepositoryInterface
->get( ->get(
[ [
'bills.*', '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'); )->sortBy('name');
@ -141,7 +141,7 @@ class BillRepository implements BillRepositoryInterface
[ [
'transaction_journals.bill_id', 'transaction_journals.bill_id',
'transaction_journals.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); $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'; $sumAmount = $paid->sum_amount ?? '0';
$amount = bcadd($amount, $sumAmount); $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); $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'; $sumAmount = $paid->sum_amount ?? '0';
$paidBill = bcadd($sumAmount, $paidBill); $paidBill = bcadd($sumAmount, $paidBill);
} }

View File

@ -229,7 +229,7 @@ class JournalRepository implements JournalRepositoryInterface
$transactions = new Collection; $transactions = new Collection;
$fields = ['transactions.id', 'transactions.created_at', 'transactions.updated_at', 'transactions.deleted_at', 'transactions.account_id', $fields = ['transactions.id', 'transactions.created_at', 'transactions.updated_at', 'transactions.deleted_at', 'transactions.account_id',
'transactions.transaction_journal_id', 'transactions.description', 'transactions.amount', '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', $groupBy = ['transactions.id', 'transactions.created_at', 'transactions.updated_at', 'transactions.deleted_at', 'transactions.account_id',
'transactions.transaction_journal_id', 'transactions.description', 'transactions.amount']; 'transactions.transaction_journal_id', 'transactions.description', 'transactions.amount'];
switch ($journal->transactionType->type) { switch ($journal->transactionType->type) {

View File

@ -124,7 +124,7 @@ class Steam
->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->groupBy('transaction_journals.date') ->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; $currentBalance = $startBalance;
foreach ($set as $entry) { foreach ($set as $entry) {
$modified = is_null($entry->modified) ? '0' : strval($entry->modified); $modified = is_null($entry->modified) ? '0' : strval($entry->modified);
@ -164,7 +164,7 @@ class Steam
->where('transaction_journals.date', '<=', $date->format('Y-m-d')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
->groupBy('transactions.account_id') ->groupBy('transactions.account_id')
->whereIn('transactions.account_id', $ids) ->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 = []; $result = [];
foreach ($balances as $entry) { foreach ($balances as $entry) {
@ -191,7 +191,7 @@ class Steam
$set = auth()->user()->transactions() $set = auth()->user()->transactions()
->whereIn('transactions.account_id', $accounts) ->whereIn('transactions.account_id', $accounts)
->groupBy(['transactions.account_id', 'transaction_journals.user_id']) ->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) { foreach ($set as $entry) {
$list[intval($entry->account_id)] = new Carbon($entry->max_date); $list[intval($entry->account_id)] = new Carbon($entry->max_date);