fix billing

This commit is contained in:
2025-08-27 22:17:33 -03:00
parent b3a4b48fe5
commit 83c97f409b
12 changed files with 129 additions and 45 deletions

View File

@@ -59,7 +59,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
if old_course:
enrollment['course'] = old_course
created_at: datetime = fromisoformat(enrollment['create_date']) # type: ignore
created_at: datetime = fromisoformat(enrollment['created_at']) # type: ignore
start_date, end_date = get_billing_period(
billing_day=new_image['billing_day'],
date_=created_at,
@@ -122,9 +122,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'user': pick(('id', 'name'), enrollment['user']),
'course': pick(('id', 'name'), enrollment['course']),
'unit_price': course['unit_price'],
# Post-migration: uncomment the following line
# 'enrolled_at': enrollment['created_at'],
'enrolled_at': enrollment['create_date'],
'enrolled_at': enrollment['created_at'],
'created_at': now_,
}
# Add author if present

View File

@@ -33,7 +33,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
+ SortKey('canceled', path_spec='author', rename_key='canceled_by')
)
created_at: datetime = fromisoformat(new_image['create_date']) # type: ignore
created_at: datetime = fromisoformat(new_image['created_at']) # type: ignore
start_date, end_date = get_billing_period(
billing_day=int(subscription['billing_day']),
date_=created_at,