IDEMPIERE-2825 - Pluggable product pricing / partial backout of 7338b68 - to avoid NPE when importing invoices, on import time the pricing is called at a time where the line still doesn't have a header in database
This commit is contained in:
parent
ca4a5a673c
commit
7c48dd78af
|
@ -26,7 +26,6 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.base.Core;
|
import org.adempiere.base.Core;
|
||||||
import org.adempiere.base.IProductPricing;
|
import org.adempiere.base.IProductPricing;
|
||||||
import org.adempiere.model.GridTabWrapper;
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
|
@ -322,9 +321,11 @@ public class CalloutInvoice extends CalloutEngine
|
||||||
mTab.setValue("M_AttributeSetInstance_ID", null);
|
mTab.setValue("M_AttributeSetInstance_ID", null);
|
||||||
|
|
||||||
/***** Price Calculation see also qty ****/
|
/***** Price Calculation see also qty ****/
|
||||||
I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
|
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
|
||||||
|
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
|
||||||
|
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyInvoiced");
|
||||||
IProductPricing pp = Core.getProductPricing();
|
IProductPricing pp = Core.getProductPricing();
|
||||||
pp.setInvoiceLine(invoiceLine, null);
|
pp.setInitialValues(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);
|
||||||
|
@ -347,6 +348,8 @@ public class CalloutInvoice extends CalloutEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||||
|
Timestamp date = Env.getContextAsDate(ctx, WindowNo, "DateInvoiced");
|
||||||
|
pp.setPriceDate(date);
|
||||||
//
|
//
|
||||||
mTab.setValue("PriceList", pp.getPriceList());
|
mTab.setValue("PriceList", pp.getPriceList());
|
||||||
mTab.setValue("PriceLimit", pp.getPriceLimit());
|
mTab.setValue("PriceLimit", pp.getPriceLimit());
|
||||||
|
@ -552,18 +555,20 @@ public class CalloutInvoice extends CalloutEngine
|
||||||
|| mField.getColumnName().equals("M_Product_ID"))
|
|| mField.getColumnName().equals("M_Product_ID"))
|
||||||
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
|
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
|
||||||
{
|
{
|
||||||
|
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
|
||||||
if (mField.getColumnName().equals("QtyEntered"))
|
if (mField.getColumnName().equals("QtyEntered"))
|
||||||
QtyInvoiced = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
QtyInvoiced = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||||
C_UOM_To_ID, QtyEntered);
|
C_UOM_To_ID, QtyEntered);
|
||||||
if (QtyInvoiced == null)
|
if (QtyInvoiced == null)
|
||||||
QtyInvoiced = QtyEntered;
|
QtyInvoiced = QtyEntered;
|
||||||
I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
|
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
|
||||||
IProductPricing pp = Core.getProductPricing();
|
IProductPricing pp = Core.getProductPricing();
|
||||||
pp.setInvoiceLine(invoiceLine, null);
|
pp.setInitialValues(M_Product_ID, C_BPartner_ID, QtyInvoiced, IsSOTrx, null);
|
||||||
pp.setM_PriceList_ID(M_PriceList_ID);
|
pp.setM_PriceList_ID(M_PriceList_ID);
|
||||||
pp.setQty(QtyInvoiced);
|
|
||||||
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);
|
||||||
|
Timestamp date = (Timestamp)mTab.getValue("DateInvoiced");
|
||||||
|
pp.setPriceDate(date);
|
||||||
//
|
//
|
||||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||||
C_UOM_To_ID, pp.getPriceStd());
|
C_UOM_To_ID, pp.getPriceStd());
|
||||||
|
@ -836,9 +841,11 @@ public class CalloutInvoice extends CalloutEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Price Calculation see also qty ****/
|
/***** Price Calculation see also qty ****/
|
||||||
I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
|
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
|
||||||
|
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
|
||||||
|
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
|
||||||
IProductPricing pp = Core.getProductPricing();
|
IProductPricing pp = Core.getProductPricing();
|
||||||
pp.setInvoiceLine(invoiceLine, null);
|
pp.setInitialValues(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);
|
||||||
|
@ -859,6 +866,7 @@ public class CalloutInvoice extends CalloutEngine
|
||||||
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
|
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
|
||||||
}
|
}
|
||||||
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||||
|
pp.setPriceDate(orderDate);
|
||||||
//
|
//
|
||||||
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
|
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
|
||||||
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
|
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.base.Core;
|
import org.adempiere.base.Core;
|
||||||
import org.adempiere.base.IProductPricing;
|
import org.adempiere.base.IProductPricing;
|
||||||
import org.adempiere.model.GridTabWrapper;
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
|
@ -779,9 +778,11 @@ public class CalloutOrder extends CalloutEngine
|
||||||
mTab.setValue("M_AttributeSetInstance_ID", null);
|
mTab.setValue("M_AttributeSetInstance_ID", null);
|
||||||
|
|
||||||
/***** Price Calculation see also qty ****/
|
/***** Price Calculation see also qty ****/
|
||||||
I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
|
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
|
||||||
|
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
|
||||||
|
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
|
||||||
IProductPricing pp = Core.getProductPricing();
|
IProductPricing pp = Core.getProductPricing();
|
||||||
pp.setOrderLine(orderLine, null);
|
pp.setInitialValues(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);
|
||||||
|
@ -802,6 +803,7 @@ public class CalloutOrder extends CalloutEngine
|
||||||
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
|
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
|
||||||
}
|
}
|
||||||
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||||
|
pp.setPriceDate(orderDate);
|
||||||
//
|
//
|
||||||
mTab.setValue("PriceList", pp.getPriceList());
|
mTab.setValue("PriceList", pp.getPriceList());
|
||||||
mTab.setValue("PriceLimit", pp.getPriceLimit());
|
mTab.setValue("PriceLimit", pp.getPriceLimit());
|
||||||
|
@ -1075,18 +1077,20 @@ public class CalloutOrder extends CalloutEngine
|
||||||
|| mField.getColumnName().equals("M_Product_ID"))
|
|| mField.getColumnName().equals("M_Product_ID"))
|
||||||
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
|
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
|
||||||
{
|
{
|
||||||
|
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
|
||||||
if (mField.getColumnName().equals("QtyEntered"))
|
if (mField.getColumnName().equals("QtyEntered"))
|
||||||
QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||||
C_UOM_To_ID, QtyEntered);
|
C_UOM_To_ID, QtyEntered);
|
||||||
if (QtyOrdered == null)
|
if (QtyOrdered == null)
|
||||||
QtyOrdered = QtyEntered;
|
QtyOrdered = QtyEntered;
|
||||||
I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
|
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
|
||||||
IProductPricing pp = Core.getProductPricing();
|
IProductPricing pp = Core.getProductPricing();
|
||||||
pp.setOrderLine(orderLine, null);
|
pp.setInitialValues(M_Product_ID, C_BPartner_ID, QtyOrdered, IsSOTrx, null);
|
||||||
pp.setQty(QtyOrdered);
|
|
||||||
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);
|
||||||
|
Timestamp date = (Timestamp)mTab.getValue("DateOrdered");
|
||||||
|
pp.setPriceDate(date);
|
||||||
//
|
//
|
||||||
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
|
||||||
C_UOM_To_ID, pp.getPriceStd());
|
C_UOM_To_ID, pp.getPriceStd());
|
||||||
|
@ -1407,9 +1411,11 @@ public class CalloutOrder extends CalloutEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Price Calculation see also qty ****/
|
/***** Price Calculation see also qty ****/
|
||||||
I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
|
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
|
||||||
|
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered");
|
||||||
|
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
|
||||||
IProductPricing pp = Core.getProductPricing();
|
IProductPricing pp = Core.getProductPricing();
|
||||||
pp.setOrderLine(orderLine, null);
|
pp.setInitialValues(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);
|
||||||
|
@ -1430,6 +1436,7 @@ public class CalloutOrder extends CalloutEngine
|
||||||
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
|
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
|
||||||
}
|
}
|
||||||
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||||
|
pp.setPriceDate(orderDate);
|
||||||
//
|
//
|
||||||
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
|
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
|
||||||
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
|
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");
|
||||||
|
|
Loading…
Reference in New Issue