Skip to content

Commit

Permalink
Merge pull request #8224 from atm-ph/fix_6.0_supplier_order_from_supp…
Browse files Browse the repository at this point in the history
…lier_proposal

Fix wrong price on supplier order line
  • Loading branch information
eldy committed Apr 27, 2018
2 parents e1585ef + d179caf commit e5df7e2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 39 deletions.
2 changes: 1 addition & 1 deletion htdocs/fourn/class/fournisseur.commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocalt
$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)
Expand Down
71 changes: 33 additions & 38 deletions htdocs/fourn/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1044,16 +1044,14 @@
$fk_parent_line = 0;
$num = count($lines);

$productsupplier = new ProductFournisseur($db);

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);
$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
Expand All @@ -1068,45 +1066,42 @@
$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;
Expand Down

0 comments on commit e5df7e2

Please sign in to comment.