diff --git a/README.md b/README.md index ae6b475..17a813a 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ to the Banqup API of Unifiedpost. **Requirements** * Python installed on the machine running this application * Credentials for accessing an Openbravo 3+ instance running with the REST API enabled +* The role in Openbravo used for the extraction/integration must have read access to 'Sales Invoices' and 'Product' via web services. * Credentials for accessing the Banqup API by Unifiedpost * Add the businessPartner id to the 'Customer code' of the customer on the 'Customers & Suppliers' section of the Banqup portal - This is critical, this programs requires this field to extract some parameters that only exist in the Banqup platform diff --git a/extract_invoice.py b/extract_invoice.py index bcebdcb..1a42fe0 100644 --- a/extract_invoice.py +++ b/extract_invoice.py @@ -64,7 +64,10 @@ def extract_invoice(document): if not first_line: lines_output = lines_output+',' first_line = False - lines_output = lines_output + '{"service_name": "","service_description": "'+linetemp['product$_identifier']+'","service_quantity": '+str(linetemp['invoicedQuantity'])+',"service_price": '+str(linetemp['unitPrice'])+',"service_vat": '+gst_rate+'}' + url = ob_api_url+"Product?_where=id='"+linetemp['product']+"'&_noActiveFilter=false" + response = requests.request("GET", url, headers=headers, data=payload) #extracts product from master + product = json.loads(response.text)['response']['data'][0]['searchKey'] + lines_output = lines_output + '{"service_name": "'+product+'","service_description": "'+linetemp['product$_identifier']+'","service_quantity": '+str(linetemp['invoicedQuantity'])+',"service_price": '+str(linetemp['unitPrice'])+',"service_vat": '+gst_rate+'}' lines_output = lines_output+']' #print(lines_output)