IDEMPIERE-3469 MProductPricing does not consider new Product in current transaction / peer review - solve deprecated warnings

This commit is contained in:
Carlos Ruiz 2017-09-08 15:29:41 +02:00
parent 9361e0f36c
commit 82ba01d4a3
11 changed files with 36 additions and 28 deletions

View File

@ -146,7 +146,7 @@ public class CalloutRMA extends CalloutEngine {
return ""; return "";
MRMA rma = new MRMA(ctx, M_RMA_ID, null); MRMA rma = new MRMA(ctx, M_RMA_ID, null);
MProductPricing pp = new MProductPricing(M_Product_ID, rma.getC_BPartner_ID(), Env.ONE, rma.isSOTrx()); MProductPricing pp = new MProductPricing(M_Product_ID, rma.getC_BPartner_ID(), Env.ONE, rma.isSOTrx(), null);
int taxId = 0; int taxId = 0;
int precision = 0; int precision = 0;

View File

@ -327,7 +327,7 @@ public class CalloutInvoice extends CalloutEngine
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyInvoiced"); BigDecimal Qty = (BigDecimal)mTab.getValue("QtyInvoiced");
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx); MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
@ -564,7 +564,7 @@ public class CalloutInvoice extends CalloutEngine
if (QtyInvoiced == null) if (QtyInvoiced == null)
QtyInvoiced = QtyEntered; QtyInvoiced = QtyEntered;
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID, C_BPartner_ID, QtyInvoiced, IsSOTrx); MProductPricing pp = new MProductPricing (M_Product_ID, C_BPartner_ID, QtyInvoiced, IsSOTrx, null);
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
@ -845,7 +845,7 @@ public class CalloutInvoice extends CalloutEngine
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered"); BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx); MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);

View File

@ -800,7 +800,7 @@ public class CalloutOrder extends CalloutEngine
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered"); BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx); MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
@ -1096,7 +1096,7 @@ public class CalloutOrder extends CalloutEngine
if (QtyOrdered == null) if (QtyOrdered == null)
QtyOrdered = QtyEntered; QtyOrdered = QtyEntered;
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID, C_BPartner_ID, QtyOrdered, IsSOTrx); MProductPricing pp = new MProductPricing (M_Product_ID, C_BPartner_ID, QtyOrdered, IsSOTrx, null);
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
@ -1425,7 +1425,7 @@ public class CalloutOrder extends CalloutEngine
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered"); BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx); MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);

View File

@ -100,7 +100,7 @@ public class CalloutRequisition extends CalloutEngine
int C_BPartner_ID = line.getC_BPartner_ID(); int C_BPartner_ID = line.getC_BPartner_ID();
BigDecimal Qty = line.getQty(); BigDecimal Qty = line.getQty();
boolean isSOTrx = false; boolean isSOTrx = false;
MProductPricing pp = new MProductPricing (line.getM_Product_ID(), C_BPartner_ID, Qty, isSOTrx); MProductPricing pp = new MProductPricing (line.getM_Product_ID(), C_BPartner_ID, Qty, isSOTrx, null);
// //
int M_PriceList_ID = req.getM_PriceList_ID(); int M_PriceList_ID = req.getM_PriceList_ID();
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);

View File

@ -72,7 +72,7 @@ public class ProjectLinePricing extends SvrProcess
// //
boolean isSOTrx = true; boolean isSOTrx = true;
MProductPricing pp = new MProductPricing (projectLine.getM_Product_ID(), MProductPricing pp = new MProductPricing (projectLine.getM_Product_ID(),
project.getC_BPartner_ID(), projectLine.getPlannedQty(), isSOTrx); project.getC_BPartner_ID(), projectLine.getPlannedQty(), isSOTrx, get_TrxName());
pp.setM_PriceList_ID(project.getM_PriceList_ID()); pp.setM_PriceList_ID(project.getM_PriceList_ID());
pp.setPriceDate(project.getDateContract()); pp.setPriceDate(project.getDateContract());
// //

View File

@ -379,7 +379,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
// //
if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID); if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID);
m_productPricing = new MProductPricing (getM_Product_ID(), m_productPricing = new MProductPricing (getM_Product_ID(),
C_BPartner_ID, getQtyInvoiced(), m_IsSOTrx); C_BPartner_ID, getQtyInvoiced(), m_IsSOTrx, get_TrxName());
m_productPricing.setM_PriceList_ID(M_PriceList_ID); m_productPricing.setM_PriceList_ID(M_PriceList_ID);
m_productPricing.setPriceDate(m_DateInvoiced); m_productPricing.setPriceDate(m_DateInvoiced);
// //

View File

@ -324,7 +324,7 @@ public class MOrderLine extends X_C_OrderLine
protected MProductPricing getProductPricing (int M_PriceList_ID) protected MProductPricing getProductPricing (int M_PriceList_ID)
{ {
m_productPrice = new MProductPricing (getM_Product_ID(), m_productPrice = new MProductPricing (getM_Product_ID(),
getC_BPartner_ID(), getQtyOrdered(), m_IsSOTrx); getC_BPartner_ID(), getQtyOrdered(), m_IsSOTrx, get_TrxName());
m_productPrice.setM_PriceList_ID(M_PriceList_ID); m_productPrice.setM_PriceList_ID(M_PriceList_ID);
m_productPrice.setPriceDate(getDateOrdered()); m_productPrice.setPriceDate(getDateOrdered());
// //

View File

@ -36,23 +36,31 @@ import org.compiere.util.Trace;
public class MProductPricing public class MProductPricing
{ {
String trxName=null; private String trxName=null;
/**
* Constructor
* @param M_Product_ID product
* @param C_BPartner_ID partner
* @param Qty quantity
* @param isSOTrx SO or PO
* @param trxName the transaction
*/
public MProductPricing (int M_Product_ID, int C_BPartner_ID, public MProductPricing (int M_Product_ID, int C_BPartner_ID,
BigDecimal Qty, boolean isSOTrx, String trxName) BigDecimal Qty, boolean isSOTrx, String trxName)
{ {
this.trxName=trxName; this.trxName=trxName;
m_M_Product_ID = M_Product_ID; m_M_Product_ID = M_Product_ID;
m_C_BPartner_ID = C_BPartner_ID; m_C_BPartner_ID = C_BPartner_ID;
if (Qty != null && Env.ZERO.compareTo(Qty) != 0) if (Qty != null && Env.ZERO.compareTo(Qty) != 0)
m_Qty = Qty; m_Qty = Qty;
m_isSOTrx = isSOTrx; m_isSOTrx = isSOTrx;
int thereAreVendorBreakRecords = DB.getSQLValue(trxName, int thereAreVendorBreakRecords = DB.getSQLValue(trxName,
"SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND (C_BPartner_ID=? OR C_BPartner_ID is NULL)", "SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND (C_BPartner_ID=? OR C_BPartner_ID is NULL)",
m_M_Product_ID, m_C_BPartner_ID); m_M_Product_ID, m_C_BPartner_ID);
m_useVendorBreak = thereAreVendorBreakRecords > 0; m_useVendorBreak = thereAreVendorBreakRecords > 0;
} }
/** /**

View File

@ -148,7 +148,7 @@ public class MProjectLine extends X_C_ProjectLine
return limitPrice; return limitPrice;
boolean isSOTrx = true; boolean isSOTrx = true;
MProductPricing pp = new MProductPricing (getM_Product_ID(), MProductPricing pp = new MProductPricing (getM_Product_ID(),
m_parent.getC_BPartner_ID(), getPlannedQty(), isSOTrx); m_parent.getC_BPartner_ID(), getPlannedQty(), isSOTrx, get_TrxName());
pp.setM_PriceList_ID(m_parent.getM_PriceList_ID()); pp.setM_PriceList_ID(m_parent.getM_PriceList_ID());
if (pp.calculatePrice()) if (pp.calculatePrice())
limitPrice = pp.getPriceLimit(); limitPrice = pp.getPriceLimit();

View File

@ -147,7 +147,7 @@ public class MRMALine extends X_M_RMALine
} }
else if (getM_Product_ID() != 0) else if (getM_Product_ID() != 0)
{ {
MProductPricing pp = new MProductPricing (getM_Product_ID(), getParent().getC_BPartner_ID(), Env.ONE, getParent().isSOTrx()); MProductPricing pp = new MProductPricing (getM_Product_ID(), getParent().getC_BPartner_ID(), Env.ONE, getParent().isSOTrx(), get_TrxName());
MInvoice invoice = getParent().getOriginalInvoice(); MInvoice invoice = getParent().getOriginalInvoice();
if (invoice != null) if (invoice != null)

View File

@ -234,7 +234,7 @@ public class MRequisitionLine extends X_M_RequisitionLine
if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID); if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID);
boolean isSOTrx = false; boolean isSOTrx = false;
MProductPricing pp = new MProductPricing (getM_Product_ID(), MProductPricing pp = new MProductPricing (getM_Product_ID(),
getC_BPartner_ID(), getQty(), isSOTrx); getC_BPartner_ID(), getQty(), isSOTrx, get_TrxName());
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
// pp.setPriceDate(getDateOrdered()); // pp.setPriceDate(getDateOrdered());
// //