Program: 59199
Project: 59199
Buggy source:
@Transactional(rollbackOn={AxelorException.class,Exception.class}) public void update(Target target){
  UserInfo userInfo=target.getUserInfo();
  Team team=target.getTeam();
  LocalDate fromDate=target.getFromDate();
  LocalDate toDate=target.getToDate();
  if (userInfo != null) {
    Query q=JPA.em().createQuery("String_Node_Str");
    q.setParameter(1,userInfo);
    BigDecimal opportunityAmountEarned=(BigDecimal)q.getResultList();
    Long callEmittedNumber=Event.all().filter("String_Node_Str",1,userInfo,fromDate,toDate).count();
    target.setCallEmittedNumber(callEmittedNumber.intValue());
    Long meetingNumber=Event.all().filter("String_Node_Str",1,userInfo,fromDate,toDate).count();
    target.setMeetingNumber(meetingNumber.intValue());
    target.setOpportunityAmountEarned(opportunityAmountEarned);
    Long opportunityCreatedNumber=Opportunity.all().filter("String_Node_Str",1,userInfo,fromDate,toDate).count();
    target.setOpportunityCreatedNumber(opportunityCreatedNumber.intValue());
    Long opportunityCreatedWon=Opportunity.all().filter("String_Node_Str",1,userInfo,fromDate,toDate).count();
    target.setOpportunityCreatedWon(opportunityCreatedWon.intValue());
  }
 else   if (team != null) {
    Query q=JPA.em().createQuery("String_Node_Str");
    q.setParameter(1,team);
    BigDecimal opportunityAmountEarned=(BigDecimal)q.getResultList();
    Long callEmittedNumber=Event.all().filter("String_Node_Str",1,team,fromDate,toDate).count();
    target.setCallEmittedNumber(callEmittedNumber.intValue());
    Long meetingNumber=Event.all().filter("String_Node_Str",1,team,fromDate,toDate).count();
    target.setMeetingNumber(meetingNumber.intValue());
    target.setOpportunityAmountEarned(opportunityAmountEarned);
    Long opportunityCreatedNumber=Opportunity.all().filter("String_Node_Str",1,team,fromDate,toDate).count();
    target.setOpportunityCreatedNumber(opportunityCreatedNumber.intValue());
    Long opportunityCreatedWon=Opportunity.all().filter("String_Node_Str",1,team,fromDate,toDate).count();
    target.setOpportunityCreatedWon(opportunityCreatedWon.intValue());
  }
  target.save();
}

Fixed version (ground truth):
@Transactional(rollbackOn={AxelorException.class,Exception.class}) public void update(Target target){
  UserInfo userInfo=target.getUserInfo();
  Team team=target.getTeam();
  LocalDate fromDate=target.getFromDate();
  LocalDate toDate=target.getToDate();
  LocalDateTime fromDateTime=new LocalDateTime(fromDate.getYear(),fromDate.getMonthOfYear(),fromDate.getDayOfMonth(),0,0);
  LocalDateTime toDateTime=new LocalDateTime(toDate.getYear(),toDate.getMonthOfYear(),toDate.getDayOfMonth(),23,59);
  if (userInfo != null) {
    Query q=JPA.em().createQuery("String_Node_Str");
    q.setParameter(1,userInfo);
    q.setParameter(2,fromDateTime);
    q.setParameter(3,toDateTime);
    BigDecimal opportunityAmountEarned=(BigDecimal)q.getSingleResult();
    Long callEmittedNumber=Event.all().filter("String_Node_Str",1,userInfo,fromDateTime,toDateTime).count();
    target.setCallEmittedNumber(callEmittedNumber.intValue());
    Long meetingNumber=Event.all().filter("String_Node_Str",1,userInfo,fromDateTime,toDateTime).count();
    target.setMeetingNumber(meetingNumber.intValue());
    target.setOpportunityAmountEarned(opportunityAmountEarned);
    Long opportunityCreatedNumber=Opportunity.all().filter("String_Node_Str",userInfo,fromDateTime,toDateTime).count();
    target.setOpportunityCreatedNumber(opportunityCreatedNumber.intValue());
    Long opportunityCreatedWon=Opportunity.all().filter("String_Node_Str",userInfo,fromDateTime,toDateTime).count();
    target.setOpportunityCreatedWon(opportunityCreatedWon.intValue());
  }
 else   if (team != null) {
    Query q=JPA.em().createQuery("String_Node_Str");
    q.setParameter(1,team);
    q.setParameter(2,fromDateTime);
    q.setParameter(3,toDateTime);
    BigDecimal opportunityAmountEarned=(BigDecimal)q.getResultList();
    Long callEmittedNumber=Event.all().filter("String_Node_Str",1,userInfo,fromDateTime,toDateTime).count();
    target.setCallEmittedNumber(callEmittedNumber.intValue());
    Long meetingNumber=Event.all().filter("String_Node_Str",1,userInfo,fromDateTime,toDateTime).count();
    target.setMeetingNumber(meetingNumber.intValue());
    target.setOpportunityAmountEarned(opportunityAmountEarned);
    Long opportunityCreatedNumber=Opportunity.all().filter("String_Node_Str",userInfo,fromDateTime,toDateTime).count();
    target.setOpportunityCreatedNumber(opportunityCreatedNumber.intValue());
    Long opportunityCreatedWon=Opportunity.all().filter("String_Node_Str",userInfo,fromDateTime,toDateTime).count();
    target.setOpportunityCreatedWon(opportunityCreatedWon.intValue());
  }
  target.save();
}