mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-03 12:47:17 -06:00
Renamed various fields from 'amount' to 'queryAmount' to prevent interfering with the getAmountAttribute property.
This commit is contained in:
parent
0224d1d59b
commit
37f40d8637
@ -60,15 +60,15 @@ class ReportHelper implements ReportHelperInterface
|
||||
$join->on('budget_limits.budget_id', '=', 'budgets.id')->where('budget_limits.startdate', '=', $date->format('Y-m-d'));
|
||||
}
|
||||
)
|
||||
->get(['budgets.*', 'budget_limits.amount as amount']);
|
||||
->get(['budgets.*', 'budget_limits.amount as queryAmount']);
|
||||
|
||||
$budgets = Steam::makeArray($set);
|
||||
$amountSet = $query->journalsByBudget($start, $end, $showSharedReports);
|
||||
$amounts = Steam::makeArray($amountSet);
|
||||
$budgets = Steam::mergeArrays($budgets, $amounts);
|
||||
$budgets[0]['spent'] = isset($budgets[0]['spent']) ? $budgets[0]['spent'] : 0.0;
|
||||
$budgets[0]['amount'] = isset($budgets[0]['amount']) ? $budgets[0]['amount'] : 0.0;
|
||||
$budgets[0]['name'] = 'No budget';
|
||||
$budgets = Steam::makeArray($set);
|
||||
$amountSet = $query->journalsByBudget($start, $end, $showSharedReports);
|
||||
$amounts = Steam::makeArray($amountSet);
|
||||
$budgets = Steam::mergeArrays($budgets, $amounts);
|
||||
$budgets[0]['spent'] = isset($budgets[0]['spent']) ? $budgets[0]['spent'] : 0.0;
|
||||
$budgets[0]['queryAmount'] = isset($budgets[0]['queryAmount']) ? $budgets[0]['queryAmount'] : 0.0;
|
||||
$budgets[0]['name'] = 'No budget';
|
||||
|
||||
// find transactions to shared asset accounts, which are without a budget by default:
|
||||
// which is only relevant when shared asset accounts are hidden.
|
||||
|
@ -96,7 +96,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
->get(
|
||||
[
|
||||
'transaction_journals.*',
|
||||
'transactions.amount'
|
||||
'transactions.amount as queryAmount'
|
||||
]
|
||||
);
|
||||
|
||||
@ -178,7 +178,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
{
|
||||
$query = $this->queryJournalsNoBudget($account, $start, $end);
|
||||
|
||||
return $query->get(['budgets.id', 'budgets.name', DB::Raw('SUM(`transactions`.`amount`) as `amount`')]);
|
||||
return $query->get(['budgets.id', 'budgets.name', DB::Raw('SUM(`transactions`.`amount`) as `queryAmount`')]);
|
||||
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
{
|
||||
$query = $this->queryJournalsNoBudget($account, $start, $end);
|
||||
|
||||
return $query->get(['budgets.name', 'transactions.amount', 'transaction_journals.*']);
|
||||
return $query->get(['budgets.name', 'transactions.amount as queryAmount', 'transaction_journals.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,7 +244,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
'transaction_journals.description',
|
||||
'transaction_journals.encrypted',
|
||||
'transaction_types.type',
|
||||
DB::Raw('SUM(`t_to`.`amount`) as `amount`'),
|
||||
DB::Raw('SUM(`t_to`.`amount`) as `queryAmount`'),
|
||||
'transaction_journals.date',
|
||||
't_from.account_id as account_id',
|
||||
'ac_from.name as name',
|
||||
@ -334,9 +334,9 @@ class ReportQuery implements ReportQueryInterface
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||
->where('transaction_types.type', 'Withdrawal')
|
||||
->groupBy('categories.id')
|
||||
->orderBy('amount');
|
||||
->orderBy('queryAmount');
|
||||
|
||||
$data = $query->get(['categories.id', 'categories.encrypted', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
|
||||
$data = $query->get(['categories.id', 'categories.encrypted', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `queryAmount`')]);
|
||||
// decrypt data:
|
||||
$data->each(
|
||||
function (Model $object) {
|
||||
@ -389,9 +389,9 @@ class ReportQuery implements ReportQueryInterface
|
||||
$query->before($end)->after($start)
|
||||
->where('transaction_journals.user_id', Auth::user()->id)
|
||||
->groupBy('t_to.account_id')
|
||||
->orderBy('amount', 'DESC');
|
||||
->orderBy('queryAmount', 'DESC');
|
||||
|
||||
$data = $query->get(['t_to.account_id as id', 'ac_to.name as name', 'ac_to.encrypted', DB::Raw('SUM(t_to.amount) as `amount`')]);
|
||||
$data = $query->get(['t_to.account_id as id', 'ac_to.name as name', 'ac_to.encrypted', DB::Raw('SUM(t_to.amount) as `queryAmount`')]);
|
||||
|
||||
// decrypt
|
||||
$data->each(
|
||||
@ -440,10 +440,10 @@ class ReportQuery implements ReportQueryInterface
|
||||
$query->where('transaction_types.type', 'Deposit');
|
||||
}
|
||||
|
||||
$query->groupBy('t_from.account_id')->orderBy('amount');
|
||||
$query->groupBy('t_from.account_id')->orderBy('queryAmount');
|
||||
|
||||
$data = $query->get(
|
||||
['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `amount`')]
|
||||
['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `queryAmount`')]
|
||||
);
|
||||
// decrypt
|
||||
$data->each(
|
||||
@ -488,7 +488,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
->where('transaction_journals.user_id', Auth::user()->id)
|
||||
->get(
|
||||
['transaction_journals.id', 'transaction_journals.description', 'transactions.account_id', 'accounts.name',
|
||||
'transactions.amount']
|
||||
'transactions.amount as queryAmount']
|
||||
);
|
||||
|
||||
}
|
||||
@ -533,7 +533,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
[
|
||||
'categories.id',
|
||||
'categories.name as name',
|
||||
DB::Raw('SUM(`transactions`.`amount`) * -1 AS `amount`')
|
||||
DB::Raw('SUM(`transactions`.`amount`) * -1 AS `queryAmount`')
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class ReportController extends Controller
|
||||
$id = intval($budget->id);
|
||||
$data = $budget->toArray();
|
||||
$array[$id] = $data;
|
||||
if (floatval($data['amount']) != 0) {
|
||||
if (floatval($data['queryAmount']) != 0) {
|
||||
$hide = false;
|
||||
}
|
||||
}
|
||||
|
@ -103,14 +103,16 @@ class Steam
|
||||
$id = intval($entry->id);
|
||||
if (isset($array[$id])) {
|
||||
$array[$id]['amount'] += floatval($entry->amount);
|
||||
$array[$id]['queryAmount'] += floatval($entry->queryAmount);
|
||||
$array[$id]['spent'] += floatval($entry->spent);
|
||||
$array[$id]['encrypted'] = intval($entry->encrypted);
|
||||
} else {
|
||||
$array[$id] = [
|
||||
'amount' => floatval($entry->amount),
|
||||
'spent' => floatval($entry->spent),
|
||||
'encrypted' => intval($entry->encrypted),
|
||||
'name' => $entry->name
|
||||
'amount' => floatval($entry->amount),
|
||||
'queryAmount' => floatval($entry->queryAmount),
|
||||
'spent' => floatval($entry->spent),
|
||||
'encrypted' => intval($entry->encrypted),
|
||||
'name' => $entry->name
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -131,7 +133,7 @@ class Steam
|
||||
foreach ($two as $id => $value) {
|
||||
// $otherId also exists in $one:
|
||||
if (isset($one[$id])) {
|
||||
$one[$id]['amount'] += $value['amount'];
|
||||
$one[$id]['queryAmount'] += $value['queryAmount'];
|
||||
$one[$id]['spent'] += $value['spent'];
|
||||
} else {
|
||||
$one[$id] = $value;
|
||||
@ -170,11 +172,11 @@ class Steam
|
||||
{
|
||||
uasort(
|
||||
$array, function ($left, $right) {
|
||||
if ($left['amount'] == $right['amount']) {
|
||||
if ($left['queryAmount'] == $right['queryAmount']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($left['amount'] < $right['amount']) ? 1 : -1;
|
||||
return ($left['queryAmount'] < $right['queryAmount']) ? 1 : -1;
|
||||
}
|
||||
);
|
||||
|
||||
@ -193,11 +195,11 @@ class Steam
|
||||
{
|
||||
uasort(
|
||||
$array, function ($left, $right) {
|
||||
if ($left['amount'] == $right['amount']) {
|
||||
if ($left['queryAmount'] == $right['queryAmount']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($left['amount'] < $right['amount']) ? -1 : 1;
|
||||
return ($left['queryAmount'] < $right['queryAmount']) ? -1 : 1;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -75,7 +75,7 @@
|
||||
@foreach($budgets as $id => $budget)
|
||||
<tr>
|
||||
<td>{{{$budget['name']}}}</td>
|
||||
<td>{!! Amount::format($budget['amount']) !!}</td>
|
||||
<td>{!! Amount::format($budget['queryAmount']) !!}</td>
|
||||
<?php $spent = 0;?>
|
||||
@foreach($accounts as $account)
|
||||
@if($account->hide === false)
|
||||
@ -83,23 +83,23 @@
|
||||
<td>
|
||||
@if($id == 0)
|
||||
<a href="{{route('reports.no-budget',[$account, $year, $month])}}" class="openModal">
|
||||
{!! Amount::format($account->budgetInformation[$id]['amount']) !!}
|
||||
{!! Amount::format($account->budgetInformation[$id]['queryAmount']) !!}
|
||||
</a>
|
||||
@else
|
||||
{!! Amount::format($account->budgetInformation[$id]['amount']) !!}
|
||||
{!! Amount::format($account->budgetInformation[$id]['queryAmount']) !!}
|
||||
@endif
|
||||
</td>
|
||||
<?php
|
||||
$spent += floatval($account->budgetInformation[$id]['amount']);
|
||||
$accountSums[$account->id] += floatval($account->budgetInformation[$id]['amount']);
|
||||
$spent += floatval($account->budgetInformation[$id]['queryAmount']);
|
||||
$accountSums[$account->id] += floatval($account->budgetInformation[$id]['queryAmount']);
|
||||
?>
|
||||
@else
|
||||
<td>{!! Amount::format(0) !!}</td>
|
||||
@endif
|
||||
@endif
|
||||
@endforeach
|
||||
<td>{!! Amount::format($budget['amount'] + $budget['spent']) !!}</td>
|
||||
<td>{!! Amount::format($budget['amount'] + $spent) !!}</td>
|
||||
<td>{!! Amount::format($budget['queryAmount'] + $budget['spent']) !!}</td>
|
||||
<td>{!! Amount::format($budget['queryAmount'] + $spent) !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
@ -122,10 +122,10 @@
|
||||
@if($account->hide === false)
|
||||
@if(isset($account->budgetInformation[0]))
|
||||
<td>
|
||||
@if($account->budgetInformation[0]['amount'] + $account->balancedAmount != 0.0)
|
||||
<a href="{{route('reports.left-unbalanced',[$account, $year, $month])}}" class="openModal">{!! Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount) !!}</a>
|
||||
@if($account->budgetInformation[0]['queryAmount'] + $account->balancedAmount != 0.0)
|
||||
<a href="{{route('reports.left-unbalanced',[$account, $year, $month])}}" class="openModal">{!! Amount::format($account->budgetInformation[0]['queryAmount'] + $account->balancedAmount) !!}</a>
|
||||
@else
|
||||
{!! Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount) !!}
|
||||
{!! Amount::format($account->budgetInformation[0]['queryAmount'] + $account->balancedAmount) !!}
|
||||
@endif
|
||||
</td>
|
||||
@else
|
||||
|
Loading…
Reference in New Issue
Block a user