How do I save prices to more than two decimal places

In some cases it may be beneficial to save prices to more than two decimals. For instance if you're using dynamic pricing and the pricing service returns a total price for a line item of more than one quantity then the per item price may need more than two decimal places to properly represent its value. In this case we need to modify the method getScaleForCurrency in the class BankersRounding. Since this method is static and the class isn't a bean we're not able to override the method with our normal bean override strategy. In this case we'll need to leverage byte code weaving to change the class at runtime. To do so you'll need to create a class with the altered version of getScaleForCurrency and some additional configuration in your CoreConfig (or any configuration class in your core project). Below is an example of the weave class to override the getScaleForCurrency method

package com.blcdemo.core.domain.weave;
import java.util.Currency;

public class WeaveOverrideBankersRounding {

    public static int getScaleForCurrency(Currency currency) { 
        if (currency != null) { 
            if (currency.getCurrencyCode().equals("USD")) { 
                return 3; 
            return currency.getDefaultFractionDigits(); 
        } else { 
            return BankersRounding.DEFAULT_SCALE; 

Next you'll need to add the following to your CoreConfig class

@Merge(targetRef = "blMergedClassTransformers", early = true) 
public List weaveBankersRounding() { 
    return Collections.singletonList(
           new DirectCopyClassTransformer("Changing Money Scale to 3")