Skip to content

Commit

Permalink
Update fournisseur.product.class.php (#28729)
Browse files Browse the repository at this point in the history
* Update fournisseur.product.class.php

#28710

* Update fournisseur.product.class.php

---------

Co-authored-by: Laurent Destailleur <[email protected]>
  • Loading branch information
le-reparateur and eldy authored Mar 9, 2024
1 parent e74e638 commit b601dab
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions htdocs/fourn/class/fournisseur.product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn
$fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code);
}

$buyprice = price2num($buyprice, 'MU');
$charges = price2num($charges, 'MU');
$qty = price2num($qty, 'MS');
$unitBuyPrice = price2num($buyprice / $qty, 'MU');
$buyprice = (float) price2num($buyprice, 'MU');
$charges = (float) price2num($charges, 'MU');
$qty = (float) price2num($qty, 'MS');
$unitBuyPrice = (float) price2num($buyprice / $qty, 'MU');

// We can have a puchase ref that need to buy 100 min for a given price and with a packaging of 50.
//$packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS');
Expand Down Expand Up @@ -359,10 +359,6 @@ public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn
$localtax2 = 0; // If = '' then = 0
}

// Check parameters
if ($buyprice != '' && !is_numeric($buyprice)) {
}

$this->db->begin();

if ($this->product_fourn_price_id > 0) {
Expand Down Expand Up @@ -391,6 +387,7 @@ public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn
}
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET fk_user = ".((int) $user->id)." ,";
$sql .= " datec = '".$this->db->idate($now)."' ,"; // Note: Even if this is an update, we update the creation date as the log of each change is tracked into product_fournisseur_log.
$sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',";
$sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',";
$sql .= " price = ".((float) $buyprice).",";
Expand Down

0 comments on commit b601dab

Please sign in to comment.