Merge pull request #14741 from Tim-Otte/fix-zero-price-lines

FIX: Allow product price equal zero in new lines
This commit is contained in:
Laurent Destailleur 2020-09-27 20:46:36 +02:00 committed by GitHub
commit f851ce2f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -825,7 +825,7 @@ if (empty($reshook))
$error++; $error++;
} }
if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht === '' && $price_ht_devise === '') // Unit price can be 0 but not ''. Also price can be negative for proposal.
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++; $error++;
@ -966,7 +966,7 @@ if (empty($reshook))
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
if (!empty($price_ht)) { if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} // On reevalue prix selon taux tva car taux tva transaction peut etre different } // On reevalue prix selon taux tva car taux tva transaction peut etre different

View File

@ -820,7 +820,7 @@ if (empty($reshook))
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
if (!empty($price_ht)) { if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} }

View File

@ -2012,7 +2012,7 @@ if (empty($reshook))
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
if (!empty($price_ht)) if (!empty($price_ht) || $price_ht === '0')
{ {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');