修复Money类的setAmount方法没有获取当前币种的小数位数而是使用的默认小数位和在遇到非2小数位的币种(如日元使用 0 位)会导致金额设置错误问题(pr#3970@Github)

This commit is contained in:
Looly 2025-06-20 11:05:49 +08:00
parent 8aff7bfb66
commit 90b83d16a5

View File

@ -310,7 +310,7 @@ public class Money implements Serializable, Comparable<Money> {
*/ */
public void setAmount(final BigDecimal amount) { public void setAmount(final BigDecimal amount) {
if (amount != null) { if (amount != null) {
cent = rounding(amount.movePointRight(2), DEFAULT_ROUNDING_MODE); cent = rounding(amount.movePointRight(currency.getDefaultFractionDigits()), DEFAULT_ROUNDING_MODE);
} }
} }