Readplace

:white_check_mark: Copy the logic for loan amounts greater than $2000.00 · FagnerMartinsBrack/jack-the-moneylender@8d0fc82

GitHub 1 min read
View original
  • current

This article is too short to summarise.

Original file line numberDiff line numberDiff line change

@@ -38,6 +38,10 @@

3838

if (loanAmount.equalsTo(Money('$10001.00'))) {

3939

let interestAmount = Money('$0.00');

4040
41+

const dollarsAboveThresholdForSecondRange = loanAmount.minus(END_OF_FIRST_RANGE);

42+

const interestAmountForSecondRange = CENTS_FOR_SECOND_RANGE.multipliedBy(dollarsAboveThresholdForSecondRange);

43+

interestAmount = interestAmount.plus(interestAmountForSecondRange);

44+
4145

const dollarsAboveThresholdForThirdRange = loanAmount.minus(END_OF_SECOND_RANGE);

4246

const interestAmountForThirdRange = CENTS_FOR_THIRD_RANGE.minus(CENTS_FOR_SECOND_RANGE).multipliedBy(dollarsAboveThresholdForThirdRange);

4347

interestAmount = interestAmount.plus(interestAmountForThirdRange);