示例#1
0
 public function add(CashFlow $cashflow)
 {
     if ($this->getFormattedDate() !== $cashflow->getFormattedDate()) {
         throw new UnexpectedDateException('Impossible to compare two cashflows not belonging to the same day.');
     }
     $newCashflow = clone $this;
     return $newCashflow->setPrice($this->price->add($cashflow->getPrice()));
 }
示例#2
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);
 }