Package sk.iway.iwcm.common
Class BasketTools
java.lang.Object
sk.iway.iwcm.common.BasketTools
Provides shared helpers for basket currencies and localized country names.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalconvertCurrency(BigDecimal amount, String fromCurrency, String toCurrency) Converts an amount using a configuredkurz_FROM_TOexchange rate.static BigDecimalconvertToBasketDisplayCurrency(BigDecimal amount, jakarta.servlet.http.HttpServletRequest request) static StringgetCountryName(String countryCode, Prop prop) static StringgetNormalizedSupportedCurrency(String currency) Normalizes a currency code and verifies that it is enabled for the basket.static String[]Returns the distinct, normalized currency codes enabled for the basket.static List<LabelValue>static StringResolves the basket system currency from the configured currency fallbacks.static booleanisCurrencySupported(String currency)
-
Field Details
-
COUNTRY_KEY_PREFIX
- See Also:
-
BASKET_PRODUCT_CURRENCY
- See Also:
-
BASKET_DISPLAY_CURRENCY
- See Also:
-
SUPPORTED_CURRENCIES
- See Also:
-
-
Method Details
-
getSystemCurrency
Resolves the basket system currency from the configured currency fallbacks.- Returns:
- the normalized three-letter currency code
- Throws:
IllegalStateException- if no valid basket currency is configured
-
convertToBasketDisplayCurrency
public static BigDecimal convertToBasketDisplayCurrency(BigDecimal amount, jakarta.servlet.http.HttpServletRequest request) -
convertCurrency
Converts an amount using a configuredkurz_FROM_TOexchange rate. A reverse rate is used when no direct rate exists. If neither rate is configured, the original amount is returned.- Parameters:
amount- amount to convertfromCurrency- source currency codetoCurrency- target currency code- Returns:
- the converted amount, or the original amount when no exchange rate is configured
- Throws:
IllegalStateException- if either currency is invalid or a configured rate is malformed
-
getCountryName
-
getSupportedCurrencies
Returns the distinct, normalized currency codes enabled for the basket.- Returns:
- configured valid currency codes in their original order
-
getSupportedCurrenciesOptions
-
isCurrencySupported
-
getNormalizedSupportedCurrency
Normalizes a currency code and verifies that it is enabled for the basket.- Parameters:
currency- currency code to validate- Returns:
- the normalized supported code, or
nullwhen the value is invalid or unsupported
-