Dolibarr ERP/CRM is a modular, open-source software suite widely adopted by SMEs and freelancers to manage everything from sales and purchases to accounting and HR. Among its many useful features is margin calculation—a critical function for understanding profitability. However, many users report issues where Dolibarr does not calculate margins correctly, or at all. This comprehensive guide explains why this happens, how margin functionality works, and offers detailed steps to troubleshoot and resolve the issue.
Table of Contents
-
Introduction: What Is Margin Calculation in Dolibarr?
-
Why Margin Calculation Matters
-
Prerequisites for Margin Calculation
-
Common Symptoms When Margin Doesn’t Work
-
Modules Required for Margin Calculation
-
Setting Up Purchase Prices and Costs
-
How Margins Are Calculated in Dolibarr
-
Troubleshooting Step-by-Step
-
Check Module Activation
-
Check Product Types and Price Settings
-
Check Third-Party Configurations
-
Verify Purchase Information
-
-
Understanding Margin Calculation Modes
-
Role of Multicurrency in Margin Accuracy
-
PDF Templates and Margin Visibility
-
Margin Calculation in Proposals vs. Orders vs. Invoices
-
Common Mistakes and Misconfigurations
-
Advanced Configuration for Precise Margin Analysis
-
Final Recommendations and Best Practices
1. Introduction: What Is Margin Calculation in Dolibarr?
Margin calculation refers to the process by which Dolibarr determines the difference between the selling price and the cost price of a product or service. This calculation is essential for assessing the profitability of quotes, orders, and invoices.
Dolibarr can display margins in documents and dashboards if configured properly. The margin module, when used correctly, provides valuable insight into which sales are profitable and which are not.
2. Why Margin Calculation Matters
Profitability is the core of every business. Without accurate margin calculations, decision-makers cannot:
-
Evaluate performance by product or service
-
Identify unprofitable deals
-
Calculate gross margins for financial analysis
-
Inform sales strategy or pricing decisions
That’s why enabling and correctly setting up margin functionality is crucial in Dolibarr.
3. Prerequisites for Margin Calculation
To get margins calculated correctly in Dolibarr, certain prerequisites must be met:
-
The Margins module must be activated.
-
Purchase or cost prices must be defined for each product or service.
-
Products must be of the type "Product" or "Service" with valid pricing information.
-
User permissions must allow access to margin-related data.
Without these in place, Dolibarr won’t display or calculate margins at all.
4. Common Symptoms When Margin Doesn’t Work
You may experience margin issues in several ways:
-
No margin columns appear in invoices or proposals.
-
Margin always shows as 0% or not available.
-
Dolibarr displays a warning: “No cost price defined.”
-
Dashboards do not reflect margin values.
-
Calculations seem inaccurate when compared to manual checks.
Each symptom helps identify what part of the configuration may be missing or incorrect.
5. Modules Required for Margin Calculation
Dolibarr uses modular architecture. The Margins module is not activated by default.
To activate it:
-
Go to Home > Setup > Modules/Applications.
-
Search for or scroll to Margins.
-
Click Activate.
This unlocks the interface and backend logic required to calculate margins across documents.
Additionally, activating the Purchase Prices and Supplier Orders modules improves margin accuracy, especially in a purchase-to-sale workflow.
6. Setting Up Purchase Prices and Costs
Without a cost price, Dolibarr cannot compute margin.
To set a purchase price for a product:
-
Go to Products/Services > List.
-
Select the product and click Modify.
-
Scroll to the "Cost Price" or "Buying Price" section.
-
Enter the cost manually or via supplier price records.
Make sure that:
-
The currency is correct.
-
The price applies to the supplier used in transactions.
-
The price is up to date.
7. How Margins Are Calculated in Dolibarr
Dolibarr supports several margin calculation methods:
-
Standard Margin = Selling Price - Purchase Price
-
Margin on Cost Price = (Selling - Cost) / Cost
-
Margin on Selling Price = (Selling - Cost) / Selling
The calculation mode can be selected in the margin module settings.
Make sure that you understand which one is being used in your configuration to avoid confusion.
8. Troubleshooting Step-by-Step
Check Module Activation
Ensure the Margins module is active. Without this, no margin data is processed.
Check Product Types and Price Settings
Products must be defined with valid selling and buying prices. Verify:
-
Correct product type (Product or Service)
-
A base price is defined
-
Cost price is properly recorded
Check Third-Party Configurations
When using different vendors or client-specific pricing, check that the right pricing is applied to the right third party.
Verify Purchase Information
Margins can only be calculated when Dolibarr knows the cost. If you use supplier prices:
-
Add suppliers to the product
-
Define buying prices for each
-
Match them to your current supplier
9. Understanding Margin Calculation Modes
You can configure how Dolibarr calculates margins:
-
Navigate to Setup > Modules > Margins
-
Choose calculation type: fixed cost, supplier cost, or weighted average
Choosing the right mode depends on how your purchasing is structured:
-
Use fixed cost if pricing is stable
-
Use supplier cost for supplier-specific workflows
-
Use weighted average if you track stock and purchasing dynamically
10. Role of Multicurrency in Margin Accuracy
If you use multiple currencies:
-
Ensure Dolibarr is set up to handle currency conversion
-
Check that exchange rates are up to date
-
Match buying and selling currencies to get accurate margin
Dolibarr does not automatically reconcile currencies unless exchange rates are defined and updated.
11. PDF Templates and Margin Visibility
Even if margins are calculated, they may not appear in PDFs unless:
-
The template supports margin fields
-
Your user role has permission to view them
-
The relevant columns are enabled in document models
To customize templates:
-
Edit or copy existing templates from
/htdocs/core/modules/facture/doc/
-
Add margin-related PHP code
12. Margin Calculation in Proposals vs. Orders vs. Invoices
Dolibarr calculates margins separately for each document type. A common error is assuming that setting a margin in a proposal will automatically reflect in the invoice.
Make sure cost prices are applied at each document level.
13. Common Mistakes and Misconfigurations
Some of the most common reasons margins aren’t calculated:
-
Margins module not enabled
-
No cost price defined
-
Wrong margin calculation method selected
-
Missing permissions
-
Currency mismatch
-
Outdated Dolibarr version (bugs in older releases)
14. Advanced Configuration for Precise Margin Analysis
To go deeper:
-
Enable advanced price management
-
Use third-party modules for margin analytics
-
Integrate external tools like spreadsheets or BI platforms for visualization
-
Use custom hooks and triggers to adjust calculation behavior
These options are particularly useful for businesses with complex pricing models.
15. Final Recommendations and Best Practices
Margin calculation is essential, but it’s only as accurate as your data and setup. Here’s how to ensure long-term reliability:
-
Keep buying and selling prices updated
-
Periodically review supplier pricing
-
Choose a calculation method that reflects your real costs
-
Train users on data input standards
-
Use version-controlled templates for PDF documents
Always test changes in a staging environment before applying them to live data.