-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontabilizar.py
36 lines (30 loc) · 926 Bytes
/
contabilizar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import boto3
import logging
import os
import uuid
def main(event, context):
body = event["detail"]
logger = logging.getLogger()
logger.setLevel(logging.INFO)
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
table_name = os.environ['CONTABILIZACAO_TABLE']
table = dynamodb.Table(table_name)
return table.put_item(
Item={
'id': str(uuid.uuid4()),
'registros': [
{
"contaContabil": "1.0.0.0.01",
"valor": body["valor"],
"documento": body["numeroCartao"],
"natureza": "CREDITO"
},
{
"contaContabil": "2.0.0.0.01",
"valor": body["valor"],
"documento": body["numeroCartao"],
"natureza": "DEBITO"
}
]
}
)