| | |
| | | private List<ErpSaleOrderItemDO> validateSaleOrderItems(List<ErpSaleOrderSaveReqVO.Item> list) { |
| | | // 转化为 ErpSaleOrderItemDO 列表(产品验证已移除) |
| | | return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOrderItemDO.class, item -> { |
| | | item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); |
| | | if (item.getTotalPrice() == null) { |
| | | // 单价为含税单价:含税金额 = 单价 × 数量;税额 = 含税金额 × 税率;不含税金额 = 含税金额 - 税额 |
| | | BigDecimal taxInclusivePrice = MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount()); |
| | | if (taxInclusivePrice == null) { |
| | | return; |
| | | } |
| | | BigDecimal taxPrice = null; |
| | | if (item.getTaxPercent() != null) { |
| | | item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); |
| | | taxPrice = MoneyUtils.priceMultiplyPercent(taxInclusivePrice, item.getTaxPercent()); |
| | | } |
| | | item.setTaxPrice(taxPrice); |
| | | item.setTotalPrice(taxPrice != null ? taxInclusivePrice.subtract(taxPrice) : taxInclusivePrice); |
| | | })); |
| | | } |
| | | |