How to Calculate Cash Conversion Cycle

Cash Conversion Cycle Calculator & Guide :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –light-gray: #e9ecef; –white: #ffffff; –border-radius: 5px; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); line-height: 1.6; margin: 0; padding: 0; } .container { max-width: 1000px; margin: 20px auto; padding: 20px; background-color: var(–white); border-radius: var(–border-radius); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } h1, h2, h3 { color: var(–primary-color); } h1 { text-align: center; margin-bottom: 30px; } .calculator-wrapper { background-color: var(–white); padding: 30px; border-radius: var(–border-radius); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); margin-bottom: 40px; } .input-group { margin-bottom: 20px; display: flex; flex-direction: column; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: 100%; padding: 12px; border: 1px solid var(–light-gray); border-radius: var(–border-radius); box-sizing: border-box; font-size: 1rem; } .input-group input[type="number"]:focus, .input-group select:focus { border-color: var(–primary-color); outline: none; box-shadow: 0 0 0 2px rgba(0, 74, 153, 0.2); } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; } .error-message { color: #dc3545; font-size: 0.85em; margin-top: 5px; display: none; /* Hidden by default */ } .button-group { display: flex; gap: 10px; margin-top: 25px; flex-wrap: wrap; } .button-group button { padding: 12px 20px; border: none; border-radius: var(–border-radius); cursor: pointer; font-size: 1rem; transition: background-color 0.3s ease; flex-grow: 1; min-width: 150px; } .calculate-btn { background-color: var(–primary-color); color: var(–white); } .calculate-btn:hover { background-color: #003366; } .reset-btn { background-color: var(–light-gray); color: var(–text-color); border: 1px solid #ccc; } .reset-btn:hover { background-color: #d3d9df; } .copy-btn { background-color: var(–success-color); color: var(–white); } .copy-btn:hover { background-color: #218838; } #results { margin-top: 30px; padding: 25px; background-color: var(–light-gray); border-radius: var(–border-radius); border-left: 5px solid var(–primary-color); } #results h3 { margin-top: 0; color: var(–primary-color); } .result-item { margin-bottom: 15px; font-size: 1.1em; } .result-item strong { color: var(–primary-color); } .primary-result { font-size: 1.8em; font-weight: bold; color: var(–success-color); background-color: var(–white); padding: 15px; border-radius: var(–border-radius); text-align: center; margin-bottom: 20px; border: 2px solid var(–success-color); } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 15px; font-style: italic; } table { width: 100%; border-collapse: collapse; margin-top: 25px; margin-bottom: 25px; overflow-x: auto; /* Make table horizontally scrollable on mobile */ display: block; /* Needed for overflow-x */ white-space: nowrap; /* Prevent wrapping within cells */ } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(–light-gray); } th { background-color: var(–primary-color); color: var(–white); font-weight: bold; } tr:nth-child(even) { background-color: #f2f6fa; } caption { font-size: 1.1em; font-weight: bold; color: var(–primary-color); margin-bottom: 15px; caption-side: top; text-align: left; } canvas { max-width: 100%; /* Ensure chart fits within its container */ height: auto !important; /* Maintain aspect ratio */ display: block; /* Remove extra space below canvas */ margin: 20px auto; border: 1px solid var(–light-gray); border-radius: var(–border-radius); } .article-content { margin-top: 40px; background-color: var(–white); padding: 30px; border-radius: var(–border-radius); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } .article-content h2, .article-content h3 { margin-top: 30px; margin-bottom: 15px; } .article-content p { margin-bottom: 15px; } .article-content ul, .article-content ol { margin-bottom: 15px; padding-left: 20px; } .article-content li { margin-bottom: 8px; } .article-content a { color: var(–primary-color); text-decoration: none; } .article-content a:hover { text-decoration: underline; } .faq-item { margin-bottom: 20px; padding: 15px; background-color: var(–light-gray); border-radius: var(–border-radius); } .faq-item strong { color: var(–primary-color); cursor: pointer; display: block; } .faq-item p { margin-top: 10px; display: none; /* Hidden by default */ } /* Responsive adjustments */ @media (max-width: 768px) { .container { margin: 10px; padding: 15px; } .calculator-wrapper, .article-content { padding: 20px; } .button-group { flex-direction: column; gap: 10px; } .button-group button { width: 100%; min-width: auto; } #results { padding: 15px; } .primary-result { font-size: 1.5em; } }

Cash Conversion Cycle Calculator

Calculate Your Cash Conversion Cycle (CCC)

Average number of days to sell inventory.
Average number of days to collect accounts receivable.
Average number of days to pay accounts payable.

Calculation Results

Days Inventory Outstanding (DIO): days
Days Sales Outstanding (DSO): days
Days Payables Outstanding (DPO): days
Working Capital Days: days
Formula: Cash Conversion Cycle = Days Inventory Outstanding + Days Sales Outstanding – Days Payables Outstanding
Key Metrics
Metric Value (Days) Interpretation
Days Inventory Outstanding (DIO) Time to sell inventory. Lower is generally better.
Days Sales Outstanding (DSO) Time to collect cash from sales. Lower is better.
Days Payables Outstanding (DPO) Time to pay suppliers. Higher can improve cash flow but may strain supplier relations.
Cash Conversion Cycle (CCC) Total time to convert investments in inventory/resources into cash from sales. Shorter is better.
Working Capital Days The combined period that needs to be financed by the company (DIO + DSO – DPO).
CCC Components Over Time

What is the Cash Conversion Cycle?

The Cash Conversion Cycle (CCC) is a crucial financial metric that measures how long it takes a company to convert its investments in inventory and other resources into cash flows from sales. Essentially, it quantizes the time lag between paying for the resources needed to produce goods or services and receiving the actual cash from customers for those goods or services. A shorter Cash Conversion Cycle indicates that a company is more efficient at managing its working capital, generating cash more quickly, and requiring less external financing to support its operations.

Who should use it? The CCC is particularly valuable for businesses with significant inventory holdings or those operating on credit terms with customers and suppliers. This includes manufacturers, retailers, wholesalers, and even some service-based businesses that extend credit. Financial analysts, investors, and lenders use the CCC to assess a company's operational efficiency and financial health. Management teams rely on it to identify areas for improvement in inventory management, sales collection, and payment terms with suppliers.

Common Misconceptions:

  • Misconception: A very long CCC is always bad. While generally true, in some niche industries (like capital-intensive manufacturing with long production cycles), a longer CCC might be normal or even strategic, provided suppliers offer favorable credit terms.
  • Misconception: A negative CCC is impossible or always indicates perfect efficiency. A negative CCC means a company receives cash from customers before it has to pay its suppliers for the inventory. While indicating strong cash flow, it can also mean a company isn't maximizing its supplier credit terms, potentially missing out on short-term financing advantages.
  • Misconception: CCC only focuses on inventory and sales. The cycle is completed by considering the payment terms offered by suppliers (Accounts Payable), making it a comprehensive measure of working capital management.

Cash Conversion Cycle Formula and Mathematical Explanation

The Cash Conversion Cycle (CCC) is calculated using a straightforward formula that sums up the days it takes to sell inventory and collect receivables, then subtracts the days it takes to pay suppliers. This provides a net number of days the company's cash is tied up in its operating cycle.

The Core Formula:

Cash Conversion Cycle (CCC) = Days Inventory Outstanding (DIO) + Days Sales Outstanding (DSO) – Days Payables Outstanding (DPO)

Variable Explanations:

  • Days Inventory Outstanding (DIO): This measures the average number of days it takes for a company to sell its inventory. A lower DIO signifies faster sales and more efficient inventory management.
  • Days Sales Outstanding (DSO): This measures the average number of days it takes for a company to collect payment from its customers after a sale has been made on credit. A lower DSO indicates quicker cash collection from receivables.
  • Days Payables Outstanding (DPO): This measures the average number of days a company takes to pay its suppliers. A higher DPO means the company is taking longer to pay its bills, effectively using supplier financing to improve its own cash flow.

Step-by-Step Derivation:

  1. Calculate DIO: Divide the average inventory by the cost of goods sold (COGS) and multiply by the number of days in the period (typically 365). Mathematically: (Average Inventory / COGS) * 365.
  2. Calculate DSO: Divide average accounts receivable by total credit sales and multiply by the number of days in the period. Mathematically: (Average Accounts Receivable / Total Credit Sales) * 365.
  3. Calculate DPO: Divide average accounts payable by the cost of goods sold (or purchases) and multiply by the number of days in the period. Mathematically: (Average Accounts Payable / COGS) * 365.
  4. Combine the values: Plug the calculated DIO, DSO, and DPO into the main CCC formula.

Variables Table:

CCC Calculation Variables
Variable Meaning Unit Typical Range / Interpretation
Days Inventory Outstanding (DIO) Average time to sell inventory. Days Lower is generally better; indicates efficient sales and inventory management.
Days Sales Outstanding (DSO) Average time to collect cash from credit sales. Days Lower is better; reflects efficient credit and collections policies.
Days Payables Outstanding (DPO) Average time to pay suppliers. Days Higher can improve cash flow but may impact supplier relationships.
Cost of Goods Sold (COGS) Direct costs attributable to the production of goods sold. Currency Unit Used to calculate DIO and DPO.
Average Inventory Average value of inventory held during a period. Currency Unit Represents capital tied up in stock.
Total Credit Sales Total revenue generated from sales made on credit. Currency Unit Used to calculate DSO.
Average Accounts Receivable Average amount owed by customers for goods/services already delivered. Currency Unit Represents outstanding customer payments.
Average Accounts Payable Average amount owed to suppliers for goods/services received. Currency Unit Represents outstanding supplier payments.
Cash Conversion Cycle (CCC) Net time to convert operating activities into cash. Days Shorter is generally better, indicating efficient working capital management.

Practical Examples (Real-World Use Cases)

Understanding the CCC is best illustrated through practical examples. These scenarios highlight how changes in operational metrics directly impact a company's cash flow cycle.

Example 1: A Retail Clothing Store

Consider "FashionForward," a retail clothing store. They want to assess their working capital efficiency.

  • Average Inventory (DIO): FashionForward takes, on average, 70 days to sell its inventory.
  • Average Collection Period (DSO): Most sales are for cash or immediate card payments, so their DSO is very low, averaging 5 days.
  • Average Payment Period (DPO): FashionForward negotiates payment terms with its suppliers, taking an average of 40 days to pay its invoices.

Calculation:

CCC = DIO + DSO – DPO

CCC = 70 days + 5 days – 40 days = 35 days

Interpretation: FashionForward has a Cash Conversion Cycle of 35 days. This means that, on average, it takes 35 days from the point they acquire inventory until they receive cash from selling it, after accounting for their payment terms to suppliers. While a 35-day cycle isn't terrible, management might look for ways to reduce inventory holding times (e.g., better forecasting, faster stock turnover) or slightly extend supplier payment terms if feasible without damaging relationships, to shorten the CCC further.

Example 2: A Software Company

Now, let's look at "CodeSolutions," a software development company that bills clients quarterly.

  • Average Inventory (DIO): Software companies typically have minimal physical inventory. CodeSolutions' DIO is negligible, effectively 2 days (representing time to deploy a completed project if there are any backend assets).
  • Average Collection Period (DSO): CodeSolutions bills clients at the start of a quarter for their services. It takes them, on average, 60 days to collect payments after the invoice is issued.
  • Average Payment Period (DPO): CodeSolutions pays its cloud hosting and software subscription bills monthly, taking an average of 25 days to pay its suppliers.

Calculation:

CCC = DIO + DSO – DPO

CCC = 2 days + 60 days – 25 days = 37 days

Interpretation: CodeSolutions has a Cash Conversion Cycle of 37 days. Despite having almost no inventory, their long collection period (DSO) significantly impacts their CCC. The company needs to finance its operations for 37 days between paying its own short-term bills and receiving cash from its clients. To improve this, CodeSolutions should focus on streamlining its billing and collections processes to reduce DSO.

How to Use This Cash Conversion Cycle Calculator

Our Cash Conversion Cycle Calculator is designed to be intuitive and provide quick insights into your company's working capital efficiency. Follow these simple steps:

  1. Input Your Data: Enter the average number of days it takes your business to sell inventory (Days Inventory Outstanding), the average number of days it takes to collect cash from customers (Days Sales Outstanding), and the average number of days you take to pay your suppliers (Days Payables Outstanding). Use the default values as a starting point or enter your company's specific figures.
  2. Click 'Calculate CCC': Once your values are entered, click the "Calculate CCC" button. The calculator will instantly process the numbers using the standard formula.
  3. Review the Results: You will see the main Cash Conversion Cycle result displayed prominently. Below that, you'll find the intermediate values (DIO, DSO, DPO) and the Working Capital Days, along with a summary table that provides a brief interpretation of each metric.
  4. Analyze the Chart: The dynamic chart visually represents the contribution of each component (DIO, DSO, DPO) to your overall CCC, making it easier to grasp the dynamics of your working capital.
  5. Understand the Interpretation: Pay close attention to the "Interpretation" column in the table. A lower CCC generally signifies better operational efficiency and less reliance on external financing for day-to-day operations.
  6. Make Informed Decisions: Use the results to identify potential areas for improvement. For instance, a high DIO might suggest issues with inventory management or slow sales, while a high DSO could point to inefficient accounts receivable management.
  7. Reset or Copy: Use the "Reset Defaults" button to start over with pre-filled example values. The "Copy Results" button allows you to easily save or share the calculated figures and key assumptions.

Key Factors That Affect Cash Conversion Cycle Results

Several interconnected factors influence a company's Cash Conversion Cycle, impacting its operational efficiency and financial flexibility. Understanding these drivers is key to effective working capital management.

  1. Inventory Management Efficiency: This is perhaps the most direct influence on DIO. Poor inventory management, including overstocking, slow-moving items, or ineffective sales strategies, leads to higher inventory levels and thus a longer DIO. Conversely, just-in-time inventory systems or highly desirable, fast-selling products reduce DIO.
  2. Sales and Credit Policies: The DSO is heavily dependent on a company's credit policies and its effectiveness in collecting payments. Offering overly generous credit terms to customers, having a lenient collection process, or dealing with a customer base known for slow payments will increase DSO. Stricter credit checks and more proactive collection efforts reduce DSO.
  3. Supplier Relationships and Payment Terms: DPO is determined by the payment terms negotiated with suppliers. Building strong relationships can allow for longer payment terms, which positively impacts the CCC by reducing the cash tied up. However, excessively stretching payables can strain supplier relationships and potentially lead to loss of discounts or supply chain disruptions.
  4. Seasonality and Business Cycles: Many businesses experience seasonal fluctuations. For example, a retailer might build up significant inventory before a holiday season (increasing DIO), and then see sales spike (decreasing DSO and CCC). Understanding these cycles is crucial for interpreting CCC fluctuations.
  5. Industry Benchmarks: What constitutes a "good" CCC varies significantly by industry. Capital-intensive industries or those with long production lead times naturally have higher CCCs than e-commerce or service businesses. Comparing your CCC to industry averages (via benchmarking data) provides essential context.
  6. Economic Conditions and Inflation: Broader economic factors can influence CCC. During economic downturns, customers may pay slower (increasing DSO), and inventory might move more slowly (increasing DIO). Inflation can also affect the value of inventory and receivables, indirectly impacting the cycle's measured duration in monetary terms.
  7. Operational Efficiency & Technology: Improvements in production processes, supply chain logistics, and the adoption of technologies like automated invoicing, inventory tracking systems (e.g., RFID), and CRM software can significantly streamline operations, reducing both DIO and DSO.

Frequently Asked Questions (FAQ)

What is the ideal Cash Conversion Cycle?

There isn't a single "ideal" CCC as it's highly industry-dependent. Generally, a shorter CCC is better, as it signifies efficient working capital management and faster cash generation. However, extremely short or negative CCCs might indicate that the company isn't fully leveraging supplier credit terms. A common target is to have a CCC shorter than the industry average.

Can the Cash Conversion Cycle be negative?

Yes, a negative Cash Conversion Cycle is possible and often seen in well-managed businesses, particularly in retail. It means the company receives cash from customers (DSO) before it has to pay its suppliers (DPO), effectively being financed by its suppliers. For example, a business that collects payment from customers in 10 days but takes 45 days to pay its suppliers would have a negative CCC component from DPO.

How is DIO calculated if I don't have COGS readily available?

If COGS is not directly available, you can sometimes approximate it using Purchases for businesses that buy and resell goods. However, for manufacturing or service businesses, COGS is essential. You might need to consult your accounting department or financial statements. If only Sales Revenue is available, you can use it as a proxy for DSO calculation, but COGS is preferred for DIO and DPO.

What's the difference between CCC and Working Capital?

Working Capital (Current Assets – Current Liabilities) represents the overall liquidity of a business. The Cash Conversion Cycle (CCC) specifically measures the *time* it takes for a company's operational activities (inventory, sales, payables) to turn into cash. A shorter CCC generally contributes to healthier working capital levels by freeing up cash.

How does improving DSO affect the CCC?

Improving DSO (reducing the number of days it takes to collect from customers) directly reduces the Cash Conversion Cycle. If DSO decreases, and DIO and DPO remain constant, the CCC will shorten, indicating better cash flow efficiency.

What are the risks of having a very high DPO?

While a high DPO can improve short-term cash flow, excessively stretching supplier payments can damage relationships, potentially leading to loss of early payment discounts, stricter payment terms in the future, or even supply disruptions if suppliers become unwilling to extend credit.

Does the CCC apply to service-based businesses?

Yes, though the "inventory" component (DIO) is often negligible or calculated differently. For service businesses, DIO might represent the time it takes to complete a project or deliver a service. The main focus then shifts to DSO and DPO. Our calculator allows a DIO of 0 if applicable.

How often should I calculate my CCC?

It's advisable to calculate your CCC regularly, typically monthly or quarterly, using updated financial data. Consistent monitoring allows you to track trends, identify changes in efficiency, and react promptly to potential issues. Annual calculations provide a broader overview but may miss short-term operational improvements or problems.

Related Tools and Internal Resources

© 2023 Your Financial Insights. All rights reserved.

var chartInstance = null; function isValidNumber(value) { return !isNaN(parseFloat(value)) && isFinite(value) && parseFloat(value) >= 0; } function updateChart(dio, dso, dpo, ccc) { var ctx = document.getElementById('cccChart').getContext('2d'); if (chartInstance) { chartInstance.destroy(); } // Prepare data for chart var labels = ['DIO', 'DSO', 'DPO (Negative Contribution)', 'Net CCC']; var dataValues = [dio, dso, -dpo, ccc]; // DPO is subtracted // Set canvas dimensions for responsiveness ctx.canvas.parentNode.style.maxWidth = '100%'; ctx.canvas.width = ctx.canvas.parentNode.offsetWidth; // Set canvas width to parent width ctx.canvas.height = Math.max(200, ctx.canvas.parentNode.offsetWidth * 0.6); // Maintain aspect ratio, min height chartInstance = new Chart(ctx, { type: 'bar', data: { labels: labels, datasets: [{ label: 'Days', data: dataValues, backgroundColor: [ 'rgba(255, 99, 132, 0.6)', // DIO 'rgba(54, 162, 235, 0.6)', // DSO 'rgba(75, 192, 192, 0.6)', // DPO (negative) 'rgba(255, 206, 86, 0.8)' // CCC (highlight) ], borderColor: [ 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(75, 192, 192, 1)', 'rgba(255, 206, 86, 1)' ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, // Allow custom aspect ratio plugins: { legend: { display: false // Hide legend, use labels directly }, title: { display: true, text: 'Components of Cash Conversion Cycle (Days)', font: { size: 16 } } }, scales: { y: { beginAtZero: true, title: { display: true, text: 'Days' } } } } }); } function calculateCCC() { var dioInput = document.getElementById('daysInventoryOutstanding'); var dsoInput = document.getElementById('daysSalesOutstanding'); var dpoInput = document.getElementById('daysPayablesOutstanding'); var dioError = document.getElementById('daysInventoryOutstandingError'); var dsoError = document.getElementById('daysSalesOutstandingError'); var dpoError = document.getElementById('daysPayablesOutstandingError'); var dio = parseFloat(dioInput.value); var dso = parseFloat(dsoInput.value); var dpo = parseFloat(dpoInput.value); var valid = true; if (!isValidNumber(dio)) { dioError.textContent = "Please enter a valid number for Days Inventory Outstanding."; dioError.style.display = 'block'; valid = false; } else { dioError.textContent = "; dioError.style.display = 'none'; } if (!isValidNumber(dso)) { dsoError.textContent = "Please enter a valid number for Days Sales Outstanding."; dsoError.style.display = 'block'; valid = false; } else { dsoError.textContent = "; dsoError.style.display = 'none'; } if (!isValidNumber(dpo)) { dpoError.textContent = "Please enter a valid number for Days Payables Outstanding."; dpoError.style.display = 'block'; valid = false; } else { dpoError.textContent = "; dpoError.style.display = 'none'; } if (!valid) { // Clear previous results if inputs are invalid document.getElementById('primaryResult').textContent = '–'; document.getElementById('resultDIO').textContent = '–'; document.getElementById('resultDSO').textContent = '–'; document.getElementById('resultDPO').textContent = '–'; document.getElementById('resultWorkingCapitalDays').textContent = '–'; updateTable('–', '–', '–', '–', '–'); if (chartInstance) chartInstance.destroy(); // Clear chart return; } var ccc = dio + dso – dpo; var workingCapitalDays = dio + dso – dpo; // Same as CCC in this simple model document.getElementById('primaryResult').textContent = ccc.toFixed(2) + ' days'; document.getElementById('resultDIO').textContent = dio.toFixed(2); document.getElementById('resultDSO').textContent = dso.toFixed(2); document.getElementById('resultDPO').textContent = dpo.toFixed(2); document.getElementById('resultWorkingCapitalDays').textContent = workingCapitalDays.toFixed(2); updateTable(dio.toFixed(2), dso.toFixed(2), dpo.toFixed(2), ccc.toFixed(2), workingCapitalDays.toFixed(2)); updateChart(dio, dso, dpo, ccc); } function updateTable(dio, dso, dpo, ccc, workingCapitalDays) { document.getElementById('tableDIO').textContent = dio; document.getElementById('tableDSO').textContent = dso; document.getElementById('tableDPO').textContent = dpo; document.getElementById('tableCCC').textContent = ccc; document.getElementById('tableWorkingCapitalDays').textContent = workingCapitalDays; } function resetCalculator() { document.getElementById('daysInventoryOutstanding').value = '60'; document.getElementById('daysSalesOutstanding').value = '45'; document.getElementById('daysPayablesOutstanding').value = '30'; document.getElementById('daysInventoryOutstandingError').style.display = 'none'; document.getElementById('daysSalesOutstandingError').style.display = 'none'; document.getElementById('daysPayablesOutstandingError').style.display = 'none'; calculateCCC(); // Recalculate with reset values } function copyResults() { var dio = document.getElementById('resultDIO').textContent; var dso = document.getElementById('resultDSO').textContent; var dpo = document.getElementById('resultDPO').textContent; var ccc = document.getElementById('primaryResult').textContent; var wcd = document.getElementById('resultWorkingCapitalDays').textContent; var assumptions = "Key Assumptions:\n"; assumptions += "- Days Inventory Outstanding (DIO): " + dio + " days\n"; assumptions += "- Days Sales Outstanding (DSO): " + dso + " days\n"; assumptions += "- Days Payables Outstanding (DPO): " + dpo + " days\n"; var resultsText = "Cash Conversion Cycle Results:\n"; resultsText += "CCC: " + ccc + "\n"; resultsText += "Working Capital Days: " + wcd + "\n\n"; resultsText += assumptions; // Use a temporary textarea to copy text var tempTextArea = document.createElement("textarea"); tempTextArea.value = resultsText; document.body.appendChild(tempTextArea); tempTextArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Results copied!' : 'Failed to copy results.'; // Provide feedback to user var copyButton = document.querySelector('.copy-btn'); var originalText = copyButton.textContent; copyButton.textContent = msg; setTimeout(function() { copyButton.textContent = originalText; }, 2000); } catch (err) { console.error('Fallback: Oops, unable to copy', err); var copyButton = document.querySelector('.copy-btn'); var originalText = copyButton.textContent; copyButton.textContent = 'Copy failed!'; setTimeout(function() { copyButton.textContent = originalText; }, 2000); } document.body.removeChild(tempTextArea); } function toggleFaq(element) { var p = element.nextElementSibling; if (p.style.display === "block") { p.style.display = "none"; } else { p.style.display = "block"; } } // Initial calculation on page load document.addEventListener('DOMContentLoaded', function() { calculateCCC(); // Ensure chart canvas is responsive on load var chartCanvas = document.getElementById('cccChart'); if (chartCanvas) { var parentContainer = chartCanvas.parentNode; if (parentContainer) { chartCanvas.style.width = '100%'; chartCanvas.style.maxWidth = '100%'; chartCanvas.style.height = 'auto'; } } }); // Re-calculate chart on window resize window.addEventListener('resize', function() { if (chartInstance) { var dio = parseFloat(document.getElementById('daysInventoryOutstanding').value); var dso = parseFloat(document.getElementById('daysSalesOutstanding').value); var dpo = parseFloat(document.getElementById('daysPayablesOutstanding').value); var ccc = dio + dso – dpo; if (isValidNumber(dio) && isValidNumber(dso) && isValidNumber(dpo)) { updateChart(dio, dso, dpo, ccc); } } }); // Include Chart.js library – NOTE: For a production environment, this should be loaded via CDN or a script tag in the // For this self-contained HTML, we'll embed a placeholder for the library structure. // In a real scenario, you would need to include the Chart.js library itself. // Example placeholder for where the Chart.js library script would be: // // Since this is a single HTML file, we assume Chart.js is available globally. // If running this code directly, you MUST include Chart.js library. // For example: /* */

Leave a Comment