From f3ebc33d1e22f78d335021874fd9805ec341d157 Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Tue, 21 Apr 2020 01:14:02 -0500 Subject: [PATCH 1/4] Fix calculator to consume with to produce i.e. to produce 100 then Order can be produce 135. --- htdocs/mrp/class/mo.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 84bf44c84fe..76bbe7ef26f 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2020 Lenin Rivas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -648,7 +648,7 @@ class Mo extends CommonObject if ($line->qty_frozen) { $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { - $moline->qty = round($line->qty * $this->qty / $line->efficiency, 2); + $moline->qty = round($line->qty * ($this->qty / $bom->qty) / $line->efficiency, 4); // Calculate with Qty to produce and more presition } if ($moline->qty <= 0) { $error++; From b469775718e9b429628a23a825031442d55c4749 Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Tue, 21 Apr 2020 01:21:08 -0500 Subject: [PATCH 2/4] More Presition to 8 decimals --- htdocs/mrp/class/mo.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 76bbe7ef26f..570281ac294 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Lenin Rivas + * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -648,7 +649,7 @@ class Mo extends CommonObject if ($line->qty_frozen) { $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { - $moline->qty = round($line->qty * ($this->qty / $bom->qty) / $line->efficiency, 4); // Calculate with Qty to produce and more presition + $moline->qty = round($line->qty * ($this->qty / $bom->qty) / $line->efficiency, 8); // Calculate with Qty to produce and more presition } if ($moline->qty <= 0) { $error++; From 1788b1b252d5da23fe062bbf93ac65c4f362f597 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Apr 2020 12:32:20 +0200 Subject: [PATCH 3/4] Update mo.class.php Use the accuracy of stock for rounding --- htdocs/mrp/class/mo.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 570281ac294..5f753f24443 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -649,7 +649,7 @@ class Mo extends CommonObject if ($line->qty_frozen) { $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { - $moline->qty = round($line->qty * ($this->qty / $bom->qty) / $line->efficiency, 8); // Calculate with Qty to produce and more presition + $moline->qty = price2num(($line->qty / $bom->qty) * $this->qty / $line->efficiency, 'MS'); // Calculate with Qty to produce and more presition } if ($moline->qty <= 0) { $error++; From 169378f2764ce9b84d09fcc28de73e303b59e458 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Apr 2020 12:34:02 +0200 Subject: [PATCH 4/4] Update mo.class.php --- htdocs/mrp/class/mo.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 5f753f24443..fdfe43f4069 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -591,7 +591,7 @@ class Mo extends CommonObject } /** - * Erase and update the line to produce. + * Erase and update the line to consume and to produce. * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers