Changes between Version 2 and Version 3 of PurchasingSubscription
- Timestamp:
- 01/22/26 02:50:30 (16 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PurchasingSubscription
v2 v3 3 3 ==== Actors: **Registered User (USER)** 4 4 5 **1.** The user selects a subscription plan.5 **1.** Display Available Subscription Plans. 6 6 7 **2.** The system creates an active subscription. 7 {{{#!sql 8 SELECT plan_id, name, price, duration_months, description 9 FROM subscription_plan; 8 10 9 **3.** The payment is recorded. 11 }}} 12 13 **2.** Check for an Active Subscription. 14 15 16 {{{#!sql 17 SELECT * 18 FROM user_subscription 19 WHERE user_id = :userId 20 AND status = 'ACTIVE' 21 AND end_date >= CURRENT_DATE; 22 23 }}} 24 25 **3.** Create a New Subscription. 10 26 11 27 12 28 {{{#!sql 13 29 INSERT INTO user_subscription (user_id, plan_id, start_date, end_date, status) 14 VALUES (1, 2, CURRENT_DATE, CURRENT_DATE + INTERVAL '6 months', 'ACTIVE'); 15 16 INSERT INTO payment (user_id, subscription_id, amount) 17 VALUES (1, 1, 49.99); 18 30 VALUES ( 31 :userId, 32 :planId, 33 CURRENT_DATE, 34 CURRENT_DATE + 35 (SELECT duration_months 36 FROM subscription_plan 37 WHERE plan_id = :planId) * INTERVAL '1 month', 38 'ACTIVE' 39 ); 19 40 20 41 }}} 42 43 **4.** Record the Payment. 44 45 {{{#!sql 46 INSERT INTO payment (user_id, subscription_id, amount) 47 VALUES ( 48 :userId, 49 currval('user_subscription_subscription_id_seq'), 50 :amount 51 ); 52 53 }}}
