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:
Enrique Barcelli 2023-12-07 17:45:10 +08:00
parent fbe55bb889
commit 825af6b8d2
Signed by: kikobar
GPG key ID: 006C13A68E25D3B7
2 changed files with 7 additions and 2 deletions

View file

@ -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 # 2) you may enter the user:password base64 encoded
#userpass_b64 = "your-ob-user:your-ob-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 API parameters
banqup_client_id = "73223" banqup_client_id = "73223"

View file

@ -67,7 +67,10 @@ def extract_invoice(document):
url = ob_api_url+"Product?_where=id='"+linetemp['product']+"'&_noActiveFilter=false" url = ob_api_url+"Product?_where=id='"+linetemp['product']+"'&_noActiveFilter=false"
response = requests.request("GET", url, headers=headers, data=payload) #extracts product from master response = requests.request("GET", url, headers=headers, data=payload) #extracts product from master
product = json.loads(response.text)['response']['data'][0]['searchKey'] 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+']' lines_output = lines_output+']'
#print(lines_output) #print(lines_output)
@ -80,7 +83,7 @@ def extract_invoice(document):
"currency_code": invoice['response']['data'][0]['currency$_identifier'], "currency_code": invoice['response']['data'][0]['currency$_identifier'],
"client_id": banqup_client_id, "client_id": banqup_client_id,
"delivery_channel": preferred_channel, "delivery_channel": preferred_channel,
"invoice_lines": json.loads(lines_output), "invoice_lines": json.loads(lines_output, strict=False),
"po_number": "NA", "po_number": "NA",
"buyer_reference": "NA", "buyer_reference": "NA",
"customer_reference": "NA", "customer_reference": "NA",