centralizing some code
This commit is contained in:
@@ -214,4 +214,16 @@ public class XMLTools extends XMLWriter {
|
|||||||
return IOUtils.toByteArray (fileinput);
|
return IOUtils.toByteArray (fileinput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String trimOrNull(Node node) {
|
||||||
|
if (node != null) {
|
||||||
|
String textContent = node.getTextContent();
|
||||||
|
if (textContent != null) {
|
||||||
|
return textContent.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,24 +79,6 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
setInputStream(pdfStream);
|
setInputStream(pdfStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String trimOrNull(Node node) {
|
|
||||||
if (node != null) {
|
|
||||||
String textContent = node.getTextContent();
|
|
||||||
if (textContent != null) {
|
|
||||||
return textContent.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String convertStreamToString(java.io.InputStream is) {
|
|
||||||
try {
|
|
||||||
return IOUtils.toString(is, StandardCharsets.UTF_8);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new UncheckedIOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPDFFilename(String pdfFilename) {
|
public void setPDFFilename(String pdfFilename) {
|
||||||
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
|
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
|
||||||
extractLowLevel(bis);
|
extractLowLevel(bis);
|
||||||
@@ -151,7 +133,8 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final InputStream XMP = doc.getDocumentCatalog().getMetadata().exportXMPMetadata();
|
final InputStream XMP = doc.getDocumentCatalog().getMetadata().exportXMPMetadata();
|
||||||
xmpString = convertStreamToString(XMP);
|
|
||||||
|
xmpString = new String(XMLTools.getBytesFromStream(XMP), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
final PDEmbeddedFilesNameTreeNode etn = names.getEmbeddedFiles();
|
final PDEmbeddedFilesNameTreeNode etn = names.getEmbeddedFiles();
|
||||||
if (etn == null) {
|
if (etn == null) {
|
||||||
@@ -330,7 +313,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
BigDecimal expectedGrandTotal = null;
|
BigDecimal expectedGrandTotal = null;
|
||||||
NodeList totalNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList totalNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
if (totalNodes.getLength() > 0) {
|
if (totalNodes.getLength() > 0) {
|
||||||
expectedGrandTotal = new BigDecimal(trimOrNull(totalNodes.item(0)));
|
expectedGrandTotal = new BigDecimal(XMLTools.trimOrNull(totalNodes.item(0)));
|
||||||
if (zpp instanceof CalculatedInvoice) {
|
if (zpp instanceof CalculatedInvoice) {
|
||||||
// usually we would re-calculate the invoice to get expectedGrandTotal
|
// usually we would re-calculate the invoice to get expectedGrandTotal
|
||||||
// however, for "minimal" invoices or other invoices without lines
|
// however, for "minimal" invoices or other invoices without lines
|
||||||
@@ -342,7 +325,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
xpr = xpath.compile("//*[local-name()=\"PrepaidAmount\"]");
|
xpr = xpath.compile("//*[local-name()=\"PrepaidAmount\"]");
|
||||||
NodeList prepaidNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList prepaidNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
if (prepaidNodes.getLength() > 0) {
|
if (prepaidNodes.getLength() > 0) {
|
||||||
zpp.setTotalPrepaidAmount(new BigDecimal(trimOrNull(prepaidNodes.item(0))));
|
zpp.setTotalPrepaidAmount(new BigDecimal(XMLTools.trimOrNull(prepaidNodes.item(0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Date issueDate = null;
|
Date issueDate = null;
|
||||||
@@ -355,17 +338,17 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
for (int documentChildIndex = 0; documentChildIndex < exchangedDocumentChilds.getLength(); documentChildIndex++) {
|
for (int documentChildIndex = 0; documentChildIndex < exchangedDocumentChilds.getLength(); documentChildIndex++) {
|
||||||
Node item = exchangedDocumentChilds.item(documentChildIndex);
|
Node item = exchangedDocumentChilds.item(documentChildIndex);
|
||||||
if ((item.getLocalName() != null) && (item.getLocalName().equals("ID"))) {
|
if ((item.getLocalName() != null) && (item.getLocalName().equals("ID"))) {
|
||||||
number = trimOrNull(item);
|
number = XMLTools.trimOrNull(item);
|
||||||
}
|
}
|
||||||
if ((item.getLocalName() != null) && (item.getLocalName().equals("TypeCode"))) {
|
if ((item.getLocalName() != null) && (item.getLocalName().equals("TypeCode"))) {
|
||||||
typeCode = trimOrNull(item);
|
typeCode = XMLTools.trimOrNull(item);
|
||||||
}
|
}
|
||||||
if ((item.getLocalName() != null) && (item.getLocalName().equals("IssueDateTime"))) {
|
if ((item.getLocalName() != null) && (item.getLocalName().equals("IssueDateTime"))) {
|
||||||
NodeList issueDateTimeChilds = item.getChildNodes();
|
NodeList issueDateTimeChilds = item.getChildNodes();
|
||||||
for (int issueDateChildIndex = 0; issueDateChildIndex < issueDateTimeChilds.getLength(); issueDateChildIndex++) {
|
for (int issueDateChildIndex = 0; issueDateChildIndex < issueDateTimeChilds.getLength(); issueDateChildIndex++) {
|
||||||
if ((issueDateTimeChilds.item(issueDateChildIndex).getLocalName() != null)
|
if ((issueDateTimeChilds.item(issueDateChildIndex).getLocalName() != null)
|
||||||
&& (issueDateTimeChilds.item(issueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
&& (issueDateTimeChilds.item(issueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
||||||
issueDate = new SimpleDateFormat("yyyyMMdd").parse(trimOrNull(issueDateTimeChilds.item(issueDateChildIndex)));
|
issueDate = new SimpleDateFormat("yyyyMMdd").parse(XMLTools.trimOrNull(issueDateTimeChilds.item(issueDateChildIndex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,7 +385,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
for (int occurenceChildIndex = 0; occurenceChildIndex < occurenceChilds.getLength(); occurenceChildIndex++) {
|
for (int occurenceChildIndex = 0; occurenceChildIndex < occurenceChilds.getLength(); occurenceChildIndex++) {
|
||||||
if ((occurenceChilds.item(occurenceChildIndex).getLocalName() != null)
|
if ((occurenceChilds.item(occurenceChildIndex).getLocalName() != null)
|
||||||
&& (occurenceChilds.item(occurenceChildIndex).getLocalName().equals("DateTimeString"))) {
|
&& (occurenceChilds.item(occurenceChildIndex).getLocalName().equals("DateTimeString"))) {
|
||||||
deliveryDate = new SimpleDateFormat("yyyyMMdd").parse(trimOrNull(occurenceChilds.item(occurenceChildIndex)));
|
deliveryDate = new SimpleDateFormat("yyyyMMdd").parse(XMLTools.trimOrNull(occurenceChilds.item(occurenceChildIndex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,7 +397,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
for (int despatchAdviceChildIndex = 0; despatchAdviceChildIndex < despatchAdviceChilds.getLength(); despatchAdviceChildIndex++) {
|
for (int despatchAdviceChildIndex = 0; despatchAdviceChildIndex < despatchAdviceChilds.getLength(); despatchAdviceChildIndex++) {
|
||||||
if (despatchAdviceChilds.item(despatchAdviceChildIndex).getLocalName() != null
|
if (despatchAdviceChilds.item(despatchAdviceChildIndex).getLocalName() != null
|
||||||
&& despatchAdviceChilds.item(despatchAdviceChildIndex).getLocalName().equals("IssuerAssignedID")) {
|
&& despatchAdviceChilds.item(despatchAdviceChildIndex).getLocalName().equals("IssuerAssignedID")) {
|
||||||
despatchAdviceReferencedDocument = trimOrNull(despatchAdviceChilds.item(despatchAdviceChildIndex));
|
despatchAdviceReferencedDocument = XMLTools.trimOrNull(despatchAdviceChilds.item(despatchAdviceChildIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +410,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
String buyerOrderIssuerAssignedID = null;
|
String buyerOrderIssuerAssignedID = null;
|
||||||
String sellerOrderIssuerAssignedID = null;
|
String sellerOrderIssuerAssignedID = null;
|
||||||
for (int i = 0; i < headerTradeAgreementNodes.getLength(); i++) {
|
for (int i = 0; i < headerTradeAgreementNodes.getLength(); i++) {
|
||||||
// trimOrNull(nodes.item(i)))) {
|
// XMLTools.trimOrNull(nodes.item(i)))) {
|
||||||
Node headerTradeAgreementNode = headerTradeAgreementNodes.item(i);
|
Node headerTradeAgreementNode = headerTradeAgreementNodes.item(i);
|
||||||
NodeList headerTradeAgreementChilds = headerTradeAgreementNode.getChildNodes();
|
NodeList headerTradeAgreementChilds = headerTradeAgreementNode.getChildNodes();
|
||||||
for (int agreementChildIndex = 0; agreementChildIndex < headerTradeAgreementChilds.getLength(); agreementChildIndex++) {
|
for (int agreementChildIndex = 0; agreementChildIndex < headerTradeAgreementChilds.getLength(); agreementChildIndex++) {
|
||||||
@@ -437,7 +420,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
for (int buyerOrderChildIndex = 0; buyerOrderChildIndex < buyerOrderChilds.getLength(); buyerOrderChildIndex++) {
|
for (int buyerOrderChildIndex = 0; buyerOrderChildIndex < buyerOrderChilds.getLength(); buyerOrderChildIndex++) {
|
||||||
if ((buyerOrderChilds.item(buyerOrderChildIndex).getLocalName() != null)
|
if ((buyerOrderChilds.item(buyerOrderChildIndex).getLocalName() != null)
|
||||||
&& (buyerOrderChilds.item(buyerOrderChildIndex).getLocalName().equals("IssuerAssignedID"))) {
|
&& (buyerOrderChilds.item(buyerOrderChildIndex).getLocalName().equals("IssuerAssignedID"))) {
|
||||||
buyerOrderIssuerAssignedID = trimOrNull(buyerOrderChilds.item(buyerOrderChildIndex));
|
buyerOrderIssuerAssignedID = XMLTools.trimOrNull(buyerOrderChilds.item(buyerOrderChildIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,7 +430,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
for (int sellerOrderChildIndex = 0; sellerOrderChildIndex < sellerOrderChilds.getLength(); sellerOrderChildIndex++) {
|
for (int sellerOrderChildIndex = 0; sellerOrderChildIndex < sellerOrderChilds.getLength(); sellerOrderChildIndex++) {
|
||||||
if ((sellerOrderChilds.item(sellerOrderChildIndex).getLocalName() != null)
|
if ((sellerOrderChilds.item(sellerOrderChildIndex).getLocalName() != null)
|
||||||
&& (sellerOrderChilds.item(sellerOrderChildIndex).getLocalName().equals("IssuerAssignedID"))) {
|
&& (sellerOrderChilds.item(sellerOrderChildIndex).getLocalName().equals("IssuerAssignedID"))) {
|
||||||
sellerOrderIssuerAssignedID = trimOrNull(sellerOrderChilds.item(sellerOrderChildIndex));
|
sellerOrderIssuerAssignedID = XMLTools.trimOrNull(sellerOrderChilds.item(sellerOrderChildIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -466,7 +449,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
String IBAN = null, BIC = null;
|
String IBAN = null, BIC = null;
|
||||||
|
|
||||||
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
||||||
// trimOrNull(nodes.item(i)))) {
|
// XMLTools.trimOrNull(nodes.item(i)))) {
|
||||||
Node headerTradeSettlementNode = headerTradeSettlementNodes.item(i);
|
Node headerTradeSettlementNode = headerTradeSettlementNodes.item(i);
|
||||||
|
|
||||||
NodeList headerTradeSettlementChilds = headerTradeSettlementNode.getChildNodes();
|
NodeList headerTradeSettlementChilds = headerTradeSettlementNode.getChildNodes();
|
||||||
@@ -479,7 +462,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes();
|
NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes();
|
||||||
for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds.getLength(); dueDateChildIndex++) {
|
for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds.getLength(); dueDateChildIndex++) {
|
||||||
if ((dueDateChilds.item(dueDateChildIndex).getLocalName() != null) && (dueDateChilds.item(dueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
if ((dueDateChilds.item(dueDateChildIndex).getLocalName() != null) && (dueDateChilds.item(dueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
||||||
dueDate = new SimpleDateFormat("yyyyMMdd").parse(trimOrNull(dueDateChilds.item(dueDateChildIndex)));
|
dueDate = new SimpleDateFormat("yyyyMMdd").parse(XMLTools.trimOrNull(dueDateChilds.item(dueDateChildIndex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -500,7 +483,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
|
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
|
||||||
for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) {
|
for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) {
|
||||||
if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("IBANID"))) {//CII
|
if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("IBANID"))) {//CII
|
||||||
IBAN = trimOrNull(accountChilds.item(accountChildIndex));
|
IBAN = XMLTools.trimOrNull(accountChilds.item(accountChildIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -508,7 +491,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
|
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
|
||||||
for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) {
|
for (int accountChildIndex = 0; accountChildIndex < accountChilds.getLength(); accountChildIndex++) {
|
||||||
if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("BICID"))) {//CII
|
if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds.item(accountChildIndex).getLocalName().equals("BICID"))) {//CII
|
||||||
BIC = trimOrNull(accountChilds.item(accountChildIndex));
|
BIC = XMLTools.trimOrNull(accountChilds.item(accountChildIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,7 +514,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList startPeriodChilds = periodChilds.item(periodChildIndex).getChildNodes();
|
NodeList startPeriodChilds = periodChilds.item(periodChildIndex).getChildNodes();
|
||||||
for (int startPeriodIndex = 0; startPeriodIndex < startPeriodChilds.getLength(); startPeriodIndex++) {
|
for (int startPeriodIndex = 0; startPeriodIndex < startPeriodChilds.getLength(); startPeriodIndex++) {
|
||||||
if ((startPeriodChilds.item(startPeriodIndex).getLocalName() != null) && (startPeriodChilds.item(startPeriodIndex).getLocalName().equals("DateTimeString"))) {//CII
|
if ((startPeriodChilds.item(startPeriodIndex).getLocalName() != null) && (startPeriodChilds.item(startPeriodIndex).getLocalName().equals("DateTimeString"))) {//CII
|
||||||
deliveryPeriodStart = trimOrNull(startPeriodChilds.item(startPeriodIndex));
|
deliveryPeriodStart = XMLTools.trimOrNull(startPeriodChilds.item(startPeriodIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -539,7 +522,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList endPeriodChilds = periodChilds.item(periodChildIndex).getChildNodes();
|
NodeList endPeriodChilds = periodChilds.item(periodChildIndex).getChildNodes();
|
||||||
for (int endPeriodIndex = 0; endPeriodIndex < endPeriodChilds.getLength(); endPeriodIndex++) {
|
for (int endPeriodIndex = 0; endPeriodIndex < endPeriodChilds.getLength(); endPeriodIndex++) {
|
||||||
if ((endPeriodChilds.item(endPeriodIndex).getLocalName() != null) && (endPeriodChilds.item(endPeriodIndex).getLocalName().equals("DateTimeString"))) {//CII
|
if ((endPeriodChilds.item(endPeriodIndex).getLocalName() != null) && (endPeriodChilds.item(endPeriodIndex).getLocalName().equals("DateTimeString"))) {//CII
|
||||||
deliveryPeriodEnd = trimOrNull(endPeriodChilds.item(endPeriodIndex));
|
deliveryPeriodEnd = XMLTools.trimOrNull(endPeriodChilds.item(endPeriodIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -558,7 +541,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList paymentMeansNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList paymentMeansNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
for (int i = 0; i < paymentMeansNodes.getLength(); i++) {
|
for (int i = 0; i < paymentMeansNodes.getLength(); i++) {
|
||||||
// trimOrNull(nodes.item(i)))) {
|
// XMLTools.trimOrNull(nodes.item(i)))) {
|
||||||
Node paymentMeansNode = paymentMeansNodes.item(i);
|
Node paymentMeansNode = paymentMeansNodes.item(i);
|
||||||
NodeList paymentMeansChilds = paymentMeansNode.getChildNodes();
|
NodeList paymentMeansChilds = paymentMeansNode.getChildNodes();
|
||||||
for (int meansChildIndex = 0; meansChildIndex < paymentMeansChilds.getLength(); meansChildIndex++) {
|
for (int meansChildIndex = 0; meansChildIndex < paymentMeansChilds.getLength(); meansChildIndex++) {
|
||||||
@@ -567,7 +550,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
NodeList paymentTermChilds = paymentMeansChilds.item(meansChildIndex).getChildNodes();
|
NodeList paymentTermChilds = paymentMeansChilds.item(meansChildIndex).getChildNodes();
|
||||||
for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds.getLength(); paymentTermChildIndex++) {
|
for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds.getLength(); paymentTermChildIndex++) {
|
||||||
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("ID"))) {
|
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("ID"))) {
|
||||||
IBAN = trimOrNull(paymentTermChilds.item(paymentTermChildIndex));
|
IBAN = XMLTools.trimOrNull(paymentTermChilds.item(paymentTermChildIndex));
|
||||||
if (IBAN != null) {
|
if (IBAN != null) {
|
||||||
BankDetails bd = new BankDetails(IBAN);
|
BankDetails bd = new BankDetails(IBAN);
|
||||||
bankDetails.add(bd);
|
bankDetails.add(bd);
|
||||||
@@ -607,7 +590,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
String buyerReference = null;
|
String buyerReference = null;
|
||||||
prepaidNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
prepaidNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
if (prepaidNodes.getLength() > 0) {
|
if (prepaidNodes.getLength() > 0) {
|
||||||
buyerReference = trimOrNull(prepaidNodes.item(0));
|
buyerReference = XMLTools.trimOrNull(prepaidNodes.item(0));
|
||||||
}
|
}
|
||||||
if (buyerReference != null) {
|
if (buyerReference != null) {
|
||||||
zpp.setReferenceNumber(buyerReference);
|
zpp.setReferenceNumber(buyerReference);
|
||||||
@@ -629,7 +612,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
xpr = xpath.compile("//*[local-name()=\"AttachmentBinaryObject\"]|//*[local-name()=\"EmbeddedDocumentBinaryObject\"]");
|
xpr = xpath.compile("//*[local-name()=\"AttachmentBinaryObject\"]|//*[local-name()=\"EmbeddedDocumentBinaryObject\"]");
|
||||||
NodeList attachmentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList attachmentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
for (int i = 0; i < attachmentNodes.getLength(); i++) {
|
for (int i = 0; i < attachmentNodes.getLength(); i++) {
|
||||||
FileAttachment fa = new FileAttachment(attachmentNodes.item(i).getAttributes().getNamedItem("filename").getNodeValue(), attachmentNodes.item(i).getAttributes().getNamedItem("mimeCode").getNodeValue(), "Data", Base64.getDecoder().decode(trimOrNull(attachmentNodes.item(i))));
|
FileAttachment fa = new FileAttachment(attachmentNodes.item(i).getAttributes().getNamedItem("filename").getNodeValue(), attachmentNodes.item(i).getAttributes().getNamedItem("mimeCode").getNodeValue(), "Data", Base64.getDecoder().decode(XMLTools.trimOrNull(attachmentNodes.item(i))));
|
||||||
fileAttachments.add(fa);
|
fileAttachments.add(fa);
|
||||||
// filename = "Aufmass.png" mimeCode = "image/png"
|
// filename = "Aufmass.png" mimeCode = "image/png"
|
||||||
//EmbeddedDocumentBinaryObject cbc:EmbeddedDocumentBinaryObject mimeCode="image/png" filename="Aufmass.png"
|
//EmbeddedDocumentBinaryObject cbc:EmbeddedDocumentBinaryObject mimeCode="image/png" filename="Aufmass.png"
|
||||||
@@ -657,21 +640,21 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
for (int indicatorChildIndex = 0; indicatorChildIndex < indicatorChilds.getLength(); indicatorChildIndex++) {
|
for (int indicatorChildIndex = 0; indicatorChildIndex < indicatorChilds.getLength(); indicatorChildIndex++) {
|
||||||
if ((indicatorChilds.item(indicatorChildIndex).getLocalName() != null)
|
if ((indicatorChilds.item(indicatorChildIndex).getLocalName() != null)
|
||||||
&& (indicatorChilds.item(indicatorChildIndex).getLocalName().equals("Indicator"))) {
|
&& (indicatorChilds.item(indicatorChildIndex).getLocalName().equals("Indicator"))) {
|
||||||
isCharge = trimOrNull(indicatorChilds.item(indicatorChildIndex)).equalsIgnoreCase("true");
|
isCharge = XMLTools.trimOrNull(indicatorChilds.item(indicatorChildIndex)).equalsIgnoreCase("true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (chargeChildName.equals("ActualAmount")) {
|
} else if (chargeChildName.equals("ActualAmount")) {
|
||||||
chargeAmount = trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
chargeAmount = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
||||||
} else if (chargeChildName.equals("Reason")) {
|
} else if (chargeChildName.equals("Reason")) {
|
||||||
reason = trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
reason = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
||||||
} else if (chargeChildName.equals("ReasonCode")) {
|
} else if (chargeChildName.equals("ReasonCode")) {
|
||||||
reasonCode = trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
reasonCode = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
||||||
} else if (chargeChildName.equals("CategoryTradeTax")) {
|
} else if (chargeChildName.equals("CategoryTradeTax")) {
|
||||||
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
||||||
String taxItemName = taxChilds.item(taxChildIndex).getLocalName();
|
String taxItemName = taxChilds.item(taxChildIndex).getLocalName();
|
||||||
if ((taxItemName != null) && (taxItemName.equals("RateApplicablePercent") || taxItemName.equals("ApplicablePercent"))) {
|
if ((taxItemName != null) && (taxItemName.equals("RateApplicablePercent") || taxItemName.equals("ApplicablePercent"))) {
|
||||||
taxPercent = trimOrNull(taxChilds.item(taxChildIndex));
|
taxPercent = XMLTools.trimOrNull(taxChilds.item(taxChildIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user