FIX #23334 Implement a price equivalent in propal
Implement a price equivalent when dealing with minimum prices and foreign currencies. Added in comm/propal/card.php as it was done in command/card.php for add and update.
This commit is contained in:
parent
07a1f8e651
commit
58d3cdb13c
@ -1117,6 +1117,16 @@ if (empty($reshook)) {
|
|||||||
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
|
||||||
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
|
||||||
|
|
||||||
|
// Prepare a price equivlanet for mimum price check
|
||||||
|
$pu_equivalent = $pu_ht;
|
||||||
|
$currency_tx = $object->multicurrency_tx;
|
||||||
|
|
||||||
|
// Check if we have a foreing currency
|
||||||
|
// If so, we update the pu_equiv as the equivalent price in base currency
|
||||||
|
if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') {
|
||||||
|
$pu_equivalent = $pu_ht_devise * $currency_tx;
|
||||||
|
}
|
||||||
|
|
||||||
// Local Taxes
|
// Local Taxes
|
||||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
|
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
|
||||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
|
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
|
||||||
@ -1126,7 +1136,8 @@ if (empty($reshook)) {
|
|||||||
$info_bits |= 0x01;
|
$info_bits |= 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
|
// Check minimum price
|
||||||
|
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_equivalent) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
|
||||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
|
||||||
setEventMessages($mesg, null, 'errors');
|
setEventMessages($mesg, null, 'errors');
|
||||||
} else {
|
} else {
|
||||||
@ -1219,6 +1230,16 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
$remise_percent = price2num(GETPOST('remise_percent'), '', 2);
|
$remise_percent = price2num(GETPOST('remise_percent'), '', 2);
|
||||||
|
|
||||||
|
// Prepare pu_equivament for checking the minimun price
|
||||||
|
$pu_equivalent = $pu_ht;
|
||||||
|
$currency_tx = $object->multicurrency_tx;
|
||||||
|
|
||||||
|
// Check if we have a foreing currency
|
||||||
|
// If so, we update the pu_equiv as the equivalent price in base currency
|
||||||
|
if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') {
|
||||||
|
$pu_equivalent = $pu_ht_devise * $currency_tx;
|
||||||
|
}
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||||
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
|
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
|
||||||
@ -1250,7 +1271,7 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
||||||
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) {
|
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_equivalent) * (1 - $remise_percent / 100) < price2num($price_min)))) {
|
||||||
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
|
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user