mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Merge pull request #8224 from atm-ph/fix_6.0_supplier_order_from_supplier_proposal
Fix wrong price on supplier order line
This commit is contained in:
commit
e5df7e206b
|
|
@ -1401,7 +1401,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$pu=$pu_ttc;
|
||||
}
|
||||
$desc=trim($desc);
|
||||
$ref_supplier=''; // Ref of supplier price when we add line
|
||||
$ref_supplier=$fourn_ref; // Ref of supplier price when we add line
|
||||
|
||||
// Check parameters
|
||||
if ($qty < 1 && ! $fk_product)
|
||||
|
|
|
|||
|
|
@ -1044,8 +1044,6 @@ if (empty($reshook))
|
|||
$fk_parent_line = 0;
|
||||
$num = count($lines);
|
||||
|
||||
$productsupplier = new ProductFournisseur($db);
|
||||
|
||||
for($i = 0; $i < $num; $i ++)
|
||||
{
|
||||
|
||||
|
|
@ -1053,7 +1051,7 @@ if (empty($reshook))
|
|||
continue;
|
||||
|
||||
$label = (! empty($lines[$i]->label) ? $lines[$i]->label : '');
|
||||
$desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle);
|
||||
$desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc);
|
||||
$product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
|
||||
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
|
|
@ -1068,45 +1066,42 @@ if (empty($reshook))
|
|||
$lines[$i]->fetch_optionals($lines[$i]->rowid);
|
||||
$array_option = $lines[$i]->array_options;
|
||||
}
|
||||
|
||||
$tva_tx = $lines[$i]->tva_tx;
|
||||
|
||||
$result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid);
|
||||
if ($result>=0)
|
||||
if ($origin=="commande")
|
||||
{
|
||||
$tva_tx = $lines[$i]->tva_tx;
|
||||
|
||||
if ($origin=="commande")
|
||||
{
|
||||
$soc=new societe($db);
|
||||
$soc->fetch($socid);
|
||||
$tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id);
|
||||
}
|
||||
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product > 0 ? $lines[$i]->fk_product : 0,
|
||||
$productsupplier->product_fourn_price_id,
|
||||
$productsupplier->ref_supplier,
|
||||
$lines[$i]->remise_percent,
|
||||
'HT',
|
||||
0,
|
||||
$lines[$i]->product_type,
|
||||
'',
|
||||
'',
|
||||
null,
|
||||
null,
|
||||
array(),
|
||||
$lines[$i]->fk_unit,
|
||||
0,
|
||||
$element,
|
||||
!empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid
|
||||
);
|
||||
$soc=new societe($db);
|
||||
$soc->fetch($socid);
|
||||
$tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id);
|
||||
}
|
||||
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product > 0 ? $lines[$i]->fk_product : 0,
|
||||
0,
|
||||
$lines[$i]->ref_fourn,
|
||||
$lines[$i]->remise_percent,
|
||||
'HT',
|
||||
0,
|
||||
$lines[$i]->product_type,
|
||||
'',
|
||||
'',
|
||||
null,
|
||||
null,
|
||||
array(),
|
||||
$lines[$i]->fk_unit,
|
||||
0,
|
||||
$element,
|
||||
!empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid,
|
||||
$label
|
||||
);
|
||||
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user