ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
234 stars 132 forks source link

ZUGFeRDInvoiceImporter does not read BankDetails.accountName #558

Open dankito opened 1 week ago

dankito commented 1 week ago

I'm using current version 2.14.2.

In ZUGFeRDInvoiceImporter.java BankDetails.accountName does not get read (line 240 ff.):

    String IBAN = null, BIC = null;
    for (int paymentMeansChildIndex = 0; paymentMeansChildIndex < paymentMeansChilds.getLength(); paymentMeansChildIndex++) {
        if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialAccount"))) {
            NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
            for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) {
                if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("IBANID"))) {//CII
                    IBAN = accountChilds.item(accountChildIndex).getTextContent();
                }

                               // TODO: also read element AccountName
            }
        }
// ...

A fix would be:

    String IBAN = null, BIC = null, accountName = null;
    for (int paymentMeansChildIndex = 0; paymentMeansChildIndex < paymentMeansChilds.getLength(); paymentMeansChildIndex++) {
        if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialAccount"))) {
            NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
            for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) {
                if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("IBANID"))) {//CII
                    IBAN = accountChilds.item(accountChildIndex).getTextContent();
                }

                                // this has to be added, as well as `accountName = null` in first line
                if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("AccountName"))) {//CII
                    accountName = accountChilds.item(accountChildIndex).getTextContent();
                }
            }
        }

// ...

    if (IBAN != null) {
        BankDetails bd = new BankDetails(IBAN);
        if (BIC != null) {
            bd.setBIC(BIC);
        }
                bd.setAccountName(accountName); // also has to be added
        bankDetails.add(bd);
    }