Changes between Version 2 and Version 3 of PurchasingSubscription


Ignore:
Timestamp:
01/22/26 02:50:30 (16 hours ago)
Author:
221296
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PurchasingSubscription

    v2 v3  
    33==== Actors: **Registered User (USER)**
    44
    5 **1.** The user selects a subscription plan.
     5**1.** Display Available Subscription Plans.
    66
    7 **2.** The system creates an active subscription.
     7{{{#!sql
     8SELECT plan_id, name, price, duration_months, description
     9FROM subscription_plan;
    810
    9 **3.** The payment is recorded.
     11}}}
     12
     13**2.** Check for an Active Subscription.
     14
     15
     16{{{#!sql
     17SELECT *
     18FROM user_subscription
     19WHERE user_id = :userId
     20  AND status = 'ACTIVE'
     21  AND end_date >= CURRENT_DATE;
     22
     23}}}
     24
     25**3.** Create a New Subscription.
    1026
    1127
    1228{{{#!sql
    1329INSERT 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 
     30VALUES (
     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);
    1940
    2041}}}
     42
     43**4.** Record the Payment.
     44
     45{{{#!sql
     46INSERT INTO payment (user_id, subscription_id, amount)
     47VALUES (
     48    :userId,
     49    currval('user_subscription_subscription_id_seq'),
     50    :amount
     51);
     52
     53}}}