Skip to content

Commit

Permalink
Merge branch 'master' into version-bump
Browse files Browse the repository at this point in the history
# Conflicts:
#	Mplusqapiclient.php
  • Loading branch information
freerk-mpluskassa committed Dec 4, 2020
2 parents b387cc6 + fbf5fe2 commit c00e3c0
Showing 1 changed file with 51 additions and 26 deletions.
77 changes: 51 additions & 26 deletions Mplusqapiclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3819,33 +3819,31 @@ public function verifyCredentials($request, $attempts=0)

//----------------------------------------------------------------------------

public function report($arguments, $attempts = 0) {
try {
if (!is_array($arguments) || !array_key_exists('method', $arguments) || empty($arguments['method'])) {
throw new Exception("No method defined for group call : " . __FUNCTION__);
}
$method = __FUNCTION__ . $arguments['method'];
unset($arguments['method']);
$parameters = $this->parser->convertReportRequest($method, $arguments);
$result = call_user_func(array($this->client, $method), $parameters);
if ($this->returnRawResult) {
return $result;
}
return $this->parser->parseReportResult($method, $result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->report($arguments, $attempts + 1);
} else {
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
}
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
}
public function report($arguments, $attempts = 0) {
try {
if (!is_array($arguments) || !array_key_exists('method', $arguments) || empty($arguments['method'])) {
throw new Exception("No method defined for group call : " . __FUNCTION__);
}
$method = __FUNCTION__ . $arguments['method'];
unset($arguments['method']);
$parameters = $this->parser->convertReportRequest($method, $arguments);
$result = call_user_func(array($this->client, $method), $parameters);
if ($this->returnRawResult) {
return $result;
}
return $this->parser->parseReportResult($method, $result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->report($arguments, $attempts + 1);
} else {
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
}
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
}
// END report()

}

//----------------------------------------------------------------------------

Expand Down Expand Up @@ -6900,6 +6898,14 @@ public function parseReportResult($method, $soapReportResult)
}
}
break;
case "reportAverageSpending":
$data = array();
if (isset($soapReportResult->averageSpendingList->averageSpending)) {
foreach ($soapReportResult->averageSpendingList->averageSpending as $soapAverageSpending) {
$data[] = $soapAverageSpending;
}
}
break;
}
return $data;
} // END parseReportResult()
Expand Down Expand Up @@ -9404,6 +9410,22 @@ public function convertReportRequest($method, $arguments) {
'branchNumbers', 'articleNumbers', 'perHour', 'turnoverGroups'
),
),
'reportBranchPerformance' => array(
'required' => array(
'fromFinancialDate', 'throughFinancialDate',
),
'optional' => array(
'branchNumbers'
),
),
'reportAverageSpending' => array(
'required' => array(
'fromFinancialDate', 'throughFinancialDate', 'source'
),
'optional' => array(
'branchNumbers', 'employeeNumbers'
),
),
);
$request = [];
if (array_key_exists($method, $fields)) {
Expand Down Expand Up @@ -9455,6 +9477,9 @@ public function convertReportRequest($method, $arguments) {
case "perHour":
$request['perHour'] = $arguments['perHour'] === true ? true : false;
break;
default:
$request[$callField] = $arguments[$callField];
break;
}
}
}
Expand Down

0 comments on commit c00e3c0

Please sign in to comment.