:hammer: Add the last arg for the function to calculate loans above $… · FagnerMartinsBrack/jack-the-moneylender@6fa4b94
View original- current
This article is too short to summarise.
@@ -7,9 +7,9 @@
77assert.strictEqual(actual, expected);
88}
9910-const calculateInterestForGreaterThan2000 = (loanAmount, endOfFirstRange, centsForSecondRange) => {
10+const calculateInterestForGreaterThan2000 = (loanAmount, endOfFirstRange, centsForSecondRange, centsForFirstRange) => {
1111const dollarsAboveThresholdForGreaterThan2000 = loanAmount.minus(endOfFirstRange);
12-const interestForGreaterThan2000 = centsForSecondRange.multipliedBy(dollarsAboveThresholdForGreaterThan2000);
12+const interestForGreaterThan2000 = centsForSecondRange.minus(centsForFirstRange).multipliedBy(dollarsAboveThresholdForGreaterThan2000);
1313return interestForGreaterThan2000;
1414};
1515@@ -39,7 +39,7 @@
3939let interestAmount = Money('$0.00');
40404141interestAmount = interestAmount.plus(
42-calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE)
42+calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE, CENTS_FOR_FIRST_RANGE)
4343);
44444545return interestAmount;
@@ -49,7 +49,7 @@
4949let interestAmount = Money('$0.00');
50505151interestAmount = interestAmount.plus(
52-calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE)
52+calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE, CENTS_FOR_FIRST_RANGE)
5353);
5454interestAmount = interestAmount.plus(
5555calculateInterestForGreaterThan5000(loanAmount, END_OF_SECOND_RANGE, CENTS_FOR_THIRD_RANGE, CENTS_FOR_SECOND_RANGE)
@@ -62,7 +62,7 @@
6262let interestAmount = Money('$0.00');
63636464interestAmount = interestAmount.plus(
65-calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE)
65+calculateInterestForGreaterThan2000(loanAmount, END_OF_FIRST_RANGE, CENTS_FOR_SECOND_RANGE, CENTS_FOR_FIRST_RANGE)
6666);
6767interestAmount = interestAmount.plus(
6868calculateInterestForGreaterThan5000(loanAmount, END_OF_SECOND_RANGE, CENTS_FOR_THIRD_RANGE, CENTS_FOR_SECOND_RANGE)