Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CurrencyUnit #4016

Merged
merged 1 commit into from
Jan 5, 2024
Merged

Fix CurrencyUnit #4016

merged 1 commit into from
Jan 5, 2024

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Jan 5, 2024

This fixes some issues that were recently detected regarding the new currency units:

  • Currency codes could not be used for the base currency (but for additional currencies) when a symbol is defined. The reason is that in this case only the symbol and not symbol and label were added to the unit formatter.

  • Units composed of a currency and an additional currency (like EUR/kWh) were not properly converted (only the non-currency part was converted). This was caused by two problems: CurrencyUnit did not inherit from AbstractUnit and therefore the converter was not properly found (always IDENTITY). After I fixed that, an additional problem occurred: the CurrencyConverter could not be used because the list of converters is a final, non-accessible list.

@jlaur FYI.

Signed-off-by: Jan N. Klug <github@klug.nrw>
@J-N-K J-N-K added the bug An unexpected problem or unintended behavior of the Core label Jan 5, 2024
@J-N-K J-N-K requested a review from a team as a code owner January 5, 2024 12:04
@jlaur
Copy link
Contributor

jlaur commented Jan 5, 2024

@J-N-K, @openhab/core-maintainers - perhaps something to be considered for 4.1.1 since it fixes an issue in a new 4.1 feature?

Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@wborn wborn merged commit 36cafd7 into openhab:main Jan 5, 2024
3 checks passed
@wborn wborn added this to the 4.2 milestone Jan 5, 2024
@J-N-K J-N-K deleted the currency branch January 5, 2024 17:28
@kaikreuzer
Copy link
Member

@J-N-K Should this be backported to 4.1.x?

@J-N-K
Copy link
Member Author

J-N-K commented Jan 5, 2024

Yes, especially because of the symbol/code issue. The conversion bug will probably not be an issue on 4.1 because there is no currency provider with more than one currency.

@kaikreuzer
Copy link
Member

Ok, cherry-picked to 4.1.x.

@kaikreuzer kaikreuzer added the patch A PR that has been cherry-picked to a patch release branch label Jan 5, 2024
cipianpascu pushed a commit to cipianpascu/openhab-core that referenced this pull request Jan 17, 2024
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core patch A PR that has been cherry-picked to a patch release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants