add billing period

This commit is contained in:
2025-08-21 13:32:44 -03:00
parent 6c301d320b
commit c70a74b94a
14 changed files with 282 additions and 98 deletions

View File

@@ -23,13 +23,13 @@ enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
new_image = event.detail['new_image']
now_ = now()
data = user_layer.get_item(
terms = user_layer.get_item(
# Post-migration: uncomment the following line
# KeyPair(new_image['org_id'], 'METADATA#BILLING_TERMS'),
KeyPair(new_image['tenant_id'], 'metadata#billing_policy'),
)
if not data:
if not terms:
return False
try:
@@ -49,8 +49,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'id': new_image['id'],
'sk': 'METADATA#SUBSCRIPTION_COVERED',
'org_id': new_image['tenant_id'],
'billing_day': data['billing_day'],
'created_at': now(),
'billing_day': terms['billing_day'],
'created_at': now_,
},
cond_expr='attribute_not_exists(sk)',
)