Merge pull request #10609 from frederic34/patch-17

Update api_invoices.class.php
This commit is contained in:
Laurent Destailleur 2019-02-15 15:11:33 +01:00 committed by GitHub
commit 3f01b590fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -392,7 +392,7 @@ class Invoices extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
$result = $this->facture->fetch($id); $result = $this->invoice->fetch($id);
if(!$result) { if(!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
@ -402,17 +402,17 @@ class Invoices extends DolibarrApi
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
} }
if(!DolibarrApi::_checkAccessToResource('invoice', $this->facture->id)) { if(!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->facture->add_contact($contactid, $type, 'external'); $result = $this->invoice->add_contact($contactid, $type, 'external');
if (!$result) { if (!$result) {
throw new RestException(500, 'Error when added the contact'); throw new RestException(500, 'Error when added the contact');
} }
return $this->facture; return $this->_cleanObjectDatas($this->invoice);
} }
/** /**
@ -434,23 +434,23 @@ class Invoices extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
$result = $this->facture->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if(!DolibarrApi::_checkAccessToResource('invoice', $this->facture->id)) { if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->facture->delete_contact($rowid); $result = $this->invoice->delete_contact($rowid);
if (!$result) { if (!$result) {
throw new RestException(500, 'Error when deleted the contact'); throw new RestException(500, 'Error when deleted the contact');
} }
return $this->facture; return $this->_cleanObjectDatas($this->invoice);
} }
/** /**