diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 95987ad40d1..d329b1692ef 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -179,7 +179,12 @@ class ProductFournisseur extends Product public $reputations = array(); // Multicurreny + + /** + * @var int ID of multicurrency + */ public $fourn_multicurrency_id; + public $fourn_multicurrency_code; public $fourn_multicurrency_tx; public $fourn_multicurrency_price; @@ -489,7 +494,7 @@ class ProductFournisseur extends Product $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; - $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? (int) $fk_multicurrency : 'null').","; $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; $sql .= " entity = ".$conf->entity.","; $sql .= " tva_tx = ".price2num($tva_tx).","; @@ -915,7 +920,7 @@ class ProductFournisseur extends Product $this->fourn_multicurrency_price = 0; $this->fourn_multicurrency_unitprice = 0; $this->fourn_multicurrency_tx = 0; - $this->fourn_multicurrency_id = ''; + $this->fourn_multicurrency_id = 0; $this->fourn_multicurrency_code = ''; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 744b73cb23e..6caa162c1b3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -579,8 +579,14 @@ if (empty($reshook)) { // Get vat rate $tva_npr = 0; if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tmpidprodfournprice = GETPOST('idprodfournprice', 'alpha'); // can be an id of price, or -1, -2, -99 or 'idprod_...' + if (is_numeric($tmpidprodfournprice) && (int) $tmpidprodfournprice > 0) { + $tmpidprodfournprice = (int) $tmpidprodfournprice; + } else { + $tmpidprodfournprice = 0; + } + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $tmpidprodfournprice); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, $tmpidprodfournprice); if (empty($tva_tx)) { $tva_npr = 0; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0f74a3d6acd..2c0ccb3a4f8 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1708,8 +1708,15 @@ if (empty($reshook)) { // Get vat rate if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tmpidprodfournprice = GETPOST('idprodfournprice', 'alpha'); // can be an id of price, or -1, -2, -99 or 'idprod_...' + if (is_numeric($tmpidprodfournprice) && (int) $tmpidprodfournprice > 0) {  + $tmpidprodfournprice = (int) $tmpidprodfournprice; + } else { + $tmpidprodfournprice = 0; + } + + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $tmpidprodfournprice); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, $tmpidprodfournprice); } if (empty($tva_tx) || empty($tva_npr)) { $tva_npr = 0; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 83ae86481f5..d3c6406672c 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -212,7 +212,8 @@ if ($action == 'order' && GETPOST('valid') && $user->hasRight('fournisseur', 'co $line->total_tva = $line->total_ht * $tva; $line->total_ttc = $line->total_ht + $line->total_tva; $line->remise_percent = (float) $productsupplier->remise_percent; - $line->ref_fourn = $productsupplier->ref_supplier; + $line->ref_fourn = $productsupplier->ref_supplier; // deprecated + $line->ref_supplier = $productsupplier->ref_supplier; $line->type = $productsupplier->type; $line->fk_unit = $productsupplier->fk_unit; @@ -275,7 +276,7 @@ if ($action == 'order' && GETPOST('valid') && $user->hasRight('fournisseur', 'co null, 0, $line->fk_unit, - $line->multicurrency_subprice ?? 0 + $line->multicurrency_subprice ); } if ($result < 0) {