
Mantel
The comanda becomes a factura
A white-label operations platform for restaurants and bars in Ecuador, from the floor to the SRI.
Juan M. Cornejo
Mantel
A notebook
This notebook covers one part of Mantel: how a comanda becomes an electronic factura for the SRI, to the cent.
- Notes2
- The bill, sketched3
- The comanda becomes a factura4
- One comanda, to the cent5
- Try it6
- The facturas, in the app7
- The comanda, in the kitchen8
- From the table to the SRI9
- In short10
A white-label operations platform for restaurants and bars in Ecuador, from the floor to the SRI. Built for one room first.
1Mantel
Notes
- Three venues run on Mantel, on the same code: El Encanto, Sincopa and La Cuadrilla. The first two have their own colours.
- In Ecuador a menu price includes the IVA, the 15% tax. The bill takes it back out, line by line.
- A discount comes off the net base. The IVA is then charged on what is left, followed by the venue’s service charge, 10% in this example. The service carries no IVA.
- The factura’s XML calls the service propina. In the app, Propina is now a different line: a tip added at payment, outside the factura.
- The screen, the server and the XML each round the numbers, so all three must agree. For the screen and the server, the code gives the reason: a bill that is a cent off is one nobody can explain at the table.
- The IVA is spread over the lines by largest remainder: the leftover cents go to the lines with the largest fractions, so the lines sum to the total.
- The access key is 49 digits. The last one is a módulo 11 check over the other 48.
- The SRI refuses a factura with a $0 total or with no tax total, so Mantel’s builder refuses them first. A $0 bill closes with no factura.
- An invoice can be borrador (draft), firmada (signed), pendiente (pending), autorizada, error or anulada (voided). The SRI’s answer leaves it autorizada, pendiente or error. A job runs every ten minutes: it retries a pendiente, and a borrador or an error for 24 hours.
2Notes
The bill, sketched
Figure 1. A bill, sketched in code. The lines and their prices are at the top, the totals under a rule, and the access key at the foot.
3Mantel
Chapter 1
The comanda becomes a factura
A comanda is a table’s order. When the table closes, Mantel turns it into a factura, an electronic invoice for the SRI, Ecuador’s tax service. The figures on the screen, on the server and in the XML must match to the cent.
Menu prices include the IVA, Ecuador’s 15% tax. The bill takes the IVA back out of each line to find the net base, takes the discount off the net, then adds the IVA and the venue’s service charge, 10% in this example. The factura spreads the IVA over the lines, and its 49-digit access key ends in a check digit.
The next page works through one invented comanda. On the page after it, change the order and pick an answer from the SRI.
4The comanda becomes a factura
One comanda, to the cent
| Line | Qty | Net unit | Net | Discount |
|---|---|---|---|---|
| Lines, with the IVA taken out | ||||
| Locro de papa | 2 | 7.39 | 14.78 | 1.48 |
| Ceviche de palmito | 1 | 7.83 | 7.83 | 0.78 |
| Copa de vino tinto | 2 | 6.09 | 12.17 | 1.22 |
| Agua con gas | 1 | 2.17 | 2.17 | 0.22 |
| The bill | ||||
| Subtotal, without IVA | 36.95 | |||
| Discount, 10% of the net | 3.70 | |||
| IVA, 15% | 4.99 | |||
| Service, 10%, no IVA | 3.33 | |||
| Total | 41.57 | |||
18102026fecha01tipoComprobante9999999999999ruc1ambiente001001serie000000128secuencial20261018codigoNumerico1tipoEmision1digitoVerificador
The discount is shared over the lines by weight, and the IVA over the taxable lines. Each share uses largest remainder, so every column sums to its total.
Table 1. One invented comanda as a bill, with its 49-digit access key. Computed when the page was built, with Mantel’s functions ported to this page. The issuer (emisor) is the demo’s: DEMO, SIN VALIDEZ TRIBUTARIA.
5Mantel
Try it
| Comanda | Price | Qty |
|---|
the SRI answers (a simulation)
the XML, unsigned
DEMO · SIN VALIDEZ TRIBUTARIA
Figure 2. An invented comanda run through Mantel’s bill, XML and access key, ported to this page. Change a quantity, the discount or the service, then pick an answer from the SRI. The answers are simulated, and nothing is signed or sent.
6Try it
The facturas, in the app

- 1Autorizadas: the SRI said yes to each of these
- 2Pendientes, Errores, Borrador: where a factura can wait
- 3A correction is a nota de crédito, with its own number
- 4Its kind, and the SRI’s answer to it
- 5The number: establishment, point of sale, sequence
- 6Autorizada: the state the row ends in
Plate 1. The Facturas list of Mantel’s demo build, with invented data. Each factura is one numbered row with the SRI’s answer, and a correction is a second document.
7Mantel
The comanda, in the kitchen

- 1The table, S3
- 2Check #1: the comanda keeps one number until it is billed
- 3A restriction travels with the order
- 4Each line is marked ready on its own
Plate 2. Table S3 on the kitchen display of the demo build. The check number the kitchen sees is the one the bill carries; the factura gets its own number.
8The comanda, in the kitchen
From the table to the SRI
Figure 3. How a comanda reaches the SRI, drawn as a line through stations: the bill, the XML and its key, then the SRI’s receipt (recepción) and authorisation (autorización). The SRI’s answer is authorised, pending or an error, and a pending one goes round again.
- 1The comanda to the bill: net base, discount, IVA, service.
- 2The bill to the XML and its 49-digit key, then the signature.
- 3The SRI receives it (recepción), then answers (autorización): authorised, pending, or an error. A pending one is tried again every ten minutes.
9Mantel
In short
A factura is sent when the table closes, but it is not always authorised then. The SRI can authorise it, leave it pending or return an error.
The rest of Mantel is in the case study: the floor, the kitchen displays, inventory and cost, roles and the public carta.
10In short

