Issue automatically sales and orders

Recent improvements to Tilby have introduced new, simplified ways of interacting with the application. In particular, it is now possible to manage sending both orders and sales via the single /sales endpoint.

Automatic issuing of receipts

Tilby allows you to automatically issue receipts using APIs. This mean for example that you can use our APIs to print a receipt, generate an electronic receipt or print an order.

Prerequisites

  • Activate automatic printing on a cash register and indicate the default printer to use (see guide)
    Keep a Tilby device constantly connected to the internet so that it processes incoming transactions
  • Send a POST to the endpoint sales where the sum of sale.sale_items[].final_amount is equal to or less than the sum of sale.payments[].amount.

If the sale do not contain a sufficient amount of payments to cover the total of the sale, then it will not be printed automatically and a notification will appear to the operator who will be invited to select a payment method to close it. In this way it is also possible to send partial payments (e.g. down payment).

The array sale.payments[] can have one or more payments.

Example of correctly compiled payments object

...  
"payments": [  
    {  
      "paid": true,  
      "payment_method_id": 2,  
      "payment_method_name": "Cash",  
      "payment_method_type_id": 2,  
      "payment_method_type_name": "Cash",  
      "amount": 50  
    }  
  ]  
...

It is essential that the parameters payment_method_id and payment_method_type_id are filled in with parameters corresponding to a payment method created on the system.
To verify the payments created simply make a call GET /payments/
The flag paid must be a true.

🚧

Please note: it is mandatory to indicate the uuid parameter both in the header and for each sale_items. Everything is fine sale_items it must have been different. UUIDs must be in v4 format, for more information Click here.

Extended example

{  
    "uuid": "9926fcef-0326-4837-96a9-8635c073c3f9",  
    "amount": 30.5,  
    "category_id": 35,  
    "currency": "EUR",  
    "external_id": "12345",  
    "final_amount": 30.5,  
    "item_id": 11,  
    "name": "Test post",  
    "open_at": "2024-03-20T13:00:00Z",  
    "order_type": "normal",  
    "payments": [  
        {  
            "amount": 30.5,  
            "date": "2024-03-20T11:00:00Z",  
            "paid": true,  
            "payment_method_id": 4,  
            "payment_method_name": "Payment online",  
            "payment_method_type_id": 4,  
            "payment_method_type_name": "Electronic payment"  
        }  
    ],  
    "sale_customer": {  
        "disable_mail_receipts": true,  
        "email": "[[email protected]](mailto:[email protected])",  
        "first_name": "Pinco",  
        "last_name": "Pallino"  
    },  
    "sale_items": [  
        {  
            "category_id": 38,  
            "department_id": 4,  
            "final_net_price": 25,  
            "final_price": 30.5,  
            "name": "Trial",  
            "price": 30.5,  
            "quantity": 1,  
            "seller_id": 0,  
            "seller_name": "",  
            "type": "sale",  
            "uuid": "6cca540a-05b8-4065-a5da-e94d7e538d4d",  
            "watt_minute": 22  
        }  
    ],  
    "seller_id": 0,  
    "seller_name": "",  
    "status": "open"  
}

Print result




Automatic printing of orders

Tilby allows you to automatically print orders sent via API, in production centers

Prerequisites

  • Activate automatic command printing (see guide)
  • Keep a Tilby device constantly connected to the internet so that it processes incoming transactions

Simple case 1 - Single print

The order will be printed in one go. No receipt will be issued, it can be closed manually later (receipt issuing).

It is necessary to send sale.auto_print_order=true and every sale.sale_items must have exit=1 (optionally increaseable if you want a printout divided into issues).

🚧

Please note: it is mandatory to indicate the uuid parameter both in the header and for each sale_items. Everything is fine sale_items it must have been different. UUIDs must be in v4 format, for more information Click here.

Example

..,  
"auto_print_order": true,  
  "sale_items": [  
    {  
      "category_id": 3,  
      "exit": 1,  
      "name": "Product name",  
      "notes": "Any additional notes",  
      "item_id": 200,  
      "price": 5,  
      "watt_minute": 22,  
      "final_net_price": 4.1,  
      "final_price": 5,  
      "quantity": 1,  
      "uuid": "864dceaf-7688-445f-982e-e4991368b33d"  
    }  
  ],  
...

Extended example

{  
    "amount": "19",  
    "auto_print_order": true,  
    "currency": "EUR",  
    "external_id": "123456",  
    "name": "Order 123456",  
    "notes": "Example header note",  
    "open_at": "2024-04-05 10:26:06",  
    "order_type": "delivery",  
    "sale_customer": {  
        "customer_id": "126",  
        "email": "[[email protected]](mailto:[email protected])",  
        "first_name": "Pinco",  
        "last_name": "Ball",  
        "phone": "+3934512345678",  
        "shipping_city": "Turin",  
        "shipping_country": "IT",  
        "shipping_street": "Via Colli, 3",  
        "shipping_zip": "10128"  
    },  
    "sale_items": [  
        {  
            "category_id": "3400",  
            "category_name": "THE PIZZAS",  
            "department_id": "3",  
            "department_name": "VAT 10% - Services",  
            "exit": "1",  
            "final_net_price": "5.4",  
            "final_price": "6",  
            "item_id": "18287",  
            "name": "Margherita",  
            "net_price": "5.4",  
            "price": "6",  
            "quantity": "1",  
            "seller_id": "0",  
            "seller_name": "Beautiful Platform",  
            "type": "sale",  
            "uuid": "5751114e-5094-4787-8be9-5ef9e92370c6",  
            "watt_minute": "10"  
        },  
        {  
            "category_id": "3400",  
            "category_name": "SECOND SIDES AND SIDES",  
            "department_id": "3",  
            "department_name": "VAT 10% - Services",  
            "exit": "1",  
            "final_net_price": "9",  
            "final_price": "10",  
            "item_id": "18330",  
            "name": "Salsiccia arrostita",  
            "net_price": "9",  
            "price": "10",  
            "quantity": "1",  
            "seller_id": "0",  
            "seller_name": "Beautiful Platform",  
            "type": "sale",  
            "uuid": "a134ea17-aeda-4bea-85d5-abfd4f6388fa",  
            "watt_minute": "10"  
        },  
        {  
            "category_id": "3400",  
            "category_name": "DRAFT BEER",  
            "department_id": "3",  
            "department_name": "VAT 10% - Services",  
            "exit": "1",  
            "final_net_price": "2.7",  
            "final_price": "3",  
            "item_id": "18388",  
            "name": "Moretti bionda 0.20",  
            "net_price": "2.7",  
            "price": "3",  
            "quantity": "1",  
            "seller_id": "0",  
            "seller_name": "Beautiful Platform",  
            "type": "sale",  
            "uuid": "769c3907-b94d-4904-a772-f36e95441007",  
            "watt_minute": "10"  
        }  
    ],  
    "seller_id": "0",  
    "seller_name": "Beautiful Platform",  
    "status": "open"  
}


Simple case 2 - Single print + Closing of sale (issue of receipt)

Both the order and the sale will be printed (receipt issuing), this case combines the paragraphAutomatic receipt printing with that Simple case 1 - Single print

🚧

Please note: it is mandatory to indicate the uuid parameter both in the header and for each sale_items. Everything is fine sale_items it must have been different. UUIDs must be in v4 format, for more information Click here.

Example

{  
    "amount": "19",  
    "auto_print_order": true,  
    "currency": "EUR",  
    "external_id": "123456",  
    "name": "Order 123456",  
    "notes": "Example header note",  
    "open_at": "2024-04-05T10:26:06.000Z",  
    "order_type": "delivery",  
    "deliver_at": "2024-04-05T10:26:06.000Z",  
    "sale_customer": {  
        "customer_id": "126",  
        "email": "[[email protected]](mailto:[email protected])",  
        "first_name": "Pinco",  
        "last_name": "Ball",  
        "phone": "+3934512345678",  
        "shipping_city": "Turin",  
        "shipping_country": "IT",  
        "shipping_street": "Via Colli, 3",  
        "shipping_zip": "10128"  
    },  
    "sale_items": [  
        {  
            "category_id": "3400",  
            "category_name": "THE PIZZAS",  
            "department_id": "3",  
            "department_name": "VAT 10% - Services",  
            "exit": "1",  
            "final_net_price": "5.4",  
            "final_price": "6",  
            "item_id": "18287",  
            "name": "Margherita",  
            "net_price": "5.4",  
            "price": "6",  
            "quantity": "1",  
            "seller_id": "0",  
            "seller_name": "Beautiful Platform",  
            "type": "sale",  
            "uuid": "5751114e-5094-4787-8be9-5ef9e92370c6",  
            "watt_minute": "10"  
        },  
        {  
            "category_id": "3400",  
            "category_name": "SECOND SIDES AND SIDES",  
            "department_id": "3",  
            "department_name": "VAT 10% - Services",  
            "exit": "1",  
            "final_net_price": "9",  
            "final_price": "10",  
            "item_id": "18330",  
            "name": "Salsiccia arrostita",  
            "net_price": "9",  
            "price": "10",  
            "quantity": "1",  
            "seller_id": "0",  
            "seller_name": "Beautiful Platform",  
            "type": "sale",  
            "uuid": "a134ea17-aeda-4bea-85d5-abfd4f6388fa",  
            "watt_minute": "10"  
        },  
        {  
            "category_id": "3400",  
            "category_name": "DRAFT BEER",  
            "department_id": "3",  
            "department_name": "VAT 10% - Services",  
            "exit": "1",  
            "final_net_price": "2.7",  
            "final_price": "3",  
            "item_id": "18388",  
            "name": "Moretti bionda 0.20",  
            "net_price": "2.7",  
            "price": "3",  
            "quantity": "1",  
            "seller_id": "0",  
            "seller_name": "Beautiful Platform",  
            "type": "sale",  
            "uuid": "769c3907-b94d-4904-a772-f36e95441007",  
            "watt_minute": "10"  
        }  
    ],  
    "seller_id": "0",  
    "seller_name": "Beautiful Platform",  
    "status": "open",  
    "payments": [  
        {  
            "amount": 19,  
            "date": "2024-04-05T11:00:00Z",  
            "paid": true,  
            "payment_method_id": 4,  
            "payment_method_name": "Online payment",  
            "payment_method_type_id": 4,  
            "payment_method_type_name": "Electronic payment"  
        }  
    ]

}

Print result



Advanced case 3 - Open table with continuous reordering

Extended case (more control): they send the salt with sale.auto_print_order=true and the lines associated with an exit.

With this method it is possible to independently send printouts relating to the same account. To do this it is necessary to send the first POST sales in which i sale_items[].exit=1, and for each additional print send PUT sales in which the value of is increased each time sale_items[].exit.

The counter must be incremented with each print. Send items to multiple exits at the same time will bring to printing all articles at once.

PUTs must refer to the room ID originally returned by the POST.

🚧

Please note: it is mandatory to indicate the uuid parameter both in the header and for each sale_items. Everything is fine sale_items it must have been different. UUIDs must be in v4 format, for more information Click here.