updated ZUGFeRD reader/importer to be ZF2 compatible, added possibility to explicitly export to ZF1 in ZUGFeRDExporter
This commit is contained in:
@@ -60,9 +60,19 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
public void setVersion(int ver) {
|
||||
if (ver==1) {
|
||||
ZUGFeRD1PullProvider z1p =new ZUGFeRD1PullProvider();
|
||||
this.xmlProvider=z1p;
|
||||
|
||||
} else {
|
||||
ZUGFeRD2PullProvider z2p =new ZUGFeRD2PullProvider();
|
||||
this.xmlProvider=z2p;
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setVersion(2);
|
||||
}
|
||||
// // MAIN CLASS
|
||||
@Deprecated
|
||||
|
||||
@@ -182,8 +182,12 @@ public class ZUGFeRDImporter {
|
||||
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
|
||||
*/
|
||||
ndList = document.getElementsByTagNameNS("*","PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","PayeePartyCICreditorFinancialAccount"); //ZF2
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*","PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
||||
}
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
|
||||
@@ -204,8 +208,11 @@ public class ZUGFeRDImporter {
|
||||
|
||||
}
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCreditorFinancialInstitution"); //$NON-NLS-1$
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCICreditorFinancialInstitution");//ZF2 //$NON-NLS-1$
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCreditorFinancialInstitution");//ZF1 //$NON-NLS-1$
|
||||
}
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
@@ -225,8 +232,12 @@ public class ZUGFeRDImporter {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","SellerCITradeParty"); //ZF2
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*","SellerTradeParty"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
@@ -423,6 +434,6 @@ public class ZUGFeRDImporter {
|
||||
|
||||
//SpecifiedExchangedDocumentContext is in the schema, so a relatively good indication if zugferd is present - better than just invoice
|
||||
String meta=getMeta();
|
||||
return (meta!=null)&&( meta.length()>0)&&( meta.contains("SpecifiedExchangedDocumentContext")); //$NON-NLS-1$
|
||||
return (meta!=null)&&( meta.length()>0)&&(( meta.contains("SpecifiedExchangedDocumentContext")/*ZF1*/||meta.contains("CIExchangedDocumentContext"))); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp
|
||||
.setCreator(System.getProperty("user.name"))
|
||||
.ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
|
||||
ze.setVersion(1);
|
||||
ze.PDFattachZugferdFile(this);
|
||||
ze.export(TARGET_PDF);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user