| | |
| | | throw new IllegalArgumentException("采购台账记录不存在,ID: " + ticketRegistrationDto.getPurchaseLedgerId()); |
| | | } |
| | | |
| | | |
| | | |
| | | // 3. 创建或更新票据登记实体 |
| | | TicketRegistration ticketRegistration = new TicketRegistration(); |
| | | BeanUtils.copyProperties(ticketRegistrationDto, ticketRegistration); |
| | |
| | | // 6. 增加采购台账产品开票记录 |
| | | List<SalesLedgerProduct> salesLedgerProducts = ticketRegistrationDto.getProductData(); |
| | | if (CollectionUtils.isNotEmpty(salesLedgerProducts)) { |
| | | int insert = 0 ; |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | ProductRecord productRecord = new ProductRecord(); |
| | | //排除掉开票为0的数据 |
| | | if (salesLedgerProduct.getTicketsNum() != null && salesLedgerProduct.getTicketsNum().compareTo(BigDecimal.ZERO) > 0) { |
| | | ProductRecord productRecord = new ProductRecord(); |
| | | |
| | | productRecord.setTicketRegistrationId(ticketRegistration.getId()); |
| | | productRecord.setPurchaseLedgerId(ticketRegistrationDto.getPurchaseLedgerId()); |
| | | productRecord.setCreatedAt(DateUtils.getNowDate()); |
| | | BeanUtils.copyProperties(salesLedgerProduct, productRecord); |
| | | productRecord.setSaleLedgerProjectId(salesLedgerProduct.getId()); |
| | | productRecord.setId(null); |
| | | productRecord.setType("2"); |
| | | productRecordMapper.insert(productRecord); |
| | | productRecord.setTicketRegistrationId(ticketRegistration.getId()); |
| | | productRecord.setPurchaseLedgerId(ticketRegistrationDto.getPurchaseLedgerId()); |
| | | productRecord.setCreatedAt(DateUtils.getNowDate()); |
| | | BeanUtils.copyProperties(salesLedgerProduct, productRecord); |
| | | productRecord.setSaleLedgerProjectId(salesLedgerProduct.getId()); |
| | | productRecord.setId(null); |
| | | productRecord.setType("2"); |
| | | insert = productRecordMapper.insert(productRecord); |
| | | } |
| | | if (insert <= 0) { |
| | | throw new RuntimeException("产品开票数都为0,请检查"); |
| | | } |
| | | } |
| | | } |
| | | // 迁移临时文件到正式目录 |