Search in sources :

Example 21 with MUOM

use of org.compiere.model.MUOM in project adempiere by adempiere.

the class RadioButtonTreeCellRenderer method parent.

//	action_fillTree
public DefaultMutableTreeNode parent(MPPProductBOMLine bomline) {
    log.fine("In parent with X_PP_Product_BOMLine");
    MProduct M_Product = MProduct.get(Env.getCtx(), bomline.getM_Product_ID());
    MUOM UOM = new MUOM(Env.getCtx(), M_Product.getC_UOM_ID(), null);
    MPPProductBOM bomproduct = new MPPProductBOM(Env.getCtx(), bomline.getPP_Product_BOM_ID(), null);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(new nodeUserObject(Msg.translate(Env.getCtx(), "M_Product_ID") + Msg.translate(Env.getCtx(), "key") + ": " + M_Product.getValue() + " " + Msg.translate(Env.getCtx(), "Name") + ": " + M_Product.getName() + " " + Msg.translate(Env.getCtx(), "C_UOM_ID") + ": " + UOM.getName(), M_Product, bomproduct, bomline));
    Vector<Comparable<?>> line = new Vector<Comparable<?>>(17);
    //  0 Select
    line.add(new Boolean(false));
    //  1 IsActive
    line.add(new Boolean(true));
    // 2 Line                
    line.add(new Integer(bomline.getLine()));
    //  3 ValidDrom
    line.add((Timestamp) bomline.getValidFrom());
    //  4 ValidTo
    line.add((Timestamp) bomline.getValidTo());
    KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getName());
    //  5 M_Product_ID
    line.add(pp);
    KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), "");
    //  6 C_UOM_ID
    line.add(uom);
    //  7 IsQtyPorcentage
    line.add(new Boolean(bomline.isQtyPercentage()));
    //  8 BatchPercent
    line.add((BigDecimal) bomline.getQtyBatch());
    //  9 QtyBOM
    line.add((BigDecimal) ((bomline.getQtyBOM() != null) ? bomline.getQtyBOM() : new BigDecimal(0)));
    //  10 IsCritical                  
    line.add(new Boolean(bomline.isCritical()));
    // 11 LTOffSet
    line.add((Integer) bomline.getLeadTimeOffset());
    // 12 Assay
    line.add((BigDecimal) bomline.getAssay());
    // 13 Scrap
    line.add((BigDecimal) (bomline.getScrap()));
    // 14 IssueMethod
    line.add((String) bomline.getIssueMethod());
    // 15 BackflushGroup
    line.add((String) bomline.getBackflushGroup());
    // 16 Forecast
    line.add((BigDecimal) bomline.getForecast());
    dataBOM.add(line);
    String whereClause = "M_Product_ID=?";
    List<MPPProductBOM> boms = new Query(Env.getCtx(), MPPProductBOM.Table_Name, whereClause, null).setParameters(new Object[] { bomproduct.getM_Product_ID() }).setOnlyActiveRecords(true).list();
    for (MPPProductBOM bom : boms) {
        MProduct component = MProduct.get(Env.getCtx(), bom.getM_Product_ID());
        return component(component, bom, bomline);
    }
    return parent;
}
Also used : MProduct(org.compiere.model.MProduct) MUOM(org.compiere.model.MUOM) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Query(org.compiere.model.Query) MPPProductBOM(org.eevolution.model.MPPProductBOM) BigDecimal(java.math.BigDecimal) KeyNamePair(org.compiere.util.KeyNamePair) Vector(java.util.Vector)

Example 22 with MUOM

use of org.compiere.model.MUOM in project adempiere by adempiere.

the class CRPDatasetFactory method calculateLoad.

public BigDecimal calculateLoad(Timestamp dateTime, MResource r, String docStatus) {
    MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
    MUOM uom = MUOM.get(Env.getCtx(), t.getC_UOM_ID());
    BigDecimal qtyOpen;
    long millis = 0l;
    for (MPPOrderNode node : getPPOrderNodes(dateTime, r)) {
        if (docStatus != null) {
            MPPOrder o = new MPPOrder(node.getCtx(), node.getPP_Order_ID(), node.get_TrxName());
            if (!o.getDocStatus().equals(docStatus)) {
                continue;
            }
        }
        millis += calculateMillisForDay(dateTime, node, t);
    }
    // Pre-converts to minutes, because its the lowest time unit of compiere 
    BigDecimal scale = new BigDecimal(1000 * 60);
    BigDecimal minutes = new BigDecimal(millis).divide(scale, 2, BigDecimal.ROUND_HALF_UP);
    return convert(minutes);
}
Also used : MPPOrderNode(org.eevolution.model.MPPOrderNode) MUOM(org.compiere.model.MUOM) MResourceType(org.compiere.model.MResourceType) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Example 23 with MUOM

use of org.compiere.model.MUOM in project adempiere by adempiere.

the class NoUOMConversionException method buildMessage.

private static String buildMessage(int M_Product_ID, int C_UOM_ID, int C_UOM_To_ID) {
    StringBuffer sb = new StringBuffer("@" + AD_Message + "@ - ");
    //
    sb.append("@M_Product_ID@:");
    MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
    if (product != null) {
        sb.append(product.getValue()).append("_").append(product.getName());
    }
    //
    if (C_UOM_ID > 0 || product == null) {
        sb.append("  @C_UOM_ID@:");
        MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID);
        if (uom != null) {
            sb.append(uom.getUOMSymbol());
        }
    }
    //
    sb.append("  @C_UOM_To_ID@:");
    MUOM uomTo = MUOM.get(Env.getCtx(), C_UOM_To_ID);
    if (uomTo != null) {
        sb.append(uomTo.getUOMSymbol());
    }
    //
    return sb.toString();
}
Also used : MProduct(org.compiere.model.MProduct) MUOM(org.compiere.model.MUOM)

Example 24 with MUOM

use of org.compiere.model.MUOM in project adempiere by adempiere.

the class TreeBOM method productSummary.

/**
	 * get Product Summary
	 * @param product Product
	 * @param isLeaf is Leaf
	 * @return String
	 */
public String productSummary(MProduct product, boolean isLeaf) {
    MUOM uom = MUOM.get(getCtx(), product.getC_UOM_ID());
    String value = product.getValue();
    String name = product.get_Translation(MProduct.COLUMNNAME_Name);
    //
    StringBuffer sb = new StringBuffer(value);
    if (name != null && !value.equals(name))
        sb.append("_").append(product.getName());
    sb.append(" [").append(uom.get_Translation(MUOM.COLUMNNAME_UOMSymbol)).append("]");
    //
    return sb.toString();
}
Also used : MUOM(org.compiere.model.MUOM)

Example 25 with MUOM

use of org.compiere.model.MUOM in project adempiere by adempiere.

the class myJTree method action_reloadBOM.

//	action_fillTree
private void action_reloadBOM() {
    //m_frame.setBusy(true);
    m_frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    reload = true;
    //int M_Product_ID = getM_Product_ID();
    int M_Product_ID = m_selected_id;
    if (M_Product_ID == 0)
        return;
    MProduct M_Product = MProduct.get(getCtx(), M_Product_ID);
    treeInfo.setText("    Current Selection: " + M_Product.getValue());
    Vector<Object> line = new Vector<Object>(17);
    //  0 Select
    line.add(new Boolean(false));
    //  1 IsActive
    line.add(new Boolean(M_Product.isActive()));
    // 2 Line
    line.add(new Integer(0));
    KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getValue().concat("_").concat(M_Product.getName()));
    //  3 M_Product_ID
    line.add(pp);
    MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName());
    KeyNamePair uom = new KeyNamePair(M_Product.getC_UOM_ID(), u.getUOMSymbol());
    //  4 C_UOM_ID
    line.add(uom);
    //  5 QtyBOM
    line.add(Env.ONE);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(line);
    dataBOM.clear();
    if (isImplosion()) {
        for (MProductBOM bomline : getParentBOMs(M_Product_ID)) {
            addParent(bomline, parent);
        }
    //m_tree = new myJTree(parent);
    } else {
        /*			m_childEn = m_selectedNode.children();
			Vector<Object> line = new Vector<Object>(17);
			while (m_childEn != null && m_childEn.hasMoreElements())
			{
				DefaultMutableTreeNode nd = (DefaultMutableTreeNode)m_childEn.nextElement();
				//String[] uo = (String[])nd.getUserObject();
				line.add(nd.getUserObject());
				dataBOM.add( line);
			}
*/
        for (MProductBOM bom : getChildBOMs(M_Product_ID, true)) {
            addChild(bom, parent);
        }
    //m_tree = new myJTree(parent);
    }
    //m_tree.addTreeSelectionListener(this);
    //treePane.getViewport().add (m_tree, null);
    loadTableBOM();
    //m_frame.setBusy(false);
    m_frame.setCursor(Cursor.getDefaultCursor());
}
Also used : MProduct(org.compiere.model.MProduct) MUOM(org.compiere.model.MUOM) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MProductBOM(org.compiere.model.MProductBOM) KeyNamePair(org.compiere.util.KeyNamePair) Vector(java.util.Vector)

Aggregations

MUOM (org.compiere.model.MUOM)31 MProduct (org.compiere.model.MProduct)17 BigDecimal (java.math.BigDecimal)15 KeyNamePair (org.compiere.util.KeyNamePair)10 Vector (java.util.Vector)8 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 Timestamp (java.sql.Timestamp)4 MProductBOM (org.compiere.model.MProductBOM)4 MResourceType (org.compiere.model.MResourceType)4 MPPProductBOM (org.eevolution.model.MPPProductBOM)4 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)4 ArrayList (java.util.ArrayList)3 MResource (org.compiere.model.MResource)3 MUOMConversion (org.compiere.model.MUOMConversion)3 Query (org.compiere.model.Query)3 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 GregorianCalendar (java.util.GregorianCalendar)2