diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 48e9c9d965a..c98dee97f51 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -523,7 +523,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
- print '
| '.$langs->trans("TotalCost").' | '.price($object->total_cost).' |
';
+ print '| '.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' | '.price($object->total_cost).' |
';
print '| '.$langs->trans("UnitCost").' | '.price($object->unit_cost).' |
';
// Other attributes
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 3e522b3c11f..86e0b84b655 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -1013,11 +1013,20 @@ class BOM extends CommonObject
$this->unit_cost = 0;
$this->total_cost = 0;
+ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
+ $productFournisseur = new ProductFournisseur($this->db);
+
foreach ($this->lines as &$line) {
$tmpproduct = new Product($this->db);
$tmpproduct->fetch($line->fk_product);
+ $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
+ if (empty($line->unit_cost)) {
+ if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0)
+ {
+ $line->unit_cost = $productFournisseur->fourn_unitprice;
+ }
+ }
- $line->unit_cost = (!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp; // TODO : add option to work with cost_price or pmp
$line->total_cost = price2num($line->qty * $line->unit_cost, 'MT');
$this->total_cost += $line->total_cost;
}
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index d3c4d3253c6..faa8eb60cf4 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -74,3 +74,4 @@ ProductsToConsume=Products to consume
ProductsToProduce=Products to produce
UnitCost=Unit cost
TotalCost=Total cost
+BOMTotalCost=The cost to produce this BOM based on cost of each quantity and product to consume (use Cost price if defined, else Average Weighted Price if defined, else the Best purchase price)
\ No newline at end of file