Skip to content

Firefly III: a personal finances manager

Fixed some views.

James Cole9e54eecfaa46
diff --git a/app/Helpers/Collection/Expense.php b/app/Helpers/Collection/Expense.php
index 3c0d908ab6..65f254b38d 100644
--- a/app/Helpers/Collection/Expense.php
+++ b/app/Helpers/Collection/Expense.php
@@ -37,14 +37,14 @@ class Expense
$accountId = $entry->account_id;
if (!$this->expenses->has($accountId)) {
$newObject = new stdClass;
- $newObject->amount = floatval($entry->queryAmount);
+ $newObject->amount = floatval($entry->amount);
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $accountId;
$this->expenses->put($accountId, $newObject);
} else {
$existing = $this->expenses->get($accountId);
- $existing->amount += floatval($entry->queryAmount);
+ $existing->amount += floatval($entry->amount);
$existing->count++;
$this->expenses->put($accountId, $existing);
}
diff --git a/app/Helpers/Collection/Income.php b/app/Helpers/Collection/Income.php
index c3e60e0cf7..420105209a 100644
--- a/app/Helpers/Collection/Income.php
+++ b/app/Helpers/Collection/Income.php
@@ -38,14 +38,14 @@ class Income
$accountId = $entry->account_id;
if (!$this->incomes->has($accountId)) {
$newObject = new stdClass;
- $newObject->amount = floatval($entry->queryAmount);
+ $newObject->amount = floatval($entry->amount);
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $accountId;
$this->incomes->put($accountId, $newObject);
} else {
$existing = $this->incomes->get($accountId);
- $existing->amount += floatval($entry->queryAmount);
+ $existing->amount += floatval($entry->amount);
$existing->count++;
$this->incomes->put($accountId, $existing);
}
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index deefb7d899..0329bf1dbe 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -332,9 +332,9 @@ class ReportHelper implements ReportHelperInterface
public function getExpenseReport($start, $end, $shared)
{
$object = new Expense;
- $set = $this->query->expenseInPeriod($start, $end, $shared);
+ $set = $this->query->expenseInPeriodCorrected($start, $end, $shared);
foreach ($set as $entry) {
- $object->addToTotal($entry->queryAmount);
+ $object->addToTotal($entry->amount);
$object->addOrCreateExpense($entry);
}
@@ -353,9 +353,9 @@ class ReportHelper implements ReportHelperInterface
public function getIncomeReport($start, $end, $shared)
{
$object = new Income;
- $set = $this->query->incomeInPeriod($start, $end, $shared);
+ $set = $this->query->incomeInPeriodCorrected($start, $end, $shared);
foreach ($set as $entry) {
- $object->addToTotal($entry->queryAmount);
+ $object->addToTotal($entry->amount);
$object->addOrCreateIncome($entry);
}
diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php
index 26b056e449..851968d08f 100644
--- a/app/Helpers/Report/ReportQuery.php
+++ b/app/Helpers/Report/ReportQuery.php
@@ -113,7 +113,22 @@ class ReportQuery implements ReportQueryInterface
$query->orderBy('transaction_journals.date');
// get everything
- $data = $query->get(['transaction_journals.*',]);
+ $data = $query->get(['transaction_journals.*', 'transaction_types.type', 'ac_from.name as name', 'ac_from.encrypted as account_encrypted']);
+
+ $data->each(
+ function (TransactionJournal $journal) {
+ if (intval($journal->account_encrypted) == 1) {
+ $journal->name = Crypt::decrypt($journal->name);
+ }
+ }
+ );
+ $data = $data->filter(
+ function (TransactionJournal $journal) {
+ if ($journal->amount != 0) {
+ return $journal;
+ }
+ }
+ );
return $data;
}
@@ -270,7 +285,22 @@ class ReportQuery implements ReportQueryInterface
$query->orderBy('transaction_journals.date');
// get everything
- $data = $query->get(['transaction_journals.*',]);
+ $data = $query->get(['transaction_journals.*', 'transaction_types.type', 'ac_from.name as name', 'ac_from.encrypted as account_encrypted']);
+
+ $data->each(
+ function (TransactionJournal $journal) {
+ if (intval($journal->account_encrypted) == 1) {
+ $journal->name = Crypt::decrypt($journal->name);
+ }
+ }
+ );
+ $data = $data->filter(
+ function (TransactionJournal $journal) {
+ if ($journal->amount != 0) {
+ return $journal;
+ }
+ }
+ );
return $data;
}
@@ -314,16 +344,16 @@ class ReportQuery implements ReportQueryInterface
{
return floatval(
- Auth::user()->transactionjournals()
- ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->transactionTypes(['Withdrawal'])
- ->where('transactions.account_id', $account->id)
- ->before($end)
- ->after($start)
- ->where('budget_transaction_journal.budget_id', $budget->id)
- ->get(['transaction_journals.*'])->sum('amount')
- ) * -1;
+ Auth::user()->transactionjournals()
+ ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
+ ->transactionTypes(['Withdrawal'])
+ ->where('transactions.account_id', $account->id)
+ ->before($end)
+ ->after($start)
+ ->where('budget_transaction_journal.budget_id', $budget->id)
+ ->get(['transaction_journals.*'])->sum('amount')
+ ) * -1;
}
/**
diff --git a/resources/twig/partials/reports/expenses.twig b/resources/twig/partials/reports/expenses.twig
index c4e588e731..ad9176e878 100644
--- a/resources/twig/partials/reports/expenses.twig
+++ b/resources/twig/partials/reports/expenses.twig
@@ -16,7 +16,7 @@
<br /><small>{{ expense.count }} {{ 'transactions'|_|lower }}</small>
{% endif %}
</td>
- <td><span class="text-danger">{{ (expense.amount*-1)|formatAmountPlain }}</span></td>
+ <td><span class="text-danger">{{ (expense.amount)|formatAmountPlain }}</span></td>
</tr>
{% endfor %}
{% if expenses.getExpenses|length > expenseTopLength %}
@@ -28,7 +28,7 @@
{% endif %}
<tr>
<td><em>{{ 'sum'|_ }}</em></td>
- <td><span class="text-danger">{{ (expenses.getTotal * -1)|formatAmountPlain }}</span></td>
+ <td><span class="text-danger">{{ (expenses.getTotal)|formatAmountPlain }}</span></td>
</tr>
</table>
</div>
\ No newline at end of file