# 4. Affiliate Discount Codes

User Type: **Super Administrator**
Source: *Mi Digital Academy - Education CRM Features Document*

---

## 4. Affiliate Discount Codes

### 4.1 Permit Affiliates to Create Discount Codes (If Permitted)
**What it does:** Permits the affiliates to create the discount codes: the Super Administrator permits (or does not permit) the affiliates to create their own discount codes (the code, the discount, the scope), so the affiliate codes are controlled (the affiliates create the codes within the limits). The Super Administrator configures the affiliate code permission (the permission, the limits, the scope) so the affiliate codes are structured and the permission is explicit.

**Sub-features:**
- Affiliate permission: the permission (the affiliates can create the codes, or not)
- Affiliate limits: the limits (the number of codes, the discount value, the scope)
- Affiliate scope: the scope (the codes, the items, the plans)
- Permission definition: the permission defined by the Super Admin (the permission, the limits, the scope)
- Code creation: the code created (the affiliate creates the code within the limits)
- Code record: the code recorded (the affiliate, the code, the discount, the scope)
- Audit logging of the permission definition and the code creation

**Super Administrator User Journey:**
1. Super Admin configures the affiliate code permission: the permission (the affiliates can create the codes, or not), the limits (the number of codes, the discount value, the scope), and the scope (the codes, the items, the plans); the permission is explicit.
2. Sets the affiliate permission: the permission (the affiliates can create the codes, or not); the permission is the control.
3. Sets the affiliate limits: the limits (the number of codes, the discount value, the scope); the limits are the boundaries.
4. Sets the affiliate scope: the scope (the codes, the items, the plans); the scope is the application.
5. Saves; the affiliate code permission is live, and the affiliates create the codes within the limits.
6. An affiliate creates a code (the code, the discount, the scope); the code is created within the limits (the permission is enforced); the code is recorded.
7. For a permission change (the permission, the limits, the scope updated), Super Admin changes the permission (the new permission, the new limits, the new scope); the change is recorded.
8. The permission definition and the code creation are audit-logged with the affiliate, the code, and the timestamp.

**Rules & Edge Cases:**
- The affiliate permission is the control (the affiliates can create the codes, or not); the permission is the gate.
- The affiliate limits are the boundaries (the number of codes, the discount value, the scope); the limits are the control.
- The affiliate scope is the application (the codes, the items, the plans); the scope is the control.
- A permission change (the permission, the limits, the scope updated) is recorded (the new permission, the new limits, the new scope); it is auditable.
- The affiliate codes are visible (the affiliates, the codes, the discounts, the scopes); the affiliate codes are managed.
- Permission definition and code creation are audit-logged with the affiliate, code, and timestamp.

### 4.2 Track Affiliate Code Usage
**What it does:** Tracks the affiliate code usage: the usage of the affiliate codes (the redemptions, the revenue, the affiliate) is tracked, so the affiliate codes are visible (the usage is recorded). The Super Administrator views the affiliate code usage (the code, the redemptions, the revenue, the affiliate) so the tracking is structured and the usage is explicit.

**Sub-features:**
- Usage tracking: the tracking (the code, the redemptions, the revenue, the affiliate)
- Usage scope: the scope (the affiliate, the codes)
- Redemption tracking: the redemptions (the number of redemptions per code)
- Revenue tracking: the revenue (the revenue per code, per affiliate)
- Usage view: the view (the usage per code, per affiliate)
- Usage record: the usage recorded (the affiliate, the code, the redemptions, the revenue)
- Audit logging of the usage tracking

**Super Administrator User Journey:**
1. Super Admin views the affiliate code usage: the codes (the affiliate codes), the redemptions (the number of redemptions per code), the revenue (the revenue per code), and the affiliates (the affiliate per code); the usage is explicit.
2. Sets the usage scope: the scope (the affiliate, the codes); the scope is the tracking.
3. Views the redemption tracking: the redemptions (the number of redemptions per code); the redemptions are the count.
4. Views the revenue tracking: the revenue (the revenue per code, per affiliate); the revenue is the value.
5. The usage is visible: the usage per code, per affiliate, so the tracking is complete.
6. For a code (a specific affiliate code), Super Admin views the code's usage (the redemptions, the revenue, the period); the usage is the detail.
7. Exports the usage (the usage report, the period); the export is the record.
8. The usage tracking is audit-logged with the affiliate, the code, and the timestamp.

**Rules & Edge Cases:**
- The usage tracking is explicit (the code, the redemptions, the revenue, the affiliate); the tracking is the visibility.
- The usage scope is the affiliate and the codes; the scope is the control.
- The redemption tracking is the count (the number of redemptions per code); the redemptions are the metric.
- The revenue tracking is the value (the revenue per code, per affiliate); the revenue is the metric.
- The usage is visible (the usage per code, per affiliate); the tracking is managed.
- Usage tracking is audit-logged with the affiliate, code, and timestamp.
