Program: 59155
Project: 59155
Buggy source:
/** 
 * Méthode réalisant l'export SI - Agresso des en-têtes pour les journaux de type vente
 * @param mlr
 * @param replay
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") @Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect6FILE1(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) {
        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.SALES_INTERFACE,mlr.getCompany(),false);
          if (exportToAgressoNumber == null) {
            throw new AxelorException(String.format("String_Node_Str",GeneralService.getExceptionAccountingMsg(),mlr.getCompany().getName()),IException.CONFIGURATION_ERROR);
          }
          Move firstMove=moves.get(0);
          String periodCode=firstMove.getPeriod().getFromDate().toString("String_Node_Str");
          for (          Move move : moves) {
            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 items[]=new String[8];
          items[0]=companyCode;
          items[1]=journalCode;
          items[2]=exportToAgressoNumber;
          items[3]=interfaceDate.toString("String_Node_Str");
          items[4]=totalDebit.toString();
          items[5]=reference;
          items[6]=dt.toString("String_Node_Str");
          items[7]=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 vente
 * @param mlr
 * @param replay
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") @Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect6FILE1(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) {
        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.SALES_INTERFACE,mlr.getCompany(),false);
          if (exportNumber == null) {
            throw new AxelorException(String.format("String_Node_Str",GeneralService.getExceptionAccountingMsg(),mlr.getCompany().getName()),IException.CONFIGURATION_ERROR);
          }
          Move firstMove=moves.get(0);
          String periodCode=firstMove.getPeriod().getFromDate().toString("String_Node_Str");
          for (          Move move : moves) {
            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 items[]=new String[8];
          items[0]=companyCode;
          items[1]=journalCode;
          items[2]=exportNumber;
          items[3]=interfaceDate.toString("String_Node_Str");
          items[4]=totalDebit.toString();
          items[5]=reference;
          items[6]=dt.toString("String_Node_Str");
          items[7]=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);
}