IDEMPIERE-2649 Not properly closed ResultSet in M_PriceList_Create
This commit is contained in:
parent
821c8c3f5e
commit
27588c7801
|
@ -685,54 +685,64 @@ public class M_PriceList_Create extends SvrProcess {
|
||||||
sqlpc.append(" WHERE s.T_Selection_ID=p.M_Product_ID");
|
sqlpc.append(" WHERE s.T_Selection_ID=p.M_Product_ID");
|
||||||
sqlpc.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID + ")");
|
sqlpc.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID + ")");
|
||||||
|
|
||||||
PreparedStatement ps = DB.prepareStatement(sqlpc.toString(), get_TrxName());
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = null;
|
||||||
while(rs.next())
|
|
||||||
{
|
try{
|
||||||
int M_Product_ID = rs.getInt(MProductPrice.COLUMNNAME_M_Product_ID);
|
ps = DB.prepareStatement(sqlpc.toString(), get_TrxName());
|
||||||
ProductCost m_productCost = new ProductCost (getCtx(), M_Product_ID, 0, get_TrxName());
|
rs = ps.executeQuery();
|
||||||
m_productCost.setQty(BigDecimal.ONE);
|
while(rs.next())
|
||||||
BigDecimal costs = m_productCost.getProductCosts(as, rsCurgen.getInt("AD_Org_ID"), null, 0, false);
|
|
||||||
|
|
||||||
if (costs == null || costs.signum() == 0) // zero costs OK
|
|
||||||
{
|
{
|
||||||
MProduct product = new MProduct(getCtx(), M_Product_ID, get_TrxName());
|
int M_Product_ID = rs.getInt(MProductPrice.COLUMNNAME_M_Product_ID);
|
||||||
if (product.isStocked())
|
ProductCost m_productCost = new ProductCost (getCtx(), M_Product_ID, 0, get_TrxName());
|
||||||
log.log(Level.WARNING, "No Costs for " + product.getName());
|
m_productCost.setQty(BigDecimal.ONE);
|
||||||
}
|
BigDecimal costs = m_productCost.getProductCosts(as, rsCurgen.getInt("AD_Org_ID"), null, 0, false);
|
||||||
else
|
|
||||||
{
|
|
||||||
sqlupd = new StringBuilder("UPDATE M_ProductPrice p ");
|
|
||||||
sqlupd.append(" SET PriceList = (DECODE('").append(rsDiscountLine.getString(MDiscountSchemaLine.COLUMNNAME_List_Base)).append("', 'P', ?, PriceList) + ?) * (1 - ?/100), ");
|
|
||||||
sqlupd.append(" PriceStd = (DECODE('").append(rsDiscountLine.getString(MDiscountSchemaLine.COLUMNNAME_Std_Base)).append("', 'P', ?, PriceStd) + ?) * (1 - ?/100),");
|
|
||||||
sqlupd.append(" PriceLimit = (DECODE('").append(rsDiscountLine.getString(MDiscountSchemaLine.COLUMNNAME_Limit_Base)).append("', 'P', ?, PriceLimit) + ?) * (1 - ?/100)");
|
|
||||||
sqlupd.append(" WHERE M_PriceList_Version_ID=").append(p_PriceList_Version_ID);
|
|
||||||
sqlupd.append(" AND M_Product_ID = ?");
|
|
||||||
sqlupd.append(" AND EXISTS (SELECT * FROM T_Selection s");
|
|
||||||
sqlupd.append(" WHERE s.T_Selection_ID=p.M_Product_ID");
|
|
||||||
sqlupd.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID + ")");
|
|
||||||
|
|
||||||
pstmu = DB.prepareStatement(sqlupd.toString(),
|
if (costs == null || costs.signum() == 0) // zero costs OK
|
||||||
ResultSet.TYPE_SCROLL_INSENSITIVE,
|
{
|
||||||
ResultSet.CONCUR_UPDATABLE, get_TrxName());
|
MProduct product = new MProduct(getCtx(), M_Product_ID, get_TrxName());
|
||||||
|
if (product.isStocked())
|
||||||
pstmu.setBigDecimal(1, costs);
|
log.log(Level.WARNING, "No Costs for " + product.getName());
|
||||||
pstmu.setDouble(2, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_List_AddAmt));
|
}
|
||||||
pstmu.setDouble(3, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_List_Discount));
|
else
|
||||||
pstmu.setBigDecimal(4, costs);
|
{
|
||||||
pstmu.setDouble(5, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Std_AddAmt));
|
sqlupd = new StringBuilder("UPDATE M_ProductPrice p ");
|
||||||
pstmu.setDouble(6, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Std_Discount));
|
sqlupd.append(" SET PriceList = (DECODE('").append(rsDiscountLine.getString(MDiscountSchemaLine.COLUMNNAME_List_Base)).append("', 'P', ?, PriceList) + ?) * (1 - ?/100), ");
|
||||||
pstmu.setBigDecimal(7, costs);
|
sqlupd.append(" PriceStd = (DECODE('").append(rsDiscountLine.getString(MDiscountSchemaLine.COLUMNNAME_Std_Base)).append("', 'P', ?, PriceStd) + ?) * (1 - ?/100),");
|
||||||
pstmu.setDouble(8, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Limit_AddAmt));
|
sqlupd.append(" PriceLimit = (DECODE('").append(rsDiscountLine.getString(MDiscountSchemaLine.COLUMNNAME_Limit_Base)).append("', 'P', ?, PriceLimit) + ?) * (1 - ?/100)");
|
||||||
pstmu.setDouble(9, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Limit_Discount));
|
sqlupd.append(" WHERE M_PriceList_Version_ID=").append(p_PriceList_Version_ID);
|
||||||
pstmu.setInt(10, M_Product_ID);
|
sqlupd.append(" AND M_Product_ID = ?");
|
||||||
|
sqlupd.append(" AND EXISTS (SELECT * FROM T_Selection s");
|
||||||
cntu = pstmu.executeUpdate();
|
sqlupd.append(" WHERE s.T_Selection_ID=p.M_Product_ID");
|
||||||
|
sqlupd.append(" AND s.AD_PInstance_ID=").append(m_AD_PInstance_ID + ")");
|
||||||
if (cntu == -1)
|
|
||||||
raiseError("Update M_ProductPrice ", sqlupd.toString());
|
pstmu = DB.prepareStatement(sqlupd.toString(),
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Updated " + cntu);
|
ResultSet.TYPE_SCROLL_INSENSITIVE,
|
||||||
|
ResultSet.CONCUR_UPDATABLE, get_TrxName());
|
||||||
|
|
||||||
|
pstmu.setBigDecimal(1, costs);
|
||||||
|
pstmu.setDouble(2, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_List_AddAmt));
|
||||||
|
pstmu.setDouble(3, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_List_Discount));
|
||||||
|
pstmu.setBigDecimal(4, costs);
|
||||||
|
pstmu.setDouble(5, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Std_AddAmt));
|
||||||
|
pstmu.setDouble(6, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Std_Discount));
|
||||||
|
pstmu.setBigDecimal(7, costs);
|
||||||
|
pstmu.setDouble(8, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Limit_AddAmt));
|
||||||
|
pstmu.setDouble(9, rsDiscountLine.getDouble(MDiscountSchemaLine.COLUMNNAME_Limit_Discount));
|
||||||
|
pstmu.setInt(10, M_Product_ID);
|
||||||
|
|
||||||
|
cntu = pstmu.executeUpdate();
|
||||||
|
|
||||||
|
if (cntu == -1)
|
||||||
|
raiseError("Update M_ProductPrice ", sqlupd.toString());
|
||||||
|
if (log.isLoggable(Level.FINE)) log.fine("Updated " + cntu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
DB.close(rs, ps);
|
||||||
|
rs = null; ps = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue