Fixed some bugs that caused inconsistencies in the monthly reports.

This commit is contained in:
James Cole
2015-08-29 07:20:53 +02:00
parent e5b88be5fa
commit c3958ed3c4
4 changed files with 6 additions and 16 deletions

View File

@@ -33,11 +33,10 @@ class Expense
*/
public function addOrCreateExpense(TransactionJournal $entry)
{
$accountId = $entry->account_id;
if (!$this->expenses->has($accountId)) {
$newObject = new stdClass;
$newObject->amount = strval(round($entry->amount, 2));
$newObject->amount = strval(round($entry->actual_amount, 2));
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $accountId;
@@ -45,7 +44,7 @@ class Expense
} else {
bcscale(2);
$existing = $this->expenses->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount);
$existing->amount = bcadd($existing->amount, $entry->actual_amount);
$existing->count++;
$this->expenses->put($accountId, $existing);
}

View File

@@ -38,7 +38,7 @@ class Income
$accountId = $entry->account_id;
if (!$this->incomes->has($accountId)) {
$newObject = new stdClass;
$newObject->amount = strval(round($entry->amount, 2));
$newObject->amount = strval(round($entry->actual_amount, 2));
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $accountId;
@@ -46,7 +46,7 @@ class Income
} else {
bcscale(2);
$existing = $this->incomes->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->amount);
$existing->amount = bcadd($existing->amount, $entry->actual_amount);
$existing->count++;
$this->incomes->put($accountId, $existing);
}