Negative expenses, as per #129

This commit is contained in:
James Cole
2015-12-11 18:30:28 +01:00
parent 28c3cfe084
commit c38ae09735
2 changed files with 3 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ 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 = strval(round($entry->amount_positive, 2)); $newObject->amount = strval(round($entry->amount, 2));
$newObject->name = $entry->name; $newObject->name = $entry->name;
$newObject->count = 1; $newObject->count = 1;
$newObject->id = $accountId; $newObject->id = $accountId;
@@ -44,7 +44,7 @@ class Expense
} else { } else {
bcscale(2); bcscale(2);
$existing = $this->expenses->get($accountId); $existing = $this->expenses->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount_positive); $existing->amount = bcadd($existing->amount, $entry->amount);
$existing->count++; $existing->count++;
$this->expenses->put($accountId, $existing); $this->expenses->put($accountId, $existing);
} }

View File

@@ -18,7 +18,7 @@
<small>{{ expense.count }} {{ 'transactions'|_|lower }}</small> <small>{{ expense.count }} {{ 'transactions'|_|lower }}</small>
{% endif %} {% endif %}
</td> </td>
<td><span class="text-danger">{{ (expense.amount)|formatAmountPlain }}</span></td> <td>{{ (expense.amount)|formatAmount }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>