Reading BT17 based on typecode

This commit is contained in:
Bharti
2025-10-20 22:49:53 +02:00
parent 9aa49d1483
commit 742fd1df21

View File

@@ -686,6 +686,8 @@ public class ZUGFeRDInvoiceImporter {
String sellerOrderIssuerAssignedID = null;
String additionalReferencedDocument = null;
Date additionalReferencedDocumentDate = null;
int typeC = 0;
for (int i = 0; i < headerTradeAgreementNodes.getLength(); i++) {
// XMLTools.trimOrNull(nodes.item(i)))) {
Node headerTradeAgreementNode = headerTradeAgreementNodes.item(i);
@@ -712,33 +714,41 @@ public class ZUGFeRDInvoiceImporter {
}
}
//Reading BT-17
if(headerTradeAgreementChilds.item(agreementChildIndex).getLocalName().equals("AdditionalReferencedDocument")) {
if (headerTradeAgreementChilds.item(agreementChildIndex).getLocalName().equals("AdditionalReferencedDocument")) {
NodeList additionalChilds = headerTradeAgreementChilds.item(agreementChildIndex).getChildNodes();
for (int additionalChildIndex = 0; additionalChildIndex < additionalChilds.getLength(); additionalChildIndex++){
if((additionalChilds.item(additionalChildIndex).getLocalName() != null)
&& (additionalChilds.item(additionalChildIndex).getLocalName().equals("IssuerAssignedID"))) {
additionalReferencedDocument = XMLTools.trimOrNull(additionalChilds.item(additionalChildIndex));
for (int additionalChildIndex = 0; additionalChildIndex < additionalChilds.getLength(); additionalChildIndex++) {
if ((additionalChilds.item(additionalChildIndex).getLocalName() != null)
&& additionalChilds.item(additionalChildIndex).getLocalName().equals("TypeCode")) {
typeC = Integer.parseInt(XMLTools.trimOrNull(additionalChilds.item(additionalChildIndex)));
}
if((additionalChilds.item(additionalChildIndex).getLocalName() != null)
&& (additionalChilds.item(additionalChildIndex).getLocalName().equals("FormattedIssueDateTime"))) {
if (typeC == 50) {
if ((additionalChilds.item(additionalChildIndex).getLocalName() != null)
&& (additionalChilds.item(additionalChildIndex).getLocalName().equals("IssuerAssignedID"))) {
additionalReferencedDocument = XMLTools.trimOrNull(additionalChilds.item(additionalChildIndex));
}
if ((additionalChilds.item(additionalChildIndex).getLocalName() != null)
&& (additionalChilds.item(additionalChildIndex).getLocalName().equals("FormattedIssueDateTime"))) {
NodeList FormattedIssueDateTimeChilds = additionalChilds.item(additionalChildIndex).getChildNodes();
for (int dateChildIndex = 0; dateChildIndex < FormattedIssueDateTimeChilds.getLength(); dateChildIndex++) {
if ((FormattedIssueDateTimeChilds.item(dateChildIndex).getLocalName() != null)
&& (FormattedIssueDateTimeChilds.item(dateChildIndex).getLocalName().equals("DateTimeString"))) {
additionalReferencedDocumentDate = XMLTools.tryDate(FormattedIssueDateTimeChilds.item(dateChildIndex));
}
NodeList FormattedIssueDateTimeChilds = additionalChilds.item(additionalChildIndex).getChildNodes();
for (int dateChildIndex = 0; dateChildIndex < FormattedIssueDateTimeChilds.getLength(); dateChildIndex++){
if((FormattedIssueDateTimeChilds.item(dateChildIndex).getLocalName() != null)
&& (FormattedIssueDateTimeChilds.item(dateChildIndex).getLocalName().equals("DateTimeString"))) {
additionalReferencedDocumentDate = XMLTools.tryDate(FormattedIssueDateTimeChilds.item(dateChildIndex));
}
}
}
}
}
}
}
}
String currency = extractString("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]/*[local-name()=\"InvoiceCurrencyCode\"]|//*[local-name()=\"DocumentCurrencyCode\"]");
zpp.setCurrency(currency);
@@ -973,6 +983,7 @@ public class ZUGFeRDInvoiceImporter {
zpp.setDespatchAdviceReferencedDocumentID(s);
}
}
if (additionalReferencedDocument != null){
if (additionalReferencedDocumentDate!=null) {
zpp.setTenderReferencedDocument(new DatedReference(additionalReferencedDocument, additionalReferencedDocumentDate));