Program: 59154
Project: 59154
Buggy source:
/** 
 * Méthode réalisant l'export SI - Agresso des en-têtes pour les journaux de type achat
 * @param mlr
 * @param replay
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") @Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect9FILE1(MoveLineReport mlr,boolean replay) throws AxelorException, IOException {
  LOG.info("String_Node_Str");
  String dateQueryStr="String_Node_Str" + String.format("String_Node_Str",mlr.getCompany().getId());
  JournalType journalType=mlrs.getJournalType(mlr);
  if (mlr.getJournal() != null) {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",mlr.getJournal().getId());
  }
 else {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",journalType.getId());
  }
  if (mlr.getPeriod() != null) {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",mlr.getPeriod().getId());
  }
  if (replay) {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",mlr.getId());
  }
 else {
    dateQueryStr+="String_Node_Str";
  }
  dateQueryStr+="String_Node_Str";
  Query dateQuery=JPA.em().createQuery("String_Node_Str" + dateQueryStr + "String_Node_Str");
  List<LocalDate> allDates=new ArrayList<LocalDate>();
  allDates=dateQuery.getResultList();
  LOG.debug("String_Node_Str",allDates);
  List<String[]> allMoveData=new ArrayList<String[]>();
  String companyCode="String_Node_Str";
  String reference="String_Node_Str";
  String moveQueryStr="String_Node_Str";
  String moveLineQueryStr="String_Node_Str";
  if (mlr.getRef() != null) {
    reference=mlr.getRef();
  }
  if (mlr.getCompany() != null) {
    companyCode=mlr.getCompany().getCode();
    moveQueryStr+="String_Node_Str";
    moveQueryStr+=String.format("String_Node_Str",mlr.getCompany().getId());
  }
  if (mlr.getPeriod() != null) {
    moveQueryStr+="String_Node_Str";
    moveQueryStr+=String.format("String_Node_Str",mlr.getPeriod().getId());
  }
  if (mlr.getDateFrom() != null) {
    moveLineQueryStr+="String_Node_Str";
    moveLineQueryStr+=String.format("String_Node_Str",mlr.getDateFrom().toString());
  }
  if (mlr.getDateTo() != null) {
    moveLineQueryStr+="String_Node_Str";
    moveLineQueryStr+=String.format("String_Node_Str",mlr.getDateTo().toString());
  }
  if (mlr.getDate() != null) {
    moveLineQueryStr+="String_Node_Str";
    moveLineQueryStr+=String.format("String_Node_Str",mlr.getDate().toString());
  }
  if (replay) {
    moveQueryStr+="String_Node_Str";
    moveQueryStr+=String.format("String_Node_Str",mlr.getId());
  }
 else {
    moveQueryStr+="String_Node_Str";
  }
  LocalDate interfaceDate=mlr.getDate();
  for (  LocalDate dt : allDates) {
    List<Journal> journalList=Journal.all().filter("String_Node_Str",journalType).fetch();
    if (mlr.getJournal() != null) {
      journalList=new ArrayList<Journal>();
      journalList.add(mlr.getJournal());
    }
    for (    Journal journal : journalList) {
      List<Move> moves=Move.all().filter("String_Node_Str" + moveQueryStr,dt,journal).fetch();
      String journalCode=journal.getExportCode();
      if (moves.size() > 0) {
        for (        Move move : moves) {
          List<MoveLine> moveLines=MoveLine.all().filter("String_Node_Str" + "String_Node_Str" + moveLineQueryStr,moves).fetch();
          LOG.debug("String_Node_Str",moveLines);
          if (moveLines.size() > 0) {
            String exportToAgressoNumber=sgs.getSequence(IAdministration.PURCHASE_INTERFACE,mlr.getCompany(),false);
            if (exportToAgressoNumber == null) {
              throw new AxelorException(String.format("String_Node_Str",GeneralService.getExceptionAccountingMsg(),mlr.getCompany().getName()),IException.CONFIGURATION_ERROR);
            }
            String periodCode=move.getPeriod().getFromDate().toString("String_Node_Str");
            move.setExportNumber(exportToAgressoNumber);
            move.setExportDate(interfaceDate);
            move.setAccountingOk(true);
            move.setMoveLineReport(mlr);
            move.save();
            BigDecimal totalDebit=BigDecimal.ZERO;
            for (            MoveLine moveLine : moveLines) {
              totalDebit=totalDebit.add(moveLine.getDebit());
            }
            String invoiceId="String_Node_Str";
            String dueDate="String_Node_Str";
            if (move.getInvoice() != null) {
              invoiceId=move.getInvoice().getInvoiceId();
              dueDate=move.getInvoice().getDueDate().toString();
            }
            MoveLine firstMoveLine=moveLines.get(0);
            String items[]=new String[12];
            items[0]=companyCode;
            items[1]=journalCode;
            items[2]=exportToAgressoNumber;
            items[3]=interfaceDate.toString("String_Node_Str");
            items[4]="String_Node_Str";
            items[5]=invoiceId;
            items[6]=dueDate;
            items[7]=firstMoveLine.getAccount().getCode();
            items[8]=totalDebit.toString();
            items[9]=reference;
            items[10]=dt.toString("String_Node_Str");
            items[11]=periodCode;
            allMoveData.add(items);
          }
        }
      }
    }
  }
  String fileName="String_Node_Str" + todayTime.toString("String_Node_Str") + "String_Node_Str";
  String filePath=this.getFilePath(mlr);
  new File(filePath).mkdirs();
  LOG.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',null,allMoveData);
}

Fixed version (ground truth):
/** 
 * Méthode réalisant l'export SI - Agresso des en-têtes pour les journaux de type achat
 * @param mlr
 * @param replay
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") @Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect9FILE1(MoveLineReport mlr,boolean replay) throws AxelorException, IOException {
  LOG.info("String_Node_Str");
  String dateQueryStr="String_Node_Str" + String.format("String_Node_Str",mlr.getCompany().getId());
  JournalType journalType=mlrs.getJournalType(mlr);
  if (mlr.getJournal() != null) {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",mlr.getJournal().getId());
  }
 else {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",journalType.getId());
  }
  if (mlr.getPeriod() != null) {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",mlr.getPeriod().getId());
  }
  if (replay) {
    dateQueryStr+="String_Node_Str" + String.format("String_Node_Str",mlr.getId());
  }
 else {
    dateQueryStr+="String_Node_Str";
  }
  dateQueryStr+="String_Node_Str";
  Query dateQuery=JPA.em().createQuery("String_Node_Str" + dateQueryStr + "String_Node_Str");
  List<LocalDate> allDates=new ArrayList<LocalDate>();
  allDates=dateQuery.getResultList();
  LOG.debug("String_Node_Str",allDates);
  List<String[]> allMoveData=new ArrayList<String[]>();
  String companyCode="String_Node_Str";
  String reference="String_Node_Str";
  String moveQueryStr="String_Node_Str";
  String moveLineQueryStr="String_Node_Str";
  if (mlr.getRef() != null) {
    reference=mlr.getRef();
  }
  if (mlr.getCompany() != null) {
    companyCode=mlr.getCompany().getCode();
    moveQueryStr+="String_Node_Str";
    moveQueryStr+=String.format("String_Node_Str",mlr.getCompany().getId());
  }
  if (mlr.getPeriod() != null) {
    moveQueryStr+="String_Node_Str";
    moveQueryStr+=String.format("String_Node_Str",mlr.getPeriod().getId());
  }
  if (mlr.getDateFrom() != null) {
    moveLineQueryStr+="String_Node_Str";
    moveLineQueryStr+=String.format("String_Node_Str",mlr.getDateFrom().toString());
  }
  if (mlr.getDateTo() != null) {
    moveLineQueryStr+="String_Node_Str";
    moveLineQueryStr+=String.format("String_Node_Str",mlr.getDateTo().toString());
  }
  if (mlr.getDate() != null) {
    moveLineQueryStr+="String_Node_Str";
    moveLineQueryStr+=String.format("String_Node_Str",mlr.getDate().toString());
  }
  if (replay) {
    moveQueryStr+="String_Node_Str";
    moveQueryStr+=String.format("String_Node_Str",mlr.getId());
  }
 else {
    moveQueryStr+="String_Node_Str";
  }
  LocalDate interfaceDate=mlr.getDate();
  for (  LocalDate dt : allDates) {
    List<Journal> journalList=Journal.all().filter("String_Node_Str",journalType).fetch();
    if (mlr.getJournal() != null) {
      journalList=new ArrayList<Journal>();
      journalList.add(mlr.getJournal());
    }
    for (    Journal journal : journalList) {
      List<Move> moves=Move.all().filter("String_Node_Str" + moveQueryStr,dt,journal).fetch();
      String journalCode=journal.getExportCode();
      if (moves.size() > 0) {
        for (        Move move : moves) {
          List<MoveLine> moveLines=MoveLine.all().filter("String_Node_Str" + "String_Node_Str" + moveLineQueryStr,moves).fetch();
          LOG.debug("String_Node_Str",moveLines);
          if (moveLines.size() > 0) {
            String exportNumber=sgs.getSequence(IAdministration.PURCHASE_INTERFACE,mlr.getCompany(),false);
            if (exportNumber == null) {
              throw new AxelorException(String.format("String_Node_Str",GeneralService.getExceptionAccountingMsg(),mlr.getCompany().getName()),IException.CONFIGURATION_ERROR);
            }
            String periodCode=move.getPeriod().getFromDate().toString("String_Node_Str");
            move.setExportNumber(exportNumber);
            move.setExportDate(interfaceDate);
            move.setAccountingOk(true);
            move.setMoveLineReport(mlr);
            move.save();
            BigDecimal totalDebit=BigDecimal.ZERO;
            for (            MoveLine moveLine : moveLines) {
              totalDebit=totalDebit.add(moveLine.getDebit());
            }
            String invoiceId="String_Node_Str";
            String dueDate="String_Node_Str";
            if (move.getInvoice() != null) {
              invoiceId=move.getInvoice().getInvoiceId();
              dueDate=move.getInvoice().getDueDate().toString();
            }
            MoveLine firstMoveLine=moveLines.get(0);
            String items[]=new String[12];
            items[0]=companyCode;
            items[1]=journalCode;
            items[2]=exportNumber;
            items[3]=interfaceDate.toString("String_Node_Str");
            items[4]="String_Node_Str";
            items[5]=invoiceId;
            items[6]=dueDate;
            items[7]=firstMoveLine.getAccount().getCode();
            items[8]=totalDebit.toString();
            items[9]=reference;
            items[10]=dt.toString("String_Node_Str");
            items[11]=periodCode;
            allMoveData.add(items);
          }
        }
      }
    }
  }
  String fileName="String_Node_Str" + todayTime.toString("String_Node_Str") + "String_Node_Str";
  String filePath=this.getFilePath(mlr);
  new File(filePath).mkdirs();
  LOG.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',null,allMoveData);
}