From be3e604588d97af83b073b574df75cb94bb85a2d Mon Sep 17 00:00:00 2001
From: jetxarri <javier.echarri@openbravo.com>
Date: Fri, 10 Sep 2021 11:55:53 +0200
Subject: [PATCH] Fixes issue NOE-4512: Discounts not applied in the same order

---
 src/org/openbravo/discounts/engine/DiscountJSExecutor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/org/openbravo/discounts/engine/DiscountJSExecutor.java b/src/org/openbravo/discounts/engine/DiscountJSExecutor.java
index c40b285..80e5b16 100644
--- a/src/org/openbravo/discounts/engine/DiscountJSExecutor.java
+++ b/src/org/openbravo/discounts/engine/DiscountJSExecutor.java
@@ -224,7 +224,7 @@ public abstract class DiscountJSExecutor implements DiscountExecutor {
       throw new OBException(e.getMessage());
     }
 
-    whereClause += " order by pa.priority";
+    whereClause += " order by pa.priority nulls first, pa.id";
 
     OBQuery<PriceAdjustment> discountCandidatesQuery = OBDal.getInstance()
         .createQuery(PriceAdjustment.class, whereClause)
-- 
2.31.0

