/** * Add to credit amount for this account * Will update parent account if required * * @param Currency $amount * @return $this */ public function credit(Currency $amount) { $this->acCr->set($this->acCr->get() + $amount()); Match::on($this->optGetParentId())->Monad_Option_Some(function ($parentId) use($amount) { $this->chart->getAccount($parentId->value())->credit($amount); }); return $this; }
/** * Write a Transaction to the Journal and update the Chart * * @param SplitTransaction $txn * @param Chart $chart * @param Journal $journal * * @return SplitTransaction Transaction with txn Id set * @throws AccountsException */ public function writeTransaction(SplitTransaction $txn, Chart $chart, Journal $journal) { return FFor::create()->txn(function () use($journal, $txn) { return $journal->write($txn); })->chart(function ($txn) use($chart) { $chart->getAccount($txn->getDrAc()[0])->debit($txn->getAmount()); $chart->getAccount($txn->getCrAc()[0])->credit($txn->getAmount()); })->fyield('txn'); }
/** * @expectedException SAccounts\AccountsException */ public function testTryingToGetANonExistentAccountWillThrowAnException() { $this->sut->getAccount(new Nominal('9999')); }