public function testASplitTransactionIsSimpleIfItHasOneDrAndOneCrEntry()
 {
     $this->assertTrue($this->sut->isSimple());
     $amount = Factory::create('gbp', 0.1);
     $this->sut->addEntry(new Entry(new Nominal('2000'), $amount, AccountType::CR()));
     $this->assertFalse($this->sut->isSimple());
 }
Beispiel #2
0
 /**
  * Write the transaction.
  * Returns transaction with Transaction Id set
  *
  * @param SplitTransaction $transaction
  * @return SplitTransaction
  */
 public function write(SplitTransaction $transaction)
 {
     return $transaction->setId($this->journalist->writeTransaction($transaction));
 }
Beispiel #3
0
 /**
  * Break transaction into its splits and write them out
  *
  * @param SplitTransaction $transaction
  * @param \DOMDocument $dom
  * @param \DOMElement $newTxn
  */
 protected function writeSplitFromTransaction(SplitTransaction $transaction, \DOMDocument $dom, \DOMElement $newTxn)
 {
     foreach ($transaction->getEntries() as $entry) {
         $this->writeSplit($dom, $newTxn, $entry->getType()->getValue() == AccountType::CR ? 'CR' : 'DR', $entry->getAmount()->get(), $entry->getId()->get());
     }
 }
 /**
  * Constructor
  *
  * @param Nominal $drAc Account to debit
  * @param Nominal $crAc Account to credit
  * @param Currency $amount Transaction amount
  * @param StringType $note Defaults to '' if not set
  * @param \DateTime $date Defaults to today if not set
  */
 public function __construct(Nominal $drAc, Nominal $crAc, Currency $amount, StringType $note = null, \DateTime $date = null)
 {
     parent::__construct($date, $note);
     $this->addEntry(new Entry($drAc, $amount, AccountType::DR()));
     $this->addEntry(new Entry($crAc, $amount, AccountType::CR()));
 }