use of org.compiere.model.MProduct in project adempiere by adempiere.
the class BOMValidate method doIt.
// prepare
/**
* Process
* @return Info
* @throws Exception
*/
protected String doIt() throws Exception {
if (p_M_Product_ID != 0) {
log.info("M_Product_ID=" + p_M_Product_ID);
return validateProduct(new MProduct(getCtx(), p_M_Product_ID, get_TrxName()));
}
log.info("M_Product_Category_ID=" + p_M_Product_Category_ID + ", IsReValidate=" + p_IsReValidate);
//
int counter = 0;
PreparedStatement pstmt = null;
String sql = "SELECT * FROM M_Product " + "WHERE IsBOM='Y' AND ";
if (p_M_Product_Category_ID == 0)
sql += "AD_Client_ID=? ";
else
sql += "M_Product_Category_ID=? ";
if (!p_IsReValidate)
sql += "AND IsVerified<>'Y' ";
sql += "ORDER BY Name";
int AD_Client_ID = Env.getAD_Client_ID(getCtx());
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
if (p_M_Product_Category_ID == 0)
pstmt.setInt(1, AD_Client_ID);
else
pstmt.setInt(1, p_M_Product_Category_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
String info = validateProduct(new MProduct(getCtx(), rs.getInt(1), get_TrxName()));
addLog(0, null, null, info);
counter++;
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return "#" + counter;
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class WMRuleEngine method applyDefinition.
/**
* Apply Definition for Warehouse Strategy
* @param inOutBoundLine Order Bound Line
* @param warehouseAreaTypeId Area Type Id
* @param warehouseSectionTypeId Section Type Id
* */
private MWMStrategy applyDefinition(MWMInOutBoundLine inOutBoundLine, int warehouseAreaTypeId, int warehouseSectionTypeId) {
StringBuffer whereClause = new StringBuffer("(");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_Category_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_M_Product_Category_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_Group1 + " IN ('',?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_Group1 + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_Group2 + " IN ('',?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_Group2 + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_Classification + " IN ('',?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_Classification + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_C_BPartner_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_C_BPartner_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_C_BP_Group_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_C_BP_Group_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Area_Type_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Area_Type_ID + " IS NULL");
whereClause.append(") AND ");
whereClause.append("(");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Section_Type_ID + " IN (0,?) OR ");
whereClause.append(MWMDefinition.COLUMNNAME_WM_Section_Type_ID + " IS NULL");
whereClause.append(")");
whereClause.append(" AND EXISTS (SELECT 1 FROM " + MWMStrategy.Table_Name);
whereClause.append(" WHERE ");
whereClause.append(MWMStrategy.Table_Name + "." + MWMStrategy.COLUMNNAME_WM_Strategy_ID + "=");
whereClause.append(MWMDefinition.Table_Name + "." + MWMDefinition.COLUMNNAME_WM_Strategy_ID);
whereClause.append(" AND ");
whereClause.append(MWMStrategy.COLUMNNAME_InOutBoundType + "=?");
whereClause.append(")");
MProduct product = inOutBoundLine.getMProduct();
MBPartner partner = inOutBoundLine.getBPartner();
MWMDefinition definition = new Query(inOutBoundLine.getCtx(), MWMDefinition.Table_Name, whereClause.toString(), inOutBoundLine.get_TrxName()).setClient_ID().setParameters(product.getM_Product_ID(), product.getM_Product_Category_ID(), product.getGroup1(), product.getGroup2(), product.getClassification(), partner.getC_BPartner_ID(), partner.getC_BP_Group_ID(), warehouseAreaTypeId, warehouseSectionTypeId, MWMStrategy.INOUTBOUNDTYPE_OutboundOperation).first();
if (definition == null) {
throw new AdempiereException("@WM_Definition_ID@ @NotFound@");
}
return definition.getWarehouseStrategy();
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class WExpressReceiptScanBarUI method addScanProduct.
private void addScanProduct() {
String upc = upcField.getDisplay();
if (upc == null)
return;
MProduct product = getMProduct(upc);
if (product == null) {
FDialog.error(form.getWindowNo(), form, Msg.parseTranslation(Env.getCtx(), "@M_Product_ID@ @NotFound@"), upc);
upcField.setValue("");
return;
}
setProduct(product);
productValueField.setValue(product.getValue());
productField.setValue(product.getName());
UOMField.setValue(product.getC_UOM().getName());
if (isLot()) {
lotField.setVisible(true);
}
if (isSerNo()) {
serNoField.setVisible(true);
} else {
qtyCountField.setVisible(true);
}
addProductLine();
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class ExpressReceiptScanBar method getMProduct.
public MProduct getMProduct(String barCode) {
MProduct product = getProductByUPC(barCode);
if (product != null)
return product;
product = getProductByValueC(barCode);
if (product != null)
return product;
int prefixPosition = barCode.toUpperCase().indexOf("P");
if (prefixPosition > 0 && prefixPosition <= 3)
product = getProductByValueC(barCode.substring(prefixPosition + 1));
return product;
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class MWMInOutBound method prepareIt.
// processIt
/**************************************************************************
* Prepare Document
* @return new status (In Progress or Invalid)
*/
public String prepareIt() {
log.info(toString());
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
// Std Period open?
/*if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
}*/
// Lines
List<MWMInOutBoundLine> lines = getLines(true, MWMInOutBoundLine.COLUMNNAME_Line);
if (lines.size() == 0) {
m_processMsg = "@NoLines@";
return DocAction.STATUS_Invalid;
}
// Bug 1564431
if (getDeliveryRule() != null && getDeliveryRule().equals(MWMInOutBound.DELIVERYVIARULE_Delivery)) {
for (MWMInOutBoundLine line : lines) {
MProduct product = line.getMProduct();
if (product != null && product.isExcludeAutoDelivery()) {
m_processMsg = "@M_Product_ID@ " + product.getValue() + " @IsExcludeAutoDelivery@";
return DocAction.STATUS_Invalid;
}
}
}
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
m_justPrepared = true;
return DocAction.STATUS_InProgress;
}
Aggregations