close bolling

This commit is contained in:
2025-07-27 20:57:41 -03:00
parent 68a187220c
commit cc28e16c29
11 changed files with 365 additions and 21 deletions

View File

@@ -6,7 +6,7 @@ from aws_lambda_powertools.utilities.data_classes import (
event_source,
)
from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dateutils import now, ttl
from layercake.dateutils import fromisoformat, now, ttl
from layercake.dynamodb import (
DynamoDBPersistenceLayer,
KeyPair,
@@ -35,12 +35,17 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
data = enrollment_layer.collection.get_items(
TransactKey(enrollment_id) + SortKey('0') + SortKey('author')
)
created_at: datetime = fromisoformat(data['create_date']) # type: ignore
if not data:
logger.debug('Enrollment not found')
return False
start_date, end_date = get_billing_period(new_image['billing_day'])
start_date, end_date = get_billing_period(
new_image['billing_day'],
year=created_at.year,
month=created_at.month,
)
pk = 'BILLING#ORG#{org_id}'.format(org_id=org_id)
sk = 'START#{start}#END#{end}'.format(
start=start_date.isoformat(),