:root {
–primary-color: #004a99;
–success-color: #28a745;
–background-color: #f8f9fa;
–text-color: #333;
–border-color: #ddd;
–card-background: #fff;
–shadow: 0 2px 5px rgba(0,0,0,0.1);
}
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;
display: flex;
flex-direction: column;
align-items: center;
}
.container {
width: 100%;
max-width: 1000px;
margin: 20px auto;
padding: 20px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: var(–shadow);
}
header {
background-color: var(–primary-color);
color: white;
padding: 20px 0;
text-align: center;
width: 100%;
}
header h1 {
margin: 0;
font-size: 2.5em;
}
main {
padding: 20px 0;
}
h1, h2, h3 {
color: var(–primary-color);
}
h1 {
font-size: 2em;
margin-bottom: 15px;
}
h2 {
font-size: 1.7em;
margin-top: 30px;
margin-bottom: 15px;
border-bottom: 2px solid var(–primary-color);
padding-bottom: 5px;
}
h3 {
font-size: 1.3em;
margin-top: 20px;
margin-bottom: 10px;
}
.loan-calc-container {
background-color: var(–card-background);
padding: 30px;
border-radius: 8px;
box-shadow: var(–shadow);
margin-bottom: 30px;
}
.input-group {
margin-bottom: 20px;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: var(–primary-color);
}
.input-group input[type=”number”],
.input-group input[type=”text”],
.input-group select {
width: calc(100% – 22px);
padding: 10px;
border: 1px solid var(–border-color);
border-radius: 4px;
font-size: 1em;
box-sizing: border-box;
}
.input-group .helper-text {
font-size: 0.85em;
color: #666;
margin-top: 5px;
display: block;
}
.error-message {
color: red;
font-size: 0.85em;
margin-top: 5px;
display: none; /* Hidden by default */
}
.button-group {
display: flex;
justify-content: space-between;
margin-top: 30px;
gap: 10px;
}
button {
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
font-weight: bold;
transition: background-color 0.3s ease;
}
button.primary {
background-color: var(–primary-color);
color: white;
}
button.primary:hover {
background-color: #003366;
}
button.success {
background-color: var(–success-color);
color: white;
}
button.success:hover {
background-color: #218838;
}
button.secondary {
background-color: #6c757d;
color: white;
}
button.secondary:hover {
background-color: #5a6268;
}
#results {
margin-top: 30px;
padding: 25px;
background-color: #e9ecef;
border-radius: 8px;
border: 1px solid #dee2e6;
}
#results h3 {
margin-top: 0;
color: var(–primary-color);
text-align: center;
font-size: 1.5em;
}
.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);
text-align: center;
margin-top: 15px;
padding: 15px;
background-color: #d4edda;
border: 1px solid #c3e6cb;
border-radius: 5px;
}
.formula-explanation {
font-size: 0.9em;
color: #555;
margin-top: 20px;
padding: 15px;
background-color: #f0f0f0;
border-left: 4px solid var(–primary-color);
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
margin-bottom: 30px;
}
th, td {
padding: 10px;
border: 1px solid var(–border-color);
text-align: left;
}
th {
background-color: var(–primary-color);
color: white;
font-weight: bold;
}
td {
background-color: var(–card-background);
}
caption {
font-size: 1.1em;
font-weight: bold;
color: var(–primary-color);
margin-bottom: 10px;
caption-side: top;
text-align: left;
}
canvas {
display: block;
margin: 20px auto;
max-width: 100%;
background-color: var(–card-background);
border-radius: 4px;
box-shadow: var(–shadow);
}
.article-content {
margin-top: 40px;
padding: 30px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: var(–shadow);
}
.article-content p, .article-content ul, .article-content ol {
margin-bottom: 15px;
}
.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: 15px;
}
.faq-item strong {
display: block;
color: var(–primary-color);
margin-bottom: 5px;
}
.related-tools {
margin-top: 30px;
padding: 20px;
background-color: #e9ecef;
border-radius: 8px;
border: 1px solid #dee2e6;
}
.related-tools h3 {
margin-top: 0;
text-align: center;
}
.related-tools ul {
list-style: none;
padding: 0;
}
.related-tools li {
margin-bottom: 10px;
}
.related-tools a {
font-weight: bold;
}
.related-tools span {
font-size: 0.9em;
color: #555;
display: block;
margin-top: 3px;
}
@media (max-width: 768px) {
.container {
margin: 10px;
padding: 15px;
}
header h1 {
font-size: 1.8em;
}
h1 {
font-size: 1.6em;
}
h2 {
font-size: 1.4em;
}
h3 {
font-size: 1.2em;
}
.button-group {
flex-direction: column;
}
button {
width: 100%;
}
}
Liquor Pricing Calculator
Liquor Pricing Calculator
Calculate the optimal selling price for your liquor products by inputting your costs and desired profit margin.
Enter the total cost to acquire one bottle of liquor.
Standard serving size in milliliters (e.g., 1.5 oz = 44.36 ml).
Approximate number of standard servings you can get from one liter (1000ml).
Enter the percentage you want to add to your cost (e.g., 300% means selling for 4x cost).
Enter the typical selling price in your market for similar products.
Pricing Breakdown
1. Cost Per Serving = Cost Per Bottle / (1000ml / Serving Size)
2. Total Servings Per Bottle = 1000ml / Serving Size
3. Cost Per Liter = Cost Per Bottle / (1 Liter / (1000ml / Serving Size)) * Simplified: Cost Per Bottle * (Serving Size / 1000)
4. Target Selling Price Per Serving = Cost Per Serving * (1 + (Desired Markup Percentage / 100))
5. Recommended Selling Price Per Serving is the Target Selling Price Per Serving, adjusted slightly if competitor price is provided and significantly lower.
Price Comparison Chart
Visualizing your recommended price against competitor pricing.
Cost and Yield Summary
| Metric | Value | Unit |
|---|---|---|
| Cost Per Bottle | — | Currency |
| Serving Size | — | ml |
| Servings Per Liter | — | Servings |
| Cost Per Serving | — | Currency |
| Cost Per Liter | — | Currency |
| Desired Markup | — | % |
| Target Selling Price Per Serving | — | Currency |
| Recommended Selling Price | — | Currency |
| Competitor Average Price | — | Currency |
What is a Liquor Pricing Calculator?
A liquor pricing calculator is a specialized financial tool designed for businesses in the hospitality and retail sectors, such as bars, restaurants, liquor stores, and event venues. Its primary function is to help users determine the optimal selling price for alcoholic beverages. This is achieved by taking into account various cost factors, desired profit margins, and sometimes market conditions like competitor pricing. Essentially, it demystifies the complex process of setting prices that are both profitable and competitive, ensuring the business thrives financially.
Who Should Use a Liquor Pricing Calculator?
Anyone involved in selling liquor can benefit from a liquor pricing calculator. This includes:
- Bar Owners & Managers: To set prices for cocktails, shots, and pours that maximize revenue while covering costs.
- Restaurant Owners: To price their wine, beer, and spirits lists effectively.
- Liquor Store Owners: To determine retail prices for bottles, considering wholesale costs and desired profit.
- Event Planners & Caterers: To accurately price beverage packages for events.
- Distributors & Wholesalers: To understand the cost structure and set wholesale prices that allow retailers to profit.
- New Business Startups: To establish a solid pricing foundation from day one.
Common Misconceptions About Liquor Pricing
Several myths surround liquor pricing. One common misconception is that pricing should be solely based on a fixed markup percentage (e.g., always 300% markup). While a markup is crucial, it doesn’t account for the actual cost per serving or competitive market dynamics. Another myth is that the cheapest price always wins; often, perceived value, brand, and service play a significant role. Finally, many underestimate the importance of calculating the true cost per serving, especially when dealing with different bottle sizes and pour volumes. A liquor pricing calculator helps overcome these by providing data-driven insights.
Liquor Pricing Calculator Formula and Mathematical Explanation
The core of a liquor pricing calculator relies on a series of calculations to arrive at a recommended selling price. Let’s break down the formula:
Step-by-Step Derivation
- Calculate Total Servings Per Bottle: This determines how many standard servings can be poured from a single bottle.
- Calculate Cost Per Serving: This is the fundamental cost associated with one unit of the beverage served.
- Calculate Cost Per Liter: Useful for understanding the base cost of the liquid itself, irrespective of serving size.
- Calculate Target Selling Price Per Serving: This applies the desired profit margin to the cost per serving.
- Determine Recommended Selling Price: This is the target price, potentially adjusted based on competitor analysis and market positioning.
Variable Explanations
Here are the key variables used in the calculation:
| Variable | Meaning | Unit | Typical Range |
|---|---|---|---|
| Cost Per Bottle (CB) | The total cost incurred to purchase one bottle of liquor (wholesale price, taxes, shipping). | Currency (e.g., USD) | $10 – $500+ |
| Serving Size (SS) | The standard volume of liquor poured for a single serving. | Milliliters (ml) | 30ml – 60ml (1oz – 2oz) |
| Bottle Volume (BV) | The standard volume of a liquor bottle. | Milliliters (ml) | 750ml or 1000ml |
| Desired Markup Percentage (MP) | The percentage of profit desired over the cost per serving. | Percent (%) | 100% – 1000%+ |
| Competitor Price (CP) | The average price similar products are sold for by competitors. | Currency (e.g., USD) | $5 – $100+ |
Mathematical Formulas
- Total Servings Per Bottle = BV / SS
- Cost Per Serving = CB / (BV / SS)
- Cost Per Liter = CB / (BV / 1000)
- Target Selling Price Per Serving = Cost Per Serving * (1 + (MP / 100))
- Recommended Selling Price Per Serving = Target Selling Price Per Serving (potentially adjusted by CP)
The calculator uses these formulas to provide a data-driven price point. For instance, if a bottle costs $25.50, has a volume of 750ml, and a serving size is 45ml, the total servings per bottle is 750 / 45 = 16.67. The cost per serving is $25.50 / 16.67 = $1.53. If a 300% markup is desired, the target selling price per serving is $1.53 * (1 + (300 / 100)) = $1.53 * 4 = $6.12.
Practical Examples (Real-World Use Cases)
Example 1: High-End Cocktail Bar
Scenario: A craft cocktail bar is pricing a premium whiskey.
- Cost Per Bottle: $75.00
- Serving Size: 60ml (2oz)
- Bottle Volume: 750ml
- Desired Markup Percentage: 500%
- Average Competitor Price: $20.00
Calculations:
- Total Servings Per Bottle: 750ml / 60ml = 16.67 servings
- Cost Per Serving: $75.00 / 16.67 = $4.50
- Target Selling Price Per Serving: $4.50 * (1 + (500 / 100)) = $4.50 * 6 = $27.00
Result Interpretation: The calculator recommends a selling price of $27.00 per serving. This is significantly higher than the competitor’s average price of $20.00. The bar must decide if the premium nature of their establishment, the quality of the whiskey, or the unique cocktail preparation justifies this higher price point. They might choose to price at $22-$25 to be more competitive while still achieving a substantial profit, or stick to $27 if their brand positioning supports it.
Example 2: Casual Restaurant Wine Pour
Scenario: A casual dining restaurant wants to price a house red wine by the glass.
- Cost Per Bottle: $12.00
- Serving Size: 150ml (approx. 5oz)
- Bottle Volume: 750ml
- Desired Markup Percentage: 250%
- Average Competitor Price: $8.00
Calculations:
- Total Servings Per Bottle: 750ml / 150ml = 5 servings
- Cost Per Serving: $12.00 / 5 = $2.40
- Target Selling Price Per Serving: $2.40 * (1 + (250 / 100)) = $2.40 * 3.5 = $8.40
Result Interpretation: The calculator suggests $8.40 per glass. This is slightly above the competitor average of $8.00. Given the small difference and the restaurant’s desire for profitability, pricing at $8.50 or even $9.00 might be acceptable, especially if the wine quality is perceived as good or if it’s part of a larger dining experience. Pricing at $8.00 would yield a lower profit margin but match competitors directly. This highlights the trade-offs between profit and market competitiveness.
How to Use This Liquor Pricing Calculator
Using the liquor pricing calculator is straightforward. Follow these steps:
- Input Costs: Enter the exact cost you pay for a bottle of liquor in the ‘Cost Per Bottle’ field. Include any taxes or shipping fees associated with acquiring the product.
- Define Serving Size: Specify the standard volume (in milliliters) you pour for a single serving. This is crucial for calculating the cost per drink.
- Specify Bottle Volume: Input the standard volume of the bottle you are using (usually 750ml or 1000ml).
- Set Desired Markup: Enter the percentage you aim to add to your cost to achieve your desired profit margin. A higher percentage means a higher selling price.
- Add Competitor Price (Optional): If known, enter the average price your competitors charge for similar products. This helps contextualize your calculated price.
- Calculate: Click the ‘Calculate Price’ button.
How to Read Results
The calculator will display:
- Cost Per Serving: The base cost of one drink.
- Total Servings Per Bottle: How many servings you can get from one bottle.
- Cost Per Liter: The cost of the liquid per liter.
- Target Selling Price Per Serving: The price based purely on your cost and desired markup.
- Recommended Selling Price Per Serving: The final suggested price, which may be slightly adjusted based on competitor data. This is the primary highlighted result.
The chart and table provide visual and detailed breakdowns of these figures.
Decision-Making Guidance
Use the ‘Recommended Selling Price’ as a strong starting point. Compare it against the ‘Target Selling Price’ and ‘Competitor Price’. If the recommended price is significantly higher than competitors, consider if your brand, quality, or service justifies it. If it’s lower, you might be leaving money on the table. Adjust your markup percentage or serving size slightly to fine-tune the price based on your business strategy and market position. Remember to factor in other overhead costs not directly tied to a single bottle, such as labor, rent, and marketing, when setting overall business pricing strategies.
Key Factors That Affect Liquor Pricing Results
Several elements influence the final pricing decisions and the effectiveness of a liquor pricing calculator:
- Cost of Goods Sold (COGS): This is the most direct input. Fluctuations in wholesale prices, supplier fees, or shipping costs directly impact the cost per bottle and, consequently, the selling price. Maintaining strong supplier relationships can help stabilize these costs.
- Desired Profit Margin: The markup percentage is a direct reflection of your profit goals. Higher margins mean higher prices, but potentially lower sales volume. Lower margins can drive volume but reduce per-unit profit. Finding the right balance is key.
- Market Competition: Competitor pricing acts as a benchmark. Pricing significantly above competitors requires justification through superior quality, unique offerings, or strong brand loyalty. Pricing below might attract more customers but could signal lower quality or reduce overall profitability.
- Brand Positioning & Perceived Value: A luxury brand or a high-end establishment can command higher prices than a budget-friendly venue, even for the same product. The perceived value associated with the brand and the overall customer experience heavily influences price tolerance.
- Operational Costs (Overhead): While not directly in the calculator, factors like rent, labor, utilities, marketing, and licensing fees must be covered by the overall revenue. The profit generated from liquor sales contributes to covering these overheads. Higher overheads may necessitate higher pricing.
- Taxes and Duties: Excise taxes, sales taxes, and import duties can significantly increase the final cost of liquor. These must be factored into the initial ‘Cost Per Bottle’ or considered separately when setting the final retail price to ensure compliance and profitability.
- Volume and Yield Consistency: Inconsistent serving sizes or inaccurate estimates of servings per bottle can lead to significant profit erosion. Standardizing pour sizes and using accurate measurements is vital for the calculator’s results to be reliable.
- Economic Conditions & Inflation: Broader economic factors like inflation can increase costs and affect consumer spending power. During inflationary periods, businesses may need to adjust prices more frequently or absorb some cost increases to remain competitive.
Frequently Asked Questions (FAQ)
A: The most common bottle size globally is 750ml. However, 1-liter (1000ml) bottles are also prevalent, especially in certain markets or for specific brands.
A: A standard serving size for spirits (like whiskey, vodka, gin) is generally considered to be 1.5 fluid ounces, which is approximately 44.36 ml. Many bars use 45ml or 60ml (2oz) for cocktails or premium pours.
A: Divide the total cost of the bottle by the number of standard servings you can get from that bottle. The calculator automates this: Cost Per Bottle / (Bottle Volume / Serving Size).
A: A 300% markup means you are adding 3 times the cost to the original price. So, if your cost is $10, a 300% markup results in a selling price of $10 + ($10 * 3) = $40. The calculator uses the formula: Cost * (1 + Markup%/100).
A: The recommended price is a data-driven guideline. You should consider your brand positioning, target audience, competitor landscape, and overall business goals. It’s a starting point for informed decision-making.
A: Spillage and waste are typically absorbed into the overall cost structure or accounted for by slightly increasing the desired markup percentage. You might add a small buffer (e.g., 5-10%) to your cost per serving before applying the markup, or simply aim for a higher overall markup to cover these losses.
A: The calculator itself doesn’t automatically add sales tax. You should include any applicable excise or import taxes in your ‘Cost Per Bottle’. The final selling price generated should typically have sales tax added on top at the point of sale, according to local regulations.
A: Yes, the principles apply. You would input the cost per bottle/keg, the serving size in ml, and the desired markup. For kegs, you’d need to estimate the total number of servings available.
var chartInstance = null; // Global variable to hold chart instance
function validateInput(id, min, max, errorMessageId, fieldName) {
var input = document.getElementById(id);
var value = parseFloat(input.value);
var errorElement = document.getElementById(errorMessageId);
var isValid = true;
errorElement.style.display = ‘none’; // Hide error initially
if (isNaN(value)) {
errorElement.textContent = fieldName + ” is required.”;
errorElement.style.display = ‘block’;
isValid = false;
} else if (value max) {
errorElement.textContent = fieldName + ” cannot be greater than ” + max + “.”;
errorElement.style.display = ‘block’;
isValid = false;
}
return isValid;
}
function calculatePricing() {
// Clear previous errors
document.getElementById(‘bottleCostError’).style.display = ‘none’;
document.getElementById(‘servingSizeError’).style.display = ‘none’;
document.getElementById(‘bottlesPerLiterError’).style.display = ‘none’;
document.getElementById(‘desiredMarkupError’).style.display = ‘none’;
document.getElementById(‘competitorPriceError’).style.display = ‘none’;
// Validate inputs
var isValid = true;
isValid = validateInput(‘bottleCost’, 0, undefined, ‘bottleCostError’, ‘Cost Per Bottle’) && isValid;
isValid = validateInput(‘servingSize’, 0.1, undefined, ‘servingSizeError’, ‘Serving Size’) && isValid;
isValid = validateInput(‘bottlesPerLiter’, 1, undefined, ‘bottlesPerLiterError’, ‘Bottles Per Liter’) && isValid; // Assuming at least 1 serving per liter
isValid = validateInput(‘desiredMarkup’, 0, undefined, ‘desiredMarkupError’, ‘Desired Markup Percentage’) && isValid;
// Competitor price is optional, only validate if entered
if (document.getElementById(‘competitorPrice’).value !== “”) {
isValid = validateInput(‘competitorPrice’, 0, undefined, ‘competitorPriceError’, ‘Competitor Price’) && isValid;
}
if (!isValid) {
return; // Stop calculation if any validation fails
}
var bottleCost = parseFloat(document.getElementById(‘bottleCost’).value);
var servingSizeMl = parseFloat(document.getElementById(‘servingSize’).value);
var bottlesPerLiter = parseFloat(document.getElementById(‘bottlesPerLiter’).value); // This is actually servings per liter
var desiredMarkupPercent = parseFloat(document.getElementById(‘desiredMarkup’).value);
var competitorPrice = parseFloat(document.getElementById(‘competitorPrice’).value);
// Constants
var mlPerLiter = 1000;
var defaultBottleVolume = 750; // Assuming standard 750ml bottle for yield calculation if needed, but using servings per liter is more direct
// Calculations
var servingsPerBottle = bottlesPerLiter; // Directly using the input as servings per liter, which implies servings per 750ml or 1000ml based on context. Let’s assume it’s servings per standard bottle volume for consistency.
// If bottlesPerLiter is meant as servings per LITER, then servings per 750ml bottle would be bottlesPerLiter * 0.75
// Let’s clarify: The input is “Bottles Per Liter (for yield calculation)”. This is confusing. Let’s assume it means “Servings Per Liter”.
// If it means “Servings Per Liter”, then servings per 750ml bottle = (Servings Per Liter) * 0.75
// Let’s rename the input conceptually to “Servings Per Liter” for clarity in calculation.
var servingsPerLiterInput = parseFloat(document.getElementById(‘bottlesPerLiter’).value);
var actualServingsPerBottle = servingsPerLiterInput * (defaultBottleVolume / mlPerLiter); // Servings from a 750ml bottle
// Recalculate based on clearer interpretation: servingsPerLiterInput is servings per 1000ml.
var costPerServing = bottleCost / actualServingsPerBottle;
var costPerLiter = bottleCost / (defaultBottleVolume / mlPerLiter); // Cost of the liquid in a 1L volume
var targetSellingPricePerServing = costPerServing * (1 + (desiredMarkupPercent / 100));
var recommendedSellingPrice = targetSellingPricePerServing;
var priceAdjustmentReason = “”;
// Adjust price based on competitor price if it’s significantly lower
if (!isNaN(competitorPrice) && competitorPrice > 0 && targetSellingPricePerServing > competitorPrice * 1.1) { // If target price is more than 10% higher than competitor
recommendedSellingPrice = Math.max(competitorPrice, costPerServing * (1 + (desiredMarkupPercent / 100) * 0.8)); // Try to stay close to competitor, but ensure markup is still reasonable
priceAdjustmentReason = ” Adjusted slightly lower to be competitive.”;
if (recommendedSellingPrice 0 && targetSellingPricePerServing < competitorPrice * 0.9) { // If target price is significantly lower than competitor
recommendedSellingPrice = competitorPrice; // Match competitor if our target is much lower
priceAdjustmentReason = " Adjusted to match competitor price.";
}
// Rounding for currency display
var formattedCostPerServing = costPerServing.toFixed(2);
var formattedCostPerLiter = costPerLiter.toFixed(2);
var formattedTargetSellingPrice = targetSellingPricePerServing.toFixed(2);
var formattedRecommendedSellingPrice = recommendedSellingPrice.toFixed(2);
// Display results
document.getElementById('costPerServing').textContent = formattedCostPerServing;
document.getElementById('totalServingsPerBottle').textContent = actualServingsPerBottle.toFixed(2);
document.getElementById('costPerLiter').textContent = formattedCostPerLiter;
document.getElementById('targetSellingPricePerServing').textContent = formattedTargetSellingPrice;
document.getElementById('recommendedSellingPrice').textContent = formattedRecommendedSellingPrice;
// Update table
document.getElementById('tableBottleCost').textContent = bottleCost.toFixed(2);
document.getElementById('tableServingSize').textContent = servingSizeMl.toFixed(1);
document.getElementById('tableServingsPerLiter').textContent = servingsPerLiterInput.toFixed(2); // Display the input value directly
document.getElementById('tableCostPerServing').textContent = formattedCostPerServing;
document.getElementById('tableCostPerLiter').textContent = formattedCostPerLiter;
document.getElementById('tableMarkup').textContent = desiredMarkupPercent.toFixed(1);
document.getElementById('tableTargetSellingPrice').textContent = formattedTargetSellingPrice;
document.getElementById('tableRecommendedSellingPrice').textContent = formattedRecommendedSellingPrice;
document.getElementById('tableCompetitorPrice').textContent = isNaN(competitorPrice) ? '–' : competitorPrice.toFixed(2);
// Update chart
updateChart(formattedRecommendedSellingPrice, isNaN(competitorPrice) ? null : competitorPrice.toFixed(2));
}
function updateChart(recommendedPrice, competitorPrice) {
var ctx = document.getElementById('priceChart').getContext('2d');
// Destroy previous chart instance if it exists
if (chartInstance) {
chartInstance.destroy();
}
var labels = ['Your Price', 'Competitor Avg'];
var data = [parseFloat(recommendedPrice)];
if (competitorPrice !== null) {
data.push(parseFloat(competitorPrice));
} else {
labels = ['Your Price']; // Adjust labels if no competitor data
}
// Define colors
var primaryColor = '#004a99'; // Corresponds to –primary-color
var successColor = '#28a745'; // Corresponds to –success-color
var borderColor = '#ddd';
chartInstance = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Price Per Serving',
data: data,
backgroundColor: [
successColor, // Color for Your Price
primaryColor // Color for Competitor Avg
],
borderColor: borderColor,
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
ticks: {
// Include a dollar sign in the ticks
callback: function(value, index, values) {
return '$' + value.toFixed(2);
}
}
}
},
plugins: {
legend: {
display: false // Hide legend as labels are on bars
},
tooltip: {
callbacks: {
label: function(context) {
var label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(context.parsed.y);
}
return label;
}
}
}
}
}
});
}
function resetCalculator() {
document.getElementById('bottleCost').value = '25.50';
document.getElementById('servingSize').value = '45';
document.getElementById('bottlesPerLiter').value = '21.1'; // Approx servings per liter for 45ml servings
document.getElementById('desiredMarkup').value = '300';
document.getElementById('competitorPrice').value = '12.00';
// Clear errors
document.getElementById('bottleCostError').style.display = 'none';
document.getElementById('servingSizeError').style.display = 'none';
document.getElementById('bottlesPerLiterError').style.display = 'none';
document.getElementById('desiredMarkupError').style.display = 'none';
document.getElementById('competitorPriceError').style.display = 'none';
// Reset results display
document.getElementById('costPerServing').textContent = '–';
document.getElementById('totalServingsPerBottle').textContent = '–';
document.getElementById('costPerLiter').textContent = '–';
document.getElementById('targetSellingPricePerServing').textContent = '–';
document.getElementById('recommendedSellingPrice').textContent = '–';
// Reset table
document.getElementById('tableBottleCost').textContent = '–';
document.getElementById('tableServingSize').textContent = '–';
document.getElementById('tableServingsPerLiter').textContent = '–';
document.getElementById('tableCostPerServing').textContent = '–';
document.getElementById('tableCostPerLiter').textContent = '–';
document.getElementById('tableMarkup').textContent = '–';
document.getElementById('tableTargetSellingPrice').textContent = '–';
document.getElementById('tableRecommendedSellingPrice').textContent = '–';
document.getElementById('tableCompetitorPrice').textContent = '–';
// Reset chart
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
var canvas = document.getElementById('priceChart');
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear canvas
// Trigger initial calculation with default values
calculatePricing();
}
function copyResults() {
var resultsText = "Liquor Pricing Calculation Results:\n\n";
resultsText += "Cost Per Serving: " + document.getElementById('costPerServing').textContent + "\n";
resultsText += "Total Servings Per Bottle: " + document.getElementById('totalServingsPerBottle').textContent + "\n";
resultsText += "Cost Per Liter: " + document.getElementById('costPerLiter').textContent + "\n";
resultsText += "Target Selling Price Per Serving: " + document.getElementById('targetSellingPricePerServing').textContent + "\n";
resultsText += "Recommended Selling Price Per Serving: " + document.getElementById('recommendedSellingPrice').textContent + "\n\n";
resultsText += "Key Assumptions:\n";
resultsText += "Cost Per Bottle: $" + document.getElementById('tableBottleCost').textContent + "\n";
resultsText += "Serving Size: " + document.getElementById('tableServingSize').textContent + " ml\n";
resultsText += "Servings Per Liter: " + document.getElementById('tableServingsPerLiter').textContent + "\n";
resultsText += "Desired Markup: " + document.getElementById('tableMarkup').textContent + "%\n";
resultsText += "Competitor Average Price: " + (document.getElementById('tableCompetitorPrice').textContent === '–' ? 'N/A' : '$' + document.getElementById('tableCompetitorPrice').textContent) + "\n";
// Use a temporary textarea to copy text to clipboard
var textArea = document.createElement("textarea");
textArea.value = resultsText;
textArea.style.position = "fixed"; // Avoid scrolling to bottom of page in MS Edge.
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = '0';
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'Results copied!' : 'Copying text command was unsuccessful';
// Optionally show a confirmation message to the user
console.log(msg);
} catch (err) {
console.log('Unable to copy text.', err);
}
document.body.removeChild(textArea);
}
// Initial calculation on page load with default values
window.onload = function() {
// Ensure Chart.js is loaded before calling updateChart
if (typeof Chart !== 'undefined') {
resetCalculator(); // Load defaults and calculate
} else {
// If Chart.js is not loaded yet, try again after a short delay
setTimeout(function() {
if (typeof Chart !== 'undefined') {
resetCalculator();
} else {
console.error("Chart.js library not loaded.");
// Optionally display a message to the user
}
}, 1000); // Wait 1 second
}
};