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
@ -1116,7 +1116,17 @@ 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_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
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
|
||||
@ -1125,8 +1135,9 @@ if (empty($reshook)) {
|
||||
if ($tva_npr) {
|
||||
$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));
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
} else {
|
||||
@ -1218,6 +1229,16 @@ if (empty($reshook)) {
|
||||
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
|
||||
|
||||
$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
|
||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||
@ -1250,7 +1271,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
$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');
|
||||
$error++;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user