Interface CurrencyConversionService
- All Known Implementing Classes:
DefaultCurrencyConversionService,NoOpCurrencyConversionService
public interface CurrencyConversionService
Implementations of this service provide support for currency conversions.
- Author:
- Brian Polster (bpolster)
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanCovert(javax.money.CurrencyUnit from, javax.money.CurrencyUnit to) Determine if conversion support is available based on a currencyCodefromandto.javax.money.MonetaryAmountconvert(javax.money.MonetaryAmount fromAmount, javax.money.CurrencyUnit toCurrency) Return a MonetaryAmount by applying a currency conversion from the fromAmount to the target currency.<P extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
voidpopulateCurrencyConversionDetails(Collection<P> priceInfos, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Converts the currencies on the priceable fields on thepriceInfosfrom the existing currency into thePriceInfoContext.getRequestedCurrency().
-
Method Details
-
canCovert
boolean canCovert(javax.money.CurrencyUnit from, javax.money.CurrencyUnit to) Determine if conversion support is available based on a currencyCodefromandto.- Parameters:
from- The currency to convert from.to- The currency to convert to.- Returns:
- whether the currency can be converted
-
convert
javax.money.MonetaryAmount convert(javax.money.MonetaryAmount fromAmount, javax.money.CurrencyUnit toCurrency) Return a MonetaryAmount by applying a currency conversion from the fromAmount to the target currency.- Parameters:
fromAmount- The MonetaryAmount to convert.toCurrency- The currency to convert to.- Returns:
- A MonetaryAmount in the target currency.
-
populateCurrencyConversionDetails
<P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> void populateCurrencyConversionDetails(Collection<P> priceInfos, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Converts the currencies on the priceable fields on thepriceInfosfrom the existing currency into thePriceInfoContext.getRequestedCurrency(). The converted currencies are stored on thePriceInfo.getConvertedPriceTypeDetails().- Parameters:
priceInfos- ThepriceInfoshaving the currencies to convert.priceInfoContext- ThePriceInfoContextcontaining the requested currency of the cart.contextInfo- Context information regarding the current API request- Since:
- Pricing Services 2.2.0, Release Train 2.3.0
-