# Queries / Sales

# Sales

**Query**
## sale — Returns [Sale](/documentation/Objects/Sales#Sale)

**Scopes required:** see_history

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the sale to retrieve |

**Example Query**

```graphql
query GetSale($id: ID!) {
    sale(id: $id) {
        id,
        clientId,
        status,
        accountSale,
        invoiceId
    }
}

# Example variables
{
    "id": "<ID>"
}
```

**Query**
## sales — Returns [ConnectionType](/documentation/General/Connections) of [Sale](/documentation/Objects/Sales#Sale)

**Scopes required:** see_history

Get the sales for the Vendor optionally filtering them, if `startDate` is not specified it defaults to three months ago, to retrieve all sales for the vendor, explicitly pass null to `startDate`

### Sortable Fields
*Fields from [Sale](/documentation/Objects/Sales#Sale) that can be used to sort the connection items*

- createdAt
- updatedAt

| Arguments | Type | Description |
| --- | --- | --- |
| startDate | [DateTime](/documentation/Types/Date-Time#DateTime) | The date and time to get sales from (inclusive), defaults to three months ago |
| endDate | [DateTime](/documentation/Types/Date-Time#DateTime) | The date and time to get sales to (inclusive) |
| invoiceId | *String* | The invoice ID (commonly called invoice number) of the invoices to retrieve, this could produce multiple sales as there is no guarantee that each invoice has a unique invoice id |
| orderReference | *String* | The order reference of the invoice to retrieve, this field is typically used by stores that sell to other businesses |
| paymentMethod | [ID](/documentation/Types/UUID#UUID) | Get sales that used the provided payment method |
| user | [ID](/documentation/Types/UUID#UUID) | Get sales that were completed by the provided user |
| register | [ID](/documentation/Types/UUID#UUID) | The register the sale occurred on |
| outlets | [[ID]](/documentation/Types/UUID#UUID) | The outlets to get sales from |
| status | [[SaleStatusEnum]](/documentation/Enums/Sale-Status-Enum#SaleStatusEnum) | Get the sales that have the provided statuses |
| discounted | *Boolean* | Whether to get only discounted sales (true is only discounted, false is all sales including discounted) |
| moreAmount | *Float* | Get sales which have a total price of more than this amount (inclusive) |
| lessAmount | *Float* | Get sales which have a total price of less than this amount (inclusive) |
| customer | [ID](/documentation/Types/UUID#UUID) | Get sales from the provided customer |
| product | [ID](/documentation/Types/UUID#UUID) | The sales which contain the provided product |
| returned | *Boolean* | Get sales that have returned products on (true is only sales that have returned items, false is all sales including returns) |
| id | [ID](/documentation/Types/UUID#UUID) | The UUID of the sale |
| ids | [[ID!]](/documentation/Types/UUID#UUID) | A list of IDs of the sales to retrieve, if `id` is also specified, it'll be appended to this list |
| giftCardCode | *String* | Get sales that involved the provided gift card code (either sold or paid for with) |
| clientId | *String* | The client ID of the sale |

**Example Query**

```graphql
query GetSales($startDate: DateTime) {
    sales(startDate: $startDate) {
        edges {
            node {
                id,
                clientId,
                status,
                accountSale,
                invoiceId
            }
        },
        pageInfo {
            hasNextPage,
            endCursor
        }
    }
}

# Example variables
{
    "startDate": "<START_DATE>"
}
```