Example #1
0
 /**
  * @param CashFlow $cashflow
  *
  * @return bool
  *
  * @throws UnexpectedDateException
  */
 public function isEqualTo(CashFlow $cashflow)
 {
     if ($this->date->format('Y-m-d') !== $cashflow->getDate()->format('Y-m-d')) {
         throw new UnexpectedDateException('Impossible to compare two cashflows not belonging to the same day.');
     }
     return $this->price->isEqualTo($cashflow->getPrice());
 }
Example #2
0
 /**
  * @expectedException \MonoidPoc\Exception\UnexpectedCurrencyException
  */
 public function testIsEqualToRaiseExceptionIfCurrenciesAreNotTheSame()
 {
     $cashflow1 = new CashFlow('2015-01-01', 25, 'EUR');
     $cashflow2 = new CashFlow('2015-01-01', 25, 'USD');
     $cashflow1->isEqualTo($cashflow2);
 }
Example #3
0
 /**
  * @param CashFlow $cashflow
  * @throws \MonoidPoc\Exception\UnexpectedDateException
  */
 private function addCashFlow(CashFlow $cashflow)
 {
     $date = $cashflow->getFormattedDate();
     if (!isset($this->cashflows[$date])) {
         $this->cashflows[$date] = new CashFlow($date, 0, $this->currencyCode);
     }
     $this->cashflows[$date] = $this->cashflows[$date]->add($cashflow);
 }