# Edit or delete a discount code

## Overview

[Video: Edit or delete a discount code](https://www.youtube.com/watch?v=G9MLwlU9IjE)

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

You can change only the discount codes of the facility, marked **Facility**. The discount codes of the deployment, marked **Instance**, have no edit or delete buttons.

## 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 its own discount code, marked **Facility** in the list. See [Create a discount code](https://docs.ohc.network/flows/billing/billing-settings/create-discount-code.md).
* 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.
* If you want to delete the code or change its **Code**, no discount component uses the code. If one does, change or delete that discount component 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 facility sidebar, with Settings outlined under Administration](/assets/images/edit-or-delete-discount-code-1-9fd35be0b8e26d50957e3b617117a6fc.webp)

### 2. Find the discount code

To filter the list, type a name or a code in **Search**.

Find the row of the discount code. Only the rows marked **Facility** have the edit and delete buttons.

![The Discount Codes list, with the facility code Festival Offer outlined and its pencil and trash icons](/assets/images/edit-or-delete-discount-code-2-137c91c9b9e59b49c0617e1d39be0e8e.webp)

### 3. Change the discount code

Follow this step to change the name or the code. To delete the code, go to step 4.

On the row of the code, select the pencil icon.

Care opens the **Edit Discount Code** form with the current values.

Change the **Name**, the **Code**, or both.

Select **Save**.

Note: **Save** stays disabled until you change a field.

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

If Care refuses the save, your changes are lost. Open the form again. Make the changes again.

If Care shows an error message, use this table.

| If the message contains | What to do |
| - | - |
| All monetary components code must be defined. | A discount component uses the old code. Keep the old code. Or, [change or delete those discount components](https://docs.ohc.network/flows/billing/billing-settings/edit-or-delete-discount-component.md) first. |
| 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. |
| 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 change 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 Edit Discount Code sheet, with the name changed to Festival Discount](/assets/images/edit-or-delete-discount-code-3-ce32ae63da83443f48ba3d6be5b6e690.webp)

### 4. Delete the discount code

Follow this step to delete the code.

On the row of the code, select the trash icon.

Care shows the **Confirm Delete** dialog with the message "Are you sure you want to delete this discount code? This action cannot be undone."

Select **Confirm**.

To keep the code, select **Cancel**.

If a discount component uses the code, Care refuses the delete. Care shows a message that contains "All monetary components code must be defined."

In that case, [change or delete those discount components](https://docs.ohc.network/flows/billing/billing-settings/edit-or-delete-discount-component.md) first. Then delete the code again.

![The Confirm Delete dialog for the discount code, with the Cancel and Confirm buttons](/assets/images/edit-or-delete-discount-code-4-47d8126bce155e58eeafed98eb1445d4.webp)

![The Discount Codes list after the delete, with only the deployment codes marked Instance](/assets/images/edit-or-delete-discount-code-5-24908c6d703cb6aa336a42e09b9f51ac.webp)

## Expected Outcome

* After you save a change, Care shows the message "Discount code updated successfully".
* After you delete a code, Care shows the message "Discount code deleted successfully".
* The list shows the changed code, or no longer shows the deleted code.
* You cannot undo a delete.

## Related

Concepts:

* [Billing settings](https://docs.ohc.network/concepts/billing/billing-settings.md)

Flows:

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