[CORE] FIX : la validation d'une demande de prix à "accéptée" ne créer plus d'entré si le prix ou la quantité est à 0.

FIX : la création d'une commande depuis une demande ne prend plus en compte les produits qui ont un prix ou quantité à 0. (#new_ask_price).
This commit is contained in:
phf 2015-02-06 10:17:10 +01:00
parent b31c77c754
commit 8ace3ee77b
2 changed files with 55 additions and 28 deletions

View File

@ -1485,7 +1485,7 @@ class AskPriceSupplier extends CommonObject
/**
* Close the commercial proposal
* Close the askprice
*
* @param User $user Object user that close
* @param int $statut Statut
@ -1587,6 +1587,9 @@ class AskPriceSupplier extends CommonObject
dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG);
foreach ($this->lines as $product) {
if ($product->subprice <= 0)
continue;
$idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty);
$res = $productsupplier->fetch($idProductFourn);
@ -2359,6 +2362,48 @@ class AskPriceSupplier extends CommonObject
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
function printOriginLinesList()
{
global $langs, $hookmanager;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('Description').'</td>';
print '<td align="right">'.$langs->trans('VAT').'</td>';
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
$num = count($this->lines);
$var = true;
$i = 0;
foreach ($this->lines as $line)
{
if (empty($line->subprice) || $line->qty <= 0)
continue;
$var=!$var;
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
{
if (empty($line->fk_parent_line))
{
$parameters=array('line'=>$line,'var'=>$var,'i'=>$i);
$action='';
$reshook=$hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
}
}
else
{
$this->printOriginLine($line,$var);
}
$i++;
}
}
}

View File

@ -854,15 +854,6 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid)) {
// Parse element/subelement (ex: project_task)
/* PHFAVRE
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs [1];
$subelement = $regs [2];
}
*/
$element = 'comm/askpricesupplier';
$subelement = 'askpricesupplier';
@ -914,24 +905,15 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
for($i = 0; $i < $num; $i ++)
{
if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0)
continue;
$label = (! empty($lines [$i]->label) ? $lines [$i]->label : '');
$desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle);
$product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0);
// Dates
// TODO mutualiser
$date_start = $lines [$i]->date_debut_prevue;
if ($lines [$i]->date_debut_reel)
$date_start = $lines [$i]->date_debut_reel;
if ($lines [$i]->date_start)
$date_start = $lines [$i]->date_start;
$date_end = $lines [$i]->date_fin_prevue;
if ($lines [$i]->date_fin_reel)
$date_end = $lines [$i]->date_fin_reel;
if ($lines [$i]->date_end)
$date_end = $lines [$i]->date_end;
// Reset fk_parent_line for no child products and special product
// Reset fk_parent_line for no child products and special product
if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) {
$fk_parent_line = 0;
}
@ -944,9 +926,9 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$array_option = $lines [$i]->array_options;
}
$idprod = $productsupplier->find_min_price_product_fournisseur($lines [$i]->fk_product, $qty);
$idprod = $productsupplier->find_min_price_product_fournisseur($lines [$i]->fk_product, $lines [$i]->qty);
$res = $productsupplier->fetch($idProductFourn);
$result = $object->addline(
$desc,
$lines [$i]->subprice,
@ -963,8 +945,8 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$lines [$i]->product_type,
'',
'',
$date_start,
$date_end
null,
null
);
if ($result < 0) {