Script to extract sales invoices from Openbravo and submit them via the Banqup API by Unifiedpost. This repo is mirrored at https://gitlab.com/kikobar/org.openbravo.kikobar.banqup and https://github.com/kikobar/org.openbravo.kikobar.banqup
Go to file
2024-01-26 03:15:33 +08:00
cache Initialize python directories 2023-06-24 20:15:53 +08:00
.gitignore Retrieve debtor_id knowing businessPartner 2023-06-24 20:01:08 +08:00
__init__.py Initialize python directories 2023-06-24 20:15:53 +08:00
api.py Add delete_invoice functionality 2024-01-26 03:15:33 +08:00
authhandler.py Improve license documentation 2023-10-29 19:46:24 +08:00
cachehandler.py Improve license documentation 2023-10-29 19:46:24 +08:00
config-sample.py Improve documentation about how to use the comment_product feature 2023-12-07 20:40:17 +08:00
CONTRIBUTING.md Change text CONTRIBUTING to MD format 2023-08-09 16:06:18 +08:00
delete_invoice.py Add delete_invoice functionality 2024-01-26 03:15:33 +08:00
extract_invoice.py Add functionality to pass to the Banqup API the invoice line description as a comment instead of the product description 2023-12-07 17:45:10 +08:00
GPLv3.md Improve license documentation 2023-10-29 19:46:24 +08:00
LICENSE.md Amend typo in LICENSE.md 2023-10-29 23:44:22 +08:00
paid_invoice.py Add support for marking invoices as paid 2023-08-09 02:14:46 +08:00
README.md Add support for marking invoices as paid 2023-08-09 02:14:46 +08:00
send_invoice.py Add funtionality to SEND invoice to customer 2023-07-23 21:25:20 +08:00

Objective

This Python script extracts data from Openbravo to generate a JSON invoice to submit 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 program requires this field to extract some parameters that only exist in the Banqup platform.

How to run this application

  • Copy the file config-sample.py to config.py.
  • Edit config.py with your credentials for Openbravo and Banqup.
  • Run python3 extract_invoice.py <documentNo>, where <documentNo> is the human readable invoice number in Openbravo, to create an invoice in the Banqup portal via the API.
    • The application will do the following:
      • Fetch the invoice <documentNo> from Openbravo.
      • Authenticate with Banqup using OAuth2, for which it will launch a webbrowser to complete the authentication. The browser will receive the response from the Banqup server including the authentication token. The user will need to 'Copy' and 'Paste' this response at the corresponding prompt in the terminal.
      • Fetch the corresponding businessPartner from Banqup to verify its existence and correct setup.
      • Build a JSON record for the requested invoice <documentNo>, which is compatible with the Banqup API format.
      • Post the invoice to the Banqup API for the creation of the corresponding invoice in Banqup.
      • Display the response from the Banqup API, confirming the success or failure of the request.
      • If the requests is successful, a new invoice will be created with status 'Draft' in the Banqup portal, so that it could be further processed on that system.
  • Run python3 send_invoice.py <documentNo>, where <documentNo> is the human readable invoice number in Openbravo, to confirm an invoice in Banqup portal and send it to the customer via the API.
    • The application will do the following:
      • Authenticate with Banqup using OAuth2, for which it will launch a webbrowser to complete the authentication. The browser will receive the response from the Banqup server including the authentication token. The user will need to 'Copy' and 'Paste' this response at the corresponding prompt in the terminal.
      • Fetch the invoice in Banqup to verify its existence in the portal and retrieve its id in Banqup.
      • Post a request to the Banqup API to confirm the invoice and send it to the customer.
      • Display the response from the Banqup API, confirming the success or failure of the request.
  • Run python3 paid_invoice.py <documentNo>, where <documentNo> is the human readable invoice number in Openbravo, to confirm an invoice in Banqup portal and send it to the customer via the API.
    • The application will do the following:
      • Authenticate with Banqup using OAuth2, for which it will launch a webbrowser to complete the authentication. The browser will receive the response from the Banqup server including the authentication token. The user will need to 'Copy' and 'Paste' this response at the corresponding prompt in the terminal.
      • Fetch the invoice in Banqup to verify its existence in the portal and retrieve its id in Banqup.
      • Post a request to the Banqup API to mark the invoice as 'Paid'.
      • Display the response from the Banqup API, confirming the success or failure of the request.

Credits