# 1. Discount Code Management

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

---

## 1. Discount Code Management

### 1.1 Create, Edit, and Deactivate Discount Codes
**What it does:** Manages the discount codes: the Super Administrator creates the discount codes (the code, the discount, the scope), edits them (the discount value, the scope, the limits), and deactivates them (the code stops working) so the discounts are controlled and the codes are explicit. Each code has a unique identifier (the code string), the discount (the percentage or the fixed amount), and the scope (what the code applies to).

**Sub-features:**
- Code creation: the code (the string, the discount, the scope)
- Code editing: the edit (the discount value, the scope, the limits)
- Code deactivation: the deactivation (the code stops working)
- Code uniqueness: the uniqueness (the code is unique)
- Code scope: the scope (the code applies to the items, the plans, the courses)
- Code status: the status (the active, the deactivated, the expired)
- Audit logging of the code creation, editing, and deactivation

**Super Administrator User Journey:**
1. Super Admin creates the discount code: the code string (e.g., WELCOME20), the discount (the percentage or the fixed amount), and the scope (the items, the plans, the courses); the code is explicit.
2. Sets the code uniqueness: the code is unique (the code is not used by another code); the uniqueness is enforced.
3. Sets the code scope: the scope (the code applies to the items, the plans, the courses); the scope is the application.
4. Saves; the code is live (the status is active), and the code can be redeemed.
5. For an edit (the discount value, the scope, the limits), Super Admin edits the code (the new value, the new scope, the new limits); the edit is recorded.
6. For a deactivation (the code stops working), Super Admin deactivates the code (the status is deactivated); the deactivation is recorded.
7. Reviews the codes: the codes, the discounts, the scopes, the statuses, so the discount codes are visible.
8. The code creation, editing, and deactivation are audit-logged with the code, the discount, and the timestamp.

**Rules & Edge Cases:**
- The code is unique (the code string is not used by another code); the uniqueness is enforced.
- The code scope is the application (the items, the plans, the courses); the scope is the control.
- The code status is the active, the deactivated, or the expired; the status is the control.
- A code edit (the discount value, the scope, the limits) is recorded (the new value, the new scope, the new limits); it is auditable.
- A code deactivation (the code stops working) is recorded (the status is deactivated); it is auditable.
- Code creation, editing, and deactivation are audit-logged with the code, discount, and timestamp.

### 1.2 Percentage and Fixed-Amount Discounts
**What it does:** Sets the discount types: the discount is either a percentage (e.g., 20% off) or a fixed amount (e.g., 500 off), so the discount is explicit (the type and the value). The Super Administrator defines the discount type and value (the type, the value) so the discount is structured and the value is explicit.

**Sub-features:**
- Discount type: the type (the percentage, the fixed amount)
- Discount value: the value (the percentage, e.g., 20%, or the fixed amount, e.g., 500)
- Discount scope: the scope (the discount applies to the items, the plans, the courses)
- Discount definition: the discount defined by the Super Admin (the type, the value, the scope)
- Discount application: the discount applied (the discount is applied to the price)
- Discount record: the discount recorded (the code, the type, the value, the scope)
- Audit logging of the discount definition and the applications

**Super Administrator User Journey:**
1. Super Admin defines the discount: the type (the percentage, the fixed amount), the value (the percentage, e.g., 20%, or the fixed amount, e.g., 500), and the scope (the items, the plans, the courses); the discount is explicit.
2. Sets the discount type: the type (the percentage, the fixed amount); the type is the discount.
3. Sets the discount value: the value (the percentage, e.g., 20%, or the fixed amount, e.g., 500); the value is the amount.
4. Saves; the discount is live, and the discount is applied to the price.
5. A learner redeems the code; the discount is applied (the discount is applied to the price, the total is reduced); the discount is the value.
6. The discount is recorded: the code, the type, the value, and the scope; the record is the proof.
7. For a discount change (the type, the value, the scope updated), Super Admin changes the discount (the new type, the new value, the new scope, the time); the change is recorded.
8. The discount definition and the applications are audit-logged with the code, the type, and the timestamp.

**Rules & Edge Cases:**
- The discount type is the percentage or the fixed amount; the type is the discount.
- The discount value is the amount (the percentage, e.g., 20%, or the fixed amount, e.g., 500); the value is the basis.
- The discount scope is the application (the items, the plans, the courses); the scope is the control.
- A discount change (the type, the value, the scope updated) is recorded (the new type, the new value, the new scope, the time); it is auditable.
- The discounts are visible (the codes, the types, the values, the scopes); the discount types are managed.
- Discount definition and applications are audit-logged with the code, type, and timestamp.

### 1.3 Usage Limits (Per User, Total Uses)
**What it does:** Sets the usage limits: the limits on the code usage (the per-user limit, the total-uses limit) are set, so the code is used within the limits (the code is not overused). The Super Administrator defines the usage limits (the per-user limit, the total-uses limit) so the usage is controlled and the limits are explicit.

**Sub-features:**
- Per-user limit: the limit (the number of times a user can use the code)
- Total-uses limit: the limit (the total number of times the code can be used)
- Limit scope: the scope (the code, the limits)
- Limit definition: the limits defined by the Super Admin (the per-user limit, the total-uses limit)
- Limit enforcement: the limits enforced (the code is not used beyond the limits)
- Limit record: the limits recorded (the code, the per-user limit, the total-uses limit, the uses)
- Audit logging of the limit definition and the enforcement

**Super Administrator User Journey:**
1. Super Admin defines the usage limits: the per-user limit (the number of times a user can use the code) and the total-uses limit (the total number of times the code can be used); the limits are explicit.
2. Sets the per-user limit: the limit (the number of times a user can use the code); the limit is the per-user control.
3. Sets the total-uses limit: the limit (the total number of times the code can be used); the limit is the total control.
4. Saves; the usage limits are live, and the code is used within the limits.
5. A learner redeems the code; the limits are enforced (the per-user limit, the total-uses limit); the code is used within the limits.
6. The limits are recorded: the code, the per-user limit, the total-uses limit, and the uses; the record is the proof.
7. For a limit change (the per-user limit, the total-uses limit updated), Super Admin changes the limits (the new per-user limit, the new total-uses limit, the time); the change is recorded.
8. The limit definition and the enforcement are audit-logged with the code, the limits, and the timestamp.

**Rules & Edge Cases:**
- The per-user limit is the per-user control (the number of times a user can use the code); the limit is the control.
- The total-uses limit is the total control (the total number of times the code can be used); the limit is the control.
- The limit scope is the code and the limits; the scope is the control.
- A limit change (the per-user limit, the total-uses limit updated) is recorded (the new per-user limit, the new total-uses limit, the time); it is auditable.
- The usage limits are visible (the codes, the per-user limits, the total-uses limits, the uses); the usage is managed.
- Limit definition and enforcement are audit-logged with the code, limits, and timestamp.

### 1.4 Validity Periods
**What it does:** Sets the validity periods: the validity of the code (the start date, the end date) is set, so the code is valid within the period (the code is not used outside the period). The Super Administrator defines the validity periods (the start date, the end date) so the validity is controlled and the period is explicit.

**Sub-features:**
- Start date: the date (the date the code becomes valid)
- End date: the date (the date the code expires)
- Validity scope: the scope (the code, the period)
- Validity definition: the validity defined by the Super Admin (the start date, the end date)
- Validity enforcement: the validity enforced (the code is not used outside the period)
- Validity record: the validity recorded (the code, the start date, the end date, the status)
- Audit logging of the validity definition and the enforcement

**Super Administrator User Journey:**
1. Super Admin defines the validity period: the start date (the date the code becomes valid) and the end date (the date the code expires); the period is explicit.
2. Sets the start date: the date (the date the code becomes valid); the date is the start.
3. Sets the end date: the date (the date the code expires); the date is the end.
4. Saves; the validity period is live, and the code is valid within the period.
5. A learner redeems the code; the validity is enforced (the code is valid within the period, the code is not used outside the period); the validity is the control.
6. The validity is recorded: the code, the start date, the end date, and the status; the record is the proof.
7. For a validity change (the start date, the end date updated), Super Admin changes the validity (the new start date, the new end date, the time); the change is recorded.
8. The validity definition and the enforcement are audit-logged with the code, the period, and the timestamp.

**Rules & Edge Cases:**
- The start date is the start (the date the code becomes valid); the date is the control.
- The end date is the end (the date the code expires); the date is the control.
- The validity scope is the code and the period; the scope is the control.
- A validity change (the start date, the end date updated) is recorded (the new start date, the new end date, the time); it is auditable.
- The validity periods are visible (the codes, the start dates, the end dates, the statuses); the validity is managed.
- Validity definition and enforcement are audit-logged with the code, period, and timestamp.
