| | |
| | | SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct(); |
| | | BeanUtils.copyProperties(salesLedgerProductImportDto, salesLedgerProduct); |
| | | salesLedgerProduct.setSingleQuantity(normalizeSingleQuantity(salesLedgerProduct.getSingleQuantity())); |
| | | salesLedgerProduct.setTotalQuantity(normalizeTotalQuantity( |
| | | salesLedgerProduct.getTotalQuantity(), |
| | | salesLedgerProduct.getQuantity(), |
| | | salesLedgerProduct.getSingleQuantity() |
| | | )); |
| | | salesLedgerProduct.setSalesLedgerId(salesLedger.getId()); |
| | | salesLedgerProduct.setType(1); |
| | | // 计算不含税总价 |
| | |
| | | .peek(p -> { |
| | | p.setSalesLedgerId(salesLedgerId); |
| | | p.setSingleQuantity(normalizeSingleQuantity(p.getSingleQuantity())); |
| | | p.setTotalQuantity(normalizeTotalQuantity(p.getTotalQuantity(), p.getQuantity(), p.getSingleQuantity())); |
| | | }) |
| | | .collect(Collectors.partitioningBy(p -> p.getId() != null)); |
| | | |
| | |
| | | return singleQuantity; |
| | | } |
| | | |
| | | private BigDecimal normalizeTotalQuantity(BigDecimal totalQuantity, BigDecimal quantity, BigDecimal singleQuantity) { |
| | | if (totalQuantity != null && totalQuantity.compareTo(BigDecimal.ZERO) > 0) { |
| | | return totalQuantity; |
| | | } |
| | | if (quantity == null || quantity.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return quantity.multiply(normalizeSingleQuantity(singleQuantity)); |
| | | } |
| | | |
| | | @Transactional(readOnly = true) |
| | | public String generateSalesContractNo() { |
| | | LocalDate currentDate = LocalDate.now(); |