How can the numerical type of a node that can contain different units be changed using @numerical-type: bind
See below, The node '[‘prijs/bewerking’ and ‘aantal’ depends on node ‘eenheid’ and can be in pieces, meter or square meters
'type bewerking': text -> ^ ^ >'model'.'Bewerkingen'[]
'eenheid': text //per meter, m^2 or stuks
'prijs/bewerking': number 'euro' = >'type bewerking'.'prijs'
'aantal': number 'aantal'
'Prijs': number 'euro'= from 'euro' product ( .'aantal' as 'aantal' , .'prijs/bewerking' )
I have a following-up question regarding the bind function:
My numerical-type looks as follows:
root {
'Currencies': collection ['Currency'] {
'Currency': text
'Sign': text
'Decimals': number 'count'
}
'Currency': text -> .'Currencies'[] = "EUR"
'Sales Price': number 'cent/Kg'
@numerical-type: ^ >'Currency'
}
numerical-types
'count'
'cent/Kg'
= '10^-3 €cent' / '10^-3 kg'
@numerical-type: bind .'Currencies'* as $ (
label: concat ( $ .'Sign', "/Kg" ) // <- equal to €
decimals: $ .'Decimals' // <- set to 2
)
Whenever ‘Currency’ is equal to “EUR”, label contains €/Kg and decimal points are qual to 2, creating, for example, 2,34 €/Kg after saving.
However, the problem lies in inserting 2,34 when adding a new value. It only allows me to insert 234, which would translate to 2,34 after saving.
How to solve this issue? How do I enable myself to insert 2,34 without being forced to remove my bind function?
I thought the above would make the decimals static, but the problem still occurs. Only after saving the newly added modifications, one is allowed to put decimal points.
I tested the following numerical value in case the definition of ‘cent/Kg’ caused it.
I have asked the webclient team to investigate this. I’m not sure if the decimals property of a numerical type can be changed dynamically while creating a new entry or editing an existing one and switching the currency, for example.