public static MPPCostCollector createCollector(MPPOrder order,int productId,int locatorId,int attributeSetInstanceId,int resourceId,int orderBOMLineId,int orderNodeId,int docTypeId,String costCollectorType,Timestamp movementDate,BigDecimal qty,BigDecimal scrap,BigDecimal reject,int durationSetup,BigDecimal duration){
  MPPCostCollector cc=new MPPCostCollector(order);
  cc.setPP_Order_BOMLine_ID(orderBOMLineId);
  cc.setPP_Order_Node_ID(orderNodeId);
  cc.setC_DocType_ID(docTypeId);
  cc.setC_DocTypeTarget_ID(docTypeId);
  cc.setCostCollectorType(costCollectorType);
  cc.setDocAction(MPPCostCollector.DOCACTION_Complete);
  cc.setDocStatus(MPPCostCollector.DOCSTATUS_Drafted);
  cc.setIsActive(true);
  cc.setM_Locator_ID(locatorId);
  cc.setM_AttributeSetInstance_ID(attributeSetInstanceId);
  cc.setS_Resource_ID(resourceId);
  cc.setMovementDate(movementDate);
  cc.setDateAcct(movementDate);
  cc.setMovementQty(qty);
  cc.setScrappedQty(scrap);
  cc.setQtyReject(reject);
  cc.setSetupTimeReal(new BigDecimal(durationSetup));
  cc.setDurationReal(duration);
  cc.setPosted(false);
  cc.setProcessed(false);
  cc.setProcessing(false);
  cc.setUser1_ID(order.getUser1_ID());
  cc.setUser2_ID(order.getUser2_ID());
  cc.setM_Product_ID(productId);
  if (orderNodeId > 0) {
    cc.setIsSubcontracting(orderNodeId);
  }
  if (orderBOMLineId > 0) {
    cc.setC_UOM_ID(0);
  }
  cc.saveEx();
  if (!cc.processIt(MPPCostCollector.DOCACTION_Complete)) {
    throw new AdempiereException(cc.getProcessMsg());
  }
  cc.saveEx();
  return cc;
}

public static MPPCostCollector createCollector ( MPPOrder order , int productId , int locatorId , int attributeSetInstanceId , int resourceId , int orderBOMLineId , int orderNodeId , int docTypeId , String costCollectorType , Timestamp movementDate , BigDecimal qty , BigDecimal scrap , BigDecimal reject , int durationSetup , BigDecimal duration ) { MPPCostCollector cc = new MPPCostCollector ( order ) ; cc . setPP_Order_BOMLine_ID ( orderBOMLineId ) ; cc . setPP_Order_Node_ID ( orderNodeId ) ; cc . setC_DocType_ID ( docTypeId ) ; cc . setC_DocTypeTarget_ID ( docTypeId ) ; cc . setCostCollectorType ( costCollectorType ) ; cc . setDocAction ( MPPCostCollector . DOCACTION_Complete ) ; cc . setDocStatus ( MPPCostCollector . DOCSTATUS_Drafted ) ; cc . setIsActive ( true ) ; cc . setM_Locator_ID ( locatorId ) ; cc . setM_AttributeSetInstance_ID ( attributeSetInstanceId ) ; cc . setS_Resource_ID ( resourceId ) ; cc . setMovementDate ( movementDate ) ; cc . setDateAcct ( movementDate ) ; cc . setMovementQty ( qty ) ; cc . setScrappedQty ( scrap ) ; cc . setQtyReject ( reject ) ; cc . setSetupTimeReal ( new BigDecimal ( durationSetup ) ) ; cc . setDurationReal ( duration ) ; cc . setPosted ( false ) ; cc . setProcessed ( false ) ; cc . setProcessing ( false ) ; cc . setUser1_ID ( order . getUser1_ID ( ) ) ; cc . setUser2_ID ( order . getUser2_ID ( ) ) ; cc . setM_Product_ID ( productId ) ; if ( orderNodeId > 0 ) { cc . setIsSubcontracting ( orderNodeId ) ; } if ( orderBOMLineId > 0 ) { cc . setC_UOM_ID ( 0 ) ; } cc . saveEx ( ) ; if ( ! cc . processIt ( MPPCostCollector . DOCACTION_Complete ) ) { throw new AdempiereException ( cc . getProcessMsg ( ) ) ; } cc . saveEx ( ) ; return cc ; }
create & complete cost collector
