use of org.compiere.model.Query in project adempiere by adempiere.
the class ViewDefinitionElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
PackOut packOut = (PackOut) ctx.get("PackOutProcess");
int AD_View_Definition_ID = Env.getContextAsInt(ctx, X_AD_View_Definition.COLUMNNAME_AD_View_Definition_ID);
MViewDefinition m_View_Definition = new MViewDefinition(ctx, AD_View_Definition_ID, getTrxName(ctx));
AttributesImpl atts = new AttributesImpl();
createViewDefinitionBinding(atts, m_View_Definition);
document.startElement("", "", "viewdefinition", atts);
// View Columns tags.
StringBuilder whereClause = new StringBuilder(I_AD_View_Definition.COLUMNNAME_AD_View_Definition_ID).append("=?");
List<MViewColumn> viewColumns = new Query(ctx, I_AD_View_Column.Table_Name, whereClause.toString(), getTrxName(ctx)).setParameters(m_View_Definition.get_ID()).list();
for (MViewColumn vc : viewColumns) {
createViewColumn(ctx, document, vc.getAD_View_Column_ID());
}
document.endElement("", "", "viewdefinition");
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class PosKeyGenerate method doIt.
/**
* Generate keys for each product
*/
@Override
protected String doIt() throws Exception {
if (posKeyLayoutId == 0)
throw new FillMandatoryException("C_POSKeyLayout_ID");
int count = 0;
String where = "";
Object[] params = new Object[] {};
if (productCategoryId > 0) {
where = "M_Product_Category_ID = ? ";
params = new Object[] { productCategoryId };
}
Query query = new Query(getCtx(), MProduct.Table_Name, where, get_TrxName()).setParameters(params).setOnlyActiveRecords(true).setOrderBy("Value");
List<MProduct> products = query.list();
for (MProduct product : products) {
MPOSKey key = new MPOSKey(getCtx(), 0, get_TrxName());
key.setName(product.getName());
key.setM_Product_ID(product.getM_Product_ID());
key.setC_POSKeyLayout_ID(posKeyLayoutId);
key.setSeqNo(count * 10);
key.setQty(Env.ONE);
key.saveEx();
count++;
}
return "@Created@ " + count;
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class MPPOrder method approveIt.
// reserveStock
public boolean approveIt() {
log.info("approveIt - " + toString());
MDocType doc = MDocType.get(getCtx(), getC_DocType_ID());
if (MDocType.DOCBASETYPE_QualityOrder.equals(doc.getDocBaseType())) {
String whereClause = COLUMNNAME_PP_Product_BOM_ID + "=? AND " + COLUMNNAME_AD_Workflow_ID + "=?";
MQMSpecification qms = new Query(getCtx(), MQMSpecification.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Product_BOM_ID(), getAD_Workflow_ID() }).firstOnly();
return qms != null ? qms.isValid(getM_AttributeSetInstance_ID()) : true;
} else {
setIsApproved(true);
}
return true;
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class MPPOrderNode method getVariance.
public BigDecimal getVariance(String costCollectorType, String columnName) {
final String whereClause = I_PP_Cost_Collector.COLUMNNAME_PP_Order_Node_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_PP_Order_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_DocStatus + " IN (?,?)" + " AND " + I_PP_Cost_Collector.COLUMNNAME_CostCollectorType + "=?";
BigDecimal variance = new Query(getCtx(), I_PP_Cost_Collector.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Order_Node_ID(), getPP_Order_ID(), X_PP_Cost_Collector.DOCSTATUS_Completed, X_PP_Cost_Collector.DOCSTATUS_Closed, costCollectorType }).sum(columnName);
//
return variance;
}
use of org.compiere.model.Query in project adempiere by adempiere.
the class MPPOrderBOMLine method getQtyVariance.
/**
* @return recorded Qty Usage Variance so far
*/
public BigDecimal getQtyVariance() {
final String whereClause = I_PP_Cost_Collector.COLUMNNAME_PP_Order_BOMLine_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_PP_Order_ID + "=?" + " AND " + I_PP_Cost_Collector.COLUMNNAME_DocStatus + " IN (?,?)" + " AND " + I_PP_Cost_Collector.COLUMNNAME_CostCollectorType + "=?";
BigDecimal qtyUsageVariance = new Query(getCtx(), I_PP_Cost_Collector.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Order_BOMLine_ID(), getPP_Order_ID(), X_PP_Cost_Collector.DOCSTATUS_Completed, X_PP_Cost_Collector.DOCSTATUS_Closed, X_PP_Cost_Collector.COSTCOLLECTORTYPE_UsegeVariance }).sum(I_PP_Cost_Collector.COLUMNNAME_MovementQty);
//
return qtyUsageVariance;
}
Aggregations