org.kapott.hbci.GV.parsers.ParsePain00800102 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hbci4j-adorsys Show documentation
Show all versions of hbci4j-adorsys Show documentation
HBCI4j - Home Banking Computer Interface for Java - Clone from https://github.com/hbci4j/hbci4java
package org.kapott.hbci.GV.parsers;
import org.kapott.hbci.GV.SepaUtil;
import org.kapott.hbci.sepa.jaxb.pain_008_001_02.*;
import javax.xml.bind.JAXB;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
/**
* Parser-Implementierung fuer Pain 008.001.02.
*/
public class ParsePain00800102 extends AbstractSepaParser>> {
/**
* @see org.kapott.hbci.GV.parsers.ISEPAParser#parse(InputStream, Object)
*/
public void parse(InputStream xml, List> sepaResults) {
Document doc = JAXB.unmarshal(xml, Document.class);
CustomerDirectDebitInitiationV02 pain = doc.getCstmrDrctDbtInitn();
if (pain == null)
return;
List pmtInfs = pain.getPmtInf();
for (PaymentInstructionInformationSDD pmtInf : pmtInfs) {
List txList = pmtInf.getDrctDbtTxInf();
for (DirectDebitTransactionInformationSDD tx : txList) {
HashMap prop = new HashMap();
put(prop, Names.PMTINFID, pmtInf.getPmtInfId());
put(prop, Names.SRC_NAME, pain.getGrpHdr().getInitgPty().getNm());
put(prop, Names.SRC_IBAN, pmtInf.getCdtrAcct().getId().getIBAN());
put(prop, Names.SRC_BIC, pmtInf.getCdtrAgt().getFinInstnId().getBIC());
put(prop, Names.DST_NAME, tx.getDbtr().getNm());
put(prop, Names.DST_IBAN, tx.getDbtrAcct().getId().getIBAN());
try {
put(prop, Names.DST_BIC, tx.getDbtrAgt().getFinInstnId().getBIC());
} catch (Exception e) {
// BIC darf fehlen
}
ActiveOrHistoricCurrencyAndAmountSEPA amt = tx.getInstdAmt();
put(prop, Names.VALUE, SepaUtil.format(amt.getValue()));
put(prop, Names.CURR, amt.getCcy().value());
if (tx.getRmtInf() != null) {
put(prop, Names.USAGE, tx.getRmtInf().getUstrd());
}
PurposeSEPA purp = tx.getPurp();
if (purp != null)
put(prop, Names.PURPOSECODE, purp.getCd());
XMLGregorianCalendar date = pmtInf.getReqdColltnDt();
if (date != null) {
put(prop, Names.TARGETDATE, SepaUtil.format(date, null));
}
put(prop, Names.ENDTOENDID, tx.getPmtId().getEndToEndId());
try {
// Auf Auftragsebene suchen
put(prop, Names.CREDITORID,
tx.getDrctDbtTx().getCdtrSchmeId().getId().getPrvtId().getOthr().getId());
} catch (Exception e) {
// Auf Header-Ebene suchen
put(prop, Names.CREDITORID, pmtInf.getCdtrSchmeId().getId().getPrvtId().getOthr().getId());
}
put(prop, Names.MANDATEID, tx.getDrctDbtTx().getMndtRltdInf().getMndtId());
XMLGregorianCalendar mandDate = tx.getDrctDbtTx().getMndtRltdInf().getDtOfSgntr();
if (mandDate != null) {
put(prop, Names.MANDDATEOFSIG, SepaUtil.format(mandDate, null));
}
put(prop, Names.SEQUENCETYPE, pmtInf.getPmtTpInf().getSeqTp().value());
put(prop, Names.LAST_TYPE, pmtInf.getPmtTpInf().getLclInstrm().getCd());
sepaResults.add(prop);
}
}
}
}