Skip to content

Commit

Permalink
Allow deletion of **all** scale prices.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Apr 22, 2019
1 parent 4d191ad commit f524a71
Showing 1 changed file with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/


import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
Expand All @@ -48,20 +47,20 @@ public class MProductScalePriceValidator implements ModelValidator
private static final Logger logger = LogManager.getLogger(MProductScalePriceValidator.class);

private final static String SQL_UPDATE_PRODUCTPRICE = //
" UPDATE "
+ I_M_ProductPrice.Table_Name //
+ " SET " //
+ I_M_ProductPrice.COLUMNNAME_PriceLimit + "=?, "
+ I_M_ProductPrice.COLUMNNAME_PriceList + "=?, "
+ I_M_ProductPrice.COLUMNNAME_PriceStd + "=? "
+ " WHERE M_ProductPrice_ID=?";
" UPDATE "
+ I_M_ProductPrice.Table_Name //
+ " SET " //
+ I_M_ProductPrice.COLUMNNAME_PriceLimit + "=?, "
+ I_M_ProductPrice.COLUMNNAME_PriceList + "=?, "
+ I_M_ProductPrice.COLUMNNAME_PriceStd + "=? "
+ " WHERE M_ProductPrice_ID=?";

private final static String SQL_SELECT_EXISTING = //
" SELECT " + I_M_ProductScalePrice.COLUMNNAME_M_ProductScalePrice_ID //
+ " FROM " + I_M_ProductScalePrice.Table_Name //
+ " WHERE " //
+ I_M_ProductScalePrice.COLUMNNAME_M_ProductPrice_ID + "=?" //
+ " AND " + I_M_ProductScalePrice.COLUMNNAME_Qty + "=?";
" SELECT " + I_M_ProductScalePrice.COLUMNNAME_M_ProductScalePrice_ID //
+ " FROM " + I_M_ProductScalePrice.Table_Name //
+ " WHERE " //
+ I_M_ProductScalePrice.COLUMNNAME_M_ProductPrice_ID + "=?" //
+ " AND " + I_M_ProductScalePrice.COLUMNNAME_Qty + "=?";

private int ad_Client_ID = -1;

Expand Down Expand Up @@ -125,10 +124,6 @@ public String modelChange(PO po, int type) throws Exception
{
return handleChange(productScalePrice, po.get_TrxName());
}
if (type == ModelValidator.TYPE_BEFORE_DELETE)
{
return handleDelete(productScalePrice);
}
return null;
}

Expand Down Expand Up @@ -157,7 +152,7 @@ private String handleChange(final I_M_ProductScalePrice productScalePrice, final
// OK, we were able to update M_Product_Price
return null;
}

throw new AdempiereException("Didn't find M_Product_Price for M_ProductSalePrice with id " + productScalePrice.getM_ProductScalePrice_ID());
}
catch (SQLException e)
Expand All @@ -172,16 +167,6 @@ private String handleChange(final I_M_ProductScalePrice productScalePrice, final
}
}

private String handleDelete(final I_M_ProductScalePrice productScalePrice)
{
if (BigDecimal.ONE.compareTo(productScalePrice.getQty()) == 0)
{
// Can't allow this scalePrice to be deleted.
throw new AdempiereException("@MProductScalePrice.CantDelete@");
}
return null;
}

private boolean isAlreadyExisting(final int currentId, final int productPriceId, final BigDecimal qty, final String trxName)
{
PreparedStatement pstmt = null;
Expand Down

0 comments on commit f524a71

Please sign in to comment.