ERP:初始化 receipt 收款单的逻辑 100%

This commit is contained in:
YunaiV 2024-02-16 08:13:21 +08:00
parent f93bad282f
commit eefd787de6
6 changed files with 16 additions and 11 deletions

View File

@ -14,8 +14,8 @@ import java.math.BigDecimal;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@TableName("erp_finance_payment_item") @TableName("erp_finance_receipt_item")
@KeySequence("erp_finance_payment_item_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写 @KeySequence("erp_finance_receipt_item_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO;
import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -41,7 +42,8 @@ public interface ErpSaleOutMapper extends BaseMapperX<ErpSaleOutDO> {
query.apply("t.receipt_price = t.total_price"); query.apply("t.receipt_price = t.total_price");
} }
if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) { if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) {
query.apply("t.receipt_price < t.total_price"); query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus())
.apply("t.receipt_price < t.total_price");
} }
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId) query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId)

View File

@ -5,8 +5,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO;
import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -41,7 +43,8 @@ public interface ErpSaleReturnMapper extends BaseMapperX<ErpSaleReturnDO> {
query.apply("t.refund_price = t.total_price"); query.apply("t.refund_price = t.total_price");
} }
if (Boolean.TRUE.equals(reqVO.getRefundEnable())) { if (Boolean.TRUE.equals(reqVO.getRefundEnable())) {
query.apply("t.refund_price < t.total_price"); query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus())
.apply("t.refund_price < t.total_price");
} }
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId) query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId)

View File

@ -96,6 +96,9 @@ public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService {
// 2.2 插入付款单项 // 2.2 插入付款单项
paymentItems.forEach(o -> o.setPaymentId(payment.getId())); paymentItems.forEach(o -> o.setPaymentId(payment.getId()));
financePaymentItemMapper.insertBatch(paymentItems); financePaymentItemMapper.insertBatch(paymentItems);
// 3. 更新采购入库退货的付款金额情况
updatePurchasePrice(paymentItems);
return payment.getId(); return payment.getId();
} }
@ -127,9 +130,6 @@ public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService {
financePaymentMapper.updateById(updateObj); financePaymentMapper.updateById(updateObj);
// 2.2 更新付款单项 // 2.2 更新付款单项
updateFinancePaymentItemList(updateReqVO.getId(), paymentItems); updateFinancePaymentItemList(updateReqVO.getId(), paymentItems);
// 3. 更新采购入库退货的付款金额情况
updatePurchasePrice(paymentItems);
} }
private void calculateTotalPrice(ErpFinancePaymentDO payment, List<ErpFinancePaymentItemDO> paymentItems) { private void calculateTotalPrice(ErpFinancePaymentDO payment, List<ErpFinancePaymentItemDO> paymentItems) {

View File

@ -96,6 +96,9 @@ public class ErpFinanceReceiptServiceImpl implements ErpFinanceReceiptService {
// 2.2 插入收款单项 // 2.2 插入收款单项
receiptItems.forEach(o -> o.setReceiptId(receipt.getId())); receiptItems.forEach(o -> o.setReceiptId(receipt.getId()));
financeReceiptItemMapper.insertBatch(receiptItems); financeReceiptItemMapper.insertBatch(receiptItems);
// 3. 更新销售出库退货的收款金额情况
updateSalePrice(receiptItems);
return receipt.getId(); return receipt.getId();
} }
@ -127,9 +130,6 @@ public class ErpFinanceReceiptServiceImpl implements ErpFinanceReceiptService {
financeReceiptMapper.updateById(updateObj); financeReceiptMapper.updateById(updateObj);
// 2.2 更新收款单项 // 2.2 更新收款单项
updateFinanceReceiptItemList(updateReqVO.getId(), receiptItems); updateFinanceReceiptItemList(updateReqVO.getId(), receiptItems);
// 3. 更新销售出库退货的收款金额情况
updateSalePrice(receiptItems);
} }
private void calculateTotalPrice(ErpFinanceReceiptDO receipt, List<ErpFinanceReceiptItemDO> receiptItems) { private void calculateTotalPrice(ErpFinanceReceiptDO receipt, List<ErpFinanceReceiptItemDO> receiptItems) {

View File

@ -286,7 +286,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
@Override @Override
public ErpSaleOutDO validateSaleOut(Long id) { public ErpSaleOutDO validateSaleOut(Long id) {
ErpSaleOutDO saleOut = validateSaleOut(id); ErpSaleOutDO saleOut = validateSaleOutExists(id);
if (ObjectUtil.notEqual(saleOut.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { if (ObjectUtil.notEqual(saleOut.getStatus(), ErpAuditStatus.APPROVE.getStatus())) {
throw exception(SALE_OUT_NOT_APPROVE); throw exception(SALE_OUT_NOT_APPROVE);
} }