From 853b3e9da89c10890225b6e8f832291b44205425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa?= Date: Wed, 4 Dec 2013 11:36:03 -0500 Subject: [PATCH] IDEMPIERE-1574 Sales Order Line lets Price under the Price Limit when updating --- .../src/org/compiere/model/CalloutInvoice.java | 4 +++- .../src/org/compiere/model/CalloutOrder.java | 4 +++- .../src/org/compiere/model/MInvoiceLine.java | 13 +++++++++++++ .../src/org/compiere/model/MOrderLine.java | 13 +++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java index 0adede9787..b3e36dc703 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInvoice.java @@ -510,6 +510,8 @@ public class CalloutInvoice extends CalloutEngine int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int StdPrecision = MPriceList.getStandardPrecision(ctx, M_PriceList_ID); + MPriceList pl = new MPriceList(ctx, M_PriceList_ID, null); + boolean isEnforcePriceLimit = pl.isEnforcePriceLimit(); BigDecimal QtyEntered, QtyInvoiced, PriceEntered, PriceActual, PriceLimit, Discount, PriceList; // get values QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); @@ -630,7 +632,7 @@ public class CalloutInvoice extends CalloutEngine // Check PriceLimit String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit"); - boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && epl.equals("Y"); + boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && !epl.equals("") ? epl.equals("Y") : isEnforcePriceLimit; if (enforce && MRole.getDefault().isOverwritePriceLimit()) enforce = false; // Check Price Limit? diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 8a5c2359e6..09331f172a 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -1038,6 +1038,8 @@ public class CalloutOrder extends CalloutEngine int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int StdPrecision = MPriceList.getStandardPrecision(ctx, M_PriceList_ID); + MPriceList pl = new MPriceList(ctx, M_PriceList_ID, null); + boolean isEnforcePriceLimit = pl.isEnforcePriceLimit(); BigDecimal QtyEntered, QtyOrdered, PriceEntered, PriceActual, PriceLimit, Discount, PriceList; // get values QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); @@ -1158,7 +1160,7 @@ public class CalloutOrder extends CalloutEngine // Check PriceLimit String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit"); - boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && epl.equals("Y"); + boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && !epl.equals("") ? epl.equals("Y") : isEnforcePriceLimit; if (enforce && MRole.getDefault().isOverwritePriceLimit()) enforce = false; // Check Price Limit? diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index b087747a1e..7df3f52bc6 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -858,6 +858,19 @@ public class MInvoiceLine extends X_C_InvoiceLine && Env.ZERO.compareTo(getPriceActual()) == 0 && Env.ZERO.compareTo(getPriceList()) == 0) setPrice(); + // IDEMPIERE-1574 Sales Order Line lets Price under the Price Limit when updating + // Check PriceLimit + boolean enforce = m_IsSOTrx && m_parent.getM_PriceList().isEnforcePriceLimit(); + if (enforce && MRole.getDefault().isOverwritePriceLimit()) + enforce = false; + // Check Price Limit? + if (enforce && getPriceLimit() != Env.ZERO + && getPriceActual().compareTo(getPriceLimit()) < 0) + { + log.saveError("UnderLimitPrice", "PriceEntered=" + getPriceEntered() + ", PriceLimit=" + getPriceLimit()); + return false; + } + // } // Set Tax diff --git a/org.adempiere.base/src/org/compiere/model/MOrderLine.java b/org.adempiere.base/src/org/compiere/model/MOrderLine.java index 561125ab46..893907b267 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrderLine.java +++ b/org.adempiere.base/src/org/compiere/model/MOrderLine.java @@ -827,6 +827,19 @@ public class MOrderLine extends X_C_OrderLine // Check if on Price list if (m_productPrice == null) getProductPricing(m_M_PriceList_ID); + // IDEMPIERE-1574 Sales Order Line lets Price under the Price Limit when updating + // Check PriceLimit + boolean enforce = m_IsSOTrx && m_parent.getM_PriceList().isEnforcePriceLimit(); + if (enforce && MRole.getDefault().isOverwritePriceLimit()) + enforce = false; + // Check Price Limit? + if (enforce && getPriceLimit() != Env.ZERO + && getPriceActual().compareTo(getPriceLimit()) < 0) + { + log.saveError("UnderLimitPrice", "PriceEntered=" + getPriceEntered() + ", PriceLimit=" + getPriceLimit()); + return false; + } + // if (!m_productPrice.isCalculated()) { throw new ProductNotOnPriceListException(m_productPrice, getLine());