View source | View content page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

Projects:POS/ERP Integration

Projects:POS

Index


Important This integration architecture needs Openbravo ERP 2.50, 3.0 or later and Openbravo POS 2.30.2 or later. If you want to integrate Openbravo ERP 2.40 and Openbravo POS 2.20 go to the document Openbravo_POS_Direct_Integration.

Contents

Summary

In an organization, more than one software application often exists to support a particular aspect of operational requirements. The result is an heterogeneous set of software applications requiring data sharing and integration. An ERP system like Openbravo ERP tries to solve this problem by offering one solution for every operational requirement. Openbravo ERP maintains one shared database for all data, integrated processes among different departments, a consistent interface for every user, and homogeneous reports/score cards that display operational data of the whole organization.

However there are specific corners of an organization that an ERP system cannot solve. For example, POS systems like Openbravo POS where special user types and hardware devices support are required.

The POS system user is a salesperson who uses an ERP in a different manner. The interface has to be very easy to use and provide only the specific information the salesperson needs. This salesperson needs to operate the POS as fast as possible, as their job is to sell, not to operate the POS. For example they do not want to deal with a mouse and a keyboard, rather they prefer a touch screen. In addition, the POS system needs to support a lot of POS hardware available for a real solution: receipt printers, barcode scanners, customer displays, cash drawers, scales, card readers etc.

Openbravo POS is a point of sale application designed for touch screens. It can be downloaded from Openbravo POS Downloads.

Integration overview

The focus of this integration is to create a system where Openbravo ERP is the central repository of the data: Products, customers, taxes, orders... And Openbravo POS has the ability to operate with the master data downloaded from Openbravo ERP and to upload orders created by the sales activity of Openbravo POS.

This integration has been developed with REST Webservices.

The Openbravo ERP REST webservice operates on Business Objects in Openbravo ERP. A Business Object (in Openbravo ERP) can be a simple entity (a table) such as a currency which just has basic primitive fields. Or can be as complex as a structure of entities, for example an order header with its order lines.

Openbravo ERP REST web services provides the following functionality:

The Openbravo ERP REST web services use the same access/authorizations as the standard Openbravo ERP application. Before calling a web service the caller must log in. The login functionality is provided by the Openbravo ERP REST framework. All REST actions are then executed in the context of a client/organization and current role of the user.

This integration module does NOT upload new customers or new products used on an invoice from the POS into the ERP. An error will occur during the sync process.

More information on REST.

The Synchronize POS process

In an integrated environment all products information, warehouse information, product categories, taxes and customers information are maintained in Openbravo ERP. This process is executed when is required to synchronize Openbravo POS with the information that has changed in Openbravo ERP.

The Synchronize Orders process

Every Openbravo POS receipt created has to be uploaded to Openbravo ERP to allow this information be processed by the Openbravo ERP system.

Openbravo ERP configuration

Introduction. Openbravo ERP modularity system

Remember: Modularity is only available on Openbravo ERP 2.50 or greater

An Extension Module is a piece of additional functionality that can be optionally and independently deployed on top of Openbravo ERP.

The experience of the user deploying modules is similar to the one of Firefox plugins: you are able to browse a catalog of modules, install (and uninstall), deploy and upgrade them directly from within the Openbravo ERP Administration UI.

A developer of an Extension Module can package and deliver a module independently from the rest of the Openbravo ERP content, meaning that is possible to package modules with a delivery mechanism that only includes files and metadata that they are responsible for.

More information regarding modularity can be found in the Modularity project article.

The functionality of the REST Webservices is very useful for standard integration scenarios and in our case allow us to get desired Business Objects from Openbravo ERP and update an existing Business Object.

The idea is to install a module (independent from the rest of Openbravo ERP) which is the responsible to deploy a REST Webservice in charge of the synchronization.

Install Openbravo POS Synchronization Webservice

There is a clear video tutorial regarding How to Install a Module. If you feel more comfortable reading follow next steps.

There are two different ways to install the module:

From the Central Repository:

Select in the list below POS Synchronization WebService module and press the Install now button.

Central repository
Rebuild finish correctly

Check the module installation

To check if the module is installed correctly, point your browser to:

http://localhost:8080/openbravo/ws/org.openbravo.pos.sync.ws

After the 1.3.0 version, it is necessary to use the follwing URL:

http://localhost:8080/openbravo/org.openbravo.service.connector/xml/org.openbravo.pos.sync.ws

Note that this example assumes that Openbravo ERP runs locally on port 8080, it maybe necessary to replace the localhost:8080 part with your own server name/port.

Before calling the web service the caller must log in, so a login dialog will appear. Enter a login and password of a operative Openbravo ERP user.

The result should a welcome page with a brief description of the web service usage.

If you get <error><message>No registration for name org.openbravo.pos.sync.ws</message></error> error message, try restarting Tomcat.

Edit the external point of sales

In Openbravo ERP edit the external point of sales to define the products that will be available for every point-of-sale. With this, when a point of sale tries to get the product catalog from Openbravo POS, the products defined in this window for this point of sale are sent. And the options defined are used in the process of orders imported.

To edit the external point of sale you have to change the role to the Openbravo ERP entity administrator of the entity you are working with, and open the menu option Sales management > Setup > External Point of Sales.

In this window you define your point of sales and include/exclude products and product categories associated with your point of sale.

You can select the products set to synchronize by category or by product. To select the product by category choose Only those defined in the Included Product Categories selector and add the category records wanted. To select the products list by product, choose Only those defined in the the Included Products selector and add the product records wanted.

Openbravo External Point Of Sale Window

Openbravo POS Web Service

Once the module is installed a Web Service is available:

http://localhost:8080/openbravo/ws/org.openbravo.pos.sync.ws

After the 1.3.0 version, it is necessary to use the following URL:

http://localhost:8080/openbravo/org.openbravo.service.connector/xml/org.openbravo.pos.sync.ws

If you point the browser to this URL a welcome page will appear showing general information about the usage of the Web Service.

The Web Service can be split in 3 subtasks:

Usage

http://localhost:8080/openbravo/ws/org.openbravo.pos.sync.ws/ BusinessObject ? parameters

After the 1.3.0 version, it is necessary to use the following URL:

http://localhost:8080/openbravo/org.openbravo.service.connector/xml/org.openbravo.pos.sync.ws/ BusinessObject ? parameters

Example: Get products

http://localhost:8080/openbravo/ws/org.openbravo.pos.sync.ws/Product?erp.id=FF8080812AFBCB14012AFBD3E373001F&erp.org=4F68EB1C1B734E79B27DE9D2DF56089F&erp.pos=POS-1

After the 1.3.0 version, it is necessary to use the following URL:

http://localhost:8080/openbravo/org.openbravo.service.connector/xml/org.openbravo.pos.sync.ws/Product?erp.id=FF8080812AFBCB14012AFBD3E373001F&erp.org=4F68EB1C1B734E79B27DE9D2DF56089F&erp.pos=POS-1

Request parameters

Available Business Objects

Important: The internal client and organization identifiers determine the accessibility to the Business Objects. Only the BO matching with the defined client and organization identifier will be synchronized.


POS Business Object POS Table ERP Table
Attribute ATTRIBUTE m_attribute
AttributeSet ATTRIBUTESET m_attributeset
AttributeValue ATTRIBUTEVALUE m_attributevalue
AttributeUse ATTRIBUTEUSE m_attributeuse
AttributeInstance ATTRIBUTEINSTANCE m_attributeisntance
AttributeSetInstance ATTRIBUTESETINSTANCE m_attributesetinstance
Warehouse LOCATIONS m_warehouse
BusinessPartnerTaxCategory TAXCUSTCATEGORIES c_bp_taxcategory
TaxCategory TAXCATEGORY c_taxcategory
Tax TAXES c_tax
ProductCategory CATEGORIES m_product_category
Product PRODUCTS m_product
Inventory STOCKCURRENT, STOCKDIARY, STOCKLEVEL m_storage_detail
BusinessPartner CUSTOMERS c_bpartner

Restrictions

The storage model in Openbravo ERP is different:

Openbravo ERP                 #     Openbravo POS
  |                           #       |
  |--- Warehouse              #       |--- Warehouse
  |-----|                     #             |
        |--- Storage Bin      #             |---Products
             |                #  
             |--- Products    #  

In External Point of Sale a Warehouse is selected. The same product could be stored in two Storage Bins inside the same Warehouse.

When the stock of a product is synchronized, the sum of the stock available in the Storage Bins of the selected Warehouse is done.

Example:

Main Warehouse
  |
  |--- First Storage Bin
  |     |
  |     |--- Hat = 50 Units
  |
  |--- Second Storage Bin
        |
        |--- Hat = 150 Units

In Openbravo POS we will have 200 units of Hat in STOCKCURRENT table.

Openbravo POS configuration

Introduction. Pentaho Data Integration (PDI or Kettle)

Pentaho Data Integration is a free, open source (LGPL) ETL (Extraction, Transformation and Loading) tool provided by Pentaho. Pentaho Data Integration delivers powerful Extraction, Transformation and Loading (ETL) capabilities using an innovative, metadata-driven approach. Using this would allow to create Web Services, get data directly from a database and store data directly in a database.

The Pentaho Data Integration suite consists of the following applications:

Pentaho Data Integration is a very flexible and friendly tool which provides a very intuitive graphic tool (Spoon) to modify and create our transformations. For the end user is very easy to use and it don't required any special programming skills. Furthermore, there is an active community behind the project, that means forum support, complete documentation and so on.

The current architecture reduces the effort required to modify an existing functionality and minimizes the impact to implement a new functionality. With the old synchronization each time when some new data needs to be synchronized a developer must add a suitable piece of code on both sides, so either in POS and in ERP. The functionality of the REST Webservices is very useful because they allow to retrieve information from all Business Objects of Openbravo ERP just doing an HTTP request. So, if more data is required, the modifications will just affect the Pentaho Data Integration environment.

Other applications can integrate with Openbravo POS through Pentaho Data Integration in a simple way: creating a new transformation or job. They don't need to modify Openbravo POS code, Pentaho Data Integration provides enough mechanism to achieve a successful synchronization between external application and Openbravo POS.

Pentaho Data Integration provides the possibility to schedule transformations or jobs to run in a remote server or force the synchronization after outstanding event happens in Openbravo POS side, for example, when cash is closed. This point is important, because is not needed a specific user interaction each time you need to make the integration run, just prepare the schedule in a suitable time and run once.

Install Pentaho Data Integration

The synchronization process has been tested until the Pentaho Data Integration community version 4.1.0-stable that can be download here: [1]. To install it simply unpack the file pdi-ce-4.1.0-stable.zip file into a folder of your choice.

Pentaho Data Integration requires the Sun Java Runtime Environment (JRE) version 1.5 or newer.

All JDBC drivers provided in Pentaho Data Integration are located into data-integration/libext/JDBC.

Is mandatory to use in Pentaho Data Integration a JDBC driver version compatible with the version of the JDBC driver used in Openbravo POS.

Suggestion:export the JDBC driver of the database used in Openbravo POS to data-integration/libext/JDBC folder of PDI (Kettle) and replace it.

Notice: If you use HTTPS to connect to Openbravo. Use version 4.1.2 of Pentaho Data Integration or greater because there is a reported error related to HTTPS in previous versions and fixed in 4.1.2: http://jira.pentaho.com/browse/PDI-4010

The particular case of Pentaho Data Integration 4.1.0 and Openbravo POS 2.30.2 the JDBC drivers provided by Pentaho Data Integration are:

The Derby JDBC driver provided in Pentaho Data Integration data-integration/libext/JDBC/derby.jar is the version 10.2.2.0 and is not compatible with the Derby JDBC driver version (10.4.2.0) used in Openbravo POS.

So is needed to replace the the derby.jar (10.2.2.0) located in data-integration/libext/JDBC/derby.jar with the newest derby.jar.

You can check the version of the .jar unpacking it and looking in the /META-INF/MANIFEST.MF file.

Bundle-Version: 10.4.2000000.689064

Get the transformation and job files

The transformation and job files are the processes needed by Pentaho Data integration that contains all the logic and steps of all the data synchronization processes between Openbravo ERP and Openbravo POS.

The latest transformation and job files are located in the folder modules/org.openbravo.pos.sync/resources/ of your Openbravo ERP installation, inside the POS Synchronizatino WebService module folder.

Execute Pentaho Data Integration

Spoon is the integration tool we are going to use to run transformations and jobs. Spoon is also the graphical tool with which you design and test every Pentaho Data Integration process. The other Pentaho Data Integration components execute the processes designed with Spoon.

To start Spoon in Windows execute the file Kettle.exe just double clicking on it or launch it from the command line. You can also create a shortcut to this file and place it in your preferred location: the desktop, the launch bar...

To start Spoon in Linux or other Unix-like operating systems, you will need to make the shell scripts executable by using the chmod command:

cd data-integration 
chmod +x spoon.sh
 
sh spoon.sh

As soon as Spoon starts, a dialog window appears asking for the repository connection data. For our purposes, we choose to just use the PDI without specifying a repository. Press the No repository button. Is possible to disable this window for the next time unchecking Present this dialog at startup checkbox.

The next thing you'll see is a Spoon tips window. Disable unchecking Show tips at startup? checkbox.

Then, the Main page screen of Spoon will appear.

Spoon main screen

The top portion of the screen contains the menu options that allow you to perform a whole host of customisations and operations of the application. The left hand side panel of the screen contains two different views:

In the main area transformations or jobs are opened in tabs. Each file has a menu which allows to execute useful operations like: run, debug, explore database...

If you are interested investigating this tool deeply take a look at the complete User Guide if you want more details about it.

Pan is a command line script that can execute transformations designed by Spoon in XML or in a database repository. Usually transformations are scheduled in batch mode to be run automatically at regular intervals.

To run a transformation from a file using Windows execute.

bat Pan.bat /file:"folder_path/transformation.ktr" /level:Basic

And using Linux and other Unix-like operating system execute.

cd data-integration
chmod +x pan.sh
 
sh pan.sh -file="folder_path/transformation.ktr" -level=Minimal

For more information read Pan User Guide.

Kitchen is a command line script that can execute jobs designed by Spoon in XML or in a database repository. Usually jobs are scheduled in batch mode to be run automatically at regular intervals.

To run a job from a file using windows execute.

bat Kitchen.bat /file:"folder_path/job.kjb" /level:Basic

And using Linux and other Unix-like operating system execute.

cd data-integration
chmod +x kitchen.sh
 
sh kitchen.sh -file="folder_path/job.kjb" -level=Minimal

For more information read Kitchen User Guide.

Configure Pentaho Data Integration

After first run of Spoon, Kettle environment variable files are created.

Variables can be used throughout Pentaho Data Integration, including in transformation steps and job entries.

In Windows the variables file is located in:

C:\Documents and Settings\<username>\.kettle\kettle.properties

In Linux and other Unix-like operating system in:

$HOME/.kettle/kettle.properties

We need to edit this file to configure our database and Openbravo ERP connections parameters adding:

# Database Connection
db.URL = jdbc:derby:/home/openbravo/openbravopos-database;create=true
db.driver = org.apache.derby.jdbc.EmbeddedDriver
db.user =
db.password =

# Openbravo ERP
erp.URL = http://localhost/openbravo/org.openbravo.service.connector/xml/org.openbravo.pos.sync.ws
erp.id = FF8080812AFBCB14012AFBD3E373001F
erp.org = 4F68EB1C1B734E79B27DE9D2DF56089F
erp.pos = POS-1
erp.user = Openbravo
erp.password = openbravo

The configuration values are as follows:

They are the same configuration values used in Openbravo.properties file stored in the $HOME directory.

Remember that the Openbravo REST web services use the same access/authorizations as the standard Openbravo application. All REST actions are then executed in the context of a client/organization and current role of the user.

Save the file and restart Spoon to make changes work.

After setting all parameters is possible to check if Spoon can access and read them and if the database connection is properly configured.

To check the variables open in Spoon one of the transformations. In the top menu go to Edit > Edit the kettle.properties file (Ctrl+ALT+P) and the variables and their values should appear in the dialog. If the Variables doesnt showup, ensure that you have included KETTLE_HOME in your environment variables, point it to the directory that has the .kettle folder.

eg. KETTLE_HOME = C:\Documents and Settings\<username>

Kettle environment variables

To check the database connection, first open in Spoon one of the transformations. Then in the top menu go to Edit > Explore DB and select openbravoposDB database to explore. If the connection is configured properly a database explorer will appear showing database tables.

Kettle database explorer

Execute the integration actions

Main synchronization

Open ALL SYNCHRONIZATION.kjb job in Spoon and run it by clicking on the run button from the main menu, toolbar or by pressing F9.

A window will appear, just click on Launch button.

The synchronization process will start automatically, you can see a brief status description of each transformation or job in Job metrics tab.

For a detailed log about the process go to Logging tab.

Running synchronization successfully

Products and Customers synchronization process

In order to avoid collisions with the search key of products and customers, the products/customers which are not defined in openbravo ERP will be renamed after doing a synchronization.

To rename the products/customer search key, the synchronization process will add a prefix to the affected products/customers search key. This prefix is created following this rules:

We will show an example to clarify it:

Step 1: Create one product in openbravo ERP with this values:

Step 2: Run the synchronization process. The product will appear in openbravo POS with the values defined in openbravo ERP.

Step 3: Remove product A from openbravo ERP.

Step 4: Run the synchronization process. This process will rename the products values in openbravo POS.

Step 5: Let’s see new values for the product in openbravo POS:

With this tasks openbravo POS is able to manage changes in the search key of products avoiding synchronization problems.

Synchronize Orders

Open ORDERS.ktr transformation in Spoon and run it by clicking on the run button from the main menu, toolbar or by pressing F9.

A window will appear, just click on Launch button.

After orders have been synchronized, to process the orders imported you have to change the role to the Openbravo ERP entity administrator of the entity you are working with, go to the menu option Master Data Management > Import Data > Import Orders and execute the process Import Orders. When the process ends a dialog with the result of the process is shown to the user. Also this process can be done running processUploadedOrders.ktr (see bellow).

Complete imported orders

Process Orders remotely

This process is equivalent to the second part of the previous proccess. After execute ORDERS.ktr open Process_Uploaded_Orders.ktr transformation in Spoon and run it by clicking on the run button from the main menu, toolbar or by pressing F9.

A window will appear, just click on Launch button. In the log you can see some information about the processed orders.

After orders have been processed, you can open in the ERP Master Data Management > Import Data > Import Orders . There are the processed orders.

Upload and process orders

This process is equivalent to execute ORDERS.ktr and then Process_Uploaded_Orders.ktr. This two tasks will be done using FULLUPLOAD.kjb in Spoon and run it by clicking on the run button from the main menu, toolbar or by pressing F9.

A window will appear, just click on Launch button. In the log you can see some information about the processed orders.

After orders have been uploaded and then processed, you can open in the ERP Master Data Management > Import Data > Import Orders . There are the processed orders.

Configure service to execute the integration actions

Carte is a simple web server that allows you to execute transformations and jobs remotely. It does so by accepting XML (using a small servlet) that contains the transformation to execute and the execution configuration. It also allows you to remotely monitor, start and stop the transformations and jobs that run on the Carte server. A server that is running Carte is called a Slave Server in the Pentaho Data Integration terminology.

Is interesting to provide authomatic synchronization between Openbravo ERP and Openbravo POS without user interaction. Each job in Pentaho Data Integration can be scheduled to run in a remote slave server. Carte User Documentation

Carte accepts 2 command line options:

Launch the server

To launch Carte in Windows execute Carte.bat file from the command line specifying the <ip> and <port>:

bat Carte.bat <ip> <port>

To launch Carte in Linux or other Unix-like operating systems, you will need to make the shell scripts executable by using the chmod command:

cd data-integration 
chmod +x carte.sh

And run specifying the <ip> and <port>:

sh carte.sh <ip> <port>

Authenticate in the server

Point your browser to http://<ip>:<port>/ and authentification dialog will appear.

The default user and password to use to gain control is cluster.

You can change either of these in the file pwd/kettle.pwd in plain text

myLogin:myPassword

From version 3.1 on you can also put this password file in $HOME/.kettle/ or $KETTLE_HOME/.kettle/

It is possible to obfuscate the password in the kettle.pwd file. There is a tool called Encr in the distribution that allows you to generate passwords that are obfuscated.

To obfuscate the password in Windows execute:

bat Encr.bat -carte test_password
OBF:1vv31vn61xtv1zlo1unf1y0s1ri71y0y1uoj1zlu1xtn1vnw1vu7

To obfuscate the password in Linux and other Unix-like operating systems execute:

sh encr.sh -carte test_password
OBF:1vv31vn61xtv1zlo1unf1y0s1ri71y0y1uoj1zlu1xtn1vnw1vu7

The string "OBF:1vv31vn61xtv1zlo1unf1y0s1ri71y0y1uoj1zlu1xtn1vnw1vu7" can then be copied into the kettle.pwd file instead of the clear-text password.

myLogin: OBF:1vv31vn61xtv1zlo1unf1y0s1ri71y0y1uoj1zlu1xtn1vnw1vu7

It is possible to make Carte use a Java Authentication and Authorization Service (JAAS). To do this, define an environment variable called "loginmodulename" as well as the "java.security.auth.login.config" property. Carte will pick these up to use these authentication settings.

Schedule a job in the server

Open in Spoon the job you want to schedule and run in a remote server. In the left panel, select view tree control and expand all nodes. Double click on Slave server node or right-clicking on 'Slave Server' and selecting the New option. Fill the parameters of the configuration dialog according to the parameters defined to Carte.

Configuring remote server on Spoon
Service tab
Proxy tab
Configure scheduling
double click on START step of the job
POS Spoon run.png

and configure desired scheduling to run the job.

Scheduling a job

Execute a job in the server

Remember: Carte server must be running

Open the job you want to execute remotely in Spoon and run it by clicking on the run button from the main menu, toolbar or by pressing F9.

Execute remotely

Select Execute remotely radio button and in the list bellow the desired Remote host. Press Launch button to start.

Check jobs executions

Point your browser to http://<ip>:<port>/ and login. Click on Show status link and you will access to Carte server administration window (Status page). Here you can see all of the transformation and jobs available and their current status:

You can access to each tranformation or job to manage them and see more details.

Carte web interface

FAQ

Derby database is locked

If you get this exception:

com.openbravo.basic.BasicException: 
Cannot connect to database. Database not available.
org.apache.derby.impl.jdbc.EmbedSQLException: 
Failed to start database '$HOME/openbravopos-database'

Go inside $HOME/openbravopos-database folder and remove db.lck and dbex.lck files.

Retrieved from "http://wiki.openbravo.com/wiki/Projects:POS/ERP_Integration"

This page has been accessed 174,549 times. This page was last modified on 19 October 2012, at 08:36. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.