|
@@ -379,15 +379,15 @@ class SupplierInvoices extends DolibarrApi
|
|
|
throw new RestException(400, 'Invoice ID is mandatory');
|
|
|
}
|
|
|
|
|
|
- if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
|
|
|
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
|
|
- }
|
|
|
-
|
|
|
$result = $this->invoice->fetch($id);
|
|
|
if (!$result) {
|
|
|
throw new RestException(404, 'Invoice not found');
|
|
|
}
|
|
|
|
|
|
+ if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
|
|
|
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
|
|
+ }
|
|
|
+
|
|
|
$result = $this->invoice->getListOfPayments();
|
|
|
if ($result < 0) {
|
|
|
throw new RestException(405, $this->invoice->error);
|
|
@@ -428,6 +428,11 @@ class SupplierInvoices extends DolibarrApi
|
|
|
throw new RestException(400, 'Invoice ID is mandatory');
|
|
|
}
|
|
|
|
|
|
+ $result = $this->invoice->fetch($id);
|
|
|
+ if (!$result) {
|
|
|
+ throw new RestException(404, 'Invoice not found');
|
|
|
+ }
|
|
|
+
|
|
|
if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) {
|
|
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
|
|
}
|
|
@@ -442,12 +447,6 @@ class SupplierInvoices extends DolibarrApi
|
|
|
throw new RestException(400, 'Payment mode ID is mandatory');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- $result = $this->invoice->fetch($id);
|
|
|
- if (!$result) {
|
|
|
- throw new RestException(404, 'Invoice not found');
|
|
|
- }
|
|
|
-
|
|
|
// Calculate amount to pay
|
|
|
$totalpaid = $this->invoice->getSommePaiement();
|
|
|
$totaldeposits = $this->invoice->getSumDepositsUsed();
|