I’m a bit confused what’s going wrong here, the code looks right to me, but somehow benefit = 9.43 * 960
instead of the expected 9.43 * 0.96
.
numerical-types
'eurocent'
= 'fraction' * 'eurocent'
@numerical-type: (
label: "Euro"
decimals: 2
)
'fraction'
// = 'fraction' * 1 * 1 ^ 1
= 'percent' * 1 * 10 ^ -2
@numerical-type: (
label: "1/%"
decimals: 3
)
'percent'
= 'fraction' * 1 * 10 ^ 2
@numerical-type: (
label: "%"
decimals: 1
)
The @numerical-type:
annotation influences only what you see in the web app/GUI. It does not affect how values are stored, so it is important to ignore them unless you are focusing on the GUI.
The name of the numerical type should correspond to the precision that you require.
From your model I can see that you want to store a childcarePercentage
with 1 decimal place. Therefore, you need a numerical type such as promille
which represents a percentage with 1 decimal place.
The numerical type fraction
is only useful for computations.
You cannot actually store a fraction
as an Alan number
; only intermediate results can have decimal places.
Example code for getting the expected result for benefit
:
...
'childcarePercentage': number 'promille' = 96 // 9.6 % in the GUI
'HoldingTarif': number 'eurocent' = 9430 // 94.30 Euro in the GUI
...
'benefit': number 'eurocent' = product ( // 9.05 Euro in the GUI
from 'promille' .'childcarePercentage' as 'fraction' ,
.'HoldingTarif'
)
...
numerical-types
'eurocent'
= 'fraction' * 'eurocent'
@numerical-type: (
label: "Euro"
decimals: 2
)
'fraction'
= 'promille' * 1 * 10 ^ -3
'promille'
@numerical-type: (
label: "%"
decimals: 1
)