From a254462bc9e360b047c2d3b44f510cdc207f64ac Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 2 Feb 2023 17:58:54 +0100 Subject: [PATCH] FIX : Sub-BOM's services prices were not good --- htdocs/bom/tpl/objectline_view.tpl.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index ac277f6e880..6208abcbf6d 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -172,7 +172,8 @@ print ''; $coldisplay++; if (!empty($line->fk_bom_child)) { echo ''.price($tmpbom->total_cost * $line->qty).''; -} else { +} +else { echo ''.price($line->total_cost).''; } print ''; @@ -301,6 +302,16 @@ if ($resql) { $sub_bom->calculateCosts(); 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->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) { + //Convert qty to hour + $unit = measuringUnitString($sub_bom_line->fk_unit, '', '', 1); + $qty = convertDurationtoHour($sub_bom_line->qty, $unit); + $workstation = new Workstation($this->db); + $res = $workstation->fetch($sub_bom_product->fk_default_workstation); + if ($res > 0) $sub_bom_line->total_cost = price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); + + print ''.price(price2num($sub_bom_line->total_cost, 'MT')).''; + $this->total_cost += $line->total_cost; } elseif ($sub_bom_product->cost_price > 0) { 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;