add() public method

Returns a new Money object that represents the sum of this and another Money object
public add ( Money $addend ) : Money
$addend Money
return Money
 /**
  * @param PlanDefinition $definition
  * @param Money $amountToPay
  * @param PlanParameters $parameters
  * @internal param string $planCode
  * @return \Ice\PaymentPlan\PaymentPlan
  */
 public function getPlan(PlanDefinition $definition, Money $amountToPay, PlanParameters $parameters)
 {
     if ($parameters->hasParameter('bursary_total_deduction') && ($bursaryTotalDeduction = intval($parameters->get('bursary_total_deduction'))) > 0) {
         $absoluteBursaryTotal = Money::GBP($bursaryTotalDeduction);
         $amountBeforeBursary = $amountToPay->add($absoluteBursaryTotal);
         $planWithoutBursary = $this->childCalculator->getPlan($definition, $amountBeforeBursary, $parameters);
         return $this->subtractBursaryFromPlan($planWithoutBursary, $absoluteBursaryTotal);
     }
     return $this->childCalculator->getPlan($definition, $amountToPay, $parameters);
 }
Esempio n. 2
0
 /**
  * @expectedException Money\InvalidArgumentException
  */
 public function testDifferentCurrenciesCannotBeAdded()
 {
     $m1 = new Money(100, new Currency('EUR'));
     $m2 = new Money(100, new Currency('USD'));
     $m1->add($m2);
 }
 public function addToAmount(Money $money)
 {
     return new static($this->amount->add($money), $this->dueDate);
 }
Esempio n. 4
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testDifferentCurrenciesCannotBeAdded()
 {
     $m1 = new Money(100, CurrencyProxy::determine('EUR'));
     $m2 = new Money(100, CurrencyProxy::determine('USD'));
     $m1->add($m2);
 }
Esempio n. 5
0
 /**
  * @param Money $amount
  *
  * @throws \InvalidArgumentException
  *
  * @return Money
  */
 public function add(Money $amount) : Money
 {
     return new self($this->money->add($amount->wrapped()));
 }
Esempio n. 6
0
 /**
  * Increase this account current balance
  *
  * @param Money $amount
  */
 public function deposit(Money $amount)
 {
     $this->balance = $this->balance->add($amount);
 }