parent
ccc55dcb1e
commit
fe1f88d2ac
@ -475,20 +475,25 @@ class MouvementStock extends CommonObject
|
||||
$newpmp = 0;
|
||||
if (!$error)
|
||||
{
|
||||
// Note: PMP is calculated on stock input only (type of movement = 0 or 3). If type == 0 or 3, qty should be > 0.
|
||||
// Note: Price should always be >0 or 0. PMP should be always >0 (calculated on input)
|
||||
if (($type == 0 || $type == 3) && $price > 0)
|
||||
if ($type == 0 || $type == 3)
|
||||
{
|
||||
$oldqtytouse = ($oldqty >= 0 ? $oldqty : 0);
|
||||
// We make a test on oldpmp>0 to avoid to use normal rule on old data with no pmp field defined
|
||||
if ($oldpmp > 0) $newpmp = price2num((($oldqtytouse * $oldpmp) + ($qty * $price)) / ($oldqtytouse + $qty), 'MU');
|
||||
else
|
||||
{
|
||||
$newpmp = $price; // For this product, PMP was not yet set. We set it to input price.
|
||||
// After a stock increase
|
||||
// Note: PMP is calculated on stock input only (type of movement = 0 or 3). If type == 0 or 3, qty should be > 0.
|
||||
// Note: Price should always be >0 or 0. PMP should be always >0 (calculated on input)
|
||||
if ($price > 0 || (! empty($conf->global->STOCK_UPDATE_AWP_EVEN_WHEN_ENTRY_PRICE_IS_NULL) && $price ==0)) {
|
||||
$oldqtytouse = ($oldqty >= 0 ? $oldqty : 0);
|
||||
// We make a test on oldpmp>0 to avoid to use normal rule on old data with no pmp field defined
|
||||
if ($oldpmp > 0) $newpmp = price2num((($oldqtytouse * $oldpmp) + ($qty * $price)) / ($oldqtytouse + $qty), 'MU');
|
||||
else
|
||||
{
|
||||
$newpmp = $price; // For this product, PMP was not yet set. We set it to input price.
|
||||
}
|
||||
//print "oldqtytouse=".$oldqtytouse." oldpmp=".$oldpmp." oldqtywarehousetouse=".$oldqtywarehousetouse." ";
|
||||
//print "qty=".$qty." newpmp=".$newpmp;
|
||||
//exit;
|
||||
} else {
|
||||
$newpmp = $oldpmp;
|
||||
}
|
||||
//print "oldqtytouse=".$oldqtytouse." oldpmp=".$oldpmp." oldqtywarehousetouse=".$oldqtywarehousetouse." ";
|
||||
//print "qty=".$qty." newpmp=".$newpmp;
|
||||
//exit;
|
||||
}
|
||||
elseif ($type == 1 || $type == 2)
|
||||
{
|
||||
@ -497,6 +502,7 @@ class MouvementStock extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
// Type of movement unknown
|
||||
$newpmp = $oldpmp;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user