Skip to content

Commit 4d68b81

Browse files
authored
Update balance_transfer_calc.md
1 parent 931e11b commit 4d68b81

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/resources/balance_transfer_calc.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,48 @@ hide:
1010
const balanceTransferFee = parseFloat(document.getElementById("balanceTransferFee").value);
1111
const balanceTransferDuration = parseInt(document.getElementById("balanceTransferDuration").value);
1212
const plannedMonthlyPayment = parseFloat(document.getElementById("plannedMonthlyPayment").value);
13+
1314
// Check if any fields are empty
1415
if (!amountToTransfer || !balanceTransferFee || !balanceTransferDuration || !plannedMonthlyPayment) {
1516
document.getElementById("result").innerHTML = "<strong style='color: red;'>Please fill in all fields.</strong>";
1617
return; // Exit the function if validation fails
1718
}
19+
1820
// Initialise Variables
1921
let totalTimeToPay = 0;
2022
let feePaid = 0;
2123
const initialAmountToTransfer = amountToTransfer;
24+
let counter = 0;
25+
let breakdownString = "";
2226

2327
while (amountToTransfer > plannedMonthlyPayment) {
28+
counter += 1;
2429
let amountTransferred = amountToTransfer * (1 + balanceTransferFee / 100);
2530
let totalTimeRequired = amountTransferred / plannedMonthlyPayment;
2631

2732
if (totalTimeRequired > balanceTransferDuration) {
33+
breakdownString += `<li> Amount to balance transfer in <strong>Year ${counter}</strong> with fee included: <strong>£${amountTransferred.toFixed(2)}</strong></li>`;
2834
feePaid += amountToTransfer * (balanceTransferFee / 100);
2935
amountToTransfer = amountTransferred - (plannedMonthlyPayment * balanceTransferDuration);
30-
totalTimeToPay += balanceTransferDuration;
36+
totalTimeToPay += 12;
3137
} else {
3238
totalTimeToPay += totalTimeRequired;
3339
amountToTransfer = amountTransferred - (plannedMonthlyPayment * totalTimeRequired);
40+
let finalPaymentAmountWithFee = plannedMonthlyPayment * totalTimeRequired;
41+
breakdownString += `<li> Amount to balance transfer in <strong>Year ${counter}</strong> with fee included: <strong>£${finalPaymentAmountWithFee.toFixed(2)}</strong></li>`;
42+
let finalPaymentAmount = finalPaymentAmountWithFee * 0.65;
43+
breakdownString += `<li> Amount to finish by one time payment in <strong>Year ${counter}</strong>: <strong>£${finalPaymentAmount.toFixed(2)}</strong></li>`;
3444
}
3545
}
3646

3747
// Display results
3848
const result = `
3949
To pay off <strong>£${initialAmountToTransfer}</strong> using monthly payments of <strong>£${plannedMonthlyPayment}</strong> with a <strong>${balanceTransferDuration} months</strong> balance transfer renewed until the whole amount is paid off and each renewal has a balance transfer fee of <strong>${balanceTransferFee} %</strong>, one will pay a total fee of <strong>£${feePaid.toFixed(2)}</strong> and will need to make the monthly payment for <strong>${Math.round(totalTimeToPay)} months</strong>.
4050
41-
Balance transfer will need to be renewed at least <strong>${Math.round(totalTimeToPay / balanceTransferDuration)} times</strong>.
51+
Balance transfer will need to be renewed at least <strong>${Math.round(totalTimeToPay / balanceTransferDuration)} times</strong>.<br><br>
52+
53+
<strong>Breakdown</strong>:<br><br>
54+
${breakdownString}
4255
`;
4356
document.getElementById("result").innerHTML = result;
4457
}

0 commit comments

Comments
 (0)