Code cleanup.

This commit is contained in:
James Cole
2015-05-17 10:30:18 +02:00
parent beedf7d780
commit 63050907b9
14 changed files with 91 additions and 138 deletions

View File

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