Git Product home page Git Product logo

jsepa's Introduction

jSEPA

This project is currently under maintenance, since the XSD versions are outdated. Further informations regarding this process can be found in the jSEPA 2.0 milestone


A java library to create valid PAIN.008.001.02 (v3.1) SEPA direct debit and PAIN.001.003.03 SEPA transfer XML documents using CORE and pain.001.003.03 SEPA transfer XML documents.

Both types of documents as created by the internal unit tests have been validated with Star Finanz SEPA XML Checker.

Includes IBAN validation by apache commons and a regular expression based validation for BICs. Strings are sanitized according to SEPA rules.

There is no national bank database lookup for IBAN and BIC validation, as that caused more harm than good in the past.

Provides IBAN/BIC based bank information lookup for german banks using data provided by the Bundesbank. This also enables IBAN to BIC conversation.

License

The MIT License

Copyright 2021 Jelmen Guhlke .

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Usage

Bank data information lookup

This is currently only implemented for german banks with data from the Bundesbank.

Get BIC from IBAN:

String bic = BankInformationStore.forIban(iban).getBic();

Get bank name from country and bank code:

String bankName = BankInformationStore.forBankCode("de", bankCode).getBic();

The bank information store throws an IllegalArgumentException if non german country codes/IBANs are used.

Creation of pain.008.001.02 direct debit xml documents

Here is a short mainly undocumented code example on how to use this. InvoiceBatch and Invoice classes are not included in jSEPA but the intention should be clear. More detailed documentation is comming soon.

public String createSepaXml(InvoiceBatch batch) {
    try {
        DirectDebitDocumentData ddd = initDirectDebitDocument(batch);

        for (Invoice i : batch.getInvoices()) {
            addInvoiceToDirectDebitDocument(ddd, i);
        }

        return ddd.toXml();
    } catch (SepaValidationException | DatatypeConfigurationException e) {
        response.sendError(500, e.getMessage());
        LOG.log(Level.SEVERE, "Could not create SEPA document", e);
    }
}

private DirectDebitDocumentData initDirectDebitDocument(InvoiceBatch batch) throws SepaValidationException {
    DirectDebitDocumentData result = new DirectDebitDocument();

    BankData payeeBankData = batch.getPayee().getInvoicingData().getBankData();
    result.setDocumentMessageId(batch.getId().toString());
    result.setCreditorBic(payeeBankData.getBic());
    result.setCreditorIban(payeeBankData.getIban());
    result.setCreditorName(payee.getName());
    result.setCreditorIdentifier(payee.getInvoicingData().getCreditorIdentifier());

    return result;
}

private void addInvoiceToDirectDebitDocument(DirectDebitDocumentData ddd, Invoice i) throws SepaValidationException {
    DirectDebitPayment result = new DirectDebitPayment();
    BankData bd = i.getRecipientBankData();
    result.setPaymentSum(i.getAfterTaxTotal());
    result.setDebitorBic(bd.getBic());
    result.setDebitorIban(bd.getIban());
    DirectDebitAuthorization dda = i.getDirectDebitAuthorization();
    result.setMandateDate(dda.getAuthorizedOn());
    result.setMandateId(dda.getAuthorizationReferenceIdentifier());
    result.setDebitorName(i.getRecipientName());
    // german "ueberweisungszweck"
    result.setReasonForPayment(sanitizeCharacters(i.getLocalizedTypeName() + " " + i.getInvoiceNumber()));

    if (!i.getDirectDebitAuthorization().isRecurrent()) {
        result.setMandateType(MandateType.ONE_OFF);
    } else if (i.isFirstUsageOfDirectDebitAuthorization()) {
        result.setMandateType(MandateType.RECURRENT_FIRST);
    } else {
        result.setMandateType(MandateType.RECURRENT);
    }

    result.setDirectDebitDueDate(i.getDirectDebitDueDate());

    ddd.addPayment(result);
}

Creation of pain.001.003.03 bank transfer xml documents

Works similar to direct debit documents using the SepaTransferDocumentBuilder.

Compiling

Just checkout the repository and run mvn clean install. A .jar file will be created in the target/ directory.

The maven build script automatically downloads a text file from the Bundesbank containing bank information data to enable IBAN to BIC transformation. The file will only be downloaded when it is missing or older than a week.

Credits

This library was originally written by Robert Becker and is now maintained by Jelmen Guhlke.

jsepa's People

Contributors

roben avatar jelmenguhlke avatar mherwig avatar dependabot[bot] avatar

Stargazers

Thorge Wandrei avatar  avatar Enrique Cardona avatar Hauke Kern avatar Niklas Reimer avatar DOCESTATE avatar Justinas Gulbinas avatar Tobin Rosenau avatar Enrico Succhielli avatar farouk.alhassan avatar  avatar Moritz Reiter avatar Emre Can Geçer avatar Moritz Riebe avatar Martin Prebio avatar Philip Miglinci avatar Moisés avatar Francisco Cascales avatar Victor Poerba avatar

Watchers

Martin Prebio avatar  avatar Emre Can Geçer avatar  avatar Moisés avatar Moritz Riebe avatar  avatar  avatar Domenico Lalla avatar

jsepa's Issues

Update `BankDataFileUpdater`

Current Issue

When running the BankDataFileUpdater a HTTP 403 response code is fired and no bank data file is downloaded.

Expected Behavior

Running the BankDataFileUpdater should fetch a fresh band data file for the German banks.

A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.3:xjc: com/sun/codemodel/CodeWriter

I cloned the repository and tried running mvn clean install, but I'm getting this error.
Already tried deleting .m2 apache repository.

[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.3:xjc (xjc-eu.rbecker.jsepa.directdebit.xml.schema.pain_008_001_02) on project jSepa: Execution xjc-eu.rbecker.jsepa.directdebit.xml.schema.pain_008_001_02 of goal org.codehaus.mojo:jaxb2-maven-plugin:2.3:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.3:xjc: com/sun/codemodel/CodeWriter
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:jaxb2-maven-plugin:2.3
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/Michal-aardwark/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/2.3/jaxb2-maven-plugin-2.3.jar
[ERROR] urls[1] = file:/C:/Users/Michal-aardwark/.m2/repository/javax/xml/bind/jaxb-api/2.2.11/jaxb-api-2.2.11.jar
[ERROR] urls[2] = file:/C:/Users/Michal-aardwark/.m2/repository/org/glassfish/jaxb/jaxb-core/2.2.11/jaxb-core-2.2.11.jar
[ERROR] urls[3] = file:/C:/Users/Michal-aardwark/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
[ERROR] urls[4] = file:/C:/Users/Michal-aardwark/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
[ERROR] urls[5] = file:/C:/Users/Michal-aardwark/.m2/repository/org/glassfish/jaxb/jaxb-jxc/2.2.11/jaxb-jxc-2.2.11.jar
[ERROR] urls[6] = file:/C:/Users/Michal-aardwark/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M3/qdox-2.0-M3.jar
[ERROR] urls[7] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
[ERROR] urls[8] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[9] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
[ERROR] urls[10] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar
[ERROR] urls[11] = file:/C:/Users/Michal-aardwark/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[12] = file:/C:/Users/Michal-aardwark/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[13] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[14] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[15] = file:/C:/Users/Michal-aardwark/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.5/plexus-compiler-api-2.5.jar
[ERROR] urls[16] = file:/C:/Users/Michal-aardwark/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[17] = file:/C:/Users/Michal-aardwark/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: com.sun.codemodel.CodeWriter

Any advices?

Rename base package name

Currently the base package name contains the old eu.rbecker.jsepa domain, which is not valid anymore.

In order to give the project a new "home" the already reserved jsepa.io domain should be used as base package name.

Furthermore the groupId and artifactId in the pom.xml should be in lined with this as well

Update License File Header

The project is currently available under the MIT license.

We want to to keep it that way, but the license header in some files are outdated, missing or wrong.

This should be uniformed and also in line with the license from the Git repository

Using the Google Java Style Guide

To uniform the code style in the project, the well known and proven Google Java style guide should be used in the project.

It convinces with clean and simple rules and paradigms.

The doc can be found here.

There are XML documents for IntelliJ and Eclipse, which can be found here and imported.

The IntelliJ plugin is also easy to use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.