| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.pojo.AccountExpense; |
| | | import com.ruoyi.account.service.AccountExpenseService; |
| | | import com.ruoyi.basic.mapper.SupplierManageMapper; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | private TicketRegistrationMapper ticketRegistrationMapper; |
| | | |
| | | private ProductRecordMapper productRecordMapper; |
| | | |
| | | private AccountExpenseService accountExpenseService; |
| | | |
| | | /** |
| | | * 查询付款登记 |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int insertPaymentRegistration(PaymentRegistration paymentRegistration) { |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId()); |
| | | SalesLedger salesLedger = salesLedgerMapper.selectOne(new QueryWrapper<SalesLedger>(). |
| | |
| | | paymentRegistration.setRegistrantId(loginUser.getUserId()); |
| | | paymentRegistration.setCreateTime(DateUtils.getNowDate()); |
| | | paymentRegistration.setUpdateTime(DateUtils.getNowDate()); |
| | | |
| | | // 2. 处理账户收入 |
| | | AccountExpense accountExpense = new AccountExpense(); |
| | | accountExpense.setExpenseDate(purchaseLedger.getEntryDate()); |
| | | accountExpense.setExpenseType("0"); |
| | | accountExpense.setSupplierName(purchaseLedger.getSupplierName()); |
| | | accountExpense.setExpenseMoney(paymentRegistration.getCurrentPaymentAmount()); |
| | | accountExpense.setExpenseDescribed("付款登记:" + tr.getInvoiceNumber()); |
| | | accountExpense.setExpenseMethod("0"); |
| | | accountExpense.setInvoiceNumber(tr.getInvoiceNumber()); |
| | | accountExpense.setInputTime(new Date()); |
| | | accountExpense.setInputUser(loginUser.getNickName()); |
| | | accountExpenseService.save(accountExpense); |
| | | return paymentRegistrationMapper.insert(paymentRegistration); |
| | | } |
| | | |
| | |
| | | if (total.add(paymentRegistration.getCurrentPaymentAmount()).compareTo(ticketRegistration.getInvoiceAmount()) > 0) { |
| | | throw new RuntimeException("付款金额超出发票金额"); |
| | | } |
| | | |
| | | List<AccountExpense> accountExpenseDBs = accountExpenseService.getByInvoiceNumberList(ticketRegistration.getInvoiceNumber()); |
| | | if (!CollectionUtils.isEmpty(accountExpenseDBs)) { |
| | | accountExpenseDBs.forEach(accountExpenseDB -> { |
| | | accountExpenseDB.setExpenseMoney(paymentRegistration.getCurrentPaymentAmount()); |
| | | accountExpenseService.updateById(accountExpenseDB); |
| | | }); |
| | | } |
| | | paymentRegistration.setUpdateTime(DateUtils.getNowDate()); |
| | | return paymentRegistrationMapper.updateById(paymentRegistration); |
| | | } |