/** * @param TransactionJournal $entry */ public function addOrCreateIncome(TransactionJournal $entry) { // add each account individually: $sources = TransactionJournal::sourceTransactionList($entry); foreach ($sources as $transaction) { $amount = strval($transaction->amount); $account = $transaction->account; $amount = bcmul($amount, '-1'); $object = new stdClass(); $object->amount = $amount; $object->name = $account->name; $object->count = 1; $object->id = $account->id; // overrule some properties: if ($this->incomes->has($account->id)) { $object = $this->incomes->get($account->id); $object->amount = bcadd($object->amount, $amount); $object->count++; } $this->incomes->put($account->id, $object); } }