diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index b1d0ff392d6..9f73b1b9e65 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -278,8 +278,8 @@ class Categories extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->category->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when delete category'); + if ($this->category->delete(DolibarrApiAccess::$user) <= 0) { + throw new RestException(500, 'Error when delete category : ' . $this->category->error); } return array( diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a898d75e52c..ef1415fc17b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6127,6 +6127,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ if (dol_strlen($decpart) > $nbdecimal) { $nbdecimal = dol_strlen($decpart); } + // If nbdecimal is higher than max to show $nbdecimalmaxshown = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN')); if ($trunc && $nbdecimal > $nbdecimalmaxshown) { diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index c0e36e1a250..7e8e8e858d9 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -373,7 +373,7 @@ class Contacts extends DolibarrApi * Delete contact * * @param int $id Contact ID - * @return integer + * @return array[] */ public function delete($id) { @@ -389,7 +389,17 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contact->oldcopy = clone $this->contact; - return $this->contact->delete(DolibarrApiAccess::$user); + + if ($this->contact->delete(DolibarrApiAccess::$user) <= 0) { + throw new RestException(500, 'Error when delete contact ' . $this->contact->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact deleted' + ) + ); } /**