FIX using decimal on stock correction

This commit is contained in:
Laurent Destailleur 2020-09-04 19:34:20 +02:00
parent 4fdbfa8224
commit 0c1a5d9e25

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;
@ -244,14 +245,14 @@ if ($action == "correct_stock" && !$cancel)
$result = $object->correct_stock_batch(
$user,
GETPOST("id_entrepot", 'int'),
GETPOST("nbpiece"),
GETPOST("mouvement"),
$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
@ -259,11 +260,11 @@ if ($action == "correct_stock" && !$cancel)
$result = $object->correct_stock(
$user,
GETPOST("id_entrepot", 'int'),
GETPOST("nbpiece"),
GETPOST("mouvement"),
$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
@ -361,18 +362,20 @@ if ($action == "transfert_stock" && !$cancel)
$sellby = $d_sellby;
}
$nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml'));
if (!$error)
{
// Remove stock
$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++;
}
@ -382,12 +385,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++;
}
@ -398,11 +401,11 @@ if ($action == "transfert_stock" && !$cancel)
$result1 = $object->correct_stock(
$user,
GETPOST("id_entrepot", 'int'),
GETPOST("nbpiece"),
$nbpiece,
1,
GETPOST("label"),
GETPOST("label", 'alphanohtml'),
$pricesrc,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alphanohtml')
);
if ($result1 < 0) $error++;
}
@ -412,11 +415,11 @@ if ($action == "transfert_stock" && !$cancel)
$result2 = $object->correct_stock(
$user,
GETPOST("id_entrepot_destination", 'int'),
GETPOST("nbpiece"),
$nbpiece,
0,
GETPOST("label"),
GETPOST("label", 'alphanohtml'),
$pricedest,
GETPOST('inventorycode')
GETPOST('inventorycode', 'alphanohtml')
);
if ($result2 < 0) $error++;
}