Orders with discounts can be created in two ways: with item-level discounts or with order-level discounts. The discount amount should always be a positive number.
Order-level discounts (most used)
The discount is applied to the total order amount. In this case, the item-level discount should be zero.
{
"subtotal": 90,
"shipping": 10.21,
"discount": 5,
"total": 95.21,
"total_paid": 95.21
}
Item-level discounts
When the discount is applied directly to the item and the total item value reflects the discounted price, the order-level discount should be zero in this scenario.
{
"items": [
{
"sku": "4544646464",
"quantity": 3,
"price": 30,
"discount": 5,
"total": 85,
"name": "Camiseta Básica Azul",
"stock_code": "136",
"commission": {
"fixed": 4,
"tax": 2,
"total_charged": 10
},
"variation": {
"sku": "variacao-1"
},
"supplier_id": "136"
}
]
}
The verification rules for values that we have are as follows:
For each item:
total =price x quantity - discount
Order totals:
subtotal = sum of all item totals
total = subtotal - discount + shipping
total_paid = total + interest