| | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 金额精度工具:统一保留 6 位小数 |
| | | * 金额精度工具:默认统一保留 6 位小数,金额(元)保留 2 位小数 |
| | | */ |
| | | public final class AmountUtils { |
| | | |
| | | public static final int AMOUNT_SCALE = 6; |
| | | public static final RoundingMode AMOUNT_ROUNDING = RoundingMode.HALF_UP; |
| | | |
| | | /** 金额(元)保留小数位数(分) */ |
| | | public static final int MONEY_SCALE = 2; |
| | | |
| | | private AmountUtils() { |
| | | } |
| | |
| | | return BigDecimal.ZERO.setScale(AMOUNT_SCALE, AMOUNT_ROUNDING); |
| | | } |
| | | return value.setScale(AMOUNT_SCALE, AMOUNT_ROUNDING); |
| | | } |
| | | |
| | | /** |
| | | * 金额(元)精度处理:四舍五入保留 2 位小数, |
| | | * 避免按含税单价累计出库金额时产生误差,全部发货后仍显示未出库零头 |
| | | */ |
| | | public static BigDecimal scaleMoney(BigDecimal value) { |
| | | if (value == null) { |
| | | return BigDecimal.ZERO.setScale(MONEY_SCALE, AMOUNT_ROUNDING); |
| | | } |
| | | return value.setScale(MONEY_SCALE, AMOUNT_ROUNDING); |
| | | } |
| | | |
| | | public static BigDecimal calcTaxExclusiveTotalPrice(BigDecimal taxInclusiveTotalPrice, BigDecimal taxRate) { |
| | |
| | | if (vo == null) { |
| | | return; |
| | | } |
| | | vo.setContractAmounts(scaleAmount(vo.getContractAmounts())); |
| | | vo.setShippedAmount(scaleAmount(vo.getShippedAmount())); |
| | | vo.setUnshippedAmount(scaleAmount(vo.getUnshippedAmount())); |
| | | vo.setContractAmounts(scaleMoney(vo.getContractAmounts())); |
| | | vo.setShippedAmount(scaleMoney(vo.getShippedAmount())); |
| | | vo.setUnshippedAmount(scaleMoney(vo.getUnshippedAmount())); |
| | | } |
| | | |
| | | public static void normalizeCustomerTransactionDetail(CustomerTransactionsDetailsVo vo) { |
| | | if (vo == null) { |
| | | return; |
| | | } |
| | | vo.setContractAmount(scaleAmount(vo.getContractAmount())); |
| | | vo.setShippedAmount(scaleAmount(vo.getShippedAmount())); |
| | | vo.setUnshippedAmount(scaleAmount(vo.getUnshippedAmount())); |
| | | vo.setContractAmount(scaleMoney(vo.getContractAmount())); |
| | | vo.setShippedAmount(scaleMoney(vo.getShippedAmount())); |
| | | vo.setUnshippedAmount(scaleMoney(vo.getUnshippedAmount())); |
| | | } |
| | | |
| | | public static void normalizeProcurementBusinessSummary(ProcurementBusinessSummaryDto dto) { |