From 7c352c9cefe8e241c0dd862d9c148dff11519b33 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 9 Dec 2022 17:00:11 +0100 Subject: [PATCH 1/6] BOM : calculate total cost of lines --- htdocs/bom/class/bom.class.php | 3 ++- htdocs/bom/tpl/objectline_view.tpl.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 0e57bebd922..4dfb47a3887 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1073,7 +1073,8 @@ class BOM extends CommonObject if ($res>0) { $bom_child->calculateCosts(); $line->childBom[] = $bom_child; - $this->total_cost += $bom_child->total_cost * $line->qty; + $line->total_cost = price2num( $bom_child->total_cost * $line->qty, 'MT'); + $this->total_cost += $line->total_cost; } else { $this->error = $bom_child->error; return -2; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 61b394a3b0f..3897b875652 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -239,13 +239,13 @@ if ($resql) { // Cost if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); - print ''.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).''; + print ''.price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT').''; $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->cost_price > 0) { - print ''.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).''; + print ''.price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT').''; $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined - print ''.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).''; + print ''.price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT').''; $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; @@ -255,7 +255,7 @@ if ($resql) { $obj = $object->db->fetch_object($resql_supplier_price); $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; - print ''.price($line_cost).''; + print ''.price2num($line_cost, 'MT').''; $total_cost+= $line_cost; } } From 92bff0fcfbbba88af2b422d4cefa6b4c3d38cd8f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 12 Dec 2022 11:41:54 +0100 Subject: [PATCH 2/6] Missing Unit TD for sub-bom lines --- htdocs/bom/tpl/objectline_view.tpl.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 3897b875652..bb83e62c07f 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -218,11 +218,16 @@ if ($resql) { } // Qty + $label = $sub_bom_product->getLabelOfUnit('long'); if ($sub_bom_line->qty_frozen > 0) { print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + print ''.($label !== '') ? $langs->trans($label) : '' . ''; print ''.$langs->trans('Yes').''; } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; + print ''; + print ''.($label !== '') ? $langs->trans($label) : '' . ''; + print ''; print ' '; } From b597a43b21a7488bd271f05d99da65539a3f0d96 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Dec 2022 08:37:30 +0000 Subject: [PATCH 3/6] Fixing style errors. --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4dfb47a3887..7f9a1aa09c6 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1073,7 +1073,7 @@ class BOM extends CommonObject if ($res>0) { $bom_child->calculateCosts(); $line->childBom[] = $bom_child; - $line->total_cost = price2num( $bom_child->total_cost * $line->qty, 'MT'); + $line->total_cost = price2num($bom_child->total_cost * $line->qty, 'MT'); $this->total_cost += $line->total_cost; } else { $this->error = $bom_child->error; From 1ebd2135e0f15c34fa62674ec9b19a7fcf4e6412 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 15 Dec 2022 15:00:27 +0100 Subject: [PATCH 4/6] Fix stickler error --- htdocs/bom/tpl/objectline_view.tpl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index bb83e62c07f..f9b39c517e9 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -221,12 +221,15 @@ if ($resql) { $label = $sub_bom_product->getLabelOfUnit('long'); if ($sub_bom_line->qty_frozen > 0) { print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; - print ''.($label !== '') ? $langs->trans($label) : '' . ''; + print ''; + if ($label !== '') print $langs->trans($label); + print ''; print ''.$langs->trans('Yes').''; } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; print ''; - print ''.($label !== '') ? $langs->trans($label) : '' . ''; + if($label !== '') print $langs->trans($label); + print ''; print ''; print ' '; } From 48b4caaa70178498146b230b9c1fceb826502c1c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Dec 2022 09:41:39 +0000 Subject: [PATCH 5/6] Fixing style errors. --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f9b39c517e9..85bd4d6b02a 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -228,7 +228,7 @@ if ($resql) { } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; print ''; - if($label !== '') print $langs->trans($label); + if ($label !== '') print $langs->trans($label); print ''; print ''; print ' '; From 6dbffb53989f8f75f7d5b1d863c7c72328f1a3b6 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 2 Jan 2023 09:48:34 +0100 Subject: [PATCH 6/6] Add price() to pricetonum() on bomline view --- htdocs/bom/tpl/objectline_view.tpl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 85bd4d6b02a..fc6b7709d14 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -247,13 +247,13 @@ if ($resql) { // Cost if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); - print ''.price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT').''; + print ''.price(price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->cost_price > 0) { - print ''.price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT').''; + print ''.price(price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined - print ''.price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT').''; + print ''.price(price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';