How decimal values are handled in Af-Arch platform


Because Af-Arch is a platform to build application likely to be used in a commercial environment it will have to handle moneraty values.

Currently, Af-Arch is using PostgreSQL as preferred database backend. However, LibAfGs module is prepared to to support other database backed by only providing six handlers that implements the abstract operations required by the Af-Arch platform.

In fat, current database interation is done through an abstract interface that do not allow to know which is the current database backed, that is actually hosting SQL target query.

However, managing moneraty values on countries where decimal separator is a dot there is no problem but, this is not the same on those countries where this separator is a comma.

This is because the SQL syntax uses the dot as decimal separator and the comma as a lenguage element to separate enumerations.

Being SQL defined this way, decimal separator for european countries is a question which will give problems not only with PostgreSQL but with every SQL database backend.

Now, think about 2 countries which are using diferent decimal separators but they are using the same distribuited system. Values stored must represent the same values but local representation must be used while showing data on client interfaces.

How decimal values are change on real-time to local representation

AfDalDecimal object is a opaque structure allowing to keep value inside separated from the representation.

Currently, AfDalDecimal is build using three handler which are used by the AfDalDecimal module to perform conversion and normalization operations.

At this moment there are supported two sets of function: "dot as decimal separator" and "comma as decimal separator". To chose the current representation function afdal_decimal_set_decimal_separator is used.

The set of function implemented are called: F, F^-1 and C. Their functions are:

With the previous function AfDal Decimal module have the hability to change on realtime current decimal format, keep user interface using local representation but using canonical representation while contacting with remote Af-Arch servers nodes.