# Get voucher details

`GET /public/api/v1/Outlets/{outletId}/OrderVoucherBases/{voucherBasisId}/Voucher`

Voucher API · VoucherBases · base URL `https://voucher-api.ancon.io` · auth: `Access-Token` header · docs: https://ancon.dev/api/voucher/voucher-bases/get-voucher-details

Builds the accounting voucher for a published voucher basis. Responds **400** with error code `aad1dadd-f6c5-401c-9ae1-cdf0788dc952` (MissingAccountNumbers) when the outlet has no account number configured for a way of payment, product group, tax rate or fee on the voucher basis. The `message` lists what is missing and `additionalData` holds the same names per category (`paymentMethods`, `productGroups`, `taxes`, `fees`). The request keeps failing until the accounts are configured in Backoffice; retrying without a configuration change does not help.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `outletId` | string (uuid) | yes |  |
| `voucherBasisId` | string (uuid) | yes |  |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `PartType` | integer (int32) | no | Allowed values: `0`, `1`, `2`. |

## Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `correlationId` | string | no | Correlation Id for the request |

## Responses

| Status | Description |
| --- | --- |
| 200 | OK |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |

### 200 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `voucher` | object or null | no |  |
| `voucher.title` | string or null | no |  |
| `voucher.voucherNo` | string or null | no |  |
| `voucher.tracking` | object or null | no |  |
| `voucher.tracking.costCenter` | string or null | no |  |
| `voucher.tracking.project` | string or null | no |  |
| `voucher.custom1` | string or null | no |  |
| `voucher.custom2` | string or null | no |  |
| `voucher.custom3` | string or null | no |  |
| `voucher.custom4` | string or null | no |  |
| `voucher.currencyCode` | string or null | no |  |
| `voucher.items` | array<object> or null | no |  |
| `voucher.items[].accountNumber` | string or null | no |  |
| `voucher.items[].debit` | number (double) | no |  |
| `voucher.items[].credit` | number (double) | no |  |
| `voucher.items[].name` | string or null | no |  |
| `voucher.items[].tracking` | object or null | no |  |
| `voucher.items[].tracking.costCenter` | string or null | no |  |
| `voucher.items[].tracking.project` | string or null | no |  |
| `voucher.items[].custom1` | string or null | no |  |
| `voucher.items[].custom2` | string or null | no |  |
| `voucher.items[].custom3` | string or null | no |  |
| `voucher.items[].custom4` | string or null | no |  |
| `voucher.items[].custom5` | string or null | no |  |

#### Example

```json
{
  "voucher": {
    "title": "Z-Dagrapport 53",
    "voucherNo": "53",
    "tracking": null,
    "custom1": null,
    "custom2": null,
    "custom3": null,
    "custom4": null,
    "currencyCode": "SEK",
    "items": [
      {
        "accountNumber": "1930",
        "debit": 1000,
        "credit": 0,
        "name": "Cash",
        "tracking": {
          "costCenter": "C12",
          "project": "P44"
        },
        "custom1": null,
        "custom2": null,
        "custom3": null,
        "custom4": null,
        "custom5": null
      },
      {
        "accountNumber": "3665",
        "debit": 0,
        "credit": 700,
        "name": "Food",
        "tracking": null,
        "custom1": null,
        "custom2": null,
        "custom3": null,
        "custom4": null,
        "custom5": null
      },
      {
        "accountNumber": "3640",
        "debit": 0,
        "credit": 300,
        "name": "Drinks",
        "tracking": null,
        "custom1": null,
        "custom2": null,
        "custom3": null,
        "custom4": null,
        "custom5": null
      }
    ]
  }
}
```

### 400 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string or null | no |  |
| `errorCode` | string (uuid) | no |  |
| `additionalData` | any or null | no |  |

#### Example

```json
{
  "message": "Cannot create voucher.\nMissing account number for way of payments:\nInvoice\nMissing account number for product groups:\nSnus, Food (TakeAway)\nMissing account number for taxes:\n20\n",
  "errorCode": "aad1dadd-f6c5-401c-9ae1-cdf0788dc952",
  "additionalData": {
    "paymentMethods": [
      "Invoice"
    ],
    "productGroups": [
      "Snus",
      "Food (TakeAway)"
    ],
    "taxes": [
      "20"
    ],
    "fees": []
  }
}
```

### 404 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string or null | no |  |
| `errorCode` | string (uuid) | no |  |

#### Example (from schema)

```json
{
  "message": "string",
  "errorCode": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
```

## Example request

```bash
curl -X GET "https://voucher-api.ancon.io/public/api/v1/Outlets/{outletId}/OrderVoucherBases/{voucherBasisId}/Voucher" \
  -H "Access-Token: $ANCON_TOKEN"
```
