Class BasketTools

java.lang.Object
sk.iway.iwcm.common.BasketTools

public class BasketTools extends Object
Provides shared helpers for basket currencies and localized country names.
  • Field Details

  • Method Details

    • getSystemCurrency

      public static String 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

      public static BigDecimal convertCurrency(BigDecimal amount, String fromCurrency, String toCurrency)
      Converts an amount using a configured kurz_FROM_TO exchange 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 convert
      fromCurrency - source currency code
      toCurrency - 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

      public static String getCountryName(String countryCode, Prop prop)
    • getSupportedCurrencies

      public static String[] getSupportedCurrencies()
      Returns the distinct, normalized currency codes enabled for the basket.
      Returns:
      configured valid currency codes in their original order
    • getSupportedCurrenciesOptions

      public static List<LabelValue> getSupportedCurrenciesOptions()
    • isCurrencySupported

      public static boolean isCurrencySupported(String currency)
    • getNormalizedSupportedCurrency

      public static String getNormalizedSupportedCurrency(String currency)
      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 null when the value is invalid or unsupported