Search in sources :

Example 16 with AdempiereException

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;
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ProcessInfoLog(org.compiere.process.ProcessInfoLog) Timestamp(java.sql.Timestamp) SQLException(java.sql.SQLException) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 17 with AdempiereException

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);
}
Also used : I_PP_Order(org.eevolution.model.I_PP_Order) AdempiereException(org.adempiere.exceptions.AdempiereException) MBPartner(org.compiere.model.MBPartner) MPPProductBOM(org.eevolution.model.MPPProductBOM) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Example 18 with AdempiereException

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);
}
Also used : I_PP_Order(org.eevolution.model.I_PP_Order) AdempiereException(org.adempiere.exceptions.AdempiereException) MBPartner(org.compiere.model.MBPartner) MPPProductBOM(org.eevolution.model.MPPProductBOM) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Example 19 with AdempiereException

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();
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) AdempiereException(org.adempiere.exceptions.AdempiereException) FileInputStream(java.io.FileInputStream) URL(java.net.URL)

Example 20 with AdempiereException

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");
}
Also used : Iframe(org.zkoss.zul.Iframe) Center(org.zkoss.zkex.zul.Center) AdempiereException(org.adempiere.exceptions.AdempiereException) Toolbarbutton(org.zkoss.zul.Toolbarbutton) North(org.zkoss.zkex.zul.North) Borderlayout(org.zkoss.zkex.zul.Borderlayout) Separator(org.zkoss.zul.Separator) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AdempiereException(org.adempiere.exceptions.AdempiereException) Toolbar(org.zkoss.zul.Toolbar)

Aggregations

AdempiereException (org.adempiere.exceptions.AdempiereException)216 BigDecimal (java.math.BigDecimal)64 SQLException (java.sql.SQLException)42 ResultSet (java.sql.ResultSet)29 PreparedStatement (java.sql.PreparedStatement)28 MProduct (org.compiere.model.MProduct)28 ArrayList (java.util.ArrayList)27 Timestamp (java.sql.Timestamp)23 Query (org.compiere.model.Query)19 PO (org.compiere.model.PO)16 MBPartner (org.compiere.model.MBPartner)14 Properties (java.util.Properties)13 File (java.io.File)12 List (java.util.List)12 ProcessInfo (org.compiere.process.ProcessInfo)12 Arrays (java.util.Arrays)10 Env (org.compiere.util.Env)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 MMovement (org.compiere.model.MMovement)9 Date (java.util.Date)8