1.1.0 in development, importer seems to work now w/ ZUGFeRD 1.0, added importer test, reset mustang-1.0.jar to original
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
||||||
<artifactId>mustang</artifactId>
|
<artifactId>mustang</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.1.0.alpha</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>mustang</name>
|
<name>mustang</name>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import org.w3c.dom.Node;
|
|||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
//root.setNamespace(Namespace.getNamespace("http://www.energystar.gov/manageBldgs/req"));
|
||||||
|
|
||||||
public class ZUGFeRDImporter {
|
public class ZUGFeRDImporter {
|
||||||
/*
|
/*
|
||||||
call extract(importFilename).
|
call extract(importFilename).
|
||||||
@@ -110,6 +112,7 @@ public class ZUGFeRDImporter {
|
|||||||
Document document = null;
|
Document document = null;
|
||||||
|
|
||||||
factory = DocumentBuilderFactory.newInstance();
|
factory = DocumentBuilderFactory.newInstance();
|
||||||
|
factory.setNamespaceAware(true); //otherwise we can not act namespace independend, i.e. use document.getElementsByTagNameNS("*",...
|
||||||
try {
|
try {
|
||||||
builder = factory.newDocumentBuilder();
|
builder = factory.newDocumentBuilder();
|
||||||
} catch (ParserConfigurationException ex3) {
|
} catch (ParserConfigurationException ex3) {
|
||||||
@@ -125,10 +128,13 @@ public class ZUGFeRDImporter {
|
|||||||
} catch (IOException ex2) {
|
} catch (IOException ex2) {
|
||||||
ex2.printStackTrace();
|
ex2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
NodeList ndList ;
|
||||||
|
|
||||||
// rootNode = document.getDocumentElement();
|
// rootNode = document.getDocumentElement();
|
||||||
// ApplicableSupplyChainTradeSettlement
|
// ApplicableSupplyChainTradeSettlement
|
||||||
NodeList ndList = document
|
ndList = document.getDocumentElement()
|
||||||
.getElementsByTagName("PaymentReference"); //$NON-NLS-1$
|
.getElementsByTagNameNS("*","PaymentReference"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
@@ -158,26 +164,38 @@ public class ZUGFeRDImporter {
|
|||||||
setIBAN(booking.getTextContent());
|
setIBAN(booking.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
<ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
<ram:IBANID>DE1234</ram:IBANID>
|
||||||
|
</ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||||
|
<ram:BICID>DE5656565</ram:BICID>
|
||||||
|
<ram:Name>Commerzbank</ram:Name>
|
||||||
|
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
ndList = document.getElementsByTagName("PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*","PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// there are many "name" elements, so get the one below
|
// there are many "name" elements, so get the one below
|
||||||
// SellerTradeParty
|
// SellerTradeParty
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
NodeList bookingDetails = booking.getChildNodes();
|
||||||
|
|
||||||
|
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||||
.getLength(); detailIndex++) {
|
.getLength(); detailIndex++) {
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if (detail.getNodeName().equals("IBANID")) { //$NON-NLS-1$
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
||||||
setIBAN(detail.getTextContent());
|
setIBAN(detail.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ndList = document.getElementsByTagName("PayeeSpecifiedCreditorFinancialInstitution"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCreditorFinancialInstitution"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
@@ -188,10 +206,10 @@ public class ZUGFeRDImporter {
|
|||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||||
.getLength(); detailIndex++) {
|
.getLength(); detailIndex++) {
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if (detail.getNodeName().equals("BICID")) { //$NON-NLS-1$
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
||||||
setBIC(detail.getTextContent());
|
setBIC(detail.getTextContent());
|
||||||
}
|
}
|
||||||
if (detail.getNodeName().equals("Name")) { //$NON-NLS-1$
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||||
setBankName(detail.getTextContent());
|
setBankName(detail.getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,7 +217,7 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ndList = document.getElementsByTagName("SellerTradeParty"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*","SellerTradeParty"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
@@ -210,14 +228,14 @@ public class ZUGFeRDImporter {
|
|||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||||
.getLength(); detailIndex++) {
|
.getLength(); detailIndex++) {
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if (detail.getNodeName().equals("Name")) { //$NON-NLS-1$
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||||
setHolder(detail.getTextContent());
|
setHolder(detail.getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ndList = document.getElementsByTagName("DuePayableAmount"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*","DuePayableAmount"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
@@ -233,7 +251,7 @@ public class ZUGFeRDImporter {
|
|||||||
/* there is apparently no requirement to mention DuePayableAmount,,
|
/* there is apparently no requirement to mention DuePayableAmount,,
|
||||||
* if it's not there, check for GrandTotalAmount
|
* if it's not there, check for GrandTotalAmount
|
||||||
*/
|
*/
|
||||||
ndList = document.getElementsByTagName("GrandTotalAmount"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*","GrandTotalAmount"); //$NON-NLS-1$
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
@@ -7,32 +9,54 @@ import junit.framework.TestSuite;
|
|||||||
/**
|
/**
|
||||||
* Unit test for simple App.
|
* Unit test for simple App.
|
||||||
*/
|
*/
|
||||||
public class AppTest
|
public class AppTest extends TestCase {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Create the test case
|
* Create the test case
|
||||||
*
|
*
|
||||||
* @param testName name of the test case
|
* @param testName
|
||||||
|
* name of the test case
|
||||||
*/
|
*/
|
||||||
public AppTest( String testName )
|
public AppTest(String testName) {
|
||||||
{
|
|
||||||
super(testName);
|
super(testName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the suite of tests being tested
|
* @return the suite of tests being tested
|
||||||
*/
|
*/
|
||||||
public static Test suite()
|
public static Test suite() {
|
||||||
{
|
|
||||||
return new TestSuite(AppTest.class);
|
return new TestSuite(AppTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rigourous Test :-)
|
* Rigourous Test :-)
|
||||||
*/
|
*/
|
||||||
public void testApp()
|
public void testImport() {
|
||||||
{
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
assertTrue( true );
|
zi.extract("./src/test/java/org/mustangproject/ZUGFeRD/RE-20140628_9.pdf");
|
||||||
|
// Reading ZUGFeRD
|
||||||
|
|
||||||
|
String amount=null;
|
||||||
|
String bic=null;
|
||||||
|
String iban=null;
|
||||||
|
String holder=null;
|
||||||
|
String ref=null;
|
||||||
|
|
||||||
|
if (zi.canParse()) {
|
||||||
|
zi.parse();
|
||||||
|
amount=zi.getAmount();
|
||||||
|
bic=zi.getBIC();
|
||||||
|
iban=zi.getIBAN();
|
||||||
|
holder=zi.getHolder();
|
||||||
|
ref=zi.getForeignReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(amount, "1.19");
|
||||||
|
assertEquals(bic, "DE5656565");
|
||||||
|
assertEquals(iban, "DE1234");
|
||||||
|
assertEquals(holder, "usegroup");
|
||||||
|
assertEquals(ref, "RE-20140628/9");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
BIN
mustang/target/mustang-1.1.0.alpha.jar
Normal file
BIN
mustang/target/mustang-1.1.0.alpha.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user