Hello @daniel.merino,
This is a bug. Thank you for reporting a problem. I created an issuer - Datatype 'bigDecimal' is not found · Issue #3839 · jmix-framework/jmix · GitHub
As a workaround, you can add a bigDecimal data type.
@DatatypeDef(id = "bigDecimal", javaClass = BigDecimal.class, defaultForClass = true, value = "custom_BigDecimalDatatype")
@NumberFormat(
pattern = "0.####",
decimalSeparator = ".",
groupingSeparator = ""
)
public class BigDecimalDatatype extends NumberDatatype implements Datatype<BigDecimal> {
@Autowired
protected FormatStringsRegistry formatStringsRegistry;
@Autowired
protected CoreProperties coreProperties;
@Override
protected java.text.NumberFormat createFormat() {
java.text.NumberFormat format = super.createFormat();
if (format instanceof DecimalFormat) {
((DecimalFormat) format).setParseBigDecimal(true);
}
return format;
}
@Override
public String format(Object value) {
return value == null ? "" : createFormat().format(value);
}
@Override
public String format(Object value, Locale locale) {
if (value == null) {
return "";
}
FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
if (formatStrings == null) {
return format(value);
}
DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
java.text.NumberFormat format = new DecimalFormat(formatStrings.getDecimalFormat(), formatSymbols);
return format.format(value);
}
@Override
public BigDecimal parse(String value) throws ParseException {
if (StringUtils.isBlank(value)) {
return null;
}
return (BigDecimal) parse(value, createFormat());
}
@Override
public BigDecimal parse(String value, Locale locale) throws ParseException {
if (StringUtils.isBlank(value)) {
return null;
}
FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
if (formatStrings == null) {
return parse(value);
}
DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
DecimalFormat format = new DecimalFormat(formatStrings.getDecimalFormat(), formatSymbols);
format.setParseBigDecimal(true);
return (BigDecimal) parse(value, format);
}
protected Number parse(String value, java.text.NumberFormat format) throws ParseException {
BigDecimal result = (BigDecimal) super.parse(value, format);
if (coreProperties.isRoundDecimalValueByFormat()) {
int maximumFractionDigits = format.getMaximumFractionDigits();
RoundingMode roundingMode = format.getRoundingMode();
result = result.setScale(maximumFractionDigits, roundingMode);
}
return result;
}
@Override
public String toString() {
return getClass().getSimpleName();
}
}
Regards,
Nikita