@Override public double totalEstimatedQuantity(final Long woActivityId,Long mbHeaderId,final Long activityId,final WorkOrder workOrder){
  Date currentTimestamp=null;
  MBHeader mbHeader=null;
  if (mbHeaderId == null) {
    mbHeaderId=-1l;
    currentTimestamp=new Date();
  }
 else {
    mbHeader=persistenceService.find(" from MBHeader where id = ?",mbHeaderId);
    currentTimestamp=mbHeader.getCreatedDate();
  }
  Object[] params=null;
  Double estQuantity=null;
  params=new Object[]{workOrder,woActivityId,activityId};
  estQuantity=(Double)genericService.findByNamedQuery("totalEstimatedQuantity",params);
  Double estQuantityRE=null;
  if (workOrder.getParent() != null)   params=new Object[]{currentTimestamp,workOrder.getParent(),workOrder.getParent(),activityId};
 else   params=new Object[]{currentTimestamp,workOrder,workOrder,activityId};
  estQuantityRE=(Double)genericService.findByNamedQuery("totalEstimatedQuantityForRE",params);
  if (estQuantity != null && estQuantityRE != null)   estQuantity=estQuantity + estQuantityRE;
  if (estQuantity == null && estQuantityRE != null)   estQuantity=estQuantityRE;
  if (estQuantity == null)   return 0.0d;
 else   return estQuantity.doubleValue();
}

@ Override public double totalEstimatedQuantity ( final Long woActivityId , Long mbHeaderId , final Long activityId , final WorkOrder workOrder ) { Date currentTimestamp = null ; MBHeader mbHeader = null ; if ( mbHeaderId == null ) { mbHeaderId = - 1l ; currentTimestamp = new Date ( ) ; } else { mbHeader = persistenceService . find ( " from MBHeader where id = ?" , mbHeaderId ) ; currentTimestamp = mbHeader . getCreatedDate ( ) ; } Object [ ] params = null ; Double estQuantity = null ; params = new Object [ ] { workOrder , woActivityId , activityId } ; estQuantity = ( Double ) genericService . findByNamedQuery ( "totalEstimatedQuantity" , params ) ; Double estQuantityRE = null ; if ( workOrder . getParent ( ) != null ) params = new Object [ ] { currentTimestamp , workOrder . getParent ( ) , workOrder . getParent ( ) , activityId } ; else params = new Object [ ] { currentTimestamp , workOrder , workOrder , activityId } ; estQuantityRE = ( Double ) genericService . findByNamedQuery ( "totalEstimatedQuantityForRE" , params ) ; if ( estQuantity != null && estQuantityRE != null ) estQuantity = estQuantity + estQuantityRE ; if ( estQuantity == null && estQuantityRE != null ) estQuantity = estQuantityRE ; if ( estQuantity == null ) return 0.0d ; else return estQuantity . doubleValue ( ) ; }
this is used by mb screens . this returns the estimated quantity for an work order activity this returns original activity quantity + all change quantities of the activity for all associated res work order activities of only approved res are considered
