use of org.compiere.model.Query in project adempiere by adempiere.
the class ScanBar method getProductByValueC.
public MProduct getProductByValueC(String barCode) {
StringBuilder whereClause = new StringBuilder();
whereClause.append("UPPER(").append(I_M_Product.COLUMNNAME_Value).append(")=?");
return new Query(Env.getCtx(), I_M_Product.Table_Name, whereClause.toString(), null).setClient_ID().setParameters(barCode.toUpperCase()).first();
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class CPOS method getCreditNotes.
// getCreditCards
/**
* Get Credit Notes
*
*/
public ValueNamePair[] getCreditNotes() {
try {
String whereClause = "C_BPartner_ID = ? " + "AND IsPaid ='N' " + "AND EXISTS(SELECT 1 " + " FROM C_DocType dt " + " WHERE dt.C_DocType_ID = C_Invoice.C_DocType_ID " + " AND dt.DocBaseType ='ARC'" + ")";
List<MInvoice> invoiceList = new Query(Env.getCtx(), MInvoice.Table_Name, whereClause, null).setParameters(currentOrder.getC_BPartner_ID()).list();
//
// to eliminate duplicates
HashMap<String, ValueNamePair> map = new HashMap<String, ValueNamePair>();
ValueNamePair valueNamePair;
for (MInvoice invoice : invoiceList) {
Integer id = invoice.getC_Invoice_ID();
valueNamePair = new ValueNamePair(id.toString(), invoice.getDocumentNo() + " " + invoice.getOpenAmt().toString());
map.put(invoice.getDocumentNo(), valueNamePair);
}
// for all payment processors
//
ValueNamePair[] retValue = new ValueNamePair[map.size()];
map.values().toArray(retValue);
return retValue;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class RollupWorkflow method getProductIds.
/**
* get products
* @return
*/
private int[] getProductIds() {
List<Object> params = new ArrayList<Object>();
StringBuffer whereClause = new StringBuffer("AD_Client_ID=?");
params.add(getAD_Client_ID());
whereClause.append(" AND (").append(MProduct.COLUMNNAME_ProductType).append("=?");
params.add(MProduct.PRODUCTTYPE_Item);
whereClause.append(" OR ").append(MProduct.COLUMNNAME_ProductType).append("=?");
params.add(MProduct.PRODUCTTYPE_Resource);
whereClause.append(") AND ").append(MProduct.COLUMNNAME_IsBOM).append("=?");
params.add(true);
if (getProductId() > 0) {
whereClause.append(" AND ").append(MProduct.COLUMNNAME_M_Product_ID).append("=?");
params.add(getProductId());
}
if (getProductCategoryId() > 0) {
whereClause.append(" AND ").append(MProduct.COLUMNNAME_M_Product_Category_ID).append("=?");
params.add(getProductCategoryId());
}
if (getProductClassId() > 0) {
whereClause.append(" AND ").append(MProduct.COLUMNNAME_M_Product_Class_ID).append("=?");
params.add(getProductClassId());
}
if (getProductGroupId() > 0) {
whereClause.append(" AND ").append(MProduct.COLUMNNAME_M_Product_Group_ID).append("=?");
params.add(getProductGroupId());
}
if (getProductClassificationId() > 0) {
whereClause.append(" AND ").append(MProduct.COLUMNNAME_M_Product_Classification_ID).append("=?");
params.add(getProductClassificationId());
}
return new Query(getCtx(), MProduct.Table_Name, whereClause.toString(), get_TrxName()).setOrderBy(MProduct.COLUMNNAME_LowLevel).setParameters(params).getIDs();
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class SimulatedPickList method loadBOM.
/**
* Action: Fill Tree with all nodes
*/
private void loadBOM() throws Exception {
int count = 0;
if (p_M_Product_ID == 0)
raiseError("Error: ", "Product ID not found");
MProduct product = new MProduct(getCtx(), p_M_Product_ID, get_TrxName());
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
tboml.setAD_Org_ID(product.getAD_Org_ID());
tboml.setPP_Product_BOM_ID(0);
tboml.setPP_Product_BOMLine_ID(0);
tboml.setSel_Product_ID(p_M_Product_ID);
tboml.setM_Product_ID(p_M_Product_ID);
tboml.setSel_Product_ID(p_M_Product_ID);
tboml.setDateTrx(p_DateTrx);
tboml.setImplosion(false);
tboml.setLevelNo(0);
tboml.setLevels("0");
tboml.setQtyBOM(Env.ONE);
tboml.setQtyRequired(p_QtyRequiered);
tboml.setM_Warehouse_ID(p_M_Warehouse_ID);
tboml.setSeqNo(0);
tboml.setAD_PInstance_ID(AD_PInstance_ID);
tboml.saveEx();
final String whereClause = MPPProductBOM.COLUMNNAME_M_Product_ID + "=?";
List<MPPProductBOM> boms = new Query(getCtx(), X_PP_Product_BOM.Table_Name, whereClause, get_TrxName()).setClient_ID().setOnlyActiveRecords(true).setParameters(p_M_Product_ID).list();
for (MPPProductBOM bom : boms) {
if (bom.isValidFromTo(p_DateTrx)) {
parentExplotion(bom.get_ID(), p_QtyRequiered);
++count;
}
}
if (count == 0)
raiseError("Error: ", "Product is not a BOM");
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class SimulatedPickList method component.
/**
* Find if this product as component
*
* @param M_Product_ID
* ID Component
*/
public void component(int M_Product_ID, BigDecimal qtyRequiered) throws Exception {
if (LevelNo == p_LevelNo)
return;
String value = DB.getSQLValueString(get_TrxName(), "SELECT Value FROM M_Product WHERE M_Product_ID=?", M_Product_ID);
final StringBuilder whereClause = new StringBuilder(MPPProductBOM.COLUMNNAME_Value).append("=? AND ").append(MPPProductBOM.COLUMNNAME_M_Product_ID).append("=?");
List<MPPProductBOM> boms = new Query(getCtx(), MPPProductBOM.Table_Name, whereClause.toString(), get_TrxName()).setClient_ID().setOnlyActiveRecords(true).setParameters(value, M_Product_ID).list();
boolean level = false;
for (MPPProductBOM bom : boms) {
if (bom.isValidFromTo(p_DateTrx)) {
if (!level)
LevelNo += 1;
level = true;
parentExplotion(bom.get_ID(), qtyRequiered);
LevelNo -= 1;
}
}
}
Aggregations