-
Notifications
You must be signed in to change notification settings - Fork 0
/
3-InvoicesUpdateDocumentDetails.robot
82 lines (63 loc) · 3.16 KB
/
3-InvoicesUpdateDocumentDetails.robot
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
*** Settings ***
Documentation Lee las facturas de una carpeta o folder y las envia a docdigitizer y airtable
Library RPA.HTTP
Library RPA.core.notebook
Library RPA.JSON
Library RPA.FileSystem
Library OperatingSystem
Library String
Library Collections
Resource res_airtable.robot
Resource res_docdigitizer.robot
#Suite Setup Setup
#Suite Teardown Teardown
*** Tasks ***
Invoices Update Document Details in AirTable
${API_URL} Create Session Airtable
Create Session DocDigitizer
# Query the "In progress" invoices in AirTable
# Those invoices has been previously sent to DocDigitizer
#${resp} Get Request airtable ${INVOICES_API_URL}?maxRecords=100&filterByFormula=Status%3D"In progress"&sort%5B0%5D%5Bfield%5D=invoiceName
&{params}= Create Dictionary
... maxRecords=100
... filterByFormula=Status="In progress"
${resp} GET On Session airtable url=${API_URL} params=${params}
${jsondata}= set Variable ${resp.json()}
${jsondata}= To Json ${resp.content}
${invoices} Set Variable ${jsondata}[records]
Log ${invoices}
Log ${invoices}.length
${contador} Get Length ${invoices}
@{all_invoices}= Get values from JSON ${jsondata} $..invoiceName
Log Many ${all_invoices}
Log Many @{all_invoices}.length
${contador} Get Length ${all_invoices}
FOR ${invoice} IN @{invoices}
#[Tags] post
# Obtenemos el Attachment del registro de AirTable
# y lo enviamos a docDigitizer
Log ${invoice}
${idAirTable} Set Variable ${invoice}[id]
${task_id} Set Variable ${invoice}[fields][taskID]
Log ${task_id}
${resp}= GET On Session docdigitizer /api/v1/tasks/${task_id}
Log ${resp}
Log ${resp.json()}
# Aqui se intentaba leer el documento pero la mayor parte de las veces NO VIENE
# Asi qe hay que crear otro STEP que interrogue las facturas con task y sin documento y actualice Airtable
${respDocument} Set Variable ${resp.json()}[document]
Log ${respDocument}[id]
# No hace falta actualizar el estado puesto que el Update Airtable Record lo deja a Done
# ${jsonFilaAir} Set Variable {"records":[{\"id\": "${idAirTable}", \"fields\": {"Status": "In progress", "documentID": "${respDocument}[id]"}}\]\}
# Log ${jsonFilaAir}
# ${datos}= Convert String to JSON ${jsonFilaAir}
# Log Actualizar registro
#${resp}= Patch Request Airtable ${INVOICES_API_URL}/${idAirTable} json=${datos}
# ${resp}= PATCH On Session Airtable ${INVOICES_API_URL} json=${datos}
# Should Be Equal As Strings ${resp.status_code} 200
# ${jsondata}= To Json ${resp.content}
IF ${respDocument}[reviewed]
${invoice_data} Set Variable ${respDocument}[annotations][data]
Update Airtable Record ${idAirTable} ${invoice_data}
END
END