Skip to main content

Overview

The Sales Price Calculator helps businesses determine the right selling price for their products by calculating prices based on cost, desired profit, and tax. It supports two fundamental pricing strategies: markup (profit on cost) and margin (profit on sales).

Markup Pricing

Calculate price based on profit percentage over cost

Margin Pricing

Calculate price based on desired profit margin on sales

Profit Tracking

See exact profit amounts in monetary terms

Tax Integration

Include tax in final customer pricing

Pricing Strategies

Understanding the difference between markup and margin is crucial for accurate pricing:

Markup Method

Markup is the profit percentage calculated on top of the cost. This is the most intuitive pricing method. Formula: Sale Price = Cost + (Cost × Markup%)
sales_price_provider.dart
if (_marginType == MarginType.markup) {
  _profitAmount = cost * (profitPercent / 100);
  _baseSalePrice = cost + _profitAmount!;
}
Cost: $50, Markup: 40%
  • Profit: 50×0.40=50 × 0.40 = **20**
  • Sale Price: 50+50 + 20 = $70
  • Margin on sales: 20/20 / 70 = 28.57% (not 40%!)

Margin Method

Margin is the profit percentage calculated as a percentage of the sale price. This method is used when you know your target profit margin. Formula: Sale Price = Cost / (1 - Margin%)
sales_price_provider.dart
else {
  _baseSalePrice = cost / (1 - (profitPercent / 100));
  _profitAmount = _baseSalePrice! - cost;
}
Cost: $50, Margin: 40%
  • Sale Price: 50/(10.40)=50 / (1 - 0.40) = **83.33**
  • Profit: 83.3383.33 - 50 = $33.33
  • Markup on cost: 33.33/33.33 / 50 = 66.67% (not 40%!)
Critical Difference: A 40% markup and a 40% margin produce very different prices:
  • 40% markup on 50=50 = 70 sale price
  • 40% margin on 50=50 = 83.33 sale price
Always verify which method your business uses!

Calculation Flow

The calculator processes pricing in a clear sequence:
1

Parse and Validate Input

All inputs are safely parsed to prevent invalid data from causing errors.
sales_price_provider.dart
final cost = double.tryParse(_costInput);
final profitPercent = double.tryParse(_profitPercentInput);
final taxPercent = _taxInput.isEmpty ? 0.0 : double.tryParse(_taxInput);

if (cost == null || profitPercent == null || taxPercent == null) {
  _errorMessage = "Valores numéricos inválidos";
  return;
}
2

Apply Pricing Formula

The appropriate formula (markup or margin) is applied based on the selected mode.
3

Calculate Tax

Tax is added to the base sale price to determine the final customer price:
sales_price_provider.dart
_taxAmount = _baseSalePrice! * (taxPercent / 100);
_finalPrice = _baseSalePrice! + _taxAmount!;
4

Update UI

All calculated values are exposed and the UI is notified to refresh.

Validation Rules

The calculator enforces business logic to ensure valid calculations:
Cost, profit percentage, and tax must all be non-negative values.
sales_price_provider.dart
if (cost < 0 || profitPercent < 0 || taxPercent < 0) {
  _errorMessage = "Los valores no pueden ser negativos";
  return;
}
In margin mode, the profit margin must be less than 100%. A 100% margin would mean the entire sale price is profit with zero cost, which is mathematically invalid (division by zero).
sales_price_provider.dart
if (_marginType == MarginType.margin && profitPercent >= 100) {
  _errorMessage = "El margen sobre venta debe ser menor a 100%";
  return;
}
There is no upper limit on markup percentage. A 200% markup is valid and means selling at 3× the cost.

Input Fields

The calculator requires these inputs:
FieldTypeRequiredDescription
CostNumberYesThe cost to acquire or produce the item
Profit PercentageNumberYesDesired profit (interpreted as markup or margin)
Tax PercentageNumberNoTax rate to add to the sale price
Pricing ModeEnumYesMarkup or Margin calculation method

Output Values

After calculation, these values are available:
  • Base Sale Price: Price before tax (your revenue per unit)
  • Profit Amount: Monetary profit per unit sold
  • Tax Amount: Tax to be collected from customer
  • Final Price: Total price customer pays (base price + tax)

State Persistence

All inputs are automatically saved and restored:
sales_price_provider.dart
_prefs.setString('sales_cost', costStr);
_prefs.setString('sales_profit', profitPercentStr);
_prefs.setString('sales_tax', taxStr);
_prefs.setInt('sales_margin_type', type == MarginType.markup ? 0 : 1);
The calculator remembers your last calculation and pricing mode preference.
For complete API documentation, see the Sales Price Provider API Reference.

Usage Examples

Example 1: Markup Pricing

Scenario: You purchase inventory for $30 per unit and want a 50% markup, with 7% sales tax.
1

Enter Values

  • Cost: 30
  • Profit Percentage: 50
  • Mode: Markup
  • Tax: 7
2

Results

  • Base Sale Price: $45.00 (30+30 + 15)
  • Profit: $15.00
  • Tax: $3.15 (7% of $45)
  • Final Price: $48.15

Example 2: Margin Pricing

Scenario: Your cost is $30 and you need a 40% profit margin to cover overhead, with 7% tax.
1

Enter Values

  • Cost: 30
  • Profit Percentage: 40
  • Mode: Margin
  • Tax: 7
2

Results

  • Base Sale Price: $50.00 ($30 / 0.6)
  • Profit: $20.00
  • Tax: $3.50 (7% of $50)
  • Final Price: $53.50
Notice how the same cost (30)withthesamepercentage(4030) with the same percentage (40%) produces **different prices** (45 vs $50) depending on whether you use markup or margin mode.

Quick Reference: Markup vs Margin

AspectMarkupMargin
BaseProfit on costProfit on sale price
FormulaSale = Cost × (1 + Markup%)Sale = Cost / (1 - Margin%)
Example50% markup on 100cost=100 cost = 150 sale50% margin on 100cost=100 cost = 200 sale
LimitNo upper limitMust be < 100%
Common UseRetail pricingFinancial planning

Discount Calculator

Calculate discounted prices with multiple discount tiers

Mathematical Precision

Learn about Numix’s mathematical accuracy approach

Build docs developers (and LLMs) love