Appearance
Bill Examples
Complete payload examples for the cases that are hardest to get right. They build on the structures described in the Bill Data Model.
Discounts
A discount can either be set to each line item individually or to the whole receipt.
Discount for individual line items
To discount a single line item, fill the discounts array in the extension:anybill of the line. Each applied discount references a definition (see below) via its discountId. If multiple discounts are applied to one line item, the sequenceNumber can be set to show the consumer how the final price is composed.
A discounted line uses the following amounts:
fullAmountInclVat– the gross line total after all discounts.extension:anybill.fullAmountInclVatBeforeDiscounts– the gross line total before any discount.item.extension:anybill.pricePerUnitBeforeDiscounts– the original gross price per unit before discounts.
Each discount vatAmounts.percentage must also be present in the line's vatAmounts.
Sign of fullAmountInclVat
Both positive and negative values are accepted for a discount's fullAmountInclVat – the sign only affects how the amount is rendered on the (PDF) receipt. We recommend using negative values for discount amounts.
Example (one line item with a 20 % discount):
json
{
"text": "Baumwoll T-Shirt",
"vatAmounts": [
{ "percentage": 19.0, "inclVat": 16.0, "exclVat": 13.45, "vat": 2.55 }
],
"fullAmountInclVat": 16.0,
"item": {
"quantity": 1.0,
"pricePerUnit": 16.0,
"extension:anybill": {
"pricePerUnitBeforeDiscounts": 20.0
}
},
"extension:anybill": {
"sequenceNumber": 0,
"fullAmountInclVatBeforeDiscounts": 20.0,
"discounts": [
{
"sequenceNumber": 0,
"discountId": "DISC_TSHIRT_20",
"vatAmounts": [
{ "percentage": 19.0, "inclVat": 4.0, "exclVat": 3.36, "vat": 0.64 }
],
"fullAmountInclVat": -4.0
}
]
}
}To describe an applied discount, add a definition to data.extension:anybill.discounts and reference it by setting the line discount's discountId to the definition's id (the id is an arbitrary reference string and is not shown to the customer). If the same discount applies to multiple line items, define it once and reference it from each line. The definition's type is one of Percentage, Monetary, MonetaryReplacement or None, and value holds the percentage (e.g. 20) or the monetary amount (e.g. 5). fullAmountInclVatBeforeDiscounts on the data extension is the gross total of the whole receipt before any discounts.
json
{
"extension:anybill": {
"fullAmountInclVatBeforeDiscounts": 40.0,
"discounts": [
{
"id": "DISC_TSHIRT_20",
"name": "20 % Rabatt T-Shirt",
"value": 20.0,
"type": "Percentage",
"vatAmounts": [
{ "percentage": 19.0, "inclVat": 4.0, "exclVat": 3.36, "vat": 0.64 }
],
"fullAmountInclVat": -4.0
},
{
"id": "DISC_CAP_5EUR",
"name": "5 € Rabatt Cap",
"value": 5.0,
"type": "Monetary",
"vatAmounts": [
{ "percentage": 19.0, "inclVat": 5.0, "exclVat": 4.2, "vat": 0.8 }
],
"fullAmountInclVat": -5.0
}
]
}
}Discount for the whole receipt
To add a discount that is applied to the whole receipt the discount line can be used. Multiple discount lines can be used for different discounts.
To enhance the information from which line items the discount is made up the relatedLines property can be used. Either use it on the vatAmounts to link the to the line item by the sequenceNumber or set all lines on the root.
Example:
json
{
"text": "Wochenendrabatt 3 %",
"additionalText": "3 % Rabatt am Wochenende",
"vatAmounts": [
{
"percentage": 7,
"inclVat": 0.09,
"exclVat": 0.08411,
"vat": 0.00589,
"relatedLines": [
0
]
},
{
"percentage": 19,
"inclVat": 0.08,
"exclVat": 0.06723,
"vat": 0.01277,
"relatedLines": [
2
]
}
],
"fullAmountInclVat": 0.17,
"relatedLines": null,
"extension:anybill": {
"sequenceNumber": 3,
"type": "discount"
},
...
}Returning a line item
If you want to return a bills line item the following steps are necessary:
- Given an existing receipt
Awith a line itemA1. - Create a new receipt
Bwith an extra line itemB1which represents the returned line itemA1. - Set the property
ReturnBarcodeReferenceof line itemB1to the value of propertyReturnBarcodeof receiptA. - Save receipt
B.
A line item is then displayed as "returned" in receipt B.
Example
Bill A:
json
{
"storeId": "8192538C-CC23-488B-B35B-0F16BE1B8F43",
"bill": {
"head": {
"date": "2020-06-20T13:00:00+00:00",
...
},
"data": {
"lines": [
{
"text": "A1",
"quantity": 1,
"fullAmountInclVat": 1.00,
...
},
{
"text": "A2",
"quantity": 3,
...
}
]
},
"misc": {
"extension:anybill": {
"returnBarcode": "123",
...
},
...
},
...
}
}Bill B:
json
{
"storeId": "8192538C-CC23-488B-B35B-0F16BE1B8F43",
"bill": {
"head": {
"date": "2020-06-20T15:00:00+00:00",
...
},
"data": {
"lines": [
{
"text": "B1",
"quantity": 1,
"fullAmountInclVat": -1.00,
"extension:anybill": {
"returnBarcodeReference": "123", // see returnBarcode of Receipt A
},
...
}
]
},
...
}
}Custom sections
Custom sections allow you to insert your own attributes between the defined areas in order to individualize the receipt and display the necessary information.
A custom section can be inserted either before or after a defined area, contains a title and a list of data which are displayed in the given order by the sequenceNumber. The title will not be displayed on pdf. May be used in digital display formats.
The customSectionId can be used if it should be needed again later via the SDK. Must be unique across all customSections.
Areas
The receipt is generally divided into the following areas:
HeadLinesPaymentDetailsVatDetailsAdditionalDataBuyerFooterTextTseInformationAfterSalesCouponsHospitalityInformation
A receipt with the marked sections can be downloaded here.
Types
Currently, data of type text, keyValue, barcode or qrCode can be added to a custom section.
text
json
{
"sequenceNumber": 0,
"customSectionId": "NameId",
"type": "text",
"text": "text message",
"alignment": "Left|Center|Right"
}keyValue
json
{
"sequenceNumber": 1,
"customSectionId": "NameId",
"type": "keyValue",
"key": "LoyaltyCard number:",
"value": "123456789"
}barcode
json
{
"sequenceNumber": 0,
"customSectionId": "NameId",
"type": "barcode",
"barcodeType": "Barcode|Code128ABarcode|Code128BBarcode|Code128CBarcode",
"value": "Value of the barcode"
}qrCode
json
{
"sequenceNumber": 0,
"customSectionId": "NameId",
"type": "qrCode",
"value": "Value of the qrCode"
}Custom section example
json
"customSections": [
{
"position": "Before",
"section": "Head",
"title": "Title of the custom head section",
"data": [
{
"sequenceNumber": 0,
"type": "Text",
"text": "Before Head text"
},
{
"sequenceNumber": 1,
"type": "KeyValue",
"key": "LoyaltyCard number:",
"value": "123456789"
}
]
},
{
"position": "After",
"section": "VatAmounts",
"title": "Title of the custom vatAmounts section",
"data": [
{
"sequenceNumber": 0,
"type": "barcode",
"barcodeType": "Code128ABarcode",
"value": "Value of the barcode"
},
{
"sequenceNumber": 1,
"type": "qrCode",
"value": "Value of the qrCode"
}
]
}
]