Some code cleanup and I sneaked in a chart optimisation.

This commit is contained in:
James Cole
2016-04-26 22:21:34 +02:00
parent 5199377113
commit 66f2df9677
4 changed files with 30 additions and 39 deletions

View File

@@ -34,21 +34,21 @@ class Income
*/
public function addOrCreateIncome(TransactionJournal $entry)
{
$accountId = $entry->account_id;
if (!$this->incomes->has($accountId)) {
$newObject = new stdClass;
$newObject->amount = strval(round($entry->journalAmount, 2));
$newObject->name = Crypt::decrypt($entry->account_name);
$newObject->count = 1;
$newObject->id = $accountId;
$this->incomes->put($accountId, $newObject);
} else {
$existing = $this->incomes->get($accountId);
$existing->amount = bcadd($existing->amount, $entry->journalAmount);
$existing->count++;
$this->incomes->put($accountId, $existing);
$object = new stdClass;
$object->amount = strval(round($entry->journalAmount, 2));
$object->name = Crypt::decrypt($entry->account_name);
$object->count = 1;
$object->id = $accountId;
// overrule some properties:
if ($this->incomes->has($accountId)) {
$object = $this->incomes->get($accountId);
$object->amount = bcadd($object->amount, $entry->journalAmount);
$object->count++;
}
$this->incomes->put($accountId, $object);
}
/**