public void generate(Properties sepaParams, OutputStream os, boolean validate) throws Exception
{
Integer maxIndex = SepaUtil.maxIndex(sepaParams);
//Document
Document doc = new Document();
//Pain00100102
doc.setPain00100102(new Pain00100102());
doc.getPain00100102().setGrpHdr(new GroupHeader20());
final String sepaId = sepaParams.getProperty("sepaid");
final String pmtInfId = sepaParams.getProperty("pmtinfid");
//Group Header
doc.getPain00100102().getGrpHdr().setMsgId(sepaId);
doc.getPain00100102().getGrpHdr().setCreDtTm(SepaUtil.createCalendar(null));
doc.getPain00100102().getGrpHdr().setNbOfTxs(String.valueOf(maxIndex != null ? maxIndex + 1 : 1));
doc.getPain00100102().getGrpHdr().setCtrlSum(SepaUtil.sumBtgValue(sepaParams, maxIndex));
doc.getPain00100102().getGrpHdr().setGrpg(Grouping2Code.GRPD);
doc.getPain00100102().getGrpHdr().setInitgPty(new PartyIdentification20());
doc.getPain00100102().getGrpHdr().getInitgPty().setNm(sepaParams.getProperty("src.name"));
//Payment Information
PaymentInstructionInformation4 pmtInf = new PaymentInstructionInformation4();
doc.getPain00100102().setPmtInf(pmtInf);
pmtInf.setPmtInfId(pmtInfId != null && pmtInfId.length() > 0 ? pmtInfId : sepaId);
pmtInf.setPmtMtd(PaymentMethod5Code.TRF);
// Payment Type Information