Skip to content
Snippets Groups Projects
Commit eb43bc49 authored by Gauthier's avatar Gauthier
Browse files

Correction when adding line with price as '0'

parent ed4f7fd0
Branches
Tags
No related merge requests found
......@@ -219,8 +219,9 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
$error++;
}
if (! GETPOST('addline_predefined') && (! GETPOST('pu') || GETPOST('pu')=='')) // Unit price can be 0 but not ''
if (! GETPOST('addline_predefined') && ( GETPOST('pu')==='')) // Unit price can be 0 but not ''
{
setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
$error++;
}
......@@ -239,7 +240,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
if (GETPOST('addline_predefined') || GETPOST('idprodfournprice')) // With combolist idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
if ((GETPOST('addline_predefined') || GETPOST('idprodfournprice')) && ( GETPOST('pu')!=='')) // With combolist idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
{
$idprod=0;
$productsupplier = new ProductFournisseur($db);
......@@ -299,7 +300,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
setEventMessage($langs->trans("ErrorQtyTooLowForThisSupplier"), 'errors');
}
}
else
else if( GETPOST('pu')!=='' || GETPOST('amountttc')!=='' )
{
$type=$_POST["type"];
$desc=$_POST['dp_desc'];
......@@ -326,7 +327,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$ttc = price2num($_POST['amountttc']);
$ht = $ttc / (1 + ($tauxtva / 100));
$price_base_type = 'HT';
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type);
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment