How to create a precise decimal field (for amounts of currency)

Hello,

I want to create a field to store a precise value (like a monetary value, for example), so I don't want to use floating point formats like double. But I've seen that in schema, the only two decimal types I can create are xs:decimal and xs:double, which, according to https://doc.nuxeo.com/710/nxdoc/schema-fields/ , are stored both as double.

I would like to use something like BigDecimal, because I'm afraid to lose the real value that the user wanted to store.

Is it possible to add something like this? If not, what is the way to go, storing as a String with validators? I've seen that in a question ( https://answers.nuxeo.com/general/q/20ba8963e6db40768835d2f9f75020a7/What-is-the-best-way-to-enter-and-store-amounts-of-currency ), but it is a bit old and I don't know if now there is another solution.

Thank you very much in advance,

0 votes

1 answers

118 views

ANSWER



There's no decimal type in Nuxeo at the moment. You can follow NXP-12071 to get notified if work on this gets scheduled. No customer has yet requested this kind of feature.

As a workaround you can use a String like suggested in the question you link to, or you can use an integer with an implied scale factor to represent your decimals.

1 votes



Thanks, Florent!

I will use a String with validators.

Kind regards,

01/05/2017