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();
}
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());
}
use of org.compiere.model.MUOM in project adempiere by adempiere.
the class RadioButtonTreeCellRenderer method component.
public DefaultMutableTreeNode component(MProduct M_Product, MPPProductBOM bomPassed, MPPProductBOMLine bomlinePassed) {
MUOM UOM = new MUOM(Env.getCtx(), M_Product.getC_UOM_ID(), null);
String whereClause = "Value=?";
List<MPPProductBOM> boms = new Query(Env.getCtx(), MPPProductBOM.Table_Name, whereClause, null).setParameters(new Object[] { M_Product.getValue() }).setOnlyActiveRecords(true).list();
for (MPPProductBOM bom : boms) {
return parent(bom);
}
return new DefaultMutableTreeNode(new nodeUserObject(Msg.translate(Env.getCtx(), "Value") + ": " + M_Product.getValue() + " " + Msg.translate(Env.getCtx(), "Name") + ": " + M_Product.getName() + " " + Msg.translate(Env.getCtx(), "C_UOM_ID") + ": " + UOM.getName(), M_Product, bomPassed, bomlinePassed));
}
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;
}
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);
}
Aggregations