ERP:销售订单的 receiptPrice 调整,为接入财务的收款单做准备

This commit is contained in:
YunaiV 2024-02-15 09:16:11 +08:00
parent 9e3858aea7
commit 33f654b73b
15 changed files with 70 additions and 64 deletions

View File

@ -17,6 +17,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class ErpSaleOutPageReqVO extends PageParam {
public static final Integer RECEIPT_STATUS_NONE = 0;
public static final Integer RECEIPT_STATUS_PART = 1;
public static final Integer RECEIPT_STATUS_ALL = 2;
@Schema(description = "销售单编号", example = "XS001")
private String no;
@ -45,8 +49,11 @@ public class ErpSaleOutPageReqVO extends PageParam {
@Schema(description = "结算账号编号", example = "1")
private Long accountId;
@Schema(description = "是否欠款", example = "true")
private Boolean debtStatus;
@Schema(description = "收款状态", example = "1")
private Integer receiptStatus;
@Schema(description = "是否可收款", example = "true")
private Boolean receiptEnable; // 对应 receiptStatus = [0, 1]
@Schema(description = "销售单号", example = "1")
private String orderNo;

View File

@ -55,6 +55,8 @@ public class ErpSaleOutRespVO {
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格")
private BigDecimal totalPrice;
@Schema(description = "已收款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal receiptPrice;
@Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal totalProductPrice;
@ -68,15 +70,9 @@ public class ErpSaleOutRespVO {
@Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal discountPrice;
@Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal otherPrice;
@Schema(description = "本次收款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal payPrice;
@Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
private BigDecimal debtPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址")
private String fileUrl;

View File

@ -35,10 +35,6 @@ public class ErpSaleOutSaveReqVO {
@Schema(description = "其它金额,单位:元", example = "7127")
private BigDecimal otherPrice;
@Schema(description = "本次收款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@NotNull(message = "本次收款不能为空")
private BigDecimal payPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn")
private String fileUrl;

View File

@ -17,6 +17,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class ErpSaleReturnPageReqVO extends PageParam {
public static final Integer REFUND_STATUS_NONE = 0;
public static final Integer REFUND_STATUS_PART = 1;
public static final Integer REFUND_STATUS_ALL = 2;
@Schema(description = "销售单编号", example = "XS001")
private String no;
@ -48,4 +52,10 @@ public class ErpSaleReturnPageReqVO extends PageParam {
@Schema(description = "销售单号", example = "1")
private String orderNo;
@Schema(description = "退款状态", example = "1")
private Integer refundStatus;
@Schema(description = "是否可退款", example = "true")
private Boolean refundEnable; // 对应 refundStatus = [0, 1]
}

View File

@ -55,6 +55,8 @@ public class ErpSaleReturnRespVO {
@Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
@ExcelProperty("最终合计价格")
private BigDecimal totalPrice;
@Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal refundPrice;
@Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal totalProductPrice;
@ -68,15 +70,9 @@ public class ErpSaleReturnRespVO {
@Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal discountPrice;
@Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal otherPrice;
@Schema(description = "本次退款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
private BigDecimal refundPrice;
@Schema(description = "本次欠款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
private BigDecimal debtPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn")
@ExcelProperty("附件地址")
private String fileUrl;

View File

@ -35,10 +35,6 @@ public class ErpSaleReturnSaveReqVO {
@Schema(description = "其它金额,单位:元", example = "7127")
private BigDecimal otherPrice;
@Schema(description = "本次退款,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127")
@NotNull(message = "本次退款不能为空")
private BigDecimal refundPrice;
@Schema(description = "附件地址", example = "https://www.iocoder.cn")
private String fileUrl;

View File

@ -0,0 +1,4 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.finance;
public class ErpFinanceReceiptDO {
}

View File

@ -83,7 +83,7 @@ public class ErpPurchaseInDO extends BaseDO {
/**
* 已支付金额单位
*
* 目的 TODO erp_finance_payment 结合记录已支付金额
* 目的 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} 结合记录已支付金额
*/
private BigDecimal paymentPrice;

View File

@ -83,7 +83,7 @@ public class ErpPurchaseReturnDO extends BaseDO {
/**
* 已退款金额单位
*
* 目的 TODO erp_finance_payment 结合记录已退款金额
* 目的 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} 结合记录已支付金额
*/
private BigDecimal refundPrice;

View File

@ -83,9 +83,15 @@ public class ErpSaleOutDO extends BaseDO {
/**
* 最终合计价格单位
*
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice
*/
private BigDecimal totalPrice;
/**
* 已收款金额单位
*
* 目的 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 结合记录已收款金额
*/
private BigDecimal receiptPrice;
/**
* 合计产品价格单位
@ -110,18 +116,6 @@ public class ErpSaleOutDO extends BaseDO {
*/
private BigDecimal otherPrice;
// TODO 芋艿receiptPrice
/**
* 本次收款单位
*
* payPrice = totalPrice + otherPrice - debtPrice
*/
private BigDecimal payPrice;
/**
* 本次欠款单位
*/
private BigDecimal debtPrice;
/**
* 附件地址
*/

View File

@ -83,9 +83,15 @@ public class ErpSaleReturnDO extends BaseDO {
/**
* 最终合计价格单位
*
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice
*/
private BigDecimal totalPrice;
/**
* 已退款金额单位
*
* 目的 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 结合记录已退款金额
*/
private BigDecimal refundPrice;
/**
* 合计产品价格单位
@ -110,17 +116,6 @@ public class ErpSaleReturnDO extends BaseDO {
*/
private BigDecimal otherPrice;
/**
* 本次收款单位
*
* refundPrice = totalPrice + otherPrice - debtPrice
*/
private BigDecimal refundPrice;
/**
* 本次欠款单位
*/
private BigDecimal debtPrice;
/**
* 附件地址
*/

View File

@ -10,8 +10,8 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* ERP 销售出库 Mapper
@ -32,10 +32,16 @@ public interface ErpSaleOutMapper extends BaseMapperX<ErpSaleOutDO> {
.eqIfPresent(ErpSaleOutDO::getAccountId, reqVO.getAccountId())
.likeIfPresent(ErpSaleOutDO::getOrderNo, reqVO.getOrderNo())
.orderByDesc(ErpSaleOutDO::getId);
if (Boolean.TRUE.equals(reqVO.getDebtStatus())) {
query.gt(ErpSaleOutDO::getDebtPrice, BigDecimal.ZERO);
} else if (Boolean.FALSE.equals(reqVO.getDebtStatus())) {
query.eq(ErpSaleOutDO::getDebtPrice, BigDecimal.ZERO);
// 收款状态为什么需要 t. 的原因是因为联表查询时需要指定表名不然会报字段不存在的错误
if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_NONE)) {
query.eq(ErpSaleOutDO::getReceiptPrice, 0);
} else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_PART)) {
query.gt(ErpSaleOutDO::getReceiptPrice, 0).apply("t.receipt_price < t.total_price");
} else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_ALL)) {
query.apply("t.receipt_price = t.total_price");
}
if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) {
query.apply("t.receipt_price < t.total_price");
}
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId)

View File

@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Objects;
/**
* ERP 销售退货 Mapper
@ -31,6 +32,17 @@ public interface ErpSaleReturnMapper extends BaseMapperX<ErpSaleReturnDO> {
.eqIfPresent(ErpSaleReturnDO::getAccountId, reqVO.getAccountId())
.likeIfPresent(ErpSaleReturnDO::getOrderNo, reqVO.getOrderNo())
.orderByDesc(ErpSaleReturnDO::getId);
// 退款状态为什么需要 t. 的原因是因为联表查询时需要指定表名不然会报字段不存在的错误
if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_NONE)) {
query.eq(ErpSaleReturnDO::getRefundPrice, 0);
} else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_PART)) {
query.gt(ErpSaleReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price");
} else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_ALL)) {
query.apply("t.refund_price = t.total_price");
}
if (Boolean.TRUE.equals(reqVO.getRefundEnable())) {
query.apply("t.refund_price < t.total_price");
}
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId)
.eq(reqVO.getWarehouseId() != null, ErpSaleReturnItemDO::getWarehouseId, reqVO.getWarehouseId())

View File

@ -148,10 +148,7 @@ public class ErpSaleOutServiceImpl implements ErpSaleOutService {
saleOut.setDiscountPercent(BigDecimal.ZERO);
}
saleOut.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOut.getTotalPrice(), saleOut.getDiscountPercent()));
saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice()));
// 计算应收金额
BigDecimal allPrice = saleOut.getTotalPrice().add(saleOut.getOtherPrice());
saleOut.setDebtPrice(allPrice.subtract(saleOut.getPayPrice()));
saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice().add(saleOut.getOtherPrice())));
}
private void updateSaleOrderOutCount(Long orderId) {

View File

@ -148,10 +148,7 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
saleReturn.setDiscountPercent(BigDecimal.ZERO);
}
saleReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleReturn.getTotalPrice(), saleReturn.getDiscountPercent()));
saleReturn.setTotalPrice(saleReturn.getTotalPrice().subtract(saleReturn.getDiscountPrice()));
// 计算应退金额
BigDecimal allPrice = saleReturn.getTotalPrice().add(saleReturn.getOtherPrice());
saleReturn.setDebtPrice(allPrice.subtract(saleReturn.getRefundPrice()));
saleReturn.setTotalPrice(saleReturn.getTotalPrice().subtract(saleReturn.getDiscountPrice().add(saleReturn.getOtherPrice())));
}
private void updateSaleOrderReturnCount(Long orderId) {