Introduction
Using these API functions, you will be able to request the receipts based on certain search criteria you set in the request.
Contents
Retrieving receipts
<?php
require_once('Mplusqapiclient.php');
$mplusqapiclient = new Mplusqapiclient();
// Initialize the client with your details.
// Then we create the request array that will contain the search criteria
$request = array(
// Search for receipts from August 1, 2014 up to and including August 31, 2014
'fromFinancialDate' => '2014-08-01',
'throughFinancialDate' => '2014-08-31',
// Only get receipts that are booked on branch 1
'branchNumbers' => array(1),
// We don't want to filter by employee, so we leave this empty
'employeeNumbers' => array(),
// We don't want to filter by customer, so we leave this empty
'relationNumbers' => array(),
// We only want receipts that contain an article with barcode '87123456789'
'articleBarcodes' => array('87123456789'),
// We don't care about the remaining article filters
'articleNumbers' => array(),
'articleTurnoverGroups' => array(),
'articlePluNumbers' => array(),
);
// Then we call the getReceipts() function wrapped in a try/catch block to intercept any exceptions.
try {
if (false !== ($receipts_result = $mplusqapiclient->getReceipts($request))) {
// Success, we show the number of found receipts
exit(sprintf('Found %d receipt(s).', count($receipts_result)));
} else {
exit('Invalid result after running getReceipts.');
}
} catch (MplusQAPIException $e) {
exit($e->getMessage());
}