Skip to content

Commit

Permalink
Merge pull request #10609 from frederic34/patch-17
Browse files Browse the repository at this point in the history
Update api_invoices.class.php
  • Loading branch information
eldy committed Feb 15, 2019
2 parents edde376 + b892fc7 commit 3f01b59
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions htdocs/compta/facture/class/api_invoices.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function putLine($id, $lineid, $request_data = null)
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->invoice->updateline(
$updateRes = $this->invoice->updateline(
$lineid,
$request_data->desc,
$request_data->subprice,
Expand All @@ -362,7 +362,7 @@ function putLine($id, $lineid, $request_data = null)
$request_data->situation_percent,
$request_data->fk_unit,
$request_data->multicurrency_subprice
);
);

if ($updateRes > 0) {
$result = $this->get($id);
Expand Down Expand Up @@ -392,7 +392,7 @@ function postContact($id, $contactid, $type)
throw new RestException(401);
}

$result = $this->facture->fetch($id);
$result = $this->invoice->fetch($id);

if(!$result) {
throw new RestException(404, 'Invoice not found');
Expand All @@ -402,17 +402,17 @@ function postContact($id, $contactid, $type)
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);
}

$result = $this->facture->add_contact($contactid, $type, 'external');
$result = $this->invoice->add_contact($contactid, $type, 'external');

if (!$result) {
throw new RestException(500, 'Error when added the contact');
}

return $this->facture;
return $this->_cleanObjectDatas($this->invoice);
}

/**
Expand All @@ -434,23 +434,23 @@ function deleteContact($id, $rowid)
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');
}

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);
}

$result = $this->facture->delete_contact($rowid);
$result = $this->invoice->delete_contact($rowid);

if (!$result) {
throw new RestException(500, 'Error when deleted the contact');
}

return $this->facture;
return $this->_cleanObjectDatas($this->invoice);
}

/**
Expand Down

0 comments on commit 3f01b59

Please sign in to comment.