# Create a discount code

## Overview

[Video: Create a discount code](https://www.youtube.com/watch?v=wtx_oXxrwLs)

This flow describes how to create a discount code for a facility in Care. Discount codes are part of the [billing settings](https://docs.ohc.network/concepts/billing/billing-settings.md) of the facility.

A discount code is a name and a code. Discount components that share a discount code show as one group when you pick a discount for a charge item definition.

## Pre-requisites

* You are a member of the facility in any role, or of its geographic organization or an organization above it.
* The facility has saved a discount configuration. If it has not, [set the discount configuration](https://docs.ohc.network/flows/billing/billing-settings/set-discount-configuration.md) first.
* You have the permissions listed below.

## Permissions

| Permission | Access |
| - | - |
| Can Update on Facility | Lets you save the billing settings of the facility. It counts when you hold it through a role in the facility's root organization, which Care names Administration. A role in the facility's geographic organization, or in an organization above it, also counts. A role that you hold only in a department or team of the facility does not count. By default, the Facility Admin, Administrator and Staff roles hold it. Every member of the facility can open the page and use its buttons. Without this permission, Care refuses the save with a message that contains "You do not have permission to create Facilities". |

## Steps

### 1. Open the discount codes

In the facility sidebar, under **Administration**, select **Settings**.

Care shows the settings sidebar of the facility.

In the **Billing** group, select **Billing**.

Under **Discount**, select **Discount Codes**.

The list shows the discount codes of the deployment first, with the badge **Instance**.

The discount codes of the facility follow, with the badge **Facility**.

![The facility sidebar, with Settings outlined under Administration](/assets/images/create-discount-code-1-9fd35be0b8e26d50957e3b617117a6fc.webp)

### 2. Open the form

Select **Create Discount Code**.

Care opens a form titled **Create Discount Code**.

![The Discount Codes page, with the Create Discount Code button outlined](/assets/images/create-discount-code-2-874b08ef7480a3d984eb2cd4825da470.webp)

### 3. Enter the name and the code

Complete the two fields.

| Components | What it captures |
| - | - |
| **Name** | The name of the discount code. Care shows the name with the code when you pick a discount code for a discount component. This field is required. |
| **Code** | The code that identifies the discount code. It must differ from the other codes of the facility and from the codes of the deployment. This field is required. |

Care removes spaces at the start and at the end of each entry.

If a field is empty, Care shows "This field is required".

![The Create Discount Code sheet, with the name Staff Discount and the code staff entered](/assets/images/create-discount-code-3-bfb916e5ae6d613b42b1b18fb6742d98.webp)

### 4. Save the discount code

Select **Save**.

Note: **Save** stays disabled until you type in a field.

Care closes the form at once, before it saves the code.

If Care refuses the save, the values that you typed are lost. Open the form again. Type the values again.

If Care shows an error message, use this table.

| If the message contains | What to do |
| - | - |
| Duplicate codes are not allowed. | The facility already has a discount code with this code. Use a different code. |
| Redefining system codes are not allowed. | The deployment already has a discount code with this code. Use a different code. Or, select the code of the deployment when you create the discount component. |
| Discount codes cannot be more than 100. | The facility already has 99 discount codes, which is the most that Care accepts. [Delete a discount code](https://docs.ohc.network/flows/billing/billing-settings/edit-or-delete-discount-code.md) that no discount component uses. Then try again. |
| Field required | The facility has not saved a discount configuration. [Set the discount configuration](https://docs.ohc.network/flows/billing/billing-settings/set-discount-configuration.md) first. Then create the code again. |
| You do not have permission to create Facilities | You do not hold the permission listed above in the right organization. Ask for a role that has it in the facility's root organization, Administration. |

![The Discount Codes list, with the new Staff Discount code marked Facility](/assets/images/create-discount-code-4-11786c93b77793f4f4d9319b8e16b9e1.webp)

## Expected Outcome

* Care shows the message "Discount code created successfully".
* The new code shows in the list with the badge **Facility**.
* When you create or edit a discount component, you can select the new code in **Discount Code**.

## Related

Concepts:

* [Billing settings](https://docs.ohc.network/concepts/billing/billing-settings.md)
* [Charge Item Definition](https://docs.ohc.network/concepts/definitions/charge-item-definition.md)

Flows:

* [Set the discount configuration](https://docs.ohc.network/flows/billing/billing-settings/set-discount-configuration.md)
* [Edit or delete a discount code](https://docs.ohc.network/flows/billing/billing-settings/edit-or-delete-discount-code.md)
* [Create a discount component](https://docs.ohc.network/flows/billing/billing-settings/create-discount-component.md)
* [Create a charge item definition](https://docs.ohc.network/flows/definitions/charge-item-definition/create-charge-item-definition.md)
