From 1f295923fcad38d11193ddb450fbfe0e4ae10c3b Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 2 Feb 2021 12:12:39 +0100 Subject: [PATCH] Show also unit cost iso pmp value for consumption --- htdocs/mrp/mo_production.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index bd254c404d4..f13853a2f72 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -707,7 +707,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$langs->trans("Product").''; print ''.$langs->trans("Qty").''; - if ($permissiontoupdatecost) print ''.$langs->trans("PMPValue").''; + if ($permissiontoupdatecost) print ''.$langs->trans("UnitCost").''; print ''.$langs->trans("QtyAlreadyConsumed").''; print ''; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); @@ -755,6 +755,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); + $linecost = price2num($tmpproduct->pmp, 'MT'); if ($line->origin_type == 'free' && $object->qty > 0) { // add free consume line cost to bomcost @@ -767,6 +768,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } $bomcost += price2num(($line->qty * $linecost) / $object->qty, 'MT'); + } elseif ($line->origin_id > 0 && $line->origin_type == 'bom' && $object->qty > 0) { + foreach ($bom->lines as $bomline) { + if ($bomline->id == $line->origin_id) { + $linecost = price2num(($line->qty * $bomline->unit_cost) / $object->qty, 'MT'); + } + } } $arrayoflines = $object->fetchLinesLinked('consumed', $line->id); @@ -791,7 +798,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($permissiontoupdatecost) { print ''; - print price($tmpproduct->pmp); + print $linecost; print ''; } print '';