FIX using decimal on stock correction

Conflicts:
	htdocs/product/stock/product.php
This commit is contained in:
Laurent Destailleur 2020-09-04 19:34:20 +02:00
parent 2e609d448c
commit 2e7f588cac

View File

@ -1,14 +1,14 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Cédric Salvador <csalvador.gpcsolutions.fr>
* Copyright (C) 2013-2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014-2015 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Cédric Salvador <csalvador.gpcsolutions.fr>
* Copyright (C) 2013-2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014-2015 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -67,8 +67,8 @@ $stocklimit = GETPOST('seuil_stock_alerte');
$desiredstock = GETPOST('desiredstock');
$cancel = GETPOST('cancel', 'alpha');
$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']);
$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']);
$d_eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
$d_sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
$pdluoid = GETPOST('pdluoid', 'int');
$batchnumber = GETPOST('batch_number', 'san_alpha');
if (!empty($batchnumber)) {
@ -224,7 +224,8 @@ if ($action == "correct_stock" && !$cancel)
if (!$error)
{
$priceunit = price2num(GETPOST("unitprice"));
if (is_numeric(GETPOST("nbpiece")) && $id)
$nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml'));
if (is_numeric($nbpiece) && $nbpiece != 0 && $id)
{
$origin_element = '';
$origin_id = null;
@ -243,15 +244,15 @@ if ($action == "correct_stock" && !$cancel)
{
$result = $object->correct_stock_batch(
$user,
GETPOST("id_entrepot"),
GETPOST("nbpiece"),
GETPOST("mouvement"),
GETPOST("label"), // label movement
GETPOST("id_entrepot", 'int'),
$nbpiece,
GETPOST("mouvement", 'int'),
GETPOST("label", 'alphanohtml'), // label movement
$priceunit,
$d_eatby,
$d_sellby,
$batchnumber,
GETPOST('inventorycode'),
GETPOST('inventorycode', 'alphanohtml'),
$origin_element,
$origin_id
); // We do not change value of stock for a correction
@ -260,12 +261,12 @@ if ($action == "correct_stock" && !$cancel)
{
$result = $object->correct_stock(
$user,
GETPOST("id_entrepot"),
GETPOST("nbpiece"),
GETPOST("mouvement"),
GETPOST("label"),
GETPOST("id_entrepot", 'int'),
$nbpiece,
GETPOST("mouvement", 'int'),
GETPOST("label", 'alphanohtml'),
$priceunit,
GETPOST('inventorycode'),
GETPOST('inventorycode', 'alphanohtml'),
$origin_element,
$origin_id
); // We do not change value of stock for a correction
@ -343,6 +344,8 @@ if ($action == "transfert_stock" && !$cancel)
if (isset($object->pmp)) $pricesrc = $object->pmp;
$pricedest = $pricesrc;
$nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml'));
if ($object->hasbatch())
{
$pdluo = new Productbatch($db);
@ -377,12 +380,12 @@ if ($action == "transfert_stock" && !$cancel)
$result1 = $object->correct_stock_batch(
$user,
$srcwarehouseid,
GETPOST("nbpiece", 'int'),
$nbpiece,
1,
GETPOST("label", 'san_alpha'),
GETPOST("label", 'alphanohtml'),
$pricesrc,
$eatby, $sellby, $batch,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alphanohtml')
);
if ($result1 < 0) $error++;
}
@ -392,12 +395,12 @@ if ($action == "transfert_stock" && !$cancel)
$result2 = $object->correct_stock_batch(
$user,
GETPOST("id_entrepot_destination", 'int'),
GETPOST("nbpiece", 'int'),
$nbpiece,
0,
GETPOST("label", 'san_alpha'),
GETPOST("label", 'alphanohtml'),
$pricedest,
$eatby, $sellby, $batch,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alphanohtml')
);
if ($result2 < 0) $error++;
}
@ -409,12 +412,12 @@ if ($action == "transfert_stock" && !$cancel)
// Remove stock
$result1 = $object->correct_stock(
$user,
GETPOST("id_entrepot"),
GETPOST("nbpiece"),
GETPOST("id_entrepot", 'int'),
$nbpiece,
1,
GETPOST("label"),
GETPOST("label", 'alphanohtml'),
$pricesrc,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alphanohtml')
);
if ($result1 < 0) $error++;
}
@ -423,12 +426,12 @@ if ($action == "transfert_stock" && !$cancel)
// Add stock
$result2 = $object->correct_stock(
$user,
GETPOST("id_entrepot_destination"),
GETPOST("nbpiece"),
GETPOST("id_entrepot_destination", 'int'),
$nbpiece,
0,
GETPOST("label"),
GETPOST("label", 'alphanohtml'),
$pricedest,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alphanohtml')
);
if ($result2 < 0) $error++;
}