Search in sources :

Example 1 with CurrencyCodeIdentifiable

use of org.broadleafcommerce.common.currency.util.CurrencyCodeIdentifiable in project BroadleafCommerce by BroadleafCommerce.

the class MoneyFieldPersistenceProvider method getCurrency.

@Override
protected Currency getCurrency(ExtractValueRequest extractValueRequest, Property property) {
    String currencyCodeField = extractValueRequest.getMetadata().getCurrencyCodeField();
    if (!StringUtils.isEmpty(currencyCodeField)) {
        try {
            return Currency.getInstance((String) extractValueRequest.getFieldManager().getFieldValue(extractValueRequest.getEntity(), currencyCodeField));
        } catch (Exception e) {
        // do nothing
        }
    }
    if (extractValueRequest.getEntity() instanceof CurrencyCodeIdentifiable) {
        try {
            return Currency.getInstance(((CurrencyCodeIdentifiable) extractValueRequest.getEntity()).getCurrencyCode());
        } catch (Exception e) {
        // do nothing
        }
    }
    BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
    return brc.getJavaCurrency();
}
Also used : BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) CurrencyCodeIdentifiable(org.broadleafcommerce.common.currency.util.CurrencyCodeIdentifiable)

Aggregations

CurrencyCodeIdentifiable (org.broadleafcommerce.common.currency.util.CurrencyCodeIdentifiable)1 BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)1