Fixed some views.

This commit is contained in:
James Cole
2015-05-20 07:20:02 +02:00
parent 95ef691077
commit 9e54eecfaa
5 changed files with 52 additions and 22 deletions

View File

@@ -37,14 +37,14 @@ class Expense
$accountId = $entry->account_id; $accountId = $entry->account_id;
if (!$this->expenses->has($accountId)) { if (!$this->expenses->has($accountId)) {
$newObject = new stdClass; $newObject = new stdClass;
$newObject->amount = floatval($entry->queryAmount); $newObject->amount = floatval($entry->amount);
$newObject->name = $entry->name; $newObject->name = $entry->name;
$newObject->count = 1; $newObject->count = 1;
$newObject->id = $accountId; $newObject->id = $accountId;
$this->expenses->put($accountId, $newObject); $this->expenses->put($accountId, $newObject);
} else { } else {
$existing = $this->expenses->get($accountId); $existing = $this->expenses->get($accountId);
$existing->amount += floatval($entry->queryAmount); $existing->amount += floatval($entry->amount);
$existing->count++; $existing->count++;
$this->expenses->put($accountId, $existing); $this->expenses->put($accountId, $existing);
} }

View File

@@ -38,14 +38,14 @@ class Income
$accountId = $entry->account_id; $accountId = $entry->account_id;
if (!$this->incomes->has($accountId)) { if (!$this->incomes->has($accountId)) {
$newObject = new stdClass; $newObject = new stdClass;
$newObject->amount = floatval($entry->queryAmount); $newObject->amount = floatval($entry->amount);
$newObject->name = $entry->name; $newObject->name = $entry->name;
$newObject->count = 1; $newObject->count = 1;
$newObject->id = $accountId; $newObject->id = $accountId;
$this->incomes->put($accountId, $newObject); $this->incomes->put($accountId, $newObject);
} else { } else {
$existing = $this->incomes->get($accountId); $existing = $this->incomes->get($accountId);
$existing->amount += floatval($entry->queryAmount); $existing->amount += floatval($entry->amount);
$existing->count++; $existing->count++;
$this->incomes->put($accountId, $existing); $this->incomes->put($accountId, $existing);
} }

View File

@@ -332,9 +332,9 @@ class ReportHelper implements ReportHelperInterface
public function getExpenseReport($start, $end, $shared) public function getExpenseReport($start, $end, $shared)
{ {
$object = new Expense; $object = new Expense;
$set = $this->query->expenseInPeriod($start, $end, $shared); $set = $this->query->expenseInPeriodCorrected($start, $end, $shared);
foreach ($set as $entry) { foreach ($set as $entry) {
$object->addToTotal($entry->queryAmount); $object->addToTotal($entry->amount);
$object->addOrCreateExpense($entry); $object->addOrCreateExpense($entry);
} }
@@ -353,9 +353,9 @@ class ReportHelper implements ReportHelperInterface
public function getIncomeReport($start, $end, $shared) public function getIncomeReport($start, $end, $shared)
{ {
$object = new Income; $object = new Income;
$set = $this->query->incomeInPeriod($start, $end, $shared); $set = $this->query->incomeInPeriodCorrected($start, $end, $shared);
foreach ($set as $entry) { foreach ($set as $entry) {
$object->addToTotal($entry->queryAmount); $object->addToTotal($entry->amount);
$object->addOrCreateIncome($entry); $object->addOrCreateIncome($entry);
} }

View File

@@ -113,7 +113,22 @@ class ReportQuery implements ReportQueryInterface
$query->orderBy('transaction_journals.date'); $query->orderBy('transaction_journals.date');
// get everything // 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; return $data;
} }
@@ -270,7 +285,22 @@ class ReportQuery implements ReportQueryInterface
$query->orderBy('transaction_journals.date'); $query->orderBy('transaction_journals.date');
// get everything // 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; return $data;
} }
@@ -314,16 +344,16 @@ class ReportQuery implements ReportQueryInterface
{ {
return floatval( return floatval(
Auth::user()->transactionjournals() Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->transactionTypes(['Withdrawal']) ->transactionTypes(['Withdrawal'])
->where('transactions.account_id', $account->id) ->where('transactions.account_id', $account->id)
->before($end) ->before($end)
->after($start) ->after($start)
->where('budget_transaction_journal.budget_id', $budget->id) ->where('budget_transaction_journal.budget_id', $budget->id)
->get(['transaction_journals.*'])->sum('amount') ->get(['transaction_journals.*'])->sum('amount')
) * -1; ) * -1;
} }
/** /**

View File

@@ -16,7 +16,7 @@
<br /><small>{{ expense.count }} {{ 'transactions'|_|lower }}</small> <br /><small>{{ expense.count }} {{ 'transactions'|_|lower }}</small>
{% endif %} {% endif %}
</td> </td>
<td><span class="text-danger">{{ (expense.amount*-1)|formatAmountPlain }}</span></td> <td><span class="text-danger">{{ (expense.amount)|formatAmountPlain }}</span></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% if expenses.getExpenses|length > expenseTopLength %} {% if expenses.getExpenses|length > expenseTopLength %}
@@ -28,7 +28,7 @@
{% endif %} {% endif %}
<tr> <tr>
<td><em>{{ 'sum'|_ }}</em></td> <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> </tr>
</table> </table>
</div> </div>