add billing
This commit is contained in:
@@ -56,7 +56,7 @@ class DeduplicationWindow(BaseModel):
|
||||
offset_days: int
|
||||
|
||||
|
||||
class SubscriptionTerms(BaseModel):
|
||||
class Subscription(BaseModel):
|
||||
billing_day: int
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ def enroll(
|
||||
)
|
||||
+ KeyPair(
|
||||
pk=str(org_id),
|
||||
sk='METADATA#SUBSCRIPTION_TERMS',
|
||||
rename_key='terms',
|
||||
sk='METADATA#SUBSCRIPTION',
|
||||
rename_key='subscription',
|
||||
table_name=USER_TABLE,
|
||||
)
|
||||
+ KeyPair(
|
||||
@@ -106,7 +106,7 @@ def enroll(
|
||||
ctx = {
|
||||
'org': Org.model_validate(org),
|
||||
'created_by': created_by,
|
||||
'terms': SubscriptionTerms.model_validate(org['terms']),
|
||||
'subscription': Subscription.model_validate(org['subscription']),
|
||||
}
|
||||
|
||||
immediate = [e for e in enrollments if not e.scheduled_for]
|
||||
@@ -150,7 +150,7 @@ Context = TypedDict(
|
||||
'Context',
|
||||
{
|
||||
'org': Org,
|
||||
'terms': SubscriptionTerms,
|
||||
'subscription': Subscription,
|
||||
'created_by': Authenticated,
|
||||
},
|
||||
)
|
||||
@@ -161,7 +161,7 @@ def enroll_now(enrollment: Enrollment, context: Context):
|
||||
user = enrollment.user
|
||||
course = enrollment.course
|
||||
org: Org = context['org']
|
||||
subscription_terms: SubscriptionTerms = context['terms']
|
||||
subscription: Subscription = context['subscription']
|
||||
created_by: Authenticated = context['created_by']
|
||||
lock_hash = md5_hash(f'{user.id}{course.id}')
|
||||
access_expires_at = now_ + timedelta(days=course.access_period)
|
||||
@@ -213,7 +213,7 @@ def enroll_now(enrollment: Enrollment, context: Context):
|
||||
'id': enrollment.id,
|
||||
'sk': 'METADATA#SUBSCRIPTION_COVERED',
|
||||
'org_id': org.id,
|
||||
'billing_day': subscription_terms.billing_day,
|
||||
'billing_day': subscription.billing_day,
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
@@ -270,7 +270,7 @@ def enroll_later(enrollment: Enrollment, context: Context):
|
||||
scheduled_for = date_to_midnight(enrollment.scheduled_for) # type: ignore
|
||||
deduplication_window = enrollment.deduplication_window
|
||||
org: Org = context['org']
|
||||
subscription_terms: SubscriptionTerms = context['terms']
|
||||
subscription: Subscription = context['subscription']
|
||||
created_by: Authenticated = context['created_by']
|
||||
lock_hash = md5_hash(f'{user.id}{course.id}')
|
||||
|
||||
@@ -289,7 +289,7 @@ def enroll_later(enrollment: Enrollment, context: Context):
|
||||
'id': created_by.id,
|
||||
'name': created_by.name,
|
||||
},
|
||||
'subscription_billing_day': subscription_terms.billing_day,
|
||||
'subscription_billing_day': subscription.billing_day,
|
||||
'ttl': ttl(start_dt=scheduled_for),
|
||||
'created_at': now_,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user