mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Merge pull request #14251 from fmarcet/develop
New: ##12972 Update supplier price also when product has batch
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2010-2019 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2017-2020 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
|
||||
*
|
||||
@@ -243,7 +243,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
|
||||
if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
|
||||
if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
|
||||
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2]);
|
||||
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int');
|
||||
if (!empty($dto)) {
|
||||
$unit_price = price2num(GETPOST("pu_".$reg[1]) * (100 - $dto) / 100, 'MU');
|
||||
}
|
||||
@@ -269,14 +269,14 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
|
||||
if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
|
||||
if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
|
||||
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2]);
|
||||
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int');
|
||||
//update supplier price
|
||||
if (GETPOSTISSET($saveprice)) {
|
||||
// TODO Use class
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql .= " SET unitprice='".GETPOST($pu)."'";
|
||||
$sql .= ", price=".GETPOST($pu)."*quantity";
|
||||
$sql .= ", remise_percent='".$dto."'";
|
||||
$sql .= ", remise_percent='".(!empty($dto)?$dto:0)."'";
|
||||
$sql .= " WHERE fk_soc=".$object->socid;
|
||||
$sql .= " AND fk_product=".GETPOST($prod, 'int');
|
||||
|
||||
@@ -306,6 +306,16 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
|
||||
$fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
|
||||
|
||||
if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
|
||||
if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
|
||||
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int');
|
||||
if (!empty($dto)) {
|
||||
$unit_price = price2num(GETPOST("pu_".$reg[1]) * (100 - $dto) / 100, 'MU');
|
||||
}
|
||||
$saveprice = "saveprice_".$reg[1].'_'.$reg[2];
|
||||
}
|
||||
}
|
||||
|
||||
// We ask to move a qty
|
||||
if (GETPOST($qty) > 0) {
|
||||
if (!(GETPOST($ent, 'int') > 0)) {
|
||||
@@ -328,6 +338,24 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
|
||||
if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
|
||||
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int');
|
||||
//update supplier price
|
||||
if (GETPOSTISSET($saveprice)) {
|
||||
// TODO Use class
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
|
||||
$sql .= " SET unitprice='".GETPOST($pu)."'";
|
||||
$sql .= ", price=".GETPOST($pu)."*quantity";
|
||||
$sql .= ", remise_percent='".(!empty($dto)?$dto:0)."'";
|
||||
$sql .= " WHERE fk_soc=".$object->socid;
|
||||
$sql .= " AND fk_product=".GETPOST($prod, 'int');
|
||||
|
||||
$resql = $db->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user