View source | View content page | Page history | Printable version   

Projects:New Discounts Engine/Specs

Back button.png   Back to Projects:New_Discounts_Engine


Contents

Goal

The main objectives of this project are:

Functional Requirements

Current State

Currently we have two different implementations for calculating discounts:

Current Discount Engine(s)

Desired Implementation

The expected requirements for the new discounts engine are:

To allow external applications use this new discounts engine, a new web service will be developed.

New Discounts Engine Proposal

Technical Specs

A Common Engine

One of the main requirements of this project is to ensure that we provide a discounts engine that is not only used in WebPOS but it can reused by different application components, including those which are part of the backend.

The new discounts engine is going to be developed using Javascript, for this reason we should provide a mechanism to execute it in the backend. In an initial stage of research, several Javascript engines for the JVM were considered:

After evaluating the different alternatives, GraalJS was the option finally taken.

To integrate GraalJS in Openbravo, we are not going to directly use the GraalVM but the Graal SDK libraries will be deployed on top of the OpenJDK instead:

GraalJS deployed in OpenJDK

Discount Executor

This project will introduce the concept of DiscountExecutor, a component that will allow to define implementations for calculating discounts. It will be the central part of an infrastructure depicted below:

DiscountExecutor class diagram


The components of this infrastructure are:

Discounts Web Service

The new discounts web service will implement the following flow:

  1. Retrieve the ticket from the HTTP request
  2. Retrieve the applicable discounts rules for the ticket from database
  3. Execute the new discount engine through the GraalJS discount executor mentioned in the previous section.
  4. Return the calculation result

Ticket API

A new API is going to be provided as an effort to try to standardize the definition on a ticket. This is the minimum properties that are required to define a POS ticket.

This API would be used and extended by different kind of web services (Discounts, OMS, Loyalty...). Thus, all of them will be using a common definition both on their input and output.

The base API definition can be found here.

API Specification

It will also be developed a mechanism that will allow to specify the API of the exposed web services in Openbravo. And we will make use of it to document the discounts web service.

After a research, OpenAPI is the selected approach to create this API documentation mechanism. Its main advantages are:

Testing Infrastructure

A new testing infrastructure is going to provided, with several features:


Module Structure

The components of this project have been divided into different modules, as many of them can be reused also by other modules. The structure is form as follows:


Discounts Module Structure


Future Work

After this project, the following topics will be opened for a future implementation:

Retrieved from "http://wiki.openbravo.com/wiki/Projects:New_Discounts_Engine/Specs"

This page has been accessed 931 times. This page was last modified on 12 September 2019, at 09:30. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.