Merge pull request #17702 from r3dge/13.0

bug fix : replacing orders by donations and setting required field to…
This commit is contained in:
Laurent Destailleur 2021-05-25 20:12:07 +02:00 committed by GitHub
commit 307c5cb276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -33,7 +33,7 @@ class Donations extends DolibarrApi
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid'
'amount'
);
/**
@ -193,7 +193,7 @@ class Donations extends DolibarrApi
}*/
if ($this->don->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->don->error), $this->don->errors));
throw new RestException(500, "Error creating donation", array_merge(array($this->don->error), $this->don->errors));
}
return $this->don->id;
@ -302,7 +302,7 @@ class Donations extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->don->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
$result = $this->don->valid_promesse($id, DolibarrApiAccess::$user->id, $notrigger);
if ($result == 0) {
throw new RestException(304, 'Error nothing done. May be object is already validated');
}
@ -355,7 +355,7 @@ class Donations extends DolibarrApi
private function _validate($data)
{
$don = array();
foreach (Orders::$FIELDS as $field) {
foreach (Donations::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, $field." field missing");
$don[$field] = $data[$field];

View File

@ -390,7 +390,7 @@ class Don extends CommonObject
$sql .= ", phone";
$sql .= ", phone_mobile";
$sql .= ") VALUES (";
$sql .= "'".$this->db->idate($now)."'";
$sql .= "'".$this->db->idate($this->date ? $this->date : $now)."'";
$sql .= ", ".$conf->entity;
$sql .= ", ".price2num($this->amount);
$sql .= ", ".($this->modepaymentid ? $this->modepaymentid : "null");