Add functionality to pass to the Banqup API the invoice line description as a comment instead of the product description
This commit is contained in:
parent
fbe55bb889
commit
825af6b8d2
|
@ -12,6 +12,8 @@ userpass_b64 = base64.b64encode((ob_user+':'+ob_pass).encode('ascii')).decode('a
|
|||
# 2) you may enter the user:password base64 encoded
|
||||
#userpass_b64 = "your-ob-user:your-ob-password-base64-encoded"
|
||||
|
||||
# You may use this one product as a 'comment' in order to print the invoice line description instead of the product description
|
||||
comment_product = 'Comment/Note'
|
||||
|
||||
# Banqup API parameters
|
||||
banqup_client_id = "73223"
|
||||
|
|
|
@ -67,7 +67,10 @@ def extract_invoice(document):
|
|||
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+'}'
|
||||
if product != comment_product:
|
||||
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+'}'
|
||||
else:
|
||||
lines_output = lines_output + '{"service_name": "'+product+'","service_description": "'+linetemp['description']+'","service_quantity": '+str(linetemp['invoicedQuantity'])+',"service_price": '+str(linetemp['unitPrice'])+',"service_vat": '+gst_rate+'}'
|
||||
lines_output = lines_output+']'
|
||||
#print(lines_output)
|
||||
|
||||
|
@ -80,7 +83,7 @@ def extract_invoice(document):
|
|||
"currency_code": invoice['response']['data'][0]['currency$_identifier'],
|
||||
"client_id": banqup_client_id,
|
||||
"delivery_channel": preferred_channel,
|
||||
"invoice_lines": json.loads(lines_output),
|
||||
"invoice_lines": json.loads(lines_output, strict=False),
|
||||
"po_number": "NA",
|
||||
"buyer_reference": "NA",
|
||||
"customer_reference": "NA",
|
||||
|
|
Loading…
Reference in a new issue