From 43b878fc35d2c4b2a7163aa472a333ac9fbd53f2 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 12 十月 2026 18:19:17 +0800
Subject: [PATCH] fix(erp/crm): 单据明细单价口径由「不含税单价」改为「含税单价」
---
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestDO.java | 7 ++-
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java | 10 +++--
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java | 10 +++-
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java | 5 +-
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java | 10 +++--
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java | 10 +++-
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java | 8 +++-
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseRequestServiceImpl.java | 8 +++-
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/quotation/CrmSaleQuotationProductDO.java | 10 +++-
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java | 5 +-
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestItemDO.java | 10 ++++-
11 files changed, 64 insertions(+), 29 deletions(-)
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/quotation/CrmSaleQuotationProductDO.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/quotation/CrmSaleQuotationProductDO.java
index bf25103..f136422 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/quotation/CrmSaleQuotationProductDO.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/quotation/CrmSaleQuotationProductDO.java
@@ -51,7 +51,7 @@
*/
private BigDecimal itemPrice;
/**
- * 鎶ヤ环鍗曚环锛屽崟浣嶏細鍏�
+ * 鎶ヤ环鍚◣鍗曚环锛屽崟浣嶏細鍏�
*/
private BigDecimal quotationPrice;
/**
@@ -59,9 +59,10 @@
*/
private BigDecimal count;
/**
- * 灏忚閲戦锛屽崟浣嶏細鍏�
+ * 涓嶅惈绋庨噾棰濓紝鍗曚綅锛氬厓
*
- * totalPrice = quotationPrice * count
+ * 鍚◣閲戦 = quotationPrice * count
+ * totalPrice = 鍚◣閲戦 - taxPrice
*/
private BigDecimal totalPrice;
/**
@@ -70,6 +71,9 @@
private BigDecimal taxPercent;
/**
* 绋庨锛屽崟浣嶏細鍏�
+ *
+ * 鍚◣閲戦 = quotationPrice * count
+ * taxPrice = 鍚◣閲戦 * taxPercent
*/
private BigDecimal taxPrice;
/**
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
index 1b0237a..9e8f428 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
@@ -181,10 +181,14 @@
// 鐗╂枡鍘熶环锛屽鏋� MDM 涓病鏈夊垯榛樿涓� 0
item.setItemPrice(mdmItem.getSalesPrice() != null ? mdmItem.getSalesPrice() : BigDecimal.ZERO);
if (item.getQuotationPrice() != null && item.getCount() != null) {
- item.setTotalPrice(MoneyUtils.priceMultiply(item.getQuotationPrice(), item.getCount()));
+ // 鎶ヤ环涓哄惈绋庡崟浠凤細鍚◣閲戦 = 鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ BigDecimal taxInclusivePrice = MoneyUtils.priceMultiply(item.getQuotationPrice(), item.getCount());
+ BigDecimal taxPrice = null;
if (item.getTaxPercent() != null) {
- item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent()));
+ taxPrice = MoneyUtils.priceMultiplyPercent(taxInclusivePrice, item.getTaxPercent());
}
+ item.setTaxPrice(taxPrice);
+ item.setTotalPrice(taxPrice != null ? taxInclusivePrice.subtract(taxPrice) : taxInclusivePrice);
}
}));
}
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java
index 0f9b877..d9a510b 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java
@@ -62,14 +62,15 @@
*/
private BigDecimal totalCount;
/**
- * 鏈�缁堝悎璁′环鏍硷紝鍗曚綅锛氬厓
+ * 鏈�缁堝悎璁′环鏍硷紙鍚◣锛夛紝鍗曚綅锛氬厓
*
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice
+ * 绛変环浜� 危(鍚◣鍗曚环 * 鏁伴噺) - discountPrice
*/
private BigDecimal totalPrice;
/**
- * 鍚堣浜у搧浠锋牸锛屽崟浣嶏細鍏�
+ * 鍚堣浜у搧浠锋牸锛堜笉鍚◣锛夛紝鍗曚綅锛氬厓
*/
private BigDecimal totalProductPrice;
/**
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java
index ba47f4d..d17e98c 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java
@@ -54,7 +54,7 @@
private Long productUnitId;
/**
- * 浜у搧鍗曚綅鍗曚环锛屽崟浣嶏細鍏�
+ * 浜у搧鍗曚綅鍚◣鍗曚环锛屽崟浣嶏細鍏�
*/
private BigDecimal productPrice;
/**
@@ -62,9 +62,10 @@
*/
private BigDecimal count;
/**
- * 鎬讳环锛屽崟浣嶏細鍏�
+ * 涓嶅惈绋庨噾棰濓紝鍗曚綅锛氬厓
*
- * totalPrice = productPrice * count
+ * 鍚◣閲戦 = productPrice * count
+ * totalPrice = 鍚◣閲戦 - taxPrice
*/
private BigDecimal totalPrice;
/**
@@ -74,7 +75,8 @@
/**
* 绋庨锛屽崟浣嶏細鍏�
*
- * taxPrice = totalPrice * taxPercent
+ * 鍚◣閲戦 = productPrice * count
+ * taxPrice = 鍚◣閲戦 * taxPercent
*/
private BigDecimal taxPrice;
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestDO.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestDO.java
index de4cde0..fe2998c 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestDO.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestDO.java
@@ -75,12 +75,15 @@
private BigDecimal totalCount;
/**
- * 鍚堣浠锋牸
+ * 鍚堣浠锋牸锛堝惈绋庯級
+ *
+ * totalPrice = totalProductPrice + totalTaxPrice - discountPrice
+ * 绛変环浜� 危(鍚◣鍗曚环 * 鏁伴噺) - discountPrice
*/
private BigDecimal totalPrice;
/**
- * 鍚堣浜у搧浠锋牸
+ * 鍚堣浜у搧浠锋牸锛堜笉鍚◣锛�
*/
private BigDecimal totalProductPrice;
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestItemDO.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestItemDO.java
index f69cae5..7422f8f 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestItemDO.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseRequestItemDO.java
@@ -44,7 +44,7 @@
private Long productUnitId;
/**
- * 浜у搧鍙傝�冨崟浠�
+ * 浜у搧鍙傝�冨惈绋庡崟浠�
*/
private BigDecimal productPrice;
@@ -54,7 +54,10 @@
private BigDecimal count;
/**
- * 鎬讳环
+ * 涓嶅惈绋庨噾棰�
+ *
+ * 鍚◣閲戦 = productPrice * count
+ * totalPrice = 鍚◣閲戦 - taxPrice
*/
private BigDecimal totalPrice;
@@ -65,6 +68,9 @@
/**
* 绋庨
+ *
+ * 鍚◣閲戦 = productPrice * count
+ * taxPrice = 鍚◣閲戦 * taxPercent
*/
private BigDecimal taxPrice;
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java
index e2998c3..94d211b 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java
@@ -76,14 +76,15 @@
*/
private BigDecimal totalCount;
/**
- * 鏈�缁堝悎璁′环鏍硷紝鍗曚綅锛氬厓
+ * 鏈�缁堝悎璁′环鏍硷紙鍚◣锛夛紝鍗曚綅锛氬厓
*
* totalPrice = totalProductPrice + totalTaxPrice - discountPrice
+ * 绛変环浜� 危(鍚◣鍗曚环 * 鏁伴噺) - discountPrice
*/
private BigDecimal totalPrice;
/**
- * 鍚堣浜у搧浠锋牸锛屽崟浣嶏細鍏�
+ * 鍚堣浜у搧浠锋牸锛堜笉鍚◣锛夛紝鍗曚綅锛氬厓
*/
private BigDecimal totalProductPrice;
/**
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java
index 451f89e..c912b11 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java
@@ -48,7 +48,7 @@
private Long productUnitId;
/**
- * 浜у搧鍗曚綅鍗曚环锛屽崟浣嶏細鍏�
+ * 浜у搧鍗曚綅鍚◣鍗曚环锛屽崟浣嶏細鍏�
*/
private BigDecimal productPrice;
/**
@@ -56,9 +56,10 @@
*/
private BigDecimal count;
/**
- * 鎬讳环锛屽崟浣嶏細鍏�
+ * 涓嶅惈绋庨噾棰濓紝鍗曚綅锛氬厓
*
- * totalPrice = productPrice * count
+ * 鍚◣閲戦 = productPrice * count
+ * totalPrice = 鍚◣閲戦 - taxPrice
*/
private BigDecimal totalPrice;
/**
@@ -68,7 +69,8 @@
/**
* 绋庨锛屽崟浣嶏細鍏�
*
- * taxPrice = totalPrice * taxPercent
+ * 鍚◣閲戦 = productPrice * count
+ * taxPrice = 鍚◣閲戦 * taxPercent
*/
private BigDecimal taxPrice;
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java
index 4b51cfc..2d67913 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java
@@ -486,13 +486,17 @@
private List<ErpPurchaseOrderItemDO> validatePurchaseOrderItems(List<ErpPurchaseOrderSaveReqVO.Item> list) {
// 杞寲涓� ErpPurchaseOrderItemDO 鍒楄〃锛堜骇鍝侀獙璇佸凡绉婚櫎锛�
return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseOrderItemDO.class, item -> {
- item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount()));
- if (item.getTotalPrice() == null) {
+ // 鍗曚环涓哄惈绋庡崟浠凤細鍚◣閲戦 = 鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ BigDecimal taxInclusivePrice = MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount());
+ if (taxInclusivePrice == null) {
return;
}
+ BigDecimal taxPrice = null;
if (item.getTaxPercent() != null) {
- item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent()));
+ taxPrice = MoneyUtils.priceMultiplyPercent(taxInclusivePrice, item.getTaxPercent());
}
+ item.setTaxPrice(taxPrice);
+ item.setTotalPrice(taxPrice != null ? taxInclusivePrice.subtract(taxPrice) : taxInclusivePrice);
}));
}
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseRequestServiceImpl.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseRequestServiceImpl.java
index 54d6447..942852a 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseRequestServiceImpl.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseRequestServiceImpl.java
@@ -363,10 +363,14 @@
private List<ErpPurchaseRequestItemDO> validatePurchaseRequestItems(List<ErpPurchaseRequestSaveReqVO.Item> list) {
return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseRequestItemDO.class, item -> {
if (item.getProductPrice() != null && item.getCount() != null) {
- item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount()));
+ // 鍗曚环涓哄惈绋庡崟浠凤細鍚◣閲戦 = 鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ BigDecimal taxInclusivePrice = MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount());
+ BigDecimal taxPrice = null;
if (item.getTaxPercent() != null) {
- item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent()));
+ taxPrice = MoneyUtils.priceMultiplyPercent(taxInclusivePrice, item.getTaxPercent());
}
+ item.setTaxPrice(taxPrice);
+ item.setTotalPrice(taxPrice != null ? taxInclusivePrice.subtract(taxPrice) : taxInclusivePrice);
}
}));
}
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java
index 18985aa..76f1155 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java
@@ -625,13 +625,17 @@
private List<ErpSaleOrderItemDO> validateSaleOrderItems(List<ErpSaleOrderSaveReqVO.Item> list) {
// 杞寲涓� ErpSaleOrderItemDO 鍒楄〃锛堜骇鍝侀獙璇佸凡绉婚櫎锛�
return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOrderItemDO.class, item -> {
- item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount()));
- if (item.getTotalPrice() == null) {
+ // 鍗曚环涓哄惈绋庡崟浠凤細鍚◣閲戦 = 鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ BigDecimal taxInclusivePrice = MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount());
+ if (taxInclusivePrice == null) {
return;
}
+ BigDecimal taxPrice = null;
if (item.getTaxPercent() != null) {
- item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent()));
+ taxPrice = MoneyUtils.priceMultiplyPercent(taxInclusivePrice, item.getTaxPercent());
}
+ item.setTaxPrice(taxPrice);
+ item.setTotalPrice(taxPrice != null ? taxInclusivePrice.subtract(taxPrice) : taxInclusivePrice);
}));
}
--
Gitblit v1.9.3