From 7b295bf738dc295cfd774871f7fdb54ea5708c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 1 Dec 2019 14:56:39 +0100 Subject: [PATCH] addPurchasePrice Update the price if already exist --- htdocs/product/class/api_products.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 1bb5aed98f5..4ce7750fddd 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -633,7 +633,7 @@ class Products extends DolibarrApi } /** - * Add purchase prices for a product. + * Add/Update purchase prices for a product. * * @param int $id ID of Product * @param float $qty Min quantity for which price is valid @@ -681,7 +681,7 @@ class Products extends DolibarrApi } $result = $this->productsupplier->add_fournisseur(DolibarrApiAccess::$user, $fourn_id, $ref_fourn, $qty); - if ($result <= 0) { + if ($result < 0) { throw new RestException(500, "Error adding supplier to product : ".$this->db->lasterror()); }