From a9068d6a15ab0d9bd6243117c4d6b7206de6f1b7 Mon Sep 17 00:00:00 2001 From: hengsin Date: Thu, 14 Jul 2022 19:32:55 +0800 Subject: [PATCH] IDEMPIERE-5327 Refactoring and clean up of BOM Drop form (#1395) - Fix unit test --- .../src/org/idempiere/apps/form/BOMDrop.java | 18 +++++++++++++++++- .../idempiere/test/form/BOMDropFormTest.java | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui/src/org/idempiere/apps/form/BOMDrop.java b/org.adempiere.ui/src/org/idempiere/apps/form/BOMDrop.java index b824b7eaab..94db3688a0 100644 --- a/org.adempiere.ui/src/org/idempiere/apps/form/BOMDrop.java +++ b/org.adempiere.ui/src/org/idempiere/apps/form/BOMDrop.java @@ -326,7 +326,23 @@ public class BOMDrop { public SelectedItem(int M_Product_ID, BigDecimal qty) { this.M_Product_ID = M_Product_ID; this.qty = qty; - } + } + + /** + * + * @return M_Product_ID + */ + public int getM_Product_ID() { + return M_Product_ID; + } + + /** + * + * @return qty + */ + public BigDecimal getQty() { + return qty; + } } /** diff --git a/org.idempiere.test/src/org/idempiere/test/form/BOMDropFormTest.java b/org.idempiere.test/src/org/idempiere/test/form/BOMDropFormTest.java index 35bdab44a3..70c4db7526 100644 --- a/org.idempiere.test/src/org/idempiere/test/form/BOMDropFormTest.java +++ b/org.idempiere.test/src/org/idempiere/test/form/BOMDropFormTest.java @@ -39,7 +39,10 @@ import org.compiere.model.MInvoice; import org.compiere.model.MInvoiceLine; import org.compiere.model.MOrder; import org.compiere.model.MOrderLine; +import org.compiere.model.MPriceList; +import org.compiere.model.MPriceListVersion; import org.compiere.model.MProduct; +import org.compiere.model.MProductPrice; import org.compiere.model.MProject; import org.compiere.model.MProjectLine; import org.compiere.util.Env; @@ -115,6 +118,18 @@ public class BOMDropFormTest extends AbstractTestCase { assertEquals(8, selectedItems.size(), "Unexpected number of components"); + int priceListId = order.getM_PriceList_ID(); + MPriceListVersion priceListVersion = MPriceList.get(priceListId).getPriceListVersion(null); + for(SelectedItem selectedItem : selectedItems) { + MProductPrice pp = MProductPrice.get(Env.getCtx(), priceListVersion.get_ID(), selectedItem.getM_Product_ID(), getTrxName()); + if (pp == null) { + pp = new MProductPrice(Env.getCtx(), 0, getTrxName()); + pp.setM_PriceList_Version_ID(priceListVersion.get_ID()); + pp.setM_Product_ID(selectedItem.getM_Product_ID()); + pp.setPrices(new BigDecimal("1"), new BigDecimal("1"), BigDecimal.ZERO); + pp.saveEx(); + } + } bomDrop.saveOrderLines(order.getC_Order_ID(), selectedItems, getTrxName()); order.load(getTrxName());