| | |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.purchase.dto.PaymentHistoryRecordVo; |
| | | import com.ruoyi.purchase.dto.PaymentLedgerDto; |
| | |
| | | /** |
| | | * 新增付款登记 |
| | | * |
| | | * @param paymentRegistrationList 付款登记 |
| | | * @param paymentRegistration 付款登记 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertPaymentRegistration(List<PaymentRegistration> paymentRegistrationList) { |
| | | public int insertPaymentRegistration(PaymentRegistration paymentRegistration) { |
| | | LoginUser userId = SecurityUtils.getLoginUser(); |
| | | for (PaymentRegistration paymentRegistration : paymentRegistrationList) { |
| | | PaymentRegistration byId = paymentRegistration; |
| | | if (!ObjectUtils.isEmpty(paymentRegistration.getId())){ |
| | | paymentRegistration = this.getById(paymentRegistration.getId()); |
| | |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId()); |
| | | if(null==purchaseLedger) throw new RuntimeException("未找到采购单"); |
| | | // 已回款金额 |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSalesLedgerProductId()); |
| | | if(null==salesLedgerProduct) throw new RuntimeException("未找到采购单产品"); |
| | | if (salesLedgerProduct.getPendingTicketsTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){ |
| | | throw new RuntimeException("本次回款金额不能大于待回款金额"); |
| | | } |
| | | // SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSalesLedgerProductId()); |
| | | // if(null==salesLedgerProduct) throw new RuntimeException("未找到采购单产品"); |
| | | // if (salesLedgerProduct.getPendingTicketsTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){ |
| | | // throw new RuntimeException("本次回款金额不能大于待回款金额"); |
| | | // } |
| | | paymentRegistration.setCreateTime(DateUtils.getNowDate()); |
| | | paymentRegistration.setUpdateTime(DateUtils.getNowDate()); |
| | | paymentRegistration.setRegistrantId(userId.getUserId()); |
| | | salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(paymentRegistration.getCurrentPaymentAmount())); |
| | | salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal())); |
| | | // salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(paymentRegistration.getCurrentPaymentAmount())); |
| | | // salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal())); |
| | | paymentRegistrationMapper.insert(paymentRegistration); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | // salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | // 2. 处理账户支出 |
| | | AccountExpense accountExpense = new AccountExpense(); |
| | | accountExpense.setExpenseDate(purchaseLedger.getEntryDate()); |
| | |
| | | accountExpense.setInputTime(new Date()); |
| | | accountExpense.setInputUser(userId.getNickName()); |
| | | accountExpenseService.save(accountExpense); |
| | | } |
| | | return 1; |
| | | |
| | | } |