Dolibarr/dolibarr — pull request #2118 by IonAgorria (2014-11-30 04:00:17+00:00)
Title: Funcionality to assign dinamic prices using math expressions

The expressions are evaluated using PriceParser class which serves as a wrapper for evalmath library. each special "#variable#" are replaced with number before passing it to evalmath, in theory the expression is evaluated safely.
PriceParser returns the value of price variable (if was declared in the math expression, for example "price = 2 * 4") or uses the latest result from evaluating expression, so "2 + 2" becomes valid, even without explicitly setting the price variable.
Each product ExtraFields are accessible from math expression using variables like "#options_myextrafieldkey#", for example "price = #options_mass# * 2"
There are special variables like #quantity# and #tva_tx# which contain the values from supplier price line
The character ; is used to separate expressions, newlines are converted to ; and empty expressions are ignored.
It's possible to use some functions like log, sin... and create new functions and variables, for example "a = 2 * 2; price = a + 3"

The expression selector and editor is only accessible when creating or changing a supplier price, and only is visible if DinamicPrices module (id 2200) is activated.

The reason of creating a new migration file for 3.7.0-3.8.0 is that I don't want to add this to 3.7.0 due to possible beta release, but I could add it to 3.6.0-3.7.0 file if requested.