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();
|
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() {
|
private void init() {
|
||||||
ZUGFeRD1PullProvider z1p =new ZUGFeRD1PullProvider();
|
setVersion(2);
|
||||||
this.xmlProvider=z1p;
|
|
||||||
}
|
}
|
||||||
// // MAIN CLASS
|
// // MAIN CLASS
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -182,8 +182,12 @@ public class ZUGFeRDImporter {
|
|||||||
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
</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
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.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
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
@@ -225,8 +232,12 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
ndList = document.getElementsByTagNameNS("*","SellerTradeParty"); //$NON-NLS-1$
|
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
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.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
|
//SpecifiedExchangedDocumentContext is in the schema, so a relatively good indication if zugferd is present - better than just invoice
|
||||||
String meta=getMeta();
|
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"))
|
.setCreator(System.getProperty("user.name"))
|
||||||
.ignorePDFAErrors()
|
.ignorePDFAErrors()
|
||||||
.load(SOURCE_PDF)) {
|
.load(SOURCE_PDF)) {
|
||||||
|
ze.setVersion(1);
|
||||||
ze.PDFattachZugferdFile(this);
|
ze.PDFattachZugferdFile(this);
|
||||||
ze.export(TARGET_PDF);
|
ze.export(TARGET_PDF);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user