Readplace

:hammer: Remove duplication for $5001.00, $5002.00 and $5003.00 loan … · FagnerMartinsBrack/jack-the-moneylender@18e7337

GitHub 1 min read
View original
  • current

This article is too short to summarise.

Original file line numberDiff line numberDiff line change

@@ -18,42 +18,14 @@

1818

return interestAmount;

1919

}

2020
21-

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

21+

if (loanAmount.greaterThan(Money('$5000.00'))) {

2222

let interestAmount = Money('$0.00');

2323
2424

const dollarsAboveThresholdForSecondRange = loanAmount.minus(END_OF_FIRST_RANGE);

2525

const interestAmountForSecondRange = CENTS_FOR_SECOND_RANGE.multipliedBy(dollarsAboveThresholdForSecondRange);

2626

interestAmount = interestAmount.plus(interestAmountForSecondRange);

2727
28-

const dollarsAboveThresholdForThirdRange = Money('$5001.00').minus(Money('$5000.00'));

29-

const interestAmountForThirdRange = Money('$0.14').minus(Money('$0.09')).multipliedBy(dollarsAboveThresholdForThirdRange);

30-

interestAmount = interestAmount.plus(interestAmountForThirdRange);

31-
32-

return interestAmount;

33-

}

34-
35-

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

36-

let interestAmount = Money('$0.00');

37-
38-

const dollarsAboveThresholdForSecondRange = loanAmount.minus(END_OF_FIRST_RANGE);

39-

const interestAmountForSecondRange = CENTS_FOR_SECOND_RANGE.multipliedBy(dollarsAboveThresholdForSecondRange);

40-

interestAmount = interestAmount.plus(interestAmountForSecondRange);

41-
42-

const dollarsAboveThresholdForThirdRange = Money('$5002.00').minus(Money('$5000.00'));

43-

const interestAmountForThirdRange = Money('$0.14').minus(Money('$0.09')).multipliedBy(dollarsAboveThresholdForThirdRange);

44-

interestAmount = interestAmount.plus(interestAmountForThirdRange);

45-
46-

return interestAmount;

47-

}

48-
49-

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

50-

let interestAmount = Money('$0.00');

51-
52-

const dollarsAboveThresholdForSecondRange = loanAmount.minus(END_OF_FIRST_RANGE);

53-

const interestAmountForSecondRange = CENTS_FOR_SECOND_RANGE.multipliedBy(dollarsAboveThresholdForSecondRange);

54-

interestAmount = interestAmount.plus(interestAmountForSecondRange);

55-
56-

const dollarsAboveThresholdForThirdRange = Money('$5003.00').minus(Money('$5000.00'));

28+

const dollarsAboveThresholdForThirdRange = loanAmount.minus(Money('$5000.00'));

5729

const interestAmountForThirdRange = Money('$0.14').minus(Money('$0.09')).multipliedBy(dollarsAboveThresholdForThirdRange);

5830

interestAmount = interestAmount.plus(interestAmountForThirdRange);

5931