FIX : [inventory] Update PMP when qty stay the same

This commit is contained in:
Adrien Raze 2022-04-28 15:49:31 +02:00
parent ed4610b36b
commit 5fe448e86c

View File

@ -186,6 +186,21 @@ if (empty($reshook)) {
break; break;
} }
// Update line with id of stock movement (and the start quantity if it has changed this last recording)
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet";
$sqlupdate .= " SET fk_movement = ".((int) $idstockmove);
if ($qty_stock != $realqtynow) {
$sqlupdate .= ", qty_stock = ".((float) $realqtynow);
}
$sqlupdate .= " WHERE rowid = ".((int) $line->rowid);
$resqlupdate = $db->query($sqlupdate);
if (! $resqlupdate) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
break;
}
}
if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
$sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product);
$resqlpmp = $db->query($sqlpmp); $resqlpmp = $db->query($sqlpmp);
@ -205,20 +220,6 @@ if (empty($reshook)) {
} }
} }
// Update line with id of stock movement (and the start quantity if it has changed this last recording)
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet";
$sqlupdate .= " SET fk_movement = ".((int) $idstockmove);
if ($qty_stock != $realqtynow) {
$sqlupdate .= ", qty_stock = ".((float) $realqtynow);
}
$sqlupdate .= " WHERE rowid = ".((int) $line->rowid);
$resqlupdate = $db->query($sqlupdate);
if (! $resqlupdate) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
break;
}
}
} }
$i++; $i++;
} }