FIX error for duplicate thirdparty found correctly returned by ws

This commit is contained in:
Laurent Destailleur 2021-03-26 01:37:19 +01:00
parent 965ee16270
commit 512a570b63
2 changed files with 9 additions and 7 deletions

View File

@ -329,7 +329,6 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
* @param array $authentication Array of authentication information
* @param int $idthirdparty Id thirdparty
* @return array Array result
*
*/
function getSupplierInvoicesForThirdParty($authentication, $idthirdparty)
{

View File

@ -298,14 +298,16 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
// Init and check authentication
$objectresp = array();
$errorcode = ''; $errorlabel = '';
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
{
$error++;
$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
$errorcode = 'BAD_PARAMETERS';
$errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
}
if (!$error)
@ -316,8 +318,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
{
$thirdparty = new Societe($db);
$result = $thirdparty->fetch($id, $ref, $ref_ext);
if ($result > 0)
{
if ($result > 0) {
$thirdparty_result_fields = array(
'id' => $thirdparty->id,
'ref' => $thirdparty->name,
@ -380,8 +381,10 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
$objectresp = array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'thirdparty'=>$thirdparty_result_fields);
}
else {
} elseif ($result == -2) {
$error++;
$errorcode = 'DUPLICATE_FOUND'; $errorlabel = 'Object found several times for id='.$id.' or ref='.$ref.' or ref_ext='.$ref_ext;
} else {
$error++;
$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
}