Price Calculation

This article explains how to perform price calculation operations. For example, you want to calculate percentage of a value, do multiplication, etc.

Initial data: 

{

  "price": 100

}

Create a new transformer: Connections -> transformers -> + for a new one

Data, transform data using mappers and conditions 

Transformer: list mapper -> key accessor (to change array)

Mappers: inherit from supplied data (populates the data in the mapper to the result)

Array*: 

{
"vatCalculation": 1.2,
"calcuateVAT": true
}

Transformer: copy using a pattern -> Pattern* - price -> Replacement* - price_incl_vat.0

Transformer: copy using a pattern -> Pattern* - VATCalculation  -> Replacement* - price_incl_vat.1

 

Now we have 2 choices:

1)

Transformer: Value mapper -> pattern accessor -> Pattern* - price_incl_vat

Mapper: Operator -> multiplication 

OR

2) 

Transformer: Operator Transformer -> Operator - Multiplication -> Data Container Left Path* - price_incl_vat.0 -> Data Container Right Path* - price_incl_vat.1 -> Data Container Destination Path (default left) - FinalPrice