Program: 58623
Project: 58623
Buggy source:
/** 
 * Method to create an XML file for SEPA transfer pain.001.001.03
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws JAXBException
 * @throws IOException
 */
@Override public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
  DatatypeFactory datatypeFactory=DatatypeFactory.newInstance();
  ObjectFactory factory=new ObjectFactory();
  ServiceLevel8Choice svcLvl=factory.createServiceLevel8Choice();
  svcLvl.setCd("String_Node_Str");
  PaymentTypeInformation19 pmtTpInf=factory.createPaymentTypeInformation19();
  pmtTpInf.setSvcLvl(svcLvl);
  PartyIdentification32 dbtr=factory.createPartyIdentification32();
  dbtr.setNm(senderBankDetails.getOwnerName());
  AccountIdentification4Choice iban=factory.createAccountIdentification4Choice();
  iban.setIBAN(senderBankDetails.getIban());
  CashAccount16 dbtrAcct=factory.createCashAccount16();
  dbtrAcct.setId(iban);
  FinancialInstitutionIdentification7 finInstnId=factory.createFinancialInstitutionIdentification7();
  finInstnId.setBIC(senderBankDetails.getBank().getCode());
  BranchAndFinancialInstitutionIdentification4 dbtrAgt=factory.createBranchAndFinancialInstitutionIdentification4();
  dbtrAgt.setFinInstnId(finInstnId);
  PaymentInstructionInformation3 pmtInf=factory.createPaymentInstructionInformation3();
  pmtInf.setPmtInfId(bankOrderSeq);
  pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
  pmtInf.setPmtTpInf(pmtTpInf);
  pmtInf.setReqdExctnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.toString("String_Node_Str")));
  pmtInf.setDbtr(dbtr);
  pmtInf.setDbtrAcct(dbtrAcct);
  pmtInf.setDbtrAgt(dbtrAgt);
  CreditTransferTransactionInformation10 cdtTrfTxInf=null;
  PaymentIdentification1 pmtId=null;
  AmountType3Choice amt=null;
  ActiveOrHistoricCurrencyAndAmount instdAmt=null;
  PartyIdentification32 cbtr=null;
  CashAccount16 cbtrAcct=null;
  BranchAndFinancialInstitutionIdentification4 cbtrAgt=null;
  RemittanceInformation5 rmtInf=null;
  for (  BankOrderLine bankOrderLine : bankOrderLineList) {
    BankDetails receiverBankDetails=bankOrderLine.getReceiverBankDetails();
    pmtId=factory.createPaymentIdentification1();
    pmtId.setEndToEndId(bankOrderLine.getSequence());
    instdAmt=factory.createActiveOrHistoricCurrencyAndAmount();
    instdAmt.setCcy(bankOrderCurrency.getCode());
    instdAmt.setValue(bankOrderLine.getBankOrderAmount());
    amt=factory.createAmountType3Choice();
    amt.setInstdAmt(instdAmt);
    cbtr=factory.createPartyIdentification32();
    cbtr.setNm(receiverBankDetails.getOwnerName());
    iban=factory.createAccountIdentification4Choice();
    iban.setIBAN(receiverBankDetails.getIban());
    cbtrAcct=factory.createCashAccount16();
    cbtrAcct.setId(iban);
    finInstnId=factory.createFinancialInstitutionIdentification7();
    finInstnId.setBIC(receiverBankDetails.getBank().getCode());
    cbtrAgt=factory.createBranchAndFinancialInstitutionIdentification4();
    cbtrAgt.setFinInstnId(finInstnId);
    rmtInf=factory.createRemittanceInformation5();
    String ustrd="String_Node_Str";
    if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverReference())) {
      ustrd+=bankOrderLine.getReceiverReference();
    }
    if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverLabel())) {
      if (!Strings.isNullOrEmpty(ustrd)) {
        ustrd+="String_Node_Str";
      }
      ustrd+=bankOrderLine.getReceiverLabel();
    }
    rmtInf.getUstrd().add(ustrd);
    cdtTrfTxInf=factory.createCreditTransferTransactionInformation10();
    cdtTrfTxInf.setPmtId(pmtId);
    cdtTrfTxInf.setAmt(amt);
    cdtTrfTxInf.setCdtr(cbtr);
    cdtTrfTxInf.setCdtrAcct(cbtrAcct);
    cdtTrfTxInf.setCdtrAgt(cbtrAgt);
    cdtTrfTxInf.setRmtInf(rmtInf);
    pmtInf.getCdtTrfTxInf().add(cdtTrfTxInf);
  }
  GroupHeader32 grpHdr=factory.createGroupHeader32();
  grpHdr.setMsgId(bankOrderSeq);
  grpHdr.setCreDtTm(datatypeFactory.newXMLGregorianCalendar(generationDateTime.toString("String_Node_Str")));
  grpHdr.setNbOfTxs(Integer.toString(nbOfLines));
  grpHdr.setCtrlSum(arithmeticTotal);
  grpHdr.setInitgPty(dbtr);
  CustomerCreditTransferInitiationV03 customerCreditTransferInitiationV03=factory.createCustomerCreditTransferInitiationV03();
  customerCreditTransferInitiationV03.setGrpHdr(grpHdr);
  customerCreditTransferInitiationV03.getPmtInf().add(pmtInf);
  Document xml=factory.createDocument();
  xml.setCstmrCdtTrfInitn(customerCreditTransferInitiationV03);
  fileToCreate=factory.createDocument(xml);
  return super.generateFile();
}

Fixed version (ground truth):
/** 
 * Method to create an XML file for SEPA transfer pain.001.001.03
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws JAXBException
 * @throws IOException
 */
@Override public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
  DatatypeFactory datatypeFactory=DatatypeFactory.newInstance();
  ObjectFactory factory=new ObjectFactory();
  ServiceLevel8Choice svcLvl=factory.createServiceLevel8Choice();
  svcLvl.setCd("String_Node_Str");
  PaymentTypeInformation19 pmtTpInf=factory.createPaymentTypeInformation19();
  pmtTpInf.setSvcLvl(svcLvl);
  PartyIdentification32 dbtr=factory.createPartyIdentification32();
  dbtr.setNm(senderBankDetails.getOwnerName());
  AccountIdentification4Choice iban=factory.createAccountIdentification4Choice();
  iban.setIBAN(senderBankDetails.getIban());
  CashAccount16 dbtrAcct=factory.createCashAccount16();
  dbtrAcct.setId(iban);
  FinancialInstitutionIdentification7 finInstnId=factory.createFinancialInstitutionIdentification7();
  finInstnId.setBIC(senderBankDetails.getBank().getCode());
  BranchAndFinancialInstitutionIdentification4 dbtrAgt=factory.createBranchAndFinancialInstitutionIdentification4();
  dbtrAgt.setFinInstnId(finInstnId);
  PaymentInstructionInformation3 pmtInf=factory.createPaymentInstructionInformation3();
  pmtInf.setPmtInfId(bankOrderSeq);
  pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
  pmtInf.setPmtTpInf(pmtTpInf);
  pmtInf.setReqdExctnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.toString("String_Node_Str")));
  pmtInf.setDbtr(dbtr);
  pmtInf.setDbtrAcct(dbtrAcct);
  pmtInf.setDbtrAgt(dbtrAgt);
  CreditTransferTransactionInformation10 cdtTrfTxInf=null;
  PaymentIdentification1 pmtId=null;
  AmountType3Choice amt=null;
  ActiveOrHistoricCurrencyAndAmount instdAmt=null;
  PartyIdentification32 cbtr=null;
  CashAccount16 cbtrAcct=null;
  BranchAndFinancialInstitutionIdentification4 cbtrAgt=null;
  RemittanceInformation5 rmtInf=null;
  for (  BankOrderLine bankOrderLine : bankOrderLineList) {
    BankDetails receiverBankDetails=bankOrderLine.getReceiverBankDetails();
    pmtId=factory.createPaymentIdentification1();
    pmtId.setEndToEndId(bankOrderLine.getSequence());
    instdAmt=factory.createActiveOrHistoricCurrencyAndAmount();
    instdAmt.setCcy(bankOrderCurrency.getCode());
    instdAmt.setValue(bankOrderLine.getBankOrderAmount());
    amt=factory.createAmountType3Choice();
    amt.setInstdAmt(instdAmt);
    cbtr=factory.createPartyIdentification32();
    cbtr.setNm(receiverBankDetails.getOwnerName());
    iban=factory.createAccountIdentification4Choice();
    iban.setIBAN(receiverBankDetails.getIban());
    cbtrAcct=factory.createCashAccount16();
    cbtrAcct.setId(iban);
    finInstnId=factory.createFinancialInstitutionIdentification7();
    finInstnId.setBIC(receiverBankDetails.getBank().getCode());
    cbtrAgt=factory.createBranchAndFinancialInstitutionIdentification4();
    cbtrAgt.setFinInstnId(finInstnId);
    rmtInf=factory.createRemittanceInformation5();
    String ustrd="String_Node_Str";
    if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverReference())) {
      ustrd+=bankOrderLine.getReceiverReference();
    }
    if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverLabel())) {
      if (!Strings.isNullOrEmpty(ustrd)) {
        ustrd+="String_Node_Str";
      }
      ustrd+=bankOrderLine.getReceiverLabel();
    }
    if (!Strings.isNullOrEmpty(ustrd)) {
      rmtInf.getUstrd().add(ustrd);
    }
    cdtTrfTxInf=factory.createCreditTransferTransactionInformation10();
    cdtTrfTxInf.setPmtId(pmtId);
    cdtTrfTxInf.setAmt(amt);
    cdtTrfTxInf.setCdtr(cbtr);
    cdtTrfTxInf.setCdtrAcct(cbtrAcct);
    cdtTrfTxInf.setCdtrAgt(cbtrAgt);
    cdtTrfTxInf.setRmtInf(rmtInf);
    pmtInf.getCdtTrfTxInf().add(cdtTrfTxInf);
  }
  GroupHeader32 grpHdr=factory.createGroupHeader32();
  grpHdr.setMsgId(bankOrderSeq);
  grpHdr.setCreDtTm(datatypeFactory.newXMLGregorianCalendar(generationDateTime.toString("String_Node_Str")));
  grpHdr.setNbOfTxs(Integer.toString(nbOfLines));
  grpHdr.setCtrlSum(arithmeticTotal);
  grpHdr.setInitgPty(dbtr);
  CustomerCreditTransferInitiationV03 customerCreditTransferInitiationV03=factory.createCustomerCreditTransferInitiationV03();
  customerCreditTransferInitiationV03.setGrpHdr(grpHdr);
  customerCreditTransferInitiationV03.getPmtInf().add(pmtInf);
  Document xml=factory.createDocument();
  xml.setCstmrCdtTrfInitn(customerCreditTransferInitiationV03);
  fileToCreate=factory.createDocument(xml);
  return super.generateFile();
}