IDEMPIERE-3401 Orderline Discount Context issue
This commit is contained in:
parent
35a3c406a9
commit
5fee4bf291
|
@ -0,0 +1,15 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-3401 Orderline Discount Context issue
|
||||
-- Jun 24, 2017 6:44:50 PM CEST
|
||||
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.navigateOrderLine', IsUpdateable='N',Updated=TO_DATE('2017-06-24 18:44:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2205
|
||||
;
|
||||
|
||||
-- Jun 24, 2017 6:45:45 PM CEST
|
||||
UPDATE AD_Column SET Callout='org.compiere.model.CalloutInvoice.navigateInvoiceLine', IsUpdateable='N',Updated=TO_DATE('2017-06-24 18:45:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3828
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201706241900_IDEMPIERE-3401.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
-- IDEMPIERE-3401 Orderline Discount Context issue
|
||||
-- Jun 24, 2017 6:44:50 PM CEST
|
||||
UPDATE AD_Column SET Callout='org.compiere.model.CalloutOrder.navigateOrderLine', IsUpdateable='N',Updated=TO_TIMESTAMP('2017-06-24 18:44:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2205
|
||||
;
|
||||
|
||||
-- Jun 24, 2017 6:45:45 PM CEST
|
||||
UPDATE AD_Column SET Callout='org.compiere.model.CalloutInvoice.navigateInvoiceLine', IsUpdateable='N',Updated=TO_TIMESTAMP('2017-06-24 18:45:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3828
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201706241900_IDEMPIERE-3401.sql') FROM dual
|
||||
;
|
||||
|
|
@ -832,6 +832,45 @@ public class CalloutInvoice extends CalloutEngine
|
|||
//
|
||||
return "";
|
||||
} // qty
|
||||
|
||||
|
||||
|
||||
public String navigateInvoiceLine(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
|
||||
Integer M_Product_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "M_Product_ID");
|
||||
if (M_Product_ID == null || M_Product_ID.intValue() == 0) {
|
||||
Env.setContext(ctx, WindowNo, "DiscountSchema", "N");
|
||||
return "";
|
||||
}
|
||||
|
||||
/***** 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");
|
||||
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx);
|
||||
//
|
||||
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
|
||||
pp.setM_PriceList_ID(M_PriceList_ID);
|
||||
Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered");
|
||||
/** PLV is only accurate if PL selected in header */
|
||||
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
|
||||
if ( M_PriceList_Version_ID == 0 && M_PriceList_ID > 0)
|
||||
{
|
||||
String sql = "SELECT plv.M_PriceList_Version_ID "
|
||||
+ "FROM M_PriceList_Version plv "
|
||||
+ "WHERE plv.M_PriceList_ID=? " // 1
|
||||
+ " AND plv.ValidFrom <= ? "
|
||||
+ "ORDER BY plv.ValidFrom DESC";
|
||||
// Use newest price list - may not be future
|
||||
|
||||
M_PriceList_Version_ID = DB.getSQLValueEx(null, sql, M_PriceList_ID, orderDate);
|
||||
if ( M_PriceList_Version_ID > 0 )
|
||||
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");
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
} // CalloutInvoice
|
||||
|
|
|
@ -1411,5 +1411,46 @@ public class CalloutOrder extends CalloutEngine
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String navigateOrderLine(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
|
||||
Integer M_Product_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "M_Product_ID");
|
||||
if (M_Product_ID == null || M_Product_ID.intValue() == 0) {
|
||||
Env.setContext(ctx, WindowNo, "DiscountSchema", "N");
|
||||
return "";
|
||||
}
|
||||
|
||||
/***** 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");
|
||||
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx);
|
||||
//
|
||||
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
|
||||
pp.setM_PriceList_ID(M_PriceList_ID);
|
||||
Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered");
|
||||
/** PLV is only accurate if PL selected in header */
|
||||
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
|
||||
if ( M_PriceList_Version_ID == 0 && M_PriceList_ID > 0)
|
||||
{
|
||||
String sql = "SELECT plv.M_PriceList_Version_ID "
|
||||
+ "FROM M_PriceList_Version plv "
|
||||
+ "WHERE plv.M_PriceList_ID=? " // 1
|
||||
+ " AND plv.ValidFrom <= ? "
|
||||
+ "ORDER BY plv.ValidFrom DESC";
|
||||
// Use newest price list - may not be future
|
||||
|
||||
M_PriceList_Version_ID = DB.getSQLValueEx(null, sql, M_PriceList_ID, orderDate);
|
||||
if ( M_PriceList_Version_ID > 0 )
|
||||
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");
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
} // CalloutOrder
|
||||
|
||||
|
|
Loading…
Reference in New Issue