---
# System prepended metadata

title: Coupon exceptions

---

# Coupon exceptions

List of extra filtering exceptions that are needed

## 1. first 4 months after register

Needed data from backend userRegisterDate
graphQL coupons have field exceptions

examples of exception content:

```
{
  "type": "start",
  "show": 0,
  "hide": 4,
  "unit": 'weeks'
}
```

```
{
  "type": "start",
  "show": 4,
  "hide": 6,
  "unit": 'weeks'
}
```

```
{
  "type": "start",
  "show": 6,
  "hide": 8,
  "unit": 'weeks'
}
```

---

## 2. Birthday coupon

examples of exception content:

```
{
  "type": "birthday",
  "show": -1,
  "hide": 1,
  "unit": 'days'
}

```

---

## Pseudocoded

```
userRegister = new Date(user.registerdate)
userBirthday = new Date(user.birthdate)
today = new Date()

if coupon.exceptions != null

    if exception.type = 'birthday'
        compareDate = userBirthday
    else
        compareDate = userRegister

        start = new Date(compareDate + exception.show * exception.unit)
        end = new Date(compareDate + exception.hide * exception.unit)

        if today >= start && today <= end
            show coupon
        else
            hide coupon
    
    
    
```


---

Otherwise logic is the same as in rest of the coupons:
- coupon can be used only once
