# Sales (/guides/sales)

## Sales summary [#summary]

```bash
curl -H "Authorization: Bearer $TMBILL_KEY" "https://openapi.tmbill.com/v1/sales/summary?store_id=1234&from=2026-11-01&to=2026-11-30&group_by=day"
```

```json
{
  "group_by": "day",
  "currency": "INR",
  "as_of": "2026-12-02T09:10:00Z",
  "final": true,
  "rows": [
    {
      "key": "2026-11-01", "order_count": 182,
      "subtotal": "52310.00", "discount": "1240.00", "net_sales": "51070.00",
      "tax": "2553.50", "aggregator_tax": "410.00", "charges": "300.00", "charges_tax": "54.00",
      "round_off": "-0.50", "total": "54387.00", "tips": "450.00",
      "free_total": "0.00", "free_count": 0, "currency": "INR"
    }
  ],
  "next_cursor": null
}
```

`group_by` is `day` (default), `hour` (hour of day, store time) or `order_type`.

## Item sales [#items]

```bash
curl -H "Authorization: Bearer $TMBILL_KEY" "https://openapi.tmbill.com/v1/sales/items?store_id=1234&from=2026-11-01&to=2026-11-30&group_by=item&limit=20"
```

```json
{ "group_by": "item", "currency": "INR", "as_of": "...", "final": true,
  "data": [ { "item_id": "88121", "name": "Cold Coffee", "quantity": 412, "amount": "61800.00" } ],
  "next_cursor": "eyJvIjoyMH0..." }
```

`group_by=category` ranks categories instead. `category` filters to one or more category names (comma separated, up to 20).

## Payment modes [#payments]

```bash
curl -H "Authorization: Bearer $TMBILL_KEY" "https://openapi.tmbill.com/v1/sales/payments?store_id=1234&from=2026-11-01&to=2026-11-30"
```

```json
{ "currency": "INR", "as_of": "...", "final": true, "due": "1250.00",
  "data": [ { "payment_option": "Cash", "count": 210, "amount": "48210.00" },
            { "payment_option": "UPI", "count": 388, "amount": "92114.00" },
            { "payment_option": "Online Paid", "count": 97, "amount": "30410.00" } ],
  "next_cursor": null }
```

`due` is the unpaid part of credit bills in the range (the same on every page).

## How sales are counted [#counting]

- Only **fulfilled** orders count (use `order_state=cancelled` for a cancellation report). Orders cleared by a day reset never count.
- `net_sales = subtotal - discount`. `tax` excludes aggregator orders (Zomato, Swiggy), whose taxes are in `aggregator_tax`.
- `charges` exclude their tax (`charges_tax`). `total` is the sum of bill totals; **tips** are apart and not in `total`.
- Complimentary orders are apart in `free_total` / `free_count`.
- Aggregator orders paid online show as **Online Paid**, cash on online pickup as **Online COD**.
- `final: false` means the range includes one of the last 3 days in store time: offline POS devices can still sync late and bills can be edited. Re-read those days later for accounting.

<Callout type="warn">
**Money is a string.** Parse it with a decimal type (`Decimal`, `BigDecimal`, `decimal.js`), never a float. Decimals follow the currency: `"249.00"` INR, `"12.500"` BHD/KWD/OMR.
</Callout>