diff --git a/applications/datamodel/entitydef/product-entitymodel.xml b/applications/datamodel/entitydef/product-entitymodel.xml
index 1f3d78a3422..80fb8ef53c3 100644
--- a/applications/datamodel/entitydef/product-entitymodel.xml
+++ b/applications/datamodel/entitydef/product-entitymodel.xml
@@ -3562,6 +3562,7 @@ under the License.
+
diff --git a/applications/product/config/ProductUiLabels.xml b/applications/product/config/ProductUiLabels.xml
index db050fc23df..a412d198991 100644
--- a/applications/product/config/ProductUiLabels.xml
+++ b/applications/product/config/ProductUiLabels.xml
@@ -21710,6 +21710,22 @@
现货数量来自组件
現貨數量來自元件
+
+ Max. Rabattbetrag
+ Max Discount Amount
+ Importe máximo de descuento
+ Montant maximum de remise
+ Importo massimo sconto
+ 最大割引額
+ Maximum kortingsbedrag
+ Valor máximo de desconto
+ Valoare maximă reducere
+ Максимальная сумма скидки
+ จำนวนส่วนลดสูงสุด
+ Số tiền giảm giá tối đa
+ 最大折扣金额
+ 最大折扣金額
+
Maximaler Preis
Max Pr
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/promo/ProductPromoActionServices.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/promo/ProductPromoActionServices.groovy
index 40bb0a43443..18f761f0726 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/promo/ProductPromoActionServices.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/promo/ProductPromoActionServices.groovy
@@ -443,6 +443,10 @@ Map productOrderPercent() {
} else {
amount = cart.getSubTotalForPromotions() * percentage
}
+ BigDecimal maxDiscountAmount = productPromoAction.maxDiscountAmount ? productPromoAction.getBigDecimal('maxDiscountAmount') : BigDecimal.ZERO
+ if (maxDiscountAmount > BigDecimal.ZERO && amount.negate().compareTo(maxDiscountAmount) > 0) {
+ amount = maxDiscountAmount.negate()
+ }
if (amount != 0) {
ProductPromoWorker.doOrderPromoAction(productPromoAction, cart, amount, 'amount', delegator)
actionResultInfo.ranAction = true
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPromoActionTests.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPromoActionTests.groovy
index 65d84290afe..f9d3eec11a7 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPromoActionTests.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPromoActionTests.groovy
@@ -191,6 +191,21 @@ class ProductPromoActionTests extends OFBizTestCase {
assert serviceResult.actionResultInfo.totalDiscountAmount == 0
}
+ /**
+ * Ensure order percent discount honors max discount amount
+ */
+ void testProductOrderPercentMaxDiscount() {
+ ShoppingCart cart = loadOrder('DEMO10090')
+
+ Map serviceContext = prepareConditionMap(cart, 15, false)
+ serviceContext.productPromoAction.maxDiscountAmount = BigDecimal.ONE
+ Map serviceResult = dispatcher.runSync('productPromoActOrderPercent', serviceContext)
+
+ assert ServiceUtil.isSuccess(serviceResult)
+ assert serviceResult.actionResultInfo.ranAction
+ assert serviceResult.actionResultInfo.totalDiscountAmount == BigDecimal.ONE.negate()
+ }
+
/**
* This test check if the function productPromoActProdPrice work correctly
* 1. test failed with passing non valid value
diff --git a/applications/product/template/promo/EditProductPromoRules.ftl b/applications/product/template/promo/EditProductPromoRules.ftl
index 08bea181df6..7783318198b 100644
--- a/applications/product/template/promo/EditProductPromoRules.ftl
+++ b/applications/product/template/promo/EditProductPromoRules.ftl
@@ -314,6 +314,7 @@ under the License.
${uiLabelMap.ProductQuantity}:
${uiLabelMap.ProductAmount}:
+ ${uiLabelMap.ProductMaxDiscountAmount}:
${uiLabelMap.ProductItemId}: <@htmlTemplate.lookupField value="${(productPromoAction.productId)!}" formName="updateProductPromoAction_${productPromoRule_index}_${productPromoAction_index}" name="productId" id="productId" fieldFormName="LookupProduct"/>
@@ -449,6 +450,7 @@ under the License.
${uiLabelMap.ProductQuantity}:
${uiLabelMap.ProductAmount}:
+ ${uiLabelMap.ProductMaxDiscountAmount}:
${uiLabelMap.ProductItemId}:<@htmlTemplate.lookupField formName="createProductPromoAction" name="productId" id="productId" fieldFormName="LookupProduct"/>