> For the complete documentation index, see [llms.txt](https://docs.fulfillmenttools.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fulfillmenttools.com/documentation/getting-started/facilities/prices.md).

# Prices and facility discounts

You can define different types of prices in fulfillmenttools. A shop price can be defined in the [attributes](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md) of the listing or the order. A sales price can be defined in the listing attributes of the selling facility's listing. And the purchase price is the result of a sales price to another facility.

Let's say we have a product called a Nerd Herd t-shirt. If a consumer buys it online from our website, they'll see the [shop price](#shop-price). If our Nerd Herd Clothing Los Angeles store buys it from the supplier, they'll see the [purchase price](#purchase-price) based on the [sales price](#sales-price) from the supplier.

| Facility           | Sales price set on the listing | Purchase price for the LA store with a 10% facility discount | Shop price for consumer set on the listing |
| ------------------ | ------------------------------ | ------------------------------------------------------------ | ------------------------------------------ |
| Nerd Herd supplier | €30                            | €27                                                          | €35                                        |

For the above to take effect, we'd need the following on our t-shirt listing, plus a facility discount set and a facility connection between our supplier and our LA store.

{% tabs %}
{% tab title="T-shirt listing code sample" %}

```json
{
    "listings": [
        {
            "tenantArticleId": "TSHIRT-W-2468",
            "title": "T-shirt",
            "decimalPlaces": 2,
            "attributes": [
                {
                    "category": "salesPrice",
                    "value": "3000",
                    "key": "valuePerUnit",
                    "type": "NUMBER"
                },
                {
                    "category": "salesPrice",
                    "value": "EUR",
                    "key": "currency",
                    "type": "CURRENCY"
                },
                {
                    "category": "shop",
                    "value": "3500",
                    "key": "valuePerUnit",
                    "type": "NUMBER"
                },
                {
                    "category": "shop",
                    "value": "EUR",
                    "key": "currency",
                    "type": "CURRENCY"
                }
            ]
        }
    ]
}
```

{% endtab %}

{% tab title="Facility discount code sample" %}

```json
{
    "context": [
        {
        "type": "FACILITY",
        "values": [
            "{YOUR_FACILITY_ID}"
            ]
        }
    ],
    "discount": {
        "type": "RELATIVE",
        "values": [
            {
                "value": 10
            }
        ]    
    },
    "priority": 20,
    "type": "SALES_PRICE"
}
```

{% endtab %}

{% tab title="Facility connection code sample" %}

```json
{
    "type": "MANAGED_FACILITY",
    "target": {
        "facilityRef": "{YOUR_FACILITY_ID}",
        "type": "MANAGED_FACILITY"
    },
    "fallbackTransitTime": {
        "maxTransitDays": 2,
        "minTransitDays": 1
    },
    "fallbackCost": {
        "value": 500,
        "currency": "EUR",
        "decimalPlaces": 2
    },
    "carrierKey": "DHL_V2",
    "carrierName": "MyDhl",
    "context": [],
    "nonDeliveryDays": [],
    "packagingUnitsByContexts": []
}
```

{% endtab %}
{% endtabs %}

## Shop price

The price at which items are sold to consumers is called the shop price. It can be stored at the listing level within the attributes or sent in the order's [article attributes](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md). Typically, only [managed facilities](/documentation/getting-started/facilities.md#managed-facilities) will have a shop price configured.

The shop price is displayed in the Backoffice [facility inventory detail view](/documentation/backoffice/facility-view/inventory.md) in the **Article details** section.

{% hint style="info" %}
More information on adding shop prices to a listing can be found in the [Article attributes article](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md#shop-price-with-currency).
{% endhint %}

## Sales price

The sales price is the amount at which items are sold to other facilities in the network and is always stored by the facility selling the articles. The sales price can be stored at the listing level in the listing attributes. It can be configured for all facility types, although primarily [supplier facilities](/documentation/getting-started/facilities.md#supplier-facilities) will configure a sales price.

The sales price is displayed in the **Sales price** section of the Backoffice facility [inventory detail view](/documentation/backoffice/facility-view/inventory.md#sales-prices) and is visible in the selling facility's view. You can also add a sales price in Backoffice for the selling facility.

{% hint style="info" %}
More information on adding sales prices to a listing can be found in the [Article attributes article](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md#sales-price-with-currency).
{% endhint %}

### Facility discounts

Facility discounts determine the value by which the [sales price](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md#category-sales-price) of the facility's listings is reduced for a specific group. It's configured on the facility that supplies the listing to other facilities.

The amount of the discount can be defined as a relative or absolute value. Discounts can be defined for a facility, a [group of facilities](/documentation/getting-started/facilities/facility-groups.md), or a [category](/documentation/by-pillar/global-inventory-hub/categories.md) (group of articles).

The scope of application can be extended or narrowed using the `AND`, `OR`, and `NOT` operators.

The contexts set in the discount (for example, facility groups) are matched with the corresponding context of the [listing attributes](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md#category-sales-price). If all contexts match, the discount is applied to the item's [sales price](/documentation/by-pillar/global-inventory-hub/articles/article-attributes.md#category-sales-price).

The priority defines the order in which the discounts should be applied.

Facility discounts can be viewed, created, and edited via the [Facility discounts API](/documentation/getting-started/facilities/prices/facility-discounts-endpoints.md).

#### **Example** <a href="#example" id="example"></a>

Let's say we have a supplier facility called Nerd Herd Distribution, and it has 3 different facility discounts set.

| Discount | Scope of discount                      | Priority |
| -------- | -------------------------------------- | -------- |
| 10%      | Nerd Herd Clothing Los Angeles store   | 10       |
| 15%      | T-shirt category                       | 50       |
| €5       | US West Coast Nerd Herd facility group | 100      |

If the Nerd Herd Clothing Los Angeles store (which is also part of the US West Coast facility group) purchases a t-shirt from Nerd Herd Distribution, it will receive a 10% discount. This is because the facility discount takes priority over both the category and facility group discounts.

If the Nerd Herd Clothing New York store purchases a t-shirt from our Nerd Herd supplier, it'll receive a 15% discount. This is because the category discount is the only discount that applies to that store.

#### Create facility discount

To add a discount to an existing facility, perform the following `POST` request with a JSON body similar to the example provided. This example applies a discount of 5 euros to articles that don't belong to the `shoes` or `trousers` categories and that belong to a facility group (`YOUR_FACILTY_GROUP_ID`).

{% tabs %}
{% tab title="Endpoint" %}

```http
POST https://ocff-{PROJECT_ID}.api.fulfillmenttools.com/api/facilities/{YOUR_FACILITY_ID}/discounts
```

{% endtab %}

{% tab title="Request" %}

```json
{
    "context": [
        {
            "operator": "NOT",           
            "type": "CATEGORY",
            "values": [
                "shoes",
                "trousers"
            ]
        },
        {
        "operator": "AND",
        "type": "FACILITY_GROUP",
        "values": [
            "YOUR_FACILITY_GROUP_ID"
            ]
        }
    ],
    "discount": {
        "type": "ABSOLUTE",
        "values": [
            {
                "value": 500,
                "currency": "EUR",
                "decimalPlaces": 2
            }
        ]    
    },
    "priority": 20,
    "type": "SALES_PRICE"
}
```

{% endtab %}
{% endtabs %}

## Purchase price

The purchase price is the amount at which items are acquired from other facilities within the network. It isn't stored specifically in fulfillmenttools but depends on the facility from which an article is sourced.

The **Purchase price** section appears within the Backoffice facility [inventory detail view](/documentation/backoffice/facility-view/inventory.md#purchase-prices) of the purchasing facility. Only prices pertinent to the purchasing facility are displayed.

{% hint style="warning" %}
The purchase price will only be displayed if there is a [facility connection](/documentation/by-pillar/advanced-order-routing/complex-routing-with-combinatorics/network-model/facility-connection.md) between the selling and the purchasing facilities.
{% endhint %}

### Discounted purchase price

Discounts can be applied to the purchase price of an article and are defined by the selling facility in the sales price. The selling facility can decide to set a discount for specific:

* Purchasing [facilities](/documentation/getting-started/facilities.md)
* Purchasing [facility groups](/documentation/getting-started/facilities/facility-groups.md)
* Article [categories](/documentation/by-pillar/global-inventory-hub/categories.md)

This is done as part of the [facility discounts](#facility-discounts).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fulfillmenttools.com/documentation/getting-started/facilities/prices.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
