View source | Discuss this page | Page history | Printable version   

Openbravo POS Integration\zh cn

重要 This integration architecture needs Openbravo ERP 2.50 or later and Openbravo POS 2.30 beta 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

概述

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 salesman who uses an ERP in a different manner. The interface has to be very easy to use and provide only the specific information the salesman needs. This salesman needs to operate the POS as fast as possible as his job is to sell, not to operate the POS. For example he does not want to deal with a mouse and a keyboard, rather he prefers a touch screen. In addition, the POS system needs to support a lot of POS hardware available for the real solution: receipt printers, barcode scanners, customer displays, cash drawers, scales, etc.

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

集成概览

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.

More information on REST.

POS同步流程

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.

订单同步流程

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配置

简介. Openbravo ERP的模块化系统

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.

安装Openbravo POS同步网络服务

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

With the module file:

Download the latest version of the module package from Sourceforge.net: OpenbravoPOS: Files. There is a description of all the files available for download in the Openbravo_POS_2.30_Release_notes#How_to_get_Openbravo_POS.

Press Browse File System button and browse to the org.openbravo.service.pos.obx module. The module file can be downloaded from the Openbravo POS project page.

POS module browser.png
Rebuild finish correctly

检查安装的模块

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

http://localhost:8080/openbravo/ws/org.openbravo.service.pos.syncWs

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 be the list of all Business Objects (entityName) inside Openbravo ERP.

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

编辑外部的POS

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 All Selected in the Included Product Categories selector and add the category records wanted. To select the products list by product, choose All Selected in the the Included Products selector and add the product records wanted.

Openbravo External Point Of Sale Window

Openbravo POS网络服务

Once the module is installed a Web Service is available:

http://localhost:8080/openbravo/ws/org.openbravo.service.pos.syncWs

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:

使用

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

Example: Get Taxes

http://localhost:8080/openbravo/ws/org.openbravo.service.pos.syncWs/Tax?erp.id=1000000&erp.org=1000000&erp.pos=1234

请求的参数

可用业务对象

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

限制

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.

举例:

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配置

简介. Pentaho数据集成(PDI或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.

安装Pentaho数据集成

The newest stable version of Pentaho Data Integration is 3.1.0-826 so the file you have to download is pdi-open-3.1.0-826.zip. To install it simply unpack the 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 pdi-open-3.1.0-826/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 pdi-open-3.1.0-826/libext/JDBC folder of PDI (Kettle) and replace it.

The particular case of Pentaho Data Integration 3.1.0-826 and Openbravo POS 2.30 the JDBC drivers provided by Pentaho Data Integration are:

The Derby JDBC driver provided in Pentaho Data Integration pdi-open-3.1.0-826/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 pdi-open-3.1.0-826/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.

Download the latest version of jobs and transformations from Sourceforge.net: OpenbravoPOS: Files. There is a description of all the files available for download in the Openbravo_POS_2.30_Release_notes#How_to_get_Openbravo_POS.

执行Pentaho数据集成

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 spoon.bat 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 pdi-open-3.1.0-826 
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 pdi-open-3.1.0-826
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 pdi-open-3.1.0-826
chmod +x kitchen.sh
 
sh kitchen.sh -file="folder_path/job.kjb" -level=Minimal

For more information read Kitchen User Guide.

配置Pentaho数据集成

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.ClientDriver
db.user = mikel
db.password = mikel

# Openbravo ERP
erp.URL = http://localhost:8080/openbravo/ws/org.openbravo.service.pos.syncWs
erp.id = 1000000
erp.org = 1000000
erp.pos = 1234
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 > Show Environment Variables (Ctrl+L) 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 open in Spoon one of the transformations. 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

执行集成动作

主同步任务

Open RUN 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

订单同步

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.

Complete imported orders

配置服务来执行集成动作

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:

启动服务器

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 pdi-open-3.1.0-826 
chmod +x carte.sh

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

sh carte.sh <ip> <port>

服务器端认证

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.

在服务器端设置定时工作

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

在服务器执行工作

提醒: Carte服务器必须在运行。

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.

检查工作执行

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

常见问题

Derby数据库被锁

如果碰到下列例外:

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

$HOME/openbravopos-database目录,删除db.lckdbex.lck文件。

Retrieved from "http://wiki.openbravo.com/wiki/Openbravo_POS_Integration%5Czh_cn"

This page has been accessed 7,104 times. This page was last modified on 14 September 2009, at 15:58. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.