| | |
| | | deviceLedger.setCreateUser(SecurityUtils.getUserId().intValue()); |
| | | } |
| | | BeanUtils.copyProperties(c, deviceLedger); |
| | | // 通过含税单价、数量、税率计算含税总价,不含税总价 |
| | | deviceLedger.setTaxIncludingPriceTotal(c.getTaxIncludingPriceUnit()); |
| | | // 数量:Excel 未填时按 1 台处理 |
| | | if (deviceLedger.getNumber() == null) { |
| | | deviceLedger.setNumber(BigDecimal.ONE); |
| | | } |
| | | // 含税总价:Excel 未填时按 含税单价 × 数量 计算 |
| | | if (deviceLedger.getTaxIncludingPriceTotal() == null && deviceLedger.getTaxIncludingPriceUnit() != null) { |
| | | deviceLedger.setTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceUnit().multiply(deviceLedger.getNumber())); |
| | | } |
| | | deviceLedger.setPlanRuntimeTime(DateUtils.toLocalDate(c.getPlanRuntimeTime())); |
| | | // 计算不含税总价,处理空值情况 |
| | | if (deviceLedger.getTaxIncludingPriceTotal() != null && c.getTaxRate() != null) { |
| | | deviceLedger.setUnTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceTotal().divide(BigDecimal.ONE.add(c.getTaxRate()), 2, RoundingMode.HALF_UP)); |
| | | // 不含税总价:含税总价与税率都有值时按税率折算,税率按百分数存储(13 表示 13%),与台账现有数据口径一致 |
| | | if (deviceLedger.getTaxIncludingPriceTotal() != null && deviceLedger.getTaxRate() != null) { |
| | | BigDecimal rate = deviceLedger.getTaxRate().divide(new BigDecimal(100), 4, RoundingMode.HALF_UP); |
| | | deviceLedger.setUnTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceTotal() |
| | | .divide(BigDecimal.ONE.add(rate), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | return deviceLedger; |
| | | } |