doc.getCstmrCdtTrfInitn().getGrpHdr().setCtrlSum(SepaUtil.sumBtgValue(sepaParams, maxIndex));
//Payment Information
ArrayList<PaymentInstructionInformationSCT> pmtInfs = (ArrayList<PaymentInstructionInformationSCT>) doc.getCstmrCdtTrfInitn().getPmtInf();
PaymentInstructionInformationSCT pmtInf = new PaymentInstructionInformationSCT();
pmtInfs.add(pmtInf);
pmtInf.setPmtInfId(pmtInfId != null && pmtInfId.length() > 0 ? pmtInfId : sepaId);
pmtInf.setPmtMtd(PaymentMethodSCTCode.TRF);
pmtInf.setNbOfTxs(String.valueOf(maxIndex != null ? maxIndex + 1 : 1));
pmtInf.setCtrlSum(SepaUtil.sumBtgValue(sepaParams, maxIndex));
// Payment Type Information
pmtInf.setPmtTpInf(new PaymentTypeInformationSCT1());
pmtInf.getPmtTpInf().setSvcLvl(new ServiceLevelSEPA());
pmtInf.getPmtTpInf().getSvcLvl().setCd(ServiceLevelSEPACode.SEPA);
String date = sepaParams.getProperty("date");
if(date == null) date = SepaUtil.DATE_UNDEFINED;
pmtInf.setReqdExctnDt(SepaUtil.createCalendar(date));
pmtInf.setDbtr(new PartyIdentificationSEPA2());
pmtInf.setDbtrAcct(new CashAccountSEPA1());
pmtInf.setDbtrAgt(new BranchAndFinancialInstitutionIdentificationSEPA1());
//Payment Information - Debtor
pmtInf.getDbtr().setNm(sepaParams.getProperty("src.name"));
//Payment Information - DebtorAccount
pmtInf.getDbtrAcct().setId(new AccountIdentificationSEPA());
pmtInf.getDbtrAcct().getId().setIBAN(sepaParams.getProperty("src.iban"));
//Payment Information - DebtorAgent
pmtInf.getDbtrAgt().setFinInstnId(new FinancialInstitutionIdentificationSEPA1());
pmtInf.getDbtrAgt().getFinInstnId().setBIC(sepaParams.getProperty("src.bic"));
//Payment Information - ChargeBearer
pmtInf.setChrgBr(ChargeBearerTypeSEPACode.SLEV);
//Payment Information - Credit Transfer Transaction Information
ArrayList<CreditTransferTransactionInformationSCT> cdtTrxTxInfs = (ArrayList<CreditTransferTransactionInformationSCT>) pmtInf.getCdtTrfTxInf();
if (maxIndex != null)
{
for (int tnr = 0; tnr <= maxIndex; tnr++)
{
cdtTrxTxInfs.add(createCreditTransferTransactionInformationSCT(sepaParams, tnr));
}
}
else
{
cdtTrxTxInfs.add(createCreditTransferTransactionInformationSCT(sepaParams, null));
}
String batch = SepaUtil.getProperty(sepaParams,"batchbook",null);
if (batch != null)
pmtInf.setBtchBookg(batch.equals("1"));
ObjectFactory of = new ObjectFactory();
this.marshal(of.createDocument(doc), os, validate);
}