peter.sanderson Posted December 18, 2023 Share Posted December 18, 2023 I have code that is to calculate the possible revenue for potential resellers. It worked before upgrading to 7.1. I also manage a friends page so I put the code on her page and it works fine, but she did not upgrade to 7.1. Link to my page that no longer works is www.tqms.com/consultant-calculator - this is my friend's page and it works fine: www.businessmsc.com/consultant_reseller. All you do is add a quantity then click calculate and it should calculate the annuity growth revenue by month and then by year. Can anyone tell me why it no longer works or what changed in 7.1 that could interfere with the script running? This is the code: <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Consultant Revenue Calculator</title> <style> <!-- table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid black; padding: 8px; text-align: center; } --> </style> <h3>Enter Product Sale Quantities</h3> <table> <tbody> <tr> <th>Code</th> <th>Product</th> <th>Quantity</th> </tr> <tr> <td>CIS-B</td> <td>CIS Basic 2023 Upfront Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-B" value="0" /></td> </tr> <tr> <td>CIS-B-GPT</td> <td>CIS Basic 2023 Plus ChatGPT Support Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-B-GPT" value="0" /></td> </tr> <tr> <td>CIS-P</td> <td>CIS Pro 2023 Upfront Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-P" value="0" /></td> </tr> <tr> <td>CIS-P-GPT</td> <td>CIS Pro 2023 Plus ChatGPT Support Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-P-GPT" value="0" /></td> </tr> <tr> <td>CIS-A</td> <td>CIS 2023 Auditing App Only</td> <td> <input type="number" min="0" max="5" id="CIS-A" value="0" /></td> </tr> </tbody> </table> <button onclick="calculateRevenue()">Calculate Revenue</button> <h3>Monthly Revenue</h3> <table id="monthlyRevenueTable"> <!-- Months 1 to 60 will be filled in by JavaScript --> </table> <h3>Yearly Revenue</h3> <table id="yearlyRevenueTable"> <!-- Years 1 to 5 will be filled in by JavaScript --> </table> <script> document.addEventListener('DOMContentLoaded', function() { const products = { "CIS-B": { setUp: 625.00, monthly: 87.50 }, "CIS-B-GPT": { setUp: 875.00, monthly: 96.25 }, "CIS-P": { setUp: 1000.00, monthly: 96.25 }, "CIS-P-GPT": { setUp: 1250.00, monthly: 103.25 }, "CIS-A": { setUp: 199.00, monthly: 19.99 } }; function calculateRevenue() { let monthlyRevenue = []; let yearlyRevenue = [0, 0, 0, 0, 0]; let accumulatedCommissions = { "CIS-B": 0, "CIS-B-GPT": 0, "CIS-P": 0, "CIS-P-GPT": 0, "CIS-A": 0 }; for (let month = 1; month <= 60; month++) { let monthlyTotal = 0; for (let product in products) { const quantity = parseInt(document.getElementById(product).value) || 0; // Monthly Set-Up Fee monthlyTotal += products[product].setUp * quantity; // Increase the accumulated commission for the current product accumulatedCommissions[product] += products[product].monthly * quantity; // Add accumulated commission to monthly total monthlyTotal += accumulatedCommissions[product]; } monthlyRevenue.push(monthlyTotal); // Add to yearly total as well const yearIndex = Math.ceil(month / 12) - 1; yearlyRevenue[yearIndex] += monthlyTotal; } // Displaying Monthly Revenue const monthlyRevenueTable = document.getElementById("monthlyRevenueTable"); monthlyRevenueTable.innerHTML = "<tr><th>Month</th><th>Revenue</th></tr>"; for (let i = 0; i < monthlyRevenue.length; i++) { monthlyRevenueTable.innerHTML += `<tr><td>Month ${i+1}</td><td>$ ${monthlyRevenue[i].toFixed(2)}</td></tr>`; } // Displaying Yearly Revenue const yearlyRevenueTable = document.getElementById("yearlyRevenueTable"); yearlyRevenueTable.innerHTML = "<tr><th>Year</th><th>Revenue</th></tr>"; for (let i = 0; i < yearlyRevenue.length; i++) { yearlyRevenueTable.innerHTML += `<tr><td>Year ${i+1}</td><td>$ ${yearlyRevenue[i].toFixed(2)}</td></tr>`; } } document.querySelector('button').addEventListener('click', calculateRevenue); });</script> Link to comment
tuanphan Posted December 19, 2023 Share Posted December 19, 2023 Can you share link to page where you added the code? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
peter.sanderson Posted January 1 Author Share Posted January 1 Hi, The link is https://www.tqms.com/consultant-calculator and the password is 2024MakeMoney Link to comment
tuanphan Posted January 2 Share Posted January 2 I think your above code is missing something I tried adding that code to 7.0 version (Brine template) and it doesn't work. https://tuan-brine.squarespace.com/test1?noredirect pass: abc Can you check again all code on this site? https://www.businessmsc.com/consultant_reseller Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
peter.sanderson Posted January 2 Author Share Posted January 2 The code is exactly the same. let accumulatedCommissions = { "CIS-B": 0, "CIS-B-GPT": 0, "CIS-P": 0, "CIS-P-GPT": 0, "CIS-A": 0 }; for (let month = 1; month <= 60; month++) { let monthlyTotal = 0; for (let product in products) { const quantity = parseInt(document.getElementById(product).value) || 0; // Monthly Set-Up Fee monthlyTotal += products[product].setUp * quantity; // Increase the accumulated commission for the current product accumulatedCommissions[product] += products[product].monthly * quantity; // Add accumulated commission to monthly total monthlyTotal += accumulatedCommissions[product]; } monthlyRevenue.push(monthlyTotal); // Add to yearly total as well const yearIndex = Math.ceil(month / 12) - 1; yearlyRevenue[yearIndex] += monthlyTotal; } // Displaying Monthly Revenue const monthlyRevenueTable = document.getElementById("monthlyRevenueTable"); monthlyRevenueTable.innerHTML = "<tr><th>Month</th><th>Revenue</th></tr>"; for (let i = 0; i < monthlyRevenue.length; i++) { monthlyRevenueTable.innerHTML += `<tr><td>Month ${i+1}</td><td>$ ${monthlyRevenue[i].toFixed(2)}</td></tr>`; } // Displaying Yearly Revenue const yearlyRevenueTable = document.getElementById("yearlyRevenueTable"); yearlyRevenueTable.innerHTML = "<tr><th>Year</th><th>Revenue</th></tr>"; for (let i = 0; i < yearlyRevenue.length; i++) { yearlyRevenueTable.innerHTML += `<tr><td>Year ${i+1}</td><td>$ ${yearlyRevenue[i].toFixed(2)}</td></tr>`; } } document.querySelector('button').addEventListener('click', calculateRevenue); });</script> Link to comment
peter.sanderson Posted January 2 Author Share Posted January 2 Sorry, bad copy and paste: This code was copied from https://www.businessmsc.com/consultant_reseller this code worked on tqms until I upgraded. <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Consultant Revenue Calculator</title> <style> <!-- table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid black; padding: 8px; text-align: center; } --> </style> <h3>Enter Product Sale Quantities</h3> <table> <tbody> <tr> <th>Code</th> <th>Product</th> <th>Quantity</th> </tr> <tr> <td>CIS-B</td> <td>CIS Basic 2023 Upfront Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-B" value="0" /></td> </tr> <tr> <td>CIS-B-GPT</td> <td>CIS Basic 2023 Plus ChatGPT Support Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-B-GPT" value="0" /></td> </tr> <tr> <td>CIS-P</td> <td>CIS Pro 2023 Upfront Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-P" value="0" /></td> </tr> <tr> <td>CIS-P-GPT</td> <td>CIS Pro 2023 Plus ChatGPT Support Set-Up Fee</td> <td> <input type="number" min="0" max="5" id="CIS-P-GPT" value="0" /></td> </tr> <tr> <td>CIS-A</td> <td>CIS 2023 Auditing App Only</td> <td> <input type="number" min="0" max="5" id="CIS-A" value="0" /></td> </tr> </tbody> </table> <button onclick="calculateRevenue()">Calculate Revenue</button> <h3>Monthly Revenue</h3> <table id="monthlyRevenueTable"> <!-- Months 1 to 60 will be filled in by JavaScript --> </table> <h3>Yearly Revenue</h3> <table id="yearlyRevenueTable"> <!-- Years 1 to 5 will be filled in by JavaScript --> </table> <script> document.addEventListener('DOMContentLoaded', function() { const products = { "CIS-B": { setUp: 625.00, monthly: 87.50 }, "CIS-B-GPT": { setUp: 875.00, monthly: 96.25 }, "CIS-P": { setUp: 1000.00, monthly: 96.25 }, "CIS-P-GPT": { setUp: 1250.00, monthly: 103.25 }, "CIS-A": { setUp: 199.00, monthly: 19.99 } }; function calculateRevenue() { let monthlyRevenue = []; let yearlyRevenue = [0, 0, 0, 0, 0]; let accumulatedCommissions = { "CIS-B": 0, "CIS-B-GPT": 0, "CIS-P": 0, "CIS-P-GPT": 0, "CIS-A": 0 }; for (let month = 1; month <= 60; month++) { let monthlyTotal = 0; for (let product in products) { const quantity = parseInt(document.getElementById(product).value) || 0; // Monthly Set-Up Fee monthlyTotal += products[product].setUp * quantity; // Increase the accumulated commission for the current product accumulatedCommissions[product] += products[product].monthly * quantity; // Add accumulated commission to monthly total monthlyTotal += accumulatedCommissions[product]; } monthlyRevenue.push(monthlyTotal); // Add to yearly total as well const yearIndex = Math.ceil(month / 12) - 1; yearlyRevenue[yearIndex] += monthlyTotal; } // Displaying Monthly Revenue const monthlyRevenueTable = document.getElementById("monthlyRevenueTable"); monthlyRevenueTable.innerHTML = "<tr><th>Month</th><th>Revenue</th></tr>"; for (let i = 0; i < monthlyRevenue.length; i++) { monthlyRevenueTable.innerHTML += `<tr><td>Month ${i+1}</td><td>$ ${monthlyRevenue[i].toFixed(2)}</td></tr>`; } // Displaying Yearly Revenue const yearlyRevenueTable = document.getElementById("yearlyRevenueTable"); yearlyRevenueTable.innerHTML = "<tr><th>Year</th><th>Revenue</th></tr>"; for (let i = 0; i < yearlyRevenue.length; i++) { yearlyRevenueTable.innerHTML += `<tr><td>Year ${i+1}</td><td>$ ${yearlyRevenue[i].toFixed(2)}</td></tr>`; } } document.querySelector('button').addEventListener('click', calculateRevenue); });</script> Link to comment
tuanphan Posted January 4 Share Posted January 4 Sometimes when pasting directly, some characters are changed to invalid. You can click icon then paste the code Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment