use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class CalculateReplenishPlan method generateProductInfo.
/**
* This method will fetch all the products based on selected category or the
* product. This will process BOMLine if product is finished good. It will
* fill the miniMRPProducts list & id of each product(including BOMlines) in
* productIds
*
* @param miniMrpProducts
* @param productIds
*/
private void generateProductInfo(Map<Integer, MiniMRPProduct> miniMrpProducts, Set<Integer> productIds) {
String sql = getQueryForProductDetails();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, trx);
pstmt.setInt(1, M_WarehouseID);
pstmt.setInt(2, AD_Client_ID);
if (p_M_Product_ID != 0)
pstmt.setInt(3, p_M_Product_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
int mProductID = rs.getInt("m_product_id");
if (!miniMrpProducts.containsKey(mProductID)) {
MiniMRPProduct miniMrpProduct = addProductToProcess(mProductID, rs, miniMrpProducts, productIds);
/* If Product is FG(Finished Goods) calculate it's BOMlines */
if (miniMrpProduct.isBOM() && miniMrpProduct.isVerified()) {
processBOMLines(miniMrpProducts, productIds, miniMrpProduct.getM_Product_ID());
}
}
}
} catch (Exception e) {
log.log(Level.SEVERE, sql.toString(), e);
getProcessInfo().setError(true);
getProcessInfo().addLog(new ProcessInfoLog(getProcessInfo().getAD_Process_ID(), new Timestamp(System.currentTimeMillis()), null, "Failed to fetch products for mini MRP >> " + e.getMessage()));
throw new AdempiereException(e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class MakeToOrderNotStandardBOMandWF method test01.
public void test01() throws Exception {
Qty = new BigDecimal(10);
//Define Product
product = MProduct.get(getCtx(), M_Product_ID);
//Define Business Partner
BPartner = new MBPartner(getCtx(), C_BPartner_ID, trxName);
//force not BOM Standard
bom = new MPPProductBOM(getCtx(), PP_Product_BOM_ID, trxName);
if (bom != null) {
bom.setValue(product.getValue() + "-Alternate");
bom.setBOMType(MPPProductBOM.BOMTYPE_Make_To_Order);
bom.setBOMUse(MPPProductBOM.BOMUSE_Manufacturing);
bom.saveEx();
}
createOrder();
MPPOrder expected = createPPOrder();
I_PP_Order actual = MPPOrder.forC_OrderLine_ID(getCtx(), oline.get_ID(), oline.getM_Product_ID(), trxName);
if (actual == null) {
throw new AdempiereException("@NotFound@ @PP_Order_ID@ not was generate");
}
assertEquals("Confirming Manufacturing Order", expected, actual);
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class MakeToOrderStandardBOMNotWF method test01.
public void test01() throws Exception {
Qty = new BigDecimal(10);
//Define Product
product = MProduct.get(getCtx(), M_Product_ID);
//Define Business Partner
BPartner = new MBPartner(getCtx(), C_BPartner_ID, trxName);
//Setting the BOM
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(product);
if (PP_Product_BOM_ID > 0)
bom = new MPPProductBOM(getCtx(), PP_Product_BOM_ID, trxName);
else
throw new AdempiereException("@NotFound@ @PP_ProductBOM_ID@");
if (bom != null) {
bom.setBOMType(MPPProductBOM.BOMTYPE_Make_To_Order);
bom.setBOMUse(MPPProductBOM.BOMUSE_Manufacturing);
bom.saveEx();
}
createOrder();
MPPOrder expected = createPPOrder();
I_PP_Order actual = MPPOrder.forC_OrderLine_ID(getCtx(), oline.get_ID(), oline.getM_Product_ID(), trxName);
if (actual == null) {
throw new AdempiereException("@NotFound@ @PP_Order_ID@ not was generate");
}
assertEquals("Confirming Manufacturing Order", expected, actual);
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class MRPTest method test01.
public void test01() throws Exception {
InputStream in = null;
if (System.getProperty("MRPTestFile") != null) {
in = new FileInputStream(System.getProperty("MRPTestFile"));
}
if (in == null) {
in = getClass().getClassLoader().getResourceAsStream("test/functional/mrp/MRPTests.csv");
}
if (System.getProperty("UseArhipacURL") != null || in == null) {
String url = "http://spreadsheets.google.com/pub?key=p_F3GDtQxWTArVGQnNvicVw&output=csv&gid=0";
in = new URL(url).openStream();
}
if (in == null) {
throw new AdempiereException("No input test file found");
}
//
CSVFactory factory = new CSVFactory();
Collection<TestableMRP> tests = factory.read(in);
//
for (TestableMRP test : tests) {
runTest(test);
rollback();
}
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class ZkJRViewer method init.
// initialization
private void init() {
Borderlayout layout = new Borderlayout();
layout.setStyle("position: absolute; height: 99%; width: 99%");
this.appendChild(layout);
this.setStyle("width: 100%; height: 100%; position: absolute");
toolbar = new Toolbar();
toolbar.setHeight("26px");
sendMail = new Toolbarbutton();
archive = new Toolbarbutton();
sendMail.setImage("/images/SendMail24.png");
sendMail.setTooltiptext("Send Mail");
toolbar.appendChild(sendMail);
sendMail.addEventListener(Events.ON_CLICK, this);
archive.setImage("/images/Archive24.png");
archive.setTooltiptext("Archived Documents/Reports");
toolbar.appendChild(archive);
archive.addEventListener(Events.ON_CLICK, this);
toolbar.appendChild(new Separator("vertical"));
//
// we have drop down in toolbar to select PDF or XLS
//
previewType.setMold("select");
previewType.appendItem("PDF", "PDF");
previewType.appendItem("Excel", "XLS");
previewType.appendItem("RTF", "RTF");
toolbar.appendChild(previewType);
previewType.addEventListener(Events.ON_SELECT, this);
North north = new North();
layout.appendChild(north);
north.appendChild(toolbar);
Center center = new Center();
center.setFlex(true);
layout.appendChild(center);
iframe = new Iframe();
iframe.setId(jasperPrint.getName());
iframe.setHeight("100%");
iframe.setWidth("100%");
iframe.setAutohide(Boolean.TRUE);
try {
renderReport();
} catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e.getMessage());
throw new AdempiereException("Failed to render report.", e);
}
center.appendChild(iframe);
this.setBorder("normal");
}
Aggregations