mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-13 03:12:35 +01:00
Merge #34508
This commit is contained in:
@@ -592,6 +592,54 @@ class ExpenseReports extends DolibarrApi
|
||||
return $this->_cleanObjectDatas($this->expensereport);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Approve an expense report
|
||||
*
|
||||
* If you get a bad value for param notrigger check, provide this in body
|
||||
* {
|
||||
* "notrigger": 0
|
||||
* }
|
||||
*
|
||||
* @since 22.0.0 Initial implementation
|
||||
*
|
||||
* @param int $id Expense report ID
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
*
|
||||
* @url POST {id}/approve
|
||||
*
|
||||
* @return Object
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function approve($id, $notrigger = 0)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('expensereport', 'approve')) {
|
||||
throw new RestException(403, "Insuffisant rights");
|
||||
}
|
||||
$result = $this->expensereport->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Expense report not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) {
|
||||
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$result = $this->expensereport->setApproved(DolibarrApiAccess::$user, $notrigger);
|
||||
if ($result == 0) {
|
||||
throw new RestException(304, 'Error nothing done. May be object is already approved');
|
||||
}
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when approving expense report: '.$this->expensereport->error);
|
||||
}
|
||||
|
||||
$this->expensereport->fetchObjectLinked();
|
||||
|
||||
return $this->_cleanObjectDatas($this->expensereport);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deny an expense report
|
||||
*
|
||||
@@ -639,6 +687,7 @@ class ExpenseReports extends DolibarrApi
|
||||
return $this->_cleanObjectDatas($this->expensereport);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of payments of an expense report
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user