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 GroupHeaderSCT());
String batch = SepaUtil.getProperty(sepaParams,"batchbook",null);
if (batch != null)
doc.getPain00100102().getGrpHdr().setBtchBookg(batch.equals("1"));
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(Grouping1CodeSCT.MIXD);
doc.getPain00100102().getGrpHdr().setInitgPty(new PartyIdentificationSCT1());
doc.getPain00100102().getGrpHdr().getInitgPty().setNm(sepaParams.getProperty("src.name"));
//Payment Information
ArrayList<PaymentInstructionInformationSCT> pmtInfs = (ArrayList<PaymentInstructionInformationSCT>) doc.getPain00100102().getPmtInf();
PaymentInstructionInformationSCT pmtInf = new PaymentInstructionInformationSCT();
pmtInfs.add(pmtInf);
pmtInf.setPmtInfId(pmtInfId != null && pmtInfId.length() > 0 ? pmtInfId : sepaId);
pmtInf.setPmtMtd(PaymentMethodSCTCode.TRF);