use of org.compiere.model.MProduct in project adempiere by adempiere.
the class CalculateReplenishPlan method runProcessCalculatePlannedQty.
private void runProcessCalculatePlannedQty(Map<Integer, MiniMRPProduct> miniMrpProducts) {
for (Date date : mapDemand.keySet()) {
Map<Integer, BigDecimal> mapOrderQty = mapDemand.get(date);
for (Integer productID : mapOrderQty.keySet()) {
MProduct product = new MProduct(getCtx(), productID, get_TrxName());
if (!product.isStocked())
return;
BigDecimal demandQty = mapOrderQty.get(productID);
if (demandQty.compareTo(Env.ZERO) != 0) {
MiniMRPProduct mrp = miniMrpProducts.get(productID);
if (mrp == null) {
MProduct p = MProduct.get(ctx, productID);
String error = "Please check Product=" + p.getValue() + " replenishment parameters may not be setup properly.";
log.severe(error);
throw new AdempiereException(error);
}
Integer nonPhantomProduct = (mrp.isPhantom() && mrp.isBOM() ? 0 : productID);
// (MRP,DateOfDemand,PID,DQty,Level,NonPhontomPID)
createPlannedQtyMap(miniMrpProducts, date, productID, demandQty, 0, nonPhantomProduct);
}
}
}
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class CalculateReplenishPlan method processBOMLines.
/**
* Process of BOM Product lines
*
* @author Sachin Bhimani
* @param miniMrpProducts
* @param productIds
* @param M_Product_ID
*/
public void processBOMLines(Map<Integer, MiniMRPProduct> miniMrpProducts, Set<Integer> productIds, int M_Product_ID) {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
if (M_Product_ID > 0) {
MProduct product = new MProduct(getCtx(), M_Product_ID, get_TrxName());
if (!product.isStocked())
return;
//MPPProductBOM bom = MPPProductBOM.getDefault(finishedProduct, get_TrxName());
pstmt = DB.prepareStatement(SQL_GET_BOMLINE_FOR_PROCESS, trx);
pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, AD_Client_ID);
pstmt.setInt(3, M_WarehouseID);
rs = pstmt.executeQuery();
while (rs.next()) {
int mProductID = rs.getInt(1);
BigDecimal qtyBom = rs.getBigDecimal(2);
MiniMRPProduct parentProduct = miniMrpProducts.get(M_Product_ID);
parentProduct.addMatireals(mProductID, qtyBom);
MiniMRPProduct miniMrpProduct = null;
// If material is already exploded.
if (miniMrpProducts.containsKey(mProductID)) {
miniMrpProduct = miniMrpProducts.get(mProductID);
explodeRequiredMaterials(miniMrpProduct, parentProduct, qtyBom);
} else {
miniMrpProduct = addProductToProcess(mProductID, rs, miniMrpProducts, productIds);
if (miniMrpProduct.isBOM() && miniMrpProduct.isVerified()) {
processBOMLines(miniMrpProducts, productIds, mProductID);
explodeRequiredMaterials(miniMrpProduct, parentProduct, qtyBom);
}
}
}
}
} catch (Exception e) {
log.log(Level.SEVERE, SQL_GET_BOMLINE_FOR_PROCESS, e);
getProcessInfo().setError(true);
getProcessInfo().addLog(new ProcessInfoLog(getProcessInfo().getAD_Process_ID(), new Timestamp(System.currentTimeMillis()), null, "Failed to process BOMLine : >> " + e.getMessage()));
throw new AdempiereException(e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class VMRPDetailed method selectAttributeSetInstance.
// prepareTable
/**
* filter by Attribute Set Instance
*/
private void selectAttributeSetInstance() {
int m_warehouse_id = getM_Warehouse_ID();
int m_product_id = getM_Product_ID();
if (m_product_id <= 0)
return;
MProduct product = MProduct.get(getCtx(), m_product_id);
MWarehouse wh = MWarehouse.get(getCtx(), m_warehouse_id);
String title = product.get_Translation(MProduct.COLUMNNAME_Name) + " - " + wh.get_Translation(MWarehouse.COLUMNNAME_Name);
// Yamel Senih FR [ 114 ] 2015-11-23
PAttributeInstance pai = new PAttributeInstance(m_frame.getCFrame(), title, m_warehouse_id, 0, m_product_id, 0);
if (pai.getM_AttributeSetInstance_ID() != -1) {
fAttrSetInstance_ID.setText(pai.getM_AttributeSetInstanceName());
fAttrSetInstance_ID.setValue(new Integer(pai.getM_AttributeSetInstance_ID()));
} else {
fAttrSetInstance_ID.setValue(Integer.valueOf(0));
}
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class CAbstractBOMTree method handleTreeEvent.
private void handleTreeEvent(MouseEvent e) {
String text = model.getBOMMessenger().getToolTipText(e);
if (text != null) {
nodeDescription.setText(text);
}
if (e.getButton() == MouseEvent.BUTTON3) {
model.getTree().setSelectionPath(model.getTree().getPathForLocation(e.getX(), e.getY()));
DefaultMutableTreeNode node = (DefaultMutableTreeNode) model.getTree().getSelectionPath().getLastPathComponent();
if (node.getUserObject() instanceof BOMLineWrapper) {
popupBOMLine.show(e.getComponent(), e.getX(), e.getY());
} else if (node.getUserObject() instanceof BOMWrapper) {
popupBOM.show(e.getComponent(), e.getX(), e.getY());
} else if (node.getUserObject() instanceof MProduct) {
popupRoot.show(e.getComponent(), e.getX(), e.getY());
} else if (node.getUserObject() instanceof MPPOrder) {
popupRoot.show(e.getComponent(), e.getX(), e.getY());
}
}
SwingTool.setCursorsFromChild(e.getComponent(), false);
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class ProductNotOnPriceListException method buildMessage.
private static final String buildMessage(MProductPricing pp, int documentLineNo) {
StringBuffer sb = new StringBuffer();
if (documentLineNo > 0) {
if (sb.length() > 0)
sb.append(", ");
sb.append("@Line@:").append(documentLineNo);
}
if (pp.getM_Product_ID() > 0) {
MProduct p = MProduct.get(Env.getCtx(), pp.getM_Product_ID());
if (sb.length() > 0)
sb.append(", ");
sb.append("@M_Product_ID@:").append(p == null ? "?" : p.get_Translation(MProduct.COLUMNNAME_Name));
}
if (pp.getM_PriceList_ID() > 0) {
MPriceList pl = MPriceList.get(Env.getCtx(), pp.getM_PriceList_ID(), null);
if (sb.length() > 0)
sb.append(", ");
sb.append("@M_PriceList_ID@:").append(pl == null ? "?" : pl.get_Translation(MPriceList.COLUMNNAME_Name));
}
if (pp.getPriceDate() != null) {
DateFormat df = DisplayType.getDateFormat(DisplayType.Date);
if (sb.length() > 0)
sb.append(", ");
sb.append("@Date@:").append(df.format(pp.getPriceDate()));
}
//
sb.insert(0, "@" + AD_Message + "@ - ");
return sb.toString();
}
Aggregations