function calculateWeeksOfSupply() {
var inventory = parseFloat(document.getElementById('currentInventory').value);
var sold = parseFloat(document.getElementById('unitsSold').value);
var weeksInPeriod = parseFloat(document.getElementById('periodLength').value);
var resultBox = document.getElementById('wos-result-box');
var resultDisplay = document.getElementById('wos-value');
var insightDisplay = document.getElementById('wos-insight-text');
if (isNaN(inventory) || isNaN(sold) || isNaN(weeksInPeriod) || weeksInPeriod <= 0) {
alert("Please enter valid positive numbers for all fields.");
return;
}
if (sold === 0) {
resultDisplay.innerText = "Infinite";
insightDisplay.innerText = "With zero sales, your inventory will last indefinitely. Consider marketing or liquidation.";
resultBox.style.display = "block";
return;
}
var averageWeeklySales = sold / weeksInPeriod;
var weeksOfSupply = inventory / averageWeeklySales;
resultDisplay.innerText = weeksOfSupply.toFixed(1) + " Weeks";
resultBox.style.display = "block";
var insight = "";
if (weeksOfSupply < 2) {
insight = "CRITICAL: You are at high risk of a stockout. Reorder immediately or expedite shipping.";
resultBox.style.borderLeftColor = "#e74c3c";
resultDisplay.style.color = "#e74c3c";
} else if (weeksOfSupply >= 2 && weeksOfSupply <= 6) {
insight = "HEALTHY: Your inventory levels are balanced for standard retail cycles.";
resultBox.style.borderLeftColor = "#27ae60";
resultDisplay.style.color = "#27ae60";
} else if (weeksOfSupply > 12) {
insight = "OVERSTOCK: You have more than 3 months of supply. This may tie up your capital unnecessarily.";
resultBox.style.borderLeftColor = "#f39c12";
resultDisplay.style.color = "#f39c12";
} else {
insight = "STABLE: You have a comfortable buffer of inventory for the coming weeks.";
resultBox.style.borderLeftColor = "#3498db";
resultDisplay.style.color = "#3498db";
}
insightDisplay.innerHTML = insight + "Average Weekly Sales: " + averageWeeklySales.toFixed(2) + " units/week.";
}
Understanding Weeks of Supply (WOS) in Inventory Management
Weeks of Supply (WOS) is a critical retail and supply chain metric that measures how long your current inventory will last based on current demand. It tells you exactly how many weeks it will take to run out of stock if sales continue at their current pace.
The Weeks of Supply Formula
To calculate Weeks of Supply manually, you first need to determine your Average Weekly Sales (AWS). The formula follows two steps:
AWS = Total Units Sold / Number of Weeks in the Data Set
WOS = Current Inventory on Hand / AWS
By using this calculation, businesses can avoid the two biggest inventory pitfalls: stockouts (running out of product and losing sales) and overstocking (tying up cash flow in products that aren't moving).
Practical Example
Imagine you run an e-commerce store selling wireless headphones:
Current Inventory: 1,200 units
Units Sold in last 4 weeks: 300 units
Step 1: Calculate Average Weekly Sales: 300 units ÷ 4 weeks = 75 units per week.
Step 2: Calculate Weeks of Supply: 1,200 units ÷ 75 units/week = 16 Weeks of Supply.
In this scenario, you have approximately 4 months of inventory left. If your lead time for new stock is 4 weeks, you don't need to reorder immediately, but you should keep an eye on sales spikes.
Why Should You Track Weeks of Supply?
Better Cash Flow: Knowing your WOS prevents you from buying too much inventory, allowing you to keep your capital liquid for other business needs.
Warehouse Optimization: Inventory that sits for 20+ weeks takes up valuable shelf space that could be used for faster-moving items.
Supplier Coordination: By knowing your WOS, you can provide your suppliers with more accurate forecasts and reorder at the perfect time relative to their lead times.
Identifying Trends: If your WOS is rapidly decreasing, it's a signal of rising popularity or a successful marketing campaign, indicating you need to scale up production.
What is a "Good" Weeks of Supply?
There is no universal "perfect" number, as it depends on your industry and lead times:
Perishable Goods: Typically require a very low WOS (1-2 weeks).
Fast-Moving Consumer Goods (FMCG): Often aim for 4-6 weeks.
Custom or Imported Goods: May require 12-16 weeks if the lead time from the factory is several months.