IDEMPIERE-2825 - Pluggable product pricing

This commit is contained in:
Diego Ruiz 2017-12-27 15:58:13 +01:00
parent 43cfdd2a96
commit 8bca99e93c
4 changed files with 25 additions and 32 deletions

View File

@ -26,6 +26,7 @@ import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.model.GridTabWrapper;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
@ -326,11 +327,9 @@ public class CalloutInvoice extends CalloutEngine
mTab.setValue("M_AttributeSetInstance_ID", null);
/***** Price Calculation see also qty ****/
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");
I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
pp.setInvoiceLine(invoiceLine, null);
//
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID);
@ -353,8 +352,6 @@ public class CalloutInvoice extends CalloutEngine
}
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("PriceLimit", pp.getPriceLimit());
@ -560,20 +557,18 @@ public class CalloutInvoice extends CalloutEngine
|| mField.getColumnName().equals("M_Product_ID"))
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
{
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
if (mField.getColumnName().equals("QtyEntered"))
QtyInvoiced = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered);
if (QtyInvoiced == null)
QtyInvoiced = QtyEntered;
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID, C_BPartner_ID, QtyInvoiced, IsSOTrx, null);
pp.setInvoiceLine(invoiceLine, null);
pp.setM_PriceList_ID(M_PriceList_ID);
pp.setQty(QtyInvoiced);
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "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,
C_UOM_To_ID, pp.getPriceStd());
@ -846,11 +841,9 @@ public class CalloutInvoice extends CalloutEngine
}
/***** Price Calculation see also qty ****/
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");
I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
pp.setInvoiceLine(invoiceLine, null);
//
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID);
@ -871,7 +864,6 @@ public class CalloutInvoice extends CalloutEngine
Env.setContext(ctx, WindowNo, "M_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, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");

View File

@ -26,6 +26,7 @@ import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.model.GridTabWrapper;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
@ -799,11 +800,9 @@ public class CalloutOrder extends CalloutEngine
mTab.setValue("M_AttributeSetInstance_ID", null);
/***** Price Calculation see also qty ****/
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");
I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
pp.setOrderLine(orderLine, null);
//
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID);
@ -824,7 +823,6 @@ public class CalloutOrder extends CalloutEngine
Env.setContext(ctx, WindowNo, "M_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("PriceLimit", pp.getPriceLimit());
@ -1092,20 +1090,18 @@ public class CalloutOrder extends CalloutEngine
|| mField.getColumnName().equals("M_Product_ID"))
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
{
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
if (mField.getColumnName().equals("QtyEntered"))
QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered);
if (QtyOrdered == null)
QtyOrdered = QtyEntered;
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");
I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID, C_BPartner_ID, QtyOrdered, IsSOTrx, null);
pp.setOrderLine(orderLine, null);
pp.setQty(QtyOrdered);
pp.setM_PriceList_ID(M_PriceList_ID);
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "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,
C_UOM_To_ID, pp.getPriceStd());
@ -1426,11 +1422,9 @@ public class CalloutOrder extends CalloutEngine
}
/***** Price Calculation see also qty ****/
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");
I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
pp.setOrderLine(orderLine, null);
//
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID);
@ -1451,7 +1445,6 @@ public class CalloutOrder extends CalloutEngine
Env.setContext(ctx, WindowNo, "M_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, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");

View File

@ -67,6 +67,11 @@ public abstract class AbstractProductPricing implements IProductPricing {
public void setM_PriceList_Version_ID(int M_PriceList_Version_ID) {
m_M_PriceList_Version_ID = M_PriceList_Version_ID;
}
@Override
public void setQty(BigDecimal qty) {
m_Qty = qty;
}
@Override
public Timestamp getPriceDate() {
@ -94,7 +99,8 @@ public abstract class AbstractProductPricing implements IProductPricing {
public void setInvoiceLine(I_C_InvoiceLine invoiceLine, String trxName) {
m_M_Product_ID = invoiceLine.getM_Product_ID();
m_C_BPartner_ID = invoiceLine.getC_Invoice().getC_BPartner_ID();
BigDecimal qty = invoiceLine.getQtyInvoiced();
BigDecimal qty = invoiceLine.getQtyInvoiced() != null ?
invoiceLine.getQtyInvoiced() : invoiceLine.getQtyEntered();
if (qty != null && Env.ZERO.compareTo(qty) != 0)
m_Qty = qty;
m_isSOTrx = invoiceLine.getC_Invoice().isSOTrx();

View File

@ -59,6 +59,8 @@ public interface IProductPricing {
void setM_PriceList_Version_ID(int M_PriceList_Version_ID);
void setQty(BigDecimal qty);
/**
* Get Price Date
* @return date