public void generate(Properties sepaParams, OutputStream os, boolean validate) throws Exception
{
Integer maxIndex = SepaUtil.maxIndex(sepaParams);
//Document
Document doc = new Document();
//Customer Credit Transfer Initiation
doc.setCstmrDrctDbtInitn(new CustomerDirectDebitInitiationV02());
doc.getCstmrDrctDbtInitn().setGrpHdr(new GroupHeaderSDD());
final String sepaId = sepaParams.getProperty("sepaid");
final String pmtInfId = sepaParams.getProperty("pmtinfid");
//Group Header
doc.getCstmrDrctDbtInitn().getGrpHdr().setMsgId(sepaId);
doc.getCstmrDrctDbtInitn().getGrpHdr().setCreDtTm(SepaUtil.createCalendar(null));
doc.getCstmrDrctDbtInitn().getGrpHdr().setNbOfTxs(String.valueOf(maxIndex != null ? maxIndex + 1 : 1));
doc.getCstmrDrctDbtInitn().getGrpHdr().setInitgPty(new PartyIdentificationSEPA1());
doc.getCstmrDrctDbtInitn().getGrpHdr().getInitgPty().setNm(sepaParams.getProperty("src.name"));
doc.getCstmrDrctDbtInitn().getGrpHdr().setCtrlSum(SepaUtil.sumBtgValue(sepaParams, maxIndex));
//Payment Information
ArrayList<PaymentInstructionInformationSDD> pmtInfs = (ArrayList<PaymentInstructionInformationSDD>) doc.getCstmrDrctDbtInitn().getPmtInf();
PaymentInstructionInformationSDD pmtInf = new PaymentInstructionInformationSDD();
pmtInfs.add(pmtInf);
pmtInf.setPmtInfId(pmtInfId != null && pmtInfId.length() > 0 ? pmtInfId : sepaId);
pmtInf.setPmtMtd(PaymentMethod2Code.DD);