Merge pull request #23335 from Amael-PE/Amael-PE-FIX-23334
FIX #23334 Price equivalent for minimum price check
This commit is contained in:
commit
525f1e89e5
@ -1233,6 +1233,20 @@ 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 equivalent for minimum price check
|
||||
$pu_equivalent = $pu_ht;
|
||||
$pu_equivalent_ttc = $pu_ttc;
|
||||
$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;
|
||||
}
|
||||
if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') {
|
||||
$pu_equivalent_ttc = $pu_ttc_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);
|
||||
@ -1246,11 +1260,11 @@ if (empty($reshook)) {
|
||||
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
||||
|
||||
if ($usermustrespectpricemin) {
|
||||
if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
||||
if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $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');
|
||||
$error++;
|
||||
} elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
} elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
$error++;
|
||||
@ -1349,6 +1363,20 @@ if (empty($reshook)) {
|
||||
|
||||
$remise_percent = price2num(GETPOST('remise_percent'), '', 2);
|
||||
|
||||
// Prepare a price equivalent for minimum price check
|
||||
$pu_equivalent = $pu_ht;
|
||||
$pu_equivalent_ttc = $pu_ttc;
|
||||
$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;
|
||||
}
|
||||
if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') {
|
||||
$pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
|
||||
}
|
||||
|
||||
// Extrafields
|
||||
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
|
||||
@ -1388,12 +1416,12 @@ if (empty($reshook)) {
|
||||
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
||||
|
||||
if ($usermustrespectpricemin) {
|
||||
if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
||||
if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $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');
|
||||
$error++;
|
||||
$action = 'editline';
|
||||
} elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
} elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
$error++;
|
||||
|
||||
@ -682,7 +682,23 @@ if (empty($reshook)) {
|
||||
$tva_tx = '';
|
||||
}
|
||||
|
||||
|
||||
// Prepare a price equivalent for minimum price check
|
||||
$pu_equivalent = $pu_ht;
|
||||
$pu_equivalent_ttc = $pu_ttc;
|
||||
$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;
|
||||
}
|
||||
if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') {
|
||||
$pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
|
||||
}
|
||||
|
||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
|
||||
|
||||
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
|
||||
if (empty($remise_percent)) {
|
||||
$remise_percent = 0;
|
||||
@ -985,11 +1001,11 @@ if (empty($reshook)) {
|
||||
$desc = dol_htmlcleanlastbr($desc);
|
||||
|
||||
if ($usermustrespectpricemin) {
|
||||
if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
||||
if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $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');
|
||||
$error++;
|
||||
} elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
} elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
$error++;
|
||||
@ -1075,6 +1091,20 @@ if (empty($reshook)) {
|
||||
|
||||
$qty = price2num(GETPOST('qty', 'alpha'), 'MS');
|
||||
|
||||
// Prepare a price equivalent for minimum price check
|
||||
$pu_equivalent = $pu_ht;
|
||||
$pu_equivalent_ttc = $pu_ttc;
|
||||
$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;
|
||||
}
|
||||
if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') {
|
||||
$pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
|
||||
}
|
||||
|
||||
// Define info_bits
|
||||
$info_bits = 0;
|
||||
if (preg_match('/\*/', $vat_rate)) {
|
||||
@ -1128,12 +1158,12 @@ if (empty($reshook)) {
|
||||
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
|
||||
|
||||
if ($usermustrespectpricemin) {
|
||||
if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
||||
if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $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');
|
||||
$error++;
|
||||
$action = 'editline';
|
||||
} elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
} elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
$error++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user