Commit eefd787de6dc731adc36cf1a4a845578cae53fea
1 parent
f93bad28
✨ ERP:初始化 receipt 收款单的逻辑 100%
Showing
6 changed files
with
16 additions
and
11 deletions
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java
| ... | ... | @@ -14,8 +14,8 @@ import java.math.BigDecimal; |
| 14 | 14 | * |
| 15 | 15 | * @author 芋道源码 |
| 16 | 16 | */ |
| 17 | -@TableName("erp_finance_payment_item") | |
| 18 | -@KeySequence("erp_finance_payment_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 17 | +@TableName("erp_finance_receipt_item") | |
| 18 | +@KeySequence("erp_finance_receipt_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 19 | 19 | @Data |
| 20 | 20 | @EqualsAndHashCode(callSuper = true) |
| 21 | 21 | @ToString(callSuper = true) | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java
| ... | ... | @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 7 | 7 | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; |
| 9 | 9 | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; |
| 10 | +import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; | |
| 10 | 11 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 11 | 12 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 13 | |
| ... | ... | @@ -41,7 +42,8 @@ public interface ErpSaleOutMapper extends BaseMapperX<ErpSaleOutDO> { |
| 41 | 42 | query.apply("t.receipt_price = t.total_price"); |
| 42 | 43 | } |
| 43 | 44 | if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) { |
| 44 | - query.apply("t.receipt_price < t.total_price"); | |
| 45 | + query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) | |
| 46 | + .apply("t.receipt_price < t.total_price"); | |
| 45 | 47 | } |
| 46 | 48 | if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { |
| 47 | 49 | query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId) | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java
| ... | ... | @@ -5,8 +5,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 7 | 7 | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; |
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; | |
| 8 | 9 | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; |
| 9 | 10 | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; |
| 11 | +import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; | |
| 10 | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 11 | 13 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 14 | |
| ... | ... | @@ -41,7 +43,8 @@ public interface ErpSaleReturnMapper extends BaseMapperX<ErpSaleReturnDO> { |
| 41 | 43 | query.apply("t.refund_price = t.total_price"); |
| 42 | 44 | } |
| 43 | 45 | if (Boolean.TRUE.equals(reqVO.getRefundEnable())) { |
| 44 | - query.apply("t.refund_price < t.total_price"); | |
| 46 | + query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) | |
| 47 | + .apply("t.refund_price < t.total_price"); | |
| 45 | 48 | } |
| 46 | 49 | if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { |
| 47 | 50 | query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId) | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java
| ... | ... | @@ -96,6 +96,9 @@ public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService { |
| 96 | 96 | // 2.2 插入付款单项 |
| 97 | 97 | paymentItems.forEach(o -> o.setPaymentId(payment.getId())); |
| 98 | 98 | financePaymentItemMapper.insertBatch(paymentItems); |
| 99 | + | |
| 100 | + // 3. 更新采购入库、退货的付款金额情况 | |
| 101 | + updatePurchasePrice(paymentItems); | |
| 99 | 102 | return payment.getId(); |
| 100 | 103 | } |
| 101 | 104 | |
| ... | ... | @@ -127,9 +130,6 @@ public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService { |
| 127 | 130 | financePaymentMapper.updateById(updateObj); |
| 128 | 131 | // 2.2 更新付款单项 |
| 129 | 132 | updateFinancePaymentItemList(updateReqVO.getId(), paymentItems); |
| 130 | - | |
| 131 | - // 3. 更新采购入库、退货的付款金额情况 | |
| 132 | - updatePurchasePrice(paymentItems); | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | private void calculateTotalPrice(ErpFinancePaymentDO payment, List<ErpFinancePaymentItemDO> paymentItems) { | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java
| ... | ... | @@ -96,6 +96,9 @@ public class ErpFinanceReceiptServiceImpl implements ErpFinanceReceiptService { |
| 96 | 96 | // 2.2 插入收款单项 |
| 97 | 97 | receiptItems.forEach(o -> o.setReceiptId(receipt.getId())); |
| 98 | 98 | financeReceiptItemMapper.insertBatch(receiptItems); |
| 99 | + | |
| 100 | + // 3. 更新销售出库、退货的收款金额情况 | |
| 101 | + updateSalePrice(receiptItems); | |
| 99 | 102 | return receipt.getId(); |
| 100 | 103 | } |
| 101 | 104 | |
| ... | ... | @@ -127,9 +130,6 @@ public class ErpFinanceReceiptServiceImpl implements ErpFinanceReceiptService { |
| 127 | 130 | financeReceiptMapper.updateById(updateObj); |
| 128 | 131 | // 2.2 更新收款单项 |
| 129 | 132 | updateFinanceReceiptItemList(updateReqVO.getId(), receiptItems); |
| 130 | - | |
| 131 | - // 3. 更新销售出库、退货的收款金额情况 | |
| 132 | - updateSalePrice(receiptItems); | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | private void calculateTotalPrice(ErpFinanceReceiptDO receipt, List<ErpFinanceReceiptItemDO> receiptItems) { | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java
| ... | ... | @@ -286,7 +286,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService { |
| 286 | 286 | |
| 287 | 287 | @Override |
| 288 | 288 | public ErpSaleOutDO validateSaleOut(Long id) { |
| 289 | - ErpSaleOutDO saleOut = validateSaleOut(id); | |
| 289 | + ErpSaleOutDO saleOut = validateSaleOutExists(id); | |
| 290 | 290 | if (ObjectUtil.notEqual(saleOut.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { |
| 291 | 291 | throw exception(SALE_OUT_NOT_APPROVE); |
| 292 | 292 | } | ... | ... |