# Order Live Model

This document describes the Order Live model, its attributes, and the calculations made by the API.

## Order Live

An order-live is a resource representing a sale made by a customer. It is composed by a list of products, menus, and payments.

All order-live are created by the POS application at the beginning of the order process and are updated every time the order is modified (new item added, item removed, payment added, etc.) or when the order is closed on the POS UI.

An order contains two different types of attributes : defined attributes are the ones that are manually defined by the user (POS) at the product creation or during the order process, and calculated attributes are the ones that are calculated by the API based on the defined attributes.

For a complete description of all the attributes of an order-live, please refer to the Order Live Schema.

A canceled product (`isCanceled = true`

) is automatically ignored in the calculation of the order. The total amount of the order is calculated based on the products that are not canceled.

### Order

**totalTax**: The total amount of the order, including taxes.`totalTax = sum of all taxAmount in productRowList`

**totalDiscount**: The total amount of the order, including discounts.`totalDiscount = sum of all totalDiscount in productRowList`

**totalWithoutTax**: The total amount of the order, excluding taxes.`totalWithoutTax = sum of all totalRow in productRowList`

**leftToPay**: The amount left to pay on the order.`leftToPay = total - sum of all amount in paymentRowList`

**total**: The total amount of the order, including taxes and discounts.`total = totalWithoutTax + totalTax - totalDiscount`

### Products

__Defined Attributes :__

**taxRate**: The tax rate applied to the product (VAT).`taxRate = manually defined in the product catalog`

**unitPriceRow**: The unit price of the product.`unitPriceRow = manually defined in the product catalog`

**quantity**: The quantity of the product added to the order.`quantity = defined during the order process`

**weight**: The weight of the product in grams (for weight-based products).`weight = manually defined in the product catalog or defined during the order process`

__Calculated Attributes :__

**totalDiscount**: The total discount applied to the product.`totalDiscount = sum of all discounts applied to the product (sum of all amount in discountRowList)`

**unitPriceRowWithModifier**: The unit price of the product with modifiers.`unitPriceRowWithModifier = unitPriceRow + totalModifier`

**totalRowWithModifier**: The total amount of the product with modifiers.`totalRowWithModifier = unitPriceRowWithModifier * quantity`

for quantity based products`totalRowWithModifier = unitPriceRowWithModifier * (weight / 100)`

for weight based products

**totalRow**: The total amount of the product.`totalRow = totalRowWithModifier - totalDiscount`

**taxableAmount**: The taxable amount of the product (VAT excluded).`taxableAmount = totalRow / (1 + taxRate)`

**taxAmount**: The tax amount of the product (VAT).`taxAmount = totalRow - taxableAmount`

### Menu

The menuRowList contains the list of products that are part of the menu. Menu products are not repeated in the productRowList, they are only present in the menuRowList.

__Defined Attributes :__

**unitPriceRow**: The unit price of the menu`unitPriceRow = manually defined in the menu catalog`

**amountToAdd**: The amount to add to the menu.`amountToAdd = defined during the order process`

**amountToSubtract**: The amount to subtract from the menu (e.g. skip the salad).`amountToSubtract = defined during the order process`

__Calculated Attributes :__

**totalRow**: The total amount of the menu.`totalRow = unitPriceRow + amountToAdd - amountToSubtract`

### Data example

The following example is a simplified version of the order data. The actual data contains more attributes and details.

"..." indicates that certain attributes are omitted for reasons of legibility.

#### Order of a menu with modifiers and discount:

The menu is a "Menu Du Soir" with 3 products: "Super Salade", "Mega Burger", and "Maxi glace" that cost 25,00€ in total.

It has 2 modifiers : "supplément fromage" with an amount of 2,00€ on the product "Super Salade" and "chantilly" with an amount of 1,00€ on the product "Maxi glace".

It has a discount of 10% on the total amount of the menu for a final price of 25,20€.

`{`

...

"total": 2520, // Total amount of the order (25,20€)

"totalTax": 131, // Total amount of the taxes (1,31€)

"totalDiscount": 280, // Total amount of the discounts (2,80€)

"totalWithoutTax": 2389, // Total amount of the order without taxes (23,89€)

"leftToPay": 0, // Amount left to pay (0€)

"data": {

...

"leftToPay": 0, // Amount left to pay (0€)

"menuRowList": [ // List of menus in the order (1 menu)

{

...

"amountToAdd": 0, // Amount to add to the menu (0€)

"amountToSubtract": 0, // Amount to subtract from the menu (0€)

"name": "Menu Du Soir", // Name of the menu

"productRowList": [ // List of products in the menu (3 products)

{

...

"discountRowList": [ // List of discounts applied to the product "Super Salade" (1 discount)

{

...

"amount": 97, // Amount of the discount (0,97€)

"name": "Remise 10%", // Name of the discount

}

],

"isCanceled": false, // Product is not canceled (false)

"menuStepName": "Etape 1",

"modifierRowList": [ // List of modifiers applied to the product "Super Salade" (1 modifier)

{

...

"amount": 200, // Amount of the modifier (2,00€)

"name": "supplément fromage", // Name of the modifier

}

],

"name": "Super Salade", // Name of the product

"quantity": 1, // Quantity of the product

"taxAmount": 45, // Tax amount of the product (0,45€)

"taxName": "TVA 5,5%",

"taxRate": 550, // Tax rate of the product (5,5%)

"taxableAmount": 824, // Taxable amount of the product (8,24€)

"totalDiscount": 97, // Total discount applied to the product (0,97€)

"totalRow": 869, // Total amount of the product (8,69€)

"totalRowWithModifier": 966, // Total amount of the product with modifiers (9,66€)

"unitPriceRow": 966, // Unit price of the product (9,66€)

"unitPriceRowWithModifier": 966, // Unit price of the product with modifiers (9,66€)

"weight": null // Weight of the product (null for non-weight based products)

},

{

...

"discountRowList": [ // List of discounts applied to the product "Mega Burger" (1 discount)

{

...

"amount": 135, // Amount of the discount (1,35€)

"name": "Remise 10%", // Name of the discount

}

],

"isCanceled": false, // Product is not canceled (false)

"menuStepName": "ETAPE 2",

"modifierRowList": [], // List of modifiers applied to the product "Mega Burger" (0 modifier)

"name": "Mega Burger", // Name of the product

"quantity": 1, // Quantity of the product

"taxAmount": 63, // Tax amount of the product (0,63€)

"taxName": "TVA 5,5%",

"taxRate": 550, // Tax rate of the product (5,5%)

"taxableAmount": 1154, // Taxable amount of the product (11,54€)

"totalDiscount": 135, // Total discount applied to the product (1,35€)

"totalRow": 1217, // Total amount of the product (12,17€)

"totalRowWithModifier": 1352, // Total amount of the product with modifiers (13,52€)

"unitPriceRow": 1352, // Unit price of the product (13,52€)

"unitPriceRowWithModifier": 1352, // Unit price of the product with modifiers (13,52€)

"weight": null // Weight of the product (null for non-weight based products)

},

{

...

"discountRowList": [ // List of discounts applied to the product "Maxi glace" (1 discount)

{

"amount": 48, // Amount of the discount (0,48€)

"name": "Remise 10%", // Name of the discount

}

],

"isCanceled": false, // Product is not canceled (false)

"menuStepName": "Etape 3",

"modifierRowList": [ // List of modifiers applied to the product "Maxi glace" (3 modifiers)

{

...

"amount": 0, // Amount of the modifier (0€)

"name": "abricot", // Name of the modifier

},

{

...

"amount": 100, // Amount of the modifier (1,00€)

"name": "chantilly", // Name of the modifier

},

{

...

"amount": 0, // Amount of the modifier (0€)

"name": "fraise", // Name of the modifier

}

],

"name": "Maxi glace", // Name of the product

"quantity": 1, // Quantity of the product

"taxAmount": 23, // Tax amount of the product (0,23€)

"taxName": "TVA 5,5%",

"taxRate": 550, // Tax rate of the product (5,5%)

"taxableAmount": 411, // Taxable amount of the product (4,11€)

"totalDiscount": 48, // Total discount applied to the product (0,48€)

"totalRow": 434, // Total amount of the product (4,34€)

"totalRowWithModifier": 482, // Total amount of the product with modifiers (4,82€)

"unitPriceRow": 482, // Unit price of the product (4,82€)

"unitPriceRowWithModifier": 482, // Unit price of the product with modifiers (4,82€)

"weight": null // Weight of the product (null for non-weight based products)

}

],

"totalRow": 2800, // Total amount of the menu with modifiers (28,00€)

"unitPriceRow": 2500 // Unit price of the menu (25,00€)

}

],

"paymentRowList": [ // List of payments on the order (1 payment)

{

...

"amount": 2520, // Amount of the payment (25,20€)

}

],

"productRowList": [], // List of products in the order not in a menu (0 product)

"total": 2520, // Total amount of the order (25,20€)

"totalDiscount": 280, // Total amount of the discounts (2,80€)

"totalTax": 131, // Total amount of the taxes (1,31€)

"totalWithoutTax": 2389, // Total amount of the order without taxes (23,89€)

},

}

#### Order of a product with weight and a product tax-free:

The first product is a "Céréales" with a weight of 100 grams that costs 1,50€.

The second product is a "Café" that costs 2,00€ and is tax-free.

`{`

...

"total": 350, // Total amount of the order (3,50€)

"totalTax": 14, // Total amount of the taxes (0,14€)

"totalDiscount": 0, // Total amount of the discounts (0€)

"totalWithoutTax": 336, // Total amount of the order without taxes (3,36€)

"leftToPay": 0, // Amount left to pay (0€)

"data": {

...

"leftToPay": 0, // Amount left to pay (0€)

"menuRowList": [], // List of menus in the order (0 menu)

"paymentRowList": [ // List of payments on the order (1 payment)

{

...

"amount": 350, // Amount of the payment (3,50€)

}

],

"productRowList": [ // List of products in the order (2 products)

{

...

"discountRowList": [], // List of discounts applied to the product "Café" (0 discount)

"isCanceled": false, // Product is not canceled (false)

"modifierRowList": [],

"name": "Café", // Name of the product

"quantity": 1, // Quantity of the product

"taxName": "TVA 0%",

"taxRate": 0, // Tax rate of the product (0%)

"taxableAmount": 200, // Taxable amount of the product (2,00€)

"totalDiscount": 0, // Total discount applied to the product (0€)

"totalRow": 200, // Total amount of the product (2,00€)

"totalRowWithModifier": 200, // Total amount of the product with modifiers (2,00€)

"unitPriceRow": 200, // Unit price of the product (2,00€)

"unitPriceRowWithModifier": 200, // Unit price of the product with modifiers (2,00€)

"weight": null // Weight of the product (null for non-weight based products)

},

{

...

"discountRowList": [], // List of discounts applied to the product "Céréales" (0 discount)

"isCanceled": false, // Product is not canceled (false)

"modifierRowList": [], // List of modifiers applied to the product "Céréales" (0 modifier)

"name": "Céréales", // Name of the product

"pricingName": "Prix au poids (Kg)",

"pricingType": "weightPrice", // Pricing type of the product (weightPrice = price per kilogram)

"quantity": 1, // Quantity of the product

"taxAmount": 14, // Tax amount of the product (0,14€)

"taxName": "TVA 10%",

"taxRate": 1000, // Tax rate of the product (10%)

"taxableAmount": 136, // Taxable amount of the product (1,36€)

"totalDiscount": 0, // Total discount applied to the product (0€)

"totalRow": 150, // Total amount of the product (1,50€)

"totalRowWithModifier": 150, // Total amount of the product with modifiers (1,50€)

"unitPriceRow": 1500, // Unit price of the product (1,50€)

"unitPriceRowWithModifier": 1500, // Unit price of the product with modifiers (1,50€)

"weight": 0.1 // Weight of the product (100 grams)

}

],

"total": 350, // Total amount of the order (3,50€)

"totalDiscount": 0, // Total amount of the discounts (0€)

"totalTax": 14, // Total amount of the taxes (0,14€)

"totalWithoutTax": 336, // Total amount of the order without taxes (3,36€)

},

}