Updated ZUGFeRDImporter.java -> getDocumentCode() to fit ZUGFeRD 2.1

Added Test
This commit is contained in:
Alexander Berndt
2020-05-22 15:16:56 +02:00
parent 5d72156bf0
commit 0cde732e43
2 changed files with 15 additions and 2 deletions

View File

@@ -259,7 +259,16 @@ public class ZUGFeRDImporter {
* @return the document code
*/
public String getDocumentCode() {
return extractString("//HeaderExchangedDocument/TypeCode");
try {
if (getVersion() == 1) {
return extractString("//HeaderExchangedDocument/TypeCode");
} else {
return extractString("//ExchangedDocument/TypeCode");
}
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@@ -458,6 +467,10 @@ public class ZUGFeRDImporter {
return s.hasNext() ? s.next() : "";
}
/**
* returns an instance of PostalTradeAddress for SellerTradeParty section
* @return an instance of PostalTradeAddress
*/
public PostalTradeAddress getSellerTradePartyAddress() {
NodeList nl = null;

View File

@@ -207,7 +207,7 @@ public class ZF2Test extends MustangReaderTestCase {
// Reading ZUGFeRD
assertEquals(zi.getAmount(), "571.04");
assertEquals(zi.getHolder(), getOwnOrganisationName());
assertEquals(zi.getDocumentCode(),"380");
assertEquals(zi.getAmount(), "571.04");
assertEquals(zi.getBIC(), getTradeSettlementPayment()[0].getOwnBIC());
assertEquals(zi.getIBAN(),getTradeSettlementPayment()[0].getOwnIBAN());