> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dmly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Coupons and loyalty

> How percentage and fixed-amount coupons discount an invoice or an order, and how loyalty points turn into a reward coupon on their own.

A coupon is a discount you attach to an [invoice](/finance/invoices) or an
[order](/finance/orders). It is either a **Percentage** off or a **Fixed amount** off, and
DMLY checks it is still valid before it takes anything off the bill.

Loyalty sits on top of the same mechanism: your clients earn points for qualifying activity,
and when a client has enough points DMLY mints a coupon for them automatically. Every loyalty
reward is just a coupon — there is no second discount system to learn.

## What a coupon takes off

<Warning>
  A coupon applies to the **gross** total — the subtotal **plus tax**, not the subtotal alone.
  A 10% coupon on a bill of 100 plus 20 tax takes off 12, not 10. Percentage coupons are "%
  off the total", and that is more than you may expect when you price them.
</Warning>

A discount never takes off more than the client owes, so a large fixed-amount coupon on a
small bill simply clears the bill rather than producing a negative balance.

## The limits you can set

Each coupon carries its own rules, and all of them are checked at the moment it is applied:

| Rule              | What it does                                                                                                                                                                                                                                  |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Type              | **Percentage** or **Fixed amount**                                                                                                                                                                                                            |
| Minimum subtotal  | The bill has to reach this before the coupon is allowed. Despite the label, it is measured against the same gross total the discount comes off — subtotal plus tax — so a coupon with a minimum of 100 is allowed on a bill of 90 plus 10 tax |
| Usage limit       | How many times the coupon can be redeemed in total, across everyone                                                                                                                                                                           |
| Per-contact limit | How many times one client can redeem it                                                                                                                                                                                                       |
| Validity window   | The dates the coupon works between                                                                                                                                                                                                            |

Outside its window, below the minimum, or past a limit, the coupon is refused and the bill is
issued at full price.

<Note>
  Redemption is first-come. If two invoices try to claim the last remaining use at the same
  moment, one gets the discount and the other is issued without it. There is no queue and no
  error to catch — check the invoice total before you send it if a coupon was meant to apply.
</Note>

An automation can apply a code to an invoice that has already been posted, with the **Apply
Coupon** node. It does nothing if the invoice is void, already paid, or already carries a
coupon — and it fails quietly, so do not rely on it to rescue a bill that has moved on.

## How loyalty points become a coupon

<Steps>
  <Step title="A client earns points">
    You pick one **Earning method**, not both. **Earn per amount spent** scales points with
    the bill, and the field below is labelled *Points per unit spent*. **Earn per activity**
    gives a flat number of points per qualifying activity regardless of the amount, and the
    same field becomes *Points per activity*. The form defaults to **Earn per activity**, so
    out of the box points do not scale with spend.
  </Step>

  <Step title="They cross the threshold">
    **Points needed to redeem** is the balance a client has to reach. The setting describes
    itself plainly: *The number of points a client must reach before they can redeem a reward
    coupon.*
  </Step>

  <Step title="DMLY mints their coupon">
    As soon as the balance crosses the threshold, a coupon is created for that client and the
    threshold's worth of points is spent. The code carries a suffix unique to that client, so
    it belongs to them and cannot be passed around.
  </Step>
</Steps>

You do not issue the reward yourself and you do not need to watch for clients hitting the
threshold. Two qualifying purchases landing at once cannot mint two coupons or push a balance
below zero.

## When points are actually awarded

This trips people up, so it is worth being exact. The trigger is not fixed — under **Earning
conditions** you choose the status that earns for each kind of activity:

| Setting                           | Choices                | Default   |
| --------------------------------- | ---------------------- | --------- |
| Award points when order status is | Paid or Confirmed      | Paid      |
| Appointment status                | Completed or Confirmed | Completed |
| Class status                      | Attended or Booked     | Attended  |

Nothing is awarded unless the activity reaches the status you configured. On the defaults
that means:

* A **paid invoice** earns points when it is paid. If you switch orders to **Confirmed**, a
  paid invoice earns nothing.
* A **confirmed order** earns points in its own right, independently of any invoice.
* An **invoice for an appointment** is the exception. Its points are awarded when the
  [appointment is completed](/appointments/overview), not when the client pays. A client who
  pays up front and then no-shows earns nothing.
* A **[class](/appointments/classes) booking** earns too, when the booking is attended.

## Undoing a sale takes the points back

Three things claw back loyalty points: **voiding an invoice**, **refunding a payment** on a
paid invoice, and **cancelling a confirmed order**. That is deliberate — a sale that did not
happen should not leave a client closer to a free reward — so a client's balance can drop
after any of them.

The claw-back goes further than the points. It also deactivates one still-unredeemed loyalty
coupon for that client, so a reward minted from points you have just reversed stops working.
The one thing it will not touch is a coupon the client has **already redeemed** — reversing
that would corrupt a settled sale, so it is left alone.

<Tip>
  DMLY messages the code to the client automatically the moment a loyalty coupon is minted,
  on their active channel, and records it to the inbox — you do not need to pass it on
  yourself. Delivery is best-effort, though: if the channel send fails, the coupon still
  exists but the client never heard about it. That is when you would tell them on
  [WhatsApp](/channels/whatsapp) yourself. Either way it is an ordinary coupon and will be
  honoured on their next bill as long as it is still inside its window.
</Tip>

## Related

<Columns cols={2}>
  <Card title="Invoices" icon="file-invoice" href="/finance/invoices">
    Where a coupon is applied and what it changes on the bill.
  </Card>

  <Card title="Finance settings" icon="gear" href="/finance/settings">
    Currency, due days, numbering and tax defaults.
  </Card>

  <Card title="Client profile" icon="user" href="/contacts/client-profile">
    A client's spend, statement balance and history.
  </Card>

  <Card title="Finance overview" icon="receipt" href="/finance/overview">
    How invoices, orders, subscriptions and payments fit together.
  </Card>
</Columns>
