Search in sources :

Example 26 with MPPOrder

use of org.eevolution.model.MPPOrder in project adempiere by adempiere.

the class CRPDatasetFactory method calculateLoad.

public BigDecimal calculateLoad(Timestamp dateTime, MResource r, String docStatus) {
    MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
    MUOM uom = MUOM.get(Env.getCtx(), t.getC_UOM_ID());
    BigDecimal qtyOpen;
    long millis = 0l;
    for (MPPOrderNode node : getPPOrderNodes(dateTime, r)) {
        if (docStatus != null) {
            MPPOrder o = new MPPOrder(node.getCtx(), node.getPP_Order_ID(), node.get_TrxName());
            if (!o.getDocStatus().equals(docStatus)) {
                continue;
            }
        }
        millis += calculateMillisForDay(dateTime, node, t);
    }
    // Pre-converts to minutes, because its the lowest time unit of compiere 
    BigDecimal scale = new BigDecimal(1000 * 60);
    BigDecimal minutes = new BigDecimal(millis).divide(scale, 2, BigDecimal.ROUND_HALF_UP);
    return convert(minutes);
}
Also used : MPPOrderNode(org.eevolution.model.MPPOrderNode) MUOM(org.compiere.model.MUOM) MResourceType(org.compiere.model.MResourceType) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Aggregations

MPPOrder (org.eevolution.model.MPPOrder)26 AdempiereException (org.adempiere.exceptions.AdempiereException)8 MProduct (org.compiere.model.MProduct)8 BigDecimal (java.math.BigDecimal)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 MPPProductBOM (org.eevolution.model.MPPProductBOM)5 BOMWrapper (org.eevolution.model.wrapper.BOMWrapper)5 MBPartner (org.compiere.model.MBPartner)4 MResource (org.compiere.model.MResource)4 I_PP_Order (org.eevolution.model.I_PP_Order)4 MPPOrderNode (org.eevolution.model.MPPOrderNode)4 MWorkflow (org.compiere.wf.MWorkflow)3 BOMLineWrapper (org.eevolution.model.wrapper.BOMLineWrapper)3 HashMap (java.util.HashMap)2 MOrderLine (org.compiere.model.MOrderLine)2 MRequisition (org.compiere.model.MRequisition)2 MResourceType (org.compiere.model.MResourceType)2 PO (org.compiere.model.PO)2 MDDOrder (org.eevolution.model.MDDOrder)2 Timestamp (java.sql.Timestamp)1