31 lines
4 KiB
Markdown
31 lines
4 KiB
Markdown
# Coupon administration and global authoring
|
|
|
|
Scope: regional admin coupon CRUD/user targeting/product targeting, superadmin global coupon CRUD and form serialization. Regional coupons have region ID; global coupons have null region and are authored only by superadmin.
|
|
|
|
Product targeting model: a coupon's target SKUs live **only** in its own `sku_ids` JSON array on the coupon row (no join table, no relation). An empty/null array means the coupon applies to the whole cart. `reserved_coupons.sku_ids` is the same field for reserved codes and is copied onto the coupon a customer redeems. Targets are validated in-region on write (a global SKU may be attached anywhere).
|
|
|
|
| ID | Priority | Action / input | Expected result |
|
|
|---|---|---|---|
|
|
| CPM-01 | P0 | Admin A creates general percentage coupon. | A-scoped coupon with exact code/limits/cap; A eligible path works. |
|
|
| CPM-02 | P1 | Create flat coupon and edit all supported fields. | Correct persisted discount type/expiry/min/limit/exclusive values. |
|
|
| CPM-03 | P0 | Superadmin creates global coupon. | Null region; usable across regions subject to user/product rules. |
|
|
| CPM-04 | P0 | Regional admin attempts null-region/global creation or edit. | Cannot author/change global coupon through any endpoint. |
|
|
| CPM-05 | P1 | Auto-generated code vs multiple explicit codes. | Intended unique count; deterministic code normalization and collisions. |
|
|
| CPM-06 | P1 | Both/neither discount type, negative values, percentage >100. | Business/schema constraints; no negative unintended promotion. |
|
|
| CPM-07 | P1 | Empty/space/case-variant/duplicate code. | Approved normalization and uniqueness; no accidental empty code. |
|
|
| CPM-08 | P0 | User-only coupon for U1 vs all-users flag. | Eligibility/applicability reflects exact intended scope. |
|
|
| CPM-09 | P1 | Missing/nonexistent/duplicate user IDs. | Validation/deduplication; no orphan applicable-user rows. |
|
|
| CPM-10 | P0 | Target A SKU and global SKU; try B regional SKU in A coupon. | Valid targets persisted in A's `sku_ids`; foreign regional target denied. |
|
|
| CPM-11 | P1 | Empty targets vs populated targets (admin form, API, redeemed reserved code). | Empty => whole cart; populated => only those SKUs discounted. No other target store exists to drift from. |
|
|
| CPM-12 | P1 | Replace/remove all product targets on edit. | Array replaced/cleared as intended; cleared means whole cart. |
|
|
| CPM-13 | P1 | Null/zero maxValue/minOrder/max-user-limit. | Defined unlimited/zero behavior; omission differs from explicit clearing. |
|
|
| CPM-14 | P1 | Expiry past/now/future, invalid date/timezone boundary. | Valid serialization and eligibility deadline. |
|
|
| CPM-15 | P0 | B admin reads/edits/invalidates A coupon ID. | Foreign access denied; coupon unchanged. |
|
|
| CPM-16 | P1 | Invalidate used coupon then inspect old order. | New spend blocked; persisted historical discount unchanged. |
|
|
| CPM-17 | P1 | Multi-code batch has later duplicate/invalid code. | Agreed atomic batch behavior; any committed subset explicitly reported, not hidden partial failure. |
|
|
| CPM-18 | P1 | Concurrent duplicate creation/save failure mid-relations. | One coherent coupon; no duplicate/orphan target rows. |
|
|
| CPM-19 | P1 | Global coupon creator has no staff-user row. | Supported author metadata persists without FK error; audit policy explicit. |
|
|
| CPM-20 | P2 | Product picker with same names, global badges and edit hydration. | Correct SKU IDs retained in `sku_ids`; selection shown on the coupon card and reconstructed on edit. |
|
|
| CPM-21 | P0 | Edit a percentage coupon to a flat discount, save, and use it; repeat the reverse switch. Test once as a regional admin and once as superadmin on a global coupon. | The opposite discount field is cleared; only the new discount type is stored and applied. Merely sending one field must not preserve the old percentage/flat value. |
|
|
|
|
Policy checkpoint: global coupons targeting regional-only products and audit attribution for superadmin creation. Do not assume an unimplemented global-coupon UI exists: API cases remain applicable.
|