Search in sources :

Example 71 with Query

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");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) Query(org.compiere.model.Query) PackOut(org.adempiere.pipo.PackOut) MViewDefinition(org.adempiere.model.MViewDefinition) MViewColumn(org.adempiere.model.MViewColumn)

Example 72 with Query

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;
}
Also used : MProduct(org.compiere.model.MProduct) Query(org.compiere.model.Query) MPOSKey(org.compiere.model.MPOSKey) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException)

Example 73 with Query

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;
}
Also used : MDocType(org.compiere.model.MDocType) Query(org.compiere.model.Query)

Example 74 with Query

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;
}
Also used : Query(org.compiere.model.Query) BigDecimal(java.math.BigDecimal)

Example 75 with Query

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;
}
Also used : Query(org.compiere.model.Query) BigDecimal(java.math.BigDecimal)

Aggregations

Query (org.compiere.model.Query)210 ArrayList (java.util.ArrayList)49 BigDecimal (java.math.BigDecimal)25 Properties (java.util.Properties)22 MProduct (org.compiere.model.MProduct)20 AdempiereException (org.adempiere.exceptions.AdempiereException)12 MTable (org.compiere.model.MTable)12 MOrderLine (org.compiere.model.MOrderLine)8 MWarehouse (org.compiere.model.MWarehouse)8 PO (org.compiere.model.PO)8 MBPartner (org.compiere.model.MBPartner)6 MQuery (org.compiere.model.MQuery)6 MPPProductBOM (org.eevolution.model.MPPProductBOM)6 MColumn (org.compiere.model.MColumn)5 MLocation (org.compiere.model.MLocation)5 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)5 SQLException (java.sql.SQLException)4 Timestamp (java.sql.Timestamp)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 MClient (org.compiere.model.MClient)4