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;
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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}
/**

View File

@ -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>