add cancel schedule

This commit is contained in:
2025-12-15 16:38:40 -03:00
parent 2774545d09
commit 62b5340b20
11 changed files with 238 additions and 85 deletions

View File

@@ -62,14 +62,14 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
enrollment['course'] = old_course
created_at: datetime = fromisoformat(enrollment['created_at']) # type: ignore
start_date, end_date = get_billing_period(
start_period, end_period = get_billing_period(
billing_day=new_image['billing_day'],
date_=created_at,
)
pk = 'BILLING#ORG#{org_id}'.format(org_id=org_id)
sk = 'START#{start}#END#{end}'.format(
start=start_date.isoformat(),
end=end_date.isoformat(),
start=start_period.isoformat(),
end=end_period.isoformat(),
)
logger.info('Enrollment found', data=enrollment)
@@ -91,7 +91,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'id': pk,
'sk': f'{sk}#SCHEDULE#AUTO_CLOSE',
'ttl': ttl(
start_dt=datetime.combine(end_date, time()) + timedelta(days=1)
start_dt=datetime.combine(end_period, time())
+ timedelta(days=1)
),
'created_at': now_,
}