public function installmentServiceFee() { $unpaidServiceFee = $this->serviceFee()->subtract($this->paidServiceFee); // todo AmountGot // todo totalamount confusion $openAmount = $this->totalAmount()->subtract($this->paidAmount)->subtract($this->forgivenAmount); // Todo money divide (times, ...) $ratio = $this->repaymentAmount->divide($openAmount); return $unpaidServiceFee->multiply($ratio); }
public function convertToUSD(Money $money, ExchangeRate $exchangeRate) { if ($exchangeRate->getCurrency() != $money->getCurrency()) { throw new InvalidCurrencyExchangeException(); } $rate = $exchangeRate->getRate(); $amountInUSD = $money->divide($rate); return Money::create($amountInUSD->getAmount(), Currency::CODE_USD); }
public function calculateAmountRaised(Money $totalBidAmount) { if ($totalBidAmount->lessThan($this->getAmount())) { $percentAmountRaised = $totalBidAmount->divide($this->getAmount()->getAmount())->multiply(100)->round(2)->getAmount(); } else { $percentAmountRaised = 100; } return $this->setAmountRaised($percentAmountRaised); }