public function refundAmount(Money $threshold) { // todo include forgiven? $unpaidAmount = $this->unpaidAmount(); $thresholdAmount = $unpaidAmount->add($threshold); if ($this->repaymentAmount->greaterThan($thresholdAmount)) { return $this->repaymentAmount->subtract($unpaidAmount->ceil()); } return Money::create(0); }