public function testCreditingAnAccountWillCreditItsParentIfOneExistsInAChart()
 {
     $ac1 = new Account($this->chart, new Nominal('9998'), AccountType::DR(), new StringType('foo1'));
     $ac2 = new Account($this->chart, new Nominal('9999'), AccountType::DR(), new StringType('foo2'));
     $this->chart->addAccount($ac1);
     $this->chart->addAccount($ac2, $ac1->getId());
     $ac2->credit(Factory::create('gbp', 1));
     $this->assertEquals(100, $ac1->getCredit()->get());
 }
 public function testGettingTheParentIdOfAnAccountThatHasAParentWillReturnTheParentId()
 {
     $ac1 = new Account($this->sut, new Nominal('9998'), AccountType::ASSET(), new StringType('Asset'));
     $this->sut->addAccount($ac1);
     $ac2 = new Account($this->sut, new Nominal('9999'), AccountType::ASSET(), new StringType('Asset-2'));
     $this->sut->addAccount($ac2, $ac1->getId());
     $f = $this->sut->getParentId($ac2->getId());
     $b = $f->get();
     $this->assertEquals('9998', $this->sut->getParentId($ac2->getId())->get());
 }
 public function testYouCanWriteATransactionToAJournalAndUpdateAChart()
 {
     $chart = new Chart(new StringType('foo bar'), new Organisation(new IntType(1), new StringType('Foo Org'), CurrencyFactory::create('gbp')));
     $chart->addAccount(new Account($chart, new Nominal('0000'), AccountType::DR(), new StringType('Foo')));
     $chart->addAccount(new Account($chart, new Nominal('0001'), AccountType::CR(), new StringType('Bar')));
     $journal = new Journal(new StringType('Foo Journal'), CurrencyFactory::create('gbp'), $this->journalist);
     $txn = new Transaction(new Nominal('0000'), new Nominal('0001'), CurrencyFactory::create('gbp', 12.26));
     $this->journalist->expects($this->once())->method('writeTransaction')->will($this->returnValue(new IntType(1)));
     $returnedTransaction = $this->sut->writeTransaction($txn, $chart, $journal);
     $this->assertEquals(1, $returnedTransaction->getId()->get());
     $this->assertEquals(1226, $chart->getAccount(new Nominal('0000'))->getDebit()->get());
     $this->assertEquals(1226, $chart->getAccount(new Nominal('0001'))->getCredit()->get());
 }