# Reports

The Tyro terminal provides a reconciliation report feature: a shorter **summary** report, or a
more comprehensive **detail** report, for either the current or previous settlement period.
Integrated reports let the POS request this report data on demand rather than relying on the
terminal's own printer — useful for terminals without a printer attached (consider a PDF printer
for saving reports), or POS systems that don't expose Windows printers directly (e.g. those using
OPOS).

Requesting reports through the POS also gives access to up to **7 days** of reconciliation data,
rather than just the current and previous day available directly from the terminal.

- Reports can be requested at any time of day, and multiple times per day.
- Reports can only be requested for dates within the last 7 days.


JS library
Before you begin, check the certification criteria:
[Certification Criteria Document](/assets/certification_criteria_iclient_retail_hospitality.7bf0b2b5462961db882fcba1f1e9ddbec0d942cc7ee96278907994599bebf62a.d564e73d.pdf).

### Making the request

| Function definition | Purpose | Parameters |
|  --- | --- | --- |
| `reconciliationReport(requestParams, responseReceivedCallback)` | Initiates a reconciliation report request on the terminal. | `requestParams` (Object); `responseReceivedCallback` — Function (a callback function to provide report data or the relevant error message) |


| Parameter | Type | Description | Required |
|  --- | --- | --- | --- |
| `terminalBusinessDay` | String | The reporting date in format `yyyyMMdd`. | Required |
| `type` | String | The report type. Valid values are `summary` and `detail`. | Required |
| `format` | String | The report format. Valid values are `txt` and `xml`. The text version is pre-formatted in a mono-spaced font. | Required |
| `mid` | Integer | Override the configured mid for multi-merchant terminals, or if your browser does not support local storage, or if you have developed headless pairing as a feature. | Optional — required for headless pairing, multi-merchant, or if your browser does not support local storage |
| `tid` | Integer | Override the configured tid for multi-merchant terminals or if your browser does not support local storage or if you have implemented headless pairing as a feature. | Optional — required for headless pairing, multi-merchant, or if your browser does not support local storage |
| `integrationKey` | String | Supply the integration key if your browser does not support local storage or if you have developed headless pairing or multi-merchant as a feature. | Optional — required for headless pairing, multi-merchant, or if your browser does not support local storage |



```javascript
function doReport(reportDate, reportType, reportFormat) {

  iclient.reconciliationReport({
    terminalBusinessDay: reportDate,
    type: reportType,
    format: reportFormat
  }, reportCallback);
}

var reportCallback = function(response) {
  console.log(JSON.stringify(response));
  $("#result").html(response.result);
  $("#data").html("<pre>" + escapeHtml(response.data) + "</pre>");
  $("#error").html(response.error);
};
```

[JS Fiddle demo](https://jsfiddle.net/IntegrationSupport/xaw5n78m/9/)

Don't click **Save** if you make changes in the JS Fiddle — click **Run** instead. Clicking Save
may break the fiddle's functionality.

### Handling the response

| Function | Description | Usage required |
|  --- | --- | --- |
| `responseReceivedCallback` | Invoked when the request has been completed on the terminal. Called with a single object containing the following fields, as shown in the below table. | Required |


| Field | Type | Description | Usage required |
|  --- | --- | --- | --- |
| `result` | String | The result of the report request, will be either `success` or `failure`. | Required |
| `format` | String | The format requested is passed back for convenience, will be either `summary` or `detailed`. | Optional |
| `type` | String | The type requested is passed back for convenience, will be either `txt` or `xml`. | Optional |
| `data` | String | The report. Pre-formatted text when format is `txt`. Parsable XML when format is `xml`. | Required |
| `error` | String | An error message to show the merchant. Only present when result is `failure`. | Required |


#### Steps to follow

1. The report requested by the POS using `reconciliationReport()` is returned using
`responseReceivedCallback` — the POS must provide the function required to handle the callback
response.
2. The `data` field contains the unparsed text or XML version of the report (as per the request);
for reference, the format and type for the requested report are also passed back in the
`format` and `type` fields.
3. The POS must then parse the report data: for a text format report, remove the labels; for an
XML format report, parse the XML to obtain the data for the transactions performed on a given
day.


If the request is unsuccessful, the POS will be provided the result and the error message in the
`result` and `error` fields — display them on the screen for the user's reference.


```javascript
var reportCallback = function(response) {
  console.log(JSON.stringify(response));
  var report=response.data;
  
  //Parsing the Text version of the report to remove the labels//
  if (($("input[name='format']:checked").val())=="txt"){
  report = report.replace(/NEW_LINE/g," ");
  report = report.replace(/MEDIUM_CENTRED:/g," ");
  report = report.replace(/MEDIUM:/g," ");
  report = report.replace(/MEDIUM_RIGHT:/g," ");
  report = report.replace(/MEDIUM_BOLD:/g," ");
  report = report.replace(/LARGE_CENTRED:/g," ");
  report = report.replace(/FORM_FEED/g," ");
  report = report.replace(/SMALL:/g," ");	
  report = report.replace(/SMALL:/g," ");
  }
     

    console.log(report);

  $("#result").html(response.result);
  $("#data").html("<pre>" + escapeHtml(report) + "</pre>");
  $("#error").html(response.error);
};
```

##### Example response

Below is an XML response example for the report request.


```json
{"result":"success",
"format":"xml",
"type":"summary",
"data":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
<reconciliation-summary mid=\"200\" tid=\"200\" terminal-business-day=\"2024-01-17\" total=\"1620.00\">\n
<card type=\"visa\" purchases=\"280.00\" refunds=\"-70.00\" total=\"210.00\"/>\n
<card type=\"mastercard\" purchases=\"200.00\" refunds=\"-80.00\" total=\"120.00\"/>\n
<card type=\"eftpos\" purchases=\"1100.00\" cash-out=\"50.00\" refunds=\"0.00\" total=\"1150.00\"/>\n
<card type=\"amex\" purchases=\"30.00\" refunds=\"0.00\" total=\"30.00\"/>\n
<card type=\"diners\" purchases=\"70.00\" refunds=\"0.00\" total=\"70.00\"/>\n
<card type=\"jcb\" purchases=\"40.00\" refunds=\"0.00\" total=\"40.00\"/>\n
</reconciliation-summary>\n"
}
```

.NET library
Terminal reports are accessed through the TTA via the .NET interface
`Tyro.Integ.ITerminalAdapterReports`. At the conclusion of the execution of the methods, control is
returned to the caller and an object containing the result of the operation is given.

Not all of Tyro's terminals have an integrated printer attached — for merchants whose terminals
lack one, consider a PDF printer so reports can be saved in PDF format. Not all POS systems make
their printers available as Windows printers either (many use OPOS for printing); the additional
API calls below are available through the TTA for these systems.

### Transaction reports

| Method | Description |
|  --- | --- |
| `IReport TransactionSummaryReport(string date)` | HTTPS GET request for a transaction summary report for the date specified (format `yyyyMMdd`), using the default MID and TID configured in the TTA configuration panel. |
| `IReport TransactionDetailedReport(string date)` | Same, for a transaction detailed report. |
| `IReport TransactionSummaryReportMidTid(string mid, string tid, string date)` | Transaction summary report for the MID, TID and date specified. |
| `IReport TransactionDetailedReportMidTid(string mid, string tid, string date)` | Transaction detailed report for the MID, TID and date specified. |


#### `IReport` return value

| Method | Description |
|  --- | --- |
| `ErrorOccurred()` | Returns `true` if a configuration or network error occurred — call `GetError()` to determine the cause. `false` indicates the call executed successfully. |
| `GetText()` | The text associated with the report — plain text, in the format detailed below. |
| `GetError()` | An `Error` object with `HttpStatusCode`, `ErrorMessage`, and other useful information. |
| `GetMid()` | The mid associated with the report. |
| `GetTid()` | The tid associated with the report. |
| `GetyyyyMMdd()` | The date associated with the report. |


#### Response error codes

Accessed via `IReport.GetError().GetHttpStatusCode()`:

| HTTP Code | HTTP Name | When |
|  --- | --- | --- |
| 200 | OK | Request succeeds |
| 202 | Accepted | System not ready to receive requests |
| 400 | Bad Request | Request does not conform to requirements |
| 403 | Authentication Failed | Submitted key does not match Terminal's key |
| 404 | Not Found | Terminal is not connected to Tyro |
| 500 | Server Error | Error in Tyro system - Please report these to Tyro |
| 501 | Not Implemented | The operation is not available |
| 504 | Gateway Timeout | Request timed out before response could be generated |


#### Report format

The format of the report content is one where each line of the report is in the format
`style: text`. The maximum length of any line is 27 characters, and the style of each line can
include various combinations of text alignment, font size and font weight.

| Name | Alignment | Font size | Font weight |
|  --- | --- | --- | --- |
| `LARGE` | Left | Large | Normal |
| `LARGE_CENTRED` | Centre | Large | Normal |
| `LARGE_RIGHT` | Right | Large | Normal |
| `LARGE_BOLD` | Left | Large | Bold |
| `MEDIUM` | Left | Medium | Normal |
| `MEDIUM_CENTRED` | Centre | Medium | Normal |
| `MEDIUM_RIGHT` | Right | Medium | Normal |
| `MEDIUM_BOLD` | Left | Medium | Bold |
| `SMALL` | Left | Small | Normal |
| `SMALL_CENTRED` | Centre | Small | Normal |
| `SMALL_RIGHT` | Right | Small | Normal |
| `SMALL_BOLD` | Left | Small | Bold |
| `TINY` | Left | Tiny | Normal |
| `TINY_CENTRED` | Centre | Tiny | Normal |
| `TINY_RIGHT` | Right | Tiny | Normal |
| `TINY_BOLD` | Left | Tiny | Bold |
| `NEW_LINE` | — | — | Write out a blank line |
| `FORM_FEED` | — | — | Feed enough paper through to allow a clean tear off |


Many of the styles listed above are not currently in use but are reserved for future use. For
centring, left pad the text with a number of spaces equal to `(27 - length of text) / 2`.

##### Summary report example response


```console
MEDIUM_CENTRED: Merchant Name Here
MEDIUM_CENTRED: 125 York Street
MEDIUM_CENTRED: Sydney NSW 2000
NEW_LINE
LARGE_CENTRED: SUMMARY REPORT
NEW_LINE
MEDIUM_CENTRED: Tyro EFTPOS
NEW_LINE
MEDIUM: Merchant ID: 123
MEDIUM: Terminal ID: 3
NEW_LINE
MEDIUM: Printed: 23/07/12 10:26
NEW_LINE
MEDIUM: Card type: All cards
NEW_LINE
MEDIUM_BOLD: Date: 17/07/12
NEW_LINE
MEDIUM: Purchase 30 $1,139.88
MEDIUM: Cash out (0) $0.00
MEDIUM: Tip (0) $0.00
MEDIUM: Refund 1 -$39.95
MEDIUM: Void 0 $0.00
MEDIUM_RIGHT: ------------
MEDIUM: NET TOTAL 31 $1,099.93
NEW_LINE
MEDIUM: EFTPOS 16 $469.93
MEDIUM: Visa 5 $194.70
MEDIUM: MasterCard 4 $259.90
MEDIUM_RIGHT: ------------
MEDIUM: TYRO TOTAL 25 $924.53
NEW_LINE
MEDIUM: AMEX 6 $175.40
MEDIUM: JCB 0 $0.00
MEDIUM: Diners 0 $0.00
MEDIUM_RIGHT: ------------
MEDIUM: NET TOTAL 31 $1,099.93
NEW_LINE
FORM_FEED
```

##### Detailed report example response


```console
MEDIUM_CENTRED: Merchant Name Here
MEDIUM_CENTRED: 127 York Street
MEDIUM_CENTRED: Sydney NSW 2000
NEW_LINE
LARGE_CENTRED: DETAIL REPORT
NEW_LINE
MEDIUM_CENTRED: Tyro EFTPOS
NEW_LINE
MEDIUM: Merchant ID: 123
MEDIUM: Terminal ID: 3
NEW_LINE
MEDIUM: Printed: 23/07/12 10:31
NEW_LINE
MEDIUM: Card type: All cards
NEW_LINE
MEDIUM_BOLD: Date: 17/07/12
NEW_LINE
MEDIUM: 08:39 Amex 6082 (s)
MEDIUM: Purchase $19.90
NEW_LINE
MEDIUM: 08:58 EFTPOS 9815 (s)
MEDIUM: Purchase $39.95
NEW_LINE
MEDIUM: 09:27 EFTPOS 0836 (c)
MEDIUM: Purchase $106.80
NEW_LINE
MEDIUM: 09:32 MasterCard 2785 (c)
MEDIUM: Purchase $24.95
NEW_LINE
MEDIUM: 09:48 EFTPOS 7926 (c)
MEDIUM: Purchase $9.90
NEW_LINE
MEDIUM: 11:36 MasterCard 6818 (c)
MEDIUM: Purchase $110.10
NEW_LINE
MEDIUM: 11:47 Amex 1003 (s)
MEDIUM: Refund -$39.95
NEW_LINE
MEDIUM: 12:04 EFTPOS 1759 (c)
MEDIUM: Purchase $44.00
NEW_LINE
MEDIUM: 12:18 EFTPOS 5161 (c)
MEDIUM: Purchase $43.40
NEW_LINE
MEDIUM: 12:21 MasterCard 7826 (c)
MEDIUM: Purchase $69.95
NEW_LINE
MEDIUM: 12:58 MasterCard 9977 (c)
MEDIUM: Purchase $54.90
NEW_LINE
MEDIUM: 13:06 EFTPOS 1090 (c)
MEDIUM: Purchase $6.95
NEW_LINE
MEDIUM: 13:12 Visa 3527 (c)
MEDIUM: Purchase $27.00
NEW_LINE
MEDIUM: 13:14 EFTPOS 4795 (s)
MEDIUM: Purchase $25.90
NEW_LINE
MEDIUM: 13:22 EFTPOS 4709 (s)
MEDIUM: Purchase $10.08
NEW_LINE
MEDIUM: 13:33 Amex 4264 (s)
MEDIUM: Purchase $69.95
NEW_LINE
MEDIUM: 13:45 Visa 0930 (s)
MEDIUM: Purchase $29.95
NEW_LINE
MEDIUM: 14:04 Amex 8661 (s)
MEDIUM: Purchase $11.95
NEW_LINE
MEDIUM: 14:15 Visa 2066 (c)
MEDIUM: Purchase $32.30
NEW_LINE
MEDIUM: 14:16 Amex 3005 (s)
MEDIUM: Purchase $53.60
NEW_LINE
MEDIUM: 14:49 EFTPOS 4739 (s)
MEDIUM: Purchase $21.95
NEW_LINE
MEDIUM: 15:06 EFTPOS 4709 (c)
MEDIUM: Purchase $8.95
NEW_LINE
MEDIUM: 15:08 Visa 2369 (c)
MEDIUM: Purchase $46.85
NEW_LINE
MEDIUM: 15:30 EFTPOS 9475 (s)
MEDIUM: Purchase $19.75
NEW_LINE
MEDIUM: 15:36 Amex 0043 (s)
MEDIUM: Purchase $59.95
NEW_LINE
MEDIUM: 16:02 EFTPOS 2923 (s)
MEDIUM: Purchase $24.95
NEW_LINE
MEDIUM: 16:40 EFTPOS 2410 (c)
MEDIUM: Purchase $21.95
NEW_LINE
MEDIUM: 16:44 Visa 3895 (c)
MEDIUM: Purchase $58.60
NEW_LINE
MEDIUM: 16:49 EFTPOS 3750 (s)
MEDIUM: Purchase $12.95
NEW_LINE
MEDIUM: 16:50 EFTPOS 3750 (s)
MEDIUM: Purchase $22.90
NEW_LINE
MEDIUM: 17:34 EFTPOS 8617 (c)
MEDIUM: Purchase $49.55
NEW_LINE
SMALL: s: swiped, c: chip, m: manual
SMALL: e: express payment
NEW_LINE
LARGE_CENTRED: SUMMARY REPORT
MEDIUM: Purchase 30 $1,139.88
MEDIUM: Cash out (0) $0.00
MEDIUM: Tip (0) $0.00
MEDIUM: Refund 1 -$39.95
MEDIUM: Void 0 $0.00
MEDIUM_RIGHT: ------------
MEDIUM: NET TOTAL 31 $1,099.93
NEW_LINE
MEDIUM: EFTPOS 16 $469.93
MEDIUM: Visa 5 $194.70
MEDIUM: MasterCard 4 $259.90
MEDIUM_RIGHT: ------------
MEDIUM: TYRO TOTAL 25 $924.53
NEW_LINE
MEDIUM: AMEX 6 $175.40
MEDIUM: JCB 0 $0.00
MEDIUM: Diners 0 $0.00
MEDIUM_RIGHT: ------------
MEDIUM: NET TOTAL 31 $1,099.93
NEW_LINE
FORM_FEED
```

### Reconciliation reports

The same `ITerminalAdapterReports` interface also exposes a second set of methods, returning
reports in XML rather than the styled plain text above. These reports are intended for POS-side
reconciliation: download the summary report first and compare totals; if they don't match,
download the detailed report to verify each transaction, then generate an "overs and unders"
report and notify the POS operator about the transactions that don't reconcile.

| Method | Description |
|  --- | --- |
| `IReport ReconciliationReportSummary(string date)` | HTTPS GET request for a summary reconciliation report for the date specified (format `yyyyMMdd`), using the default MID and TID configured in the TTA configuration panel. |
| `IReport ReconciliationReportDetailed(string date)` | Same, for a detailed reconciliation report. |
| `IReport ReconciliationReportSummaryMidTid(string mid, string tid, string date)` | Summary reconciliation report for the MID, TID and date specified. |
| `IReport ReconciliationReportDetailedMidTid(string mid, string tid, string date)` | Detailed reconciliation report for the MID, TID and date specified. |


Returns the same `IReport` interface as above — `GetText()` here returns an XML document instead
of plain text.

#### Summary report XML schema

| Response parameter | Description |
|  --- | --- |
| `reconciliation-summary/@mid` | The mid (Merchant ID) for this report |
| `reconciliation-summary/@tid` | The tid (Terminal ID) for this report |
| `reconciliation-summary/@terminal-business-day` | The terminal business day for this report (format `yyyy-MM-dd`) |
| `reconciliation-summary/@total` | The total amount of all the transactions for the business day |
| `reconciliation-summary/card` | The list of card schemes reported on (currently 6 — Visa, MasterCard, EFTPOS, Amex, Diners, JCB). Within each `card` element: `@type` (visa/mastercard/eftpos/amex/diners/jcb), `@purchases` (total purchases), `@cash-out` (total cash out), `@refunds` (total refunds, shown as a negative amount), `@total` (net total for the card scheme) |


#### Detail report XML schema

| Response parameter | Description |
|  --- | --- |
| `reconciliation-detail/@mid` | The mid (Merchant ID) for this report |
| `reconciliation-detail/@tid` | The tid (Terminal ID) for this report |
| `reconciliation-detail/@terminal-business-day` | The terminal business day for this report (format `yyyy-MM-dd`) |
| `reconciliation-detail/@total` | The total amount of all the transactions for the business day |
| `reconciliation-detail/transaction` | The list of transactions processed by that terminal on that business day. Within each `transaction` element: `@type` (purchase/refund/void), `@card-type` (visa/mastercard/eftpos/amex/diners/jcb), `@amount` (transaction amount, not including tip or cash out), `@cash-out` (cash-out amount), `@tip` (tip amount), `@transaction-local-date-time` (format `yyyy-MM-dd HH:mm:ss`), `@tyro-reference` (a Tyro reference, unique when combined with MID, TID, and business day), `@merchant-reference` (the integrated transaction ID, if passed in at initiation), `@settlement-date` (not known for Amex, Diners, or JCB) |


The XML used in the reports does not come with a DTD or XML Schema. We reserve the right to add
elements or attributes in the future if we need to. We will not, however, remove elements or
attributes. Our suggestion is that developers use XPath for retrieving data from the XML
responses.

##### Summary report example response


```console
<?xml version="1.0" encoding="UTF-8"?>
<reconciliation-summary mid="200" tid="200" terminal-business-day="2011-
09-14" total="1620.00"> 
 <card type="visa" purchases="280.00" refunds="-70.00" total="210.00"
/> 
 <card type="mastercard" purchases="200.00" refunds="-80.00" total="
120.00"/> 
 <card type="eftpos" purchases="1100.00" cash-out="50.00" refunds="
0.00" total="1150.00"/> 
 <card type="amex" purchases="30.00" refunds="0.00" total="30.00"/> 
 <card type="diners" purchases="70.00" refunds="0.00" total="70.00"/> 
 <card type="jcb" purchases="40.00" refunds="0.00" total="40.00"/> 
</reconciliation-summary>
```

##### Detail report example response


```console
<?xml version="1.0" encoding="UTF-8"?>
<reconciliation-detail mid="200" tid="200" terminal-business-day="2011-
09-14" total="1620.00"> 
<transaction type="purchase" card-type="visa" amount="100.00" tip="
10.00" transaction-local-date-time="2011-09-14 12:30:30" tyro-reference="870020" merchant-reference="071061048231306351219677" 
settlement-date="2011-09-16"/> 
 <transaction type="purchase" card-type="mastercard" amount="200.00" 
transaction-local-date-time="2011-09-14 12:31:20" tyro-reference="
885214" merchant-reference="071061048231306351219678" settlement-date="
2011-09-16"/> 
 <transaction type="purchase" card-type="jcb" amount="40.00" 
transaction-local-date-time="2011-09-14 12:33:23" tyro-reference="
896534" merchant-reference="071061048231306351219679"/> 
 <transaction type="purchase" card-type="amex" amount="30.00" 
transaction-local-date-time="2011-09-14 12:36:35" tyro-reference="
905845" merchant-reference="071061048231306351219680"/> 
 <transaction type="purchase" card-type="eftpos" amount="650.00" cash-out="50.00" transaction-local-date-time="2011-09-14 12:40:30" tyro-reference="912556" merchant-reference="071061048231306351219681" 
settlement-date="2011-09-16"/> 
 <transaction type="purchase" card-type="eftpos" amount="450.00" 
transaction-local-date-time="2011-09-14 12:50:30" tyro-reference="
920187" merchant-reference="071061048231306351219682" settlement-date="
2011-09-16"/> 
 <transaction type="purchase" card-type="diners" amount="70.00" 
transaction-local-date-time="2011-09-14 13:30:30" tyro-reference="
935587" merchant-reference="071061048231306351219683"/> 
 <transaction type="void" card-type="mastercard" amount="-80.00" 
transaction-local-date-time="2011-09-14 13:50:30" tyro-reference="
946585" merchant-reference="071061048231306351219684" settlement-date="
2011-09-16"/> 
 <transaction type="purchase" card-type="visa" amount="170.00" 
transaction-local-date-time="2011-09-14 14:23:25" tyro-reference="
953594" merchant-reference="071061048231306351219685" settlement-date="
2011-09-16"/> 
 <transaction type="refund" card-type="visa" amount="-70.00" 
transaction-local-date-time="2011-09-14 15:41:12" tyro-reference="
962548" merchant-reference="071061048231306351219685" settlement-date="
2011-09-16"/> 
</reconciliation-detail>
```

##### Empty summary report example response


```console
<?xml version="1.0" encoding="UTF-8"?>
<reconciliation-summary mid="200" tid="200" terminal-business-day="2011-
05-28" total="0.00">
 <card type="visa" purchases="0.00" refunds="0.00" total="0.00"/>
 <card type="mastercard" purchases="0.00" refunds="0.00" total="0.00"
/>
 <card type="eftpos" purchases="0.00" cash-out="0.00" refunds="0.00"
 total="0.00"/>
 <card type="amex" purchases="0.00" refunds="0.00" total="0.00"/>
 <card type="diners" purchases="0.00" refunds="0.00" total="0.00"/>
 <card type="jcb" purchases="0.00" refunds="0.00" total="0.00"/>
</reconciliation-summary>
```

##### Empty detail report example response


```console
<?xml version="1.0" encoding="UTF-8"?>
<reconciliation-detail mid="200" tid="200" terminal-business-day="2011-
05-28" total="0.00"></reconciliation-detail>
```