-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add funtionality to SEND invoice to customer
- Loading branch information
Showing
2 changed files
with
52 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import requests | ||
from requests_oauthlib import OAuth2Session | ||
import json | ||
import sys | ||
import webbrowser | ||
from config import * | ||
from cachehandler import CacheHandler | ||
from authhandler import AuthHandler | ||
from api import OpenbravoToBanqupAPI | ||
from datetime import timedelta, date | ||
|
||
def send_invoice(document): | ||
|
||
api = OpenbravoToBanqupAPI(bq_client_id,bq_client_secret) | ||
authUrl = api.authHandler.getAuthURL(bq_redirect_uri) | ||
webbrowser.open(authUrl) | ||
response = input('Paste response: ') | ||
token = api.authHandler.retrieveToken(response, redirectUri=bq_redirect_uri) | ||
#print(token) | ||
invoice_list = api.get('sales-invoices?client_id='+banqup_client_id+'&sales_invoice_number='+document,None,None) | ||
if not invoice_list[2]['results']: | ||
print('***********************') | ||
print('The invoice number provided does not exist in the Banqup portal.') | ||
print('Please verify and try again.') | ||
print('***********************') | ||
return | ||
invoice_id = str(invoice_list[2]['results'][0]['id']) | ||
#print(invoice_id) | ||
payload = json.dumps({ | ||
"type": "SEND" | ||
}) | ||
invoice_action = api.post('sales-invoices/'+invoice_id+'/action',json.loads(payload),None,None) | ||
print(invoice_action) | ||
|
||
|
||
if __name__ == '__main__': | ||
send_invoice(str(sys.argv[1])) |