fix: allow list mass action update price when price mode is multiprice price

This commit is contained in:
Florian HENRY 2025-01-20 17:11:06 +01:00
parent 36b48a81ec
commit 02dea8d103
2 changed files with 33 additions and 14 deletions

View File

@ -1281,18 +1281,38 @@ if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoa
$result = $object->fetch($toselectid);
//var_dump($contcats);exit;
if ($result > 0) {
if ($obj->price_base_type == 'TTC') {
$newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
$minprice = $object->price_min_ttc;
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
for ($level = 1; $level <= getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); $level++) {
// Force the update of the price of the product using the new VAT
if ($object->price_base_type == 'TTC') {
$newprice = $object->multiprices_ttc[$level] * (100 + $pricepercentage) / 100;
$minprice = $object->multiprices_min_ttc[$level];
} else {
$newprice = $object->multiprices[$level] * (100 + $pricepercentage) / 100;
$minprice = $object->multiprices_min[$level];
}
$ret = $object->updatePrice($newprice, $object->price_base_type, $user, $object->tva_tx, $minprice, $level, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
if ($res > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} else {
$newprice = $object->price * (100 + $pricepercentage) / 100;
$minprice = $object->price_min;
}
$res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
if ($res > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
if ($object->price_base_type == 'TTC') {
$newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
$minprice = $object->price_min_ttc;
} else {
$newprice = $object->price * (100 + $pricepercentage) / 100;
$minprice = $object->price_min;
}
$res = $object->updatePrice($newprice, $object->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
if ($res > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} else {
setEventMessages($object->error, $object->errors, 'errors');

View File

@ -829,9 +829,8 @@ $arrayofmassactions = array(
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
if ($user->hasRight($rightskey, 'creer')) {
if (getDolGlobalString('PRODUCT_PRICE_UNIQ') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) {
$arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
}
$arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
$arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus");
$arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus");