Program: 58842
Project: 58842
Buggy source:
public void chargeByMachineHours(ActionRequest request,ActionResponse response) throws AxelorException {
  List<Map<String,Object>> dataList=new ArrayList<Map<String,Object>>();
  DateTimeFormatter parser=ISODateTimeFormat.dateTime();
  LocalDateTime fromDateTime=LocalDateTime.parse(request.getContext().get("String_Node_Str").toString(),parser);
  LocalDateTime toDateTime=LocalDateTime.parse(request.getContext().get("String_Node_Str").toString(),parser);
  LocalDateTime itDateTime=new LocalDateTime(fromDateTime);
  if (Days.daysBetween(new LocalDate(fromDateTime.getYear(),fromDateTime.getMonthOfYear(),fromDateTime.getDayOfMonth()),new LocalDate(toDateTime.getYear(),toDateTime.getMonthOfYear(),toDateTime.getDayOfMonth())).getDays() > 20) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)),IException.CONFIGURATION_ERROR);
  }
  List<OperationOrder> operationOrderListTemp=operationOrderRepo.all().filter("String_Node_Str",fromDateTime,toDateTime).fetch();
  Set<String> machineNameList=new HashSet<String>();
  for (  OperationOrder operationOrder : operationOrderListTemp) {
    if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
      if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) {
        machineNameList.add(operationOrder.getWorkCenter().getMachine().getName());
      }
    }
  }
  while (!itDateTime.isAfter(toDateTime)) {
    List<OperationOrder> operationOrderList=operationOrderRepo.all().filter("String_Node_Str",itDateTime,itDateTime.plusHours(1)).fetch();
    Map<String,BigDecimal> map=new HashMap<String,BigDecimal>();
    for (    OperationOrder operationOrder : operationOrderList) {
      if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
        String machine=operationOrder.getWorkCenter().getMachine().getName();
        int numberOfMinutes=0;
        if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) {
          numberOfMinutes=Minutes.minutesBetween(itDateTime,operationOrder.getPlannedEndDateT()).getMinutes();
        }
 else         if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) {
          numberOfMinutes=Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),itDateTime.plusHours(1)).getMinutes();
        }
 else {
          numberOfMinutes=Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),operationOrder.getPlannedEndDateT()).getMinutes();
        }
        if (numberOfMinutes > 60) {
          numberOfMinutes=60;
        }
        BigDecimal percentage=new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100)).divide(new BigDecimal(60),2,RoundingMode.HALF_UP);
        if (map.containsKey(machine)) {
          map.put(machine,map.get(machine).add(percentage));
        }
 else {
          map.put(machine,percentage);
        }
      }
    }
    Set<String> keyList=map.keySet();
    Map<String,Object> dataMap=new HashMap<String,Object>();
    for (    String key : machineNameList) {
      if (keyList.contains(key)) {
        dataMap.put("String_Node_Str",(Object)itDateTime.toString());
        dataMap.put("String_Node_Str",(Object)map.get(key));
        dataMap.put("String_Node_Str",(Object)key);
        dataList.add(dataMap);
      }
 else {
        dataMap.put("String_Node_Str",(Object)itDateTime.toString());
        dataMap.put("String_Node_Str",(Object)BigDecimal.ZERO);
        dataMap.put("String_Node_Str",(Object)key);
        dataList.add(dataMap);
      }
    }
    itDateTime=itDateTime.plusHours(1);
  }
  response.setData(dataList);
}

Fixed version (ground truth):
public void chargeByMachineHours(ActionRequest request,ActionResponse response) throws AxelorException {
  List<Map<String,Object>> dataList=new ArrayList<Map<String,Object>>();
  DateTimeFormatter parser=ISODateTimeFormat.dateTime();
  LocalDateTime fromDateTime=LocalDateTime.parse(request.getContext().get("String_Node_Str").toString(),parser);
  LocalDateTime toDateTime=LocalDateTime.parse(request.getContext().get("String_Node_Str").toString(),parser);
  LocalDateTime itDateTime=new LocalDateTime(fromDateTime);
  if (Days.daysBetween(new LocalDate(fromDateTime.getYear(),fromDateTime.getMonthOfYear(),fromDateTime.getDayOfMonth()),new LocalDate(toDateTime.getYear(),toDateTime.getMonthOfYear(),toDateTime.getDayOfMonth())).getDays() > 20) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)),IException.CONFIGURATION_ERROR);
  }
  List<OperationOrder> operationOrderListTemp=operationOrderRepo.all().filter("String_Node_Str",fromDateTime,toDateTime).fetch();
  Set<String> machineNameList=new HashSet<String>();
  for (  OperationOrder operationOrder : operationOrderListTemp) {
    if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
      if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) {
        machineNameList.add(operationOrder.getWorkCenter().getMachine().getName());
      }
    }
  }
  while (!itDateTime.isAfter(toDateTime)) {
    List<OperationOrder> operationOrderList=operationOrderRepo.all().filter("String_Node_Str",itDateTime,itDateTime.plusHours(1)).fetch();
    Map<String,BigDecimal> map=new HashMap<String,BigDecimal>();
    for (    OperationOrder operationOrder : operationOrderList) {
      if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
        String machine=operationOrder.getWorkCenter().getMachine().getName();
        int numberOfMinutes=0;
        if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) {
          numberOfMinutes=Minutes.minutesBetween(itDateTime,operationOrder.getPlannedEndDateT()).getMinutes();
        }
 else         if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) {
          numberOfMinutes=Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),itDateTime.plusHours(1)).getMinutes();
        }
 else {
          numberOfMinutes=Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),operationOrder.getPlannedEndDateT()).getMinutes();
        }
        if (numberOfMinutes > 60) {
          numberOfMinutes=60;
        }
        BigDecimal percentage=new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100)).divide(new BigDecimal(60),2,RoundingMode.HALF_UP);
        if (map.containsKey(machine)) {
          map.put(machine,map.get(machine).add(percentage));
        }
 else {
          map.put(machine,percentage);
        }
      }
    }
    Set<String> keyList=map.keySet();
    for (    String key : machineNameList) {
      if (keyList.contains(key)) {
        Map<String,Object> dataMap=new HashMap<String,Object>();
        dataMap.put("String_Node_Str",(Object)itDateTime.toString());
        dataMap.put("String_Node_Str",(Object)map.get(key));
        dataMap.put("String_Node_Str",(Object)key);
        dataList.add(dataMap);
      }
 else {
        Map<String,Object> dataMap=new HashMap<String,Object>();
        dataMap.put("String_Node_Str",(Object)itDateTime.toString());
        dataMap.put("String_Node_Str",(Object)BigDecimal.ZERO);
        dataMap.put("String_Node_Str",(Object)key);
        dataList.add(dataMap);
      }
    }
    itDateTime=itDateTime.plusHours(1);
  }
  response.setData(dataList);
}