st-tu-dresden/salespoint

Re-evaluate storing the monetary amounts including the currency

Opened this issue · 0 comments

We currently store MonetaryAmount values as String in the database and include the currency with it. This causes the sorting to break as the values are compared lexically rather than numerically. We essentially have two options:

  1. Assume Euro as the only currency to be used with Salespoint – that would allow us to simply store the amount value and thus the database schema to change to a numeric value so that ordering works again. Downside of this: we'd rule out Salespoint to be used with multiple currencies. We could make the one currency to be used configurable, though.
  2. Use better database mapping – We currently use JPA AttributeConverter implementations to store the MonetaryAmount values. Another option would be a Hibernate user type that supports mapping a value to multiple columns. That still raises the question of how that would behave in terms of ordering, as a mixture of currencies wouldn't sort properly without knowing the exchange rates.