support loans with 0% rate (#30658)

math is simple in this case: capital divided by remaining payment count

#30657
This commit is contained in:
Oliver Lippert 2024-08-17 12:13:26 +02:00 committed by GitHub
parent 9757e18960
commit 04793197c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -419,8 +419,12 @@ class LoanSchedule extends CommonObject
{
$result = '';
if (!empty($capital) && !empty($rate) && !empty($nbterm)) {
$result = ($capital * ($rate / 12)) / (1 - pow((1 + ($rate / 12)), ($nbterm * -1)));
if (!empty($capital) && !empty($nbterm)) {
if (!empty($rate)) {
$result = ($capital * ($rate / 12)) / (1 - pow((1 + ($rate / 12)), ($nbterm * -1)));
} else {
$result = $capital / $nbterm;
}
}
return $result;