Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong price on supplier order line #8224

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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