Fix stock amount can be a decimal

This commit is contained in:
Laurent Destailleur 2020-12-08 17:53:12 +01:00
parent 0f2a8d0262
commit aaf1910c25

View File

@ -240,7 +240,7 @@ if (empty($reshook))
$stockLocation = "ent1".$i."_0"; $stockLocation = "ent1".$i."_0";
$qty = "qtyl".$i; $qty = "qtyl".$i;
if ($objectsrc->lines[$i]->product_tobatch) // If product need a batch number if (!empty($conf->productbatch->enabled) && $objectsrc->lines[$i]->product_tobatch) // If product need a batch number
{ {
if (GETPOSTISSET($batch)) if (GETPOSTISSET($batch))
{ {
@ -275,27 +275,26 @@ if (empty($reshook))
setEventMessages($langs->trans("StockIsRequiredToChooseWhichLotToUse"), null, 'errors'); setEventMessages($langs->trans("StockIsRequiredToChooseWhichLotToUse"), null, 'errors');
} }
} }
} elseif (GETPOSTISSET($stockLocation)) } elseif (GETPOSTISSET($stockLocation)) {
{
//shipment line from multiple stock locations //shipment line from multiple stock locations
$qty .= '_'.$j; $qty .= '_'.$j;
while (GETPOSTISSET($stockLocation)) while (GETPOSTISSET($stockLocation))
{ {
// save sub line of warehouse // save sub line of warehouse
$stockLine[$i][$j]['qty'] = GETPOST($qty, 'int'); $stockLine[$i][$j]['qty'] = price2num(GETPOST($qty, 'alpha'), 'MS');
$stockLine[$i][$j]['warehouse_id'] = GETPOST($stockLocation, 'int'); $stockLine[$i][$j]['warehouse_id'] = GETPOST($stockLocation, 'int');
$stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int'); $stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int');
$totalqty += GETPOST($qty, 'int'); $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
$j++; $j++;
$stockLocation = "ent1".$i."_".$j; $stockLocation = "ent1".$i."_".$j;
$qty = "qtyl".$i.'_'.$j; $qty = "qtyl".$i.'_'.$j;
} }
} else { } else {
//var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; //var_dump(GETPOST($qty,'alpha')); var_dump($_POST); var_dump($batch);exit;
//shipment line for product with no batch management and no multiple stock location //shipment line for product with no batch management and no multiple stock location
if (GETPOST($qty, 'int') > 0) $totalqty += GETPOST($qty, 'int'); if (GETPOST($qty, 'int') > 0) $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
} }
// Extrafields // Extrafields