Add ZUGFeRDImporter#getDeliveryTradePartyAddress

Add ZUGFeRDImporter#getDeliveryTradePartyName
This commit is contained in:
Sebastian Sieber
2022-10-26 16:29:22 +02:00
parent f2e6a2e580
commit 9af931d1de
3 changed files with 111 additions and 21 deletions

View File

@@ -463,6 +463,11 @@ public class ZUGFeRDImporter {
*/
public String getBuyerTradePartyName() {
return extractString("//*[local-name() = 'BuyerTradeParty']//*[local-name() = 'Name']");
} /**
* @return the BuyerTradeParty Name
*/
public String getDeliveryTradePartyName() {
return extractString("//*[local-name() = 'ShipToTradeParty']//*[local-name() = 'Name']");
}
@@ -658,7 +663,7 @@ public class ZUGFeRDImporter {
if (!containsMeta) {
throw new Exception("Not yet parsed");
}
String head = getUTF8();
final String head = getUTF8();
if (head.contains("<rsm:CrossIndustryDocument")) {
return EStandard.zugferd;
} else if (head.contains("<CrossIndustryDocument")) {
@@ -678,10 +683,11 @@ public class ZUGFeRDImporter {
if (!containsMeta) {
throw new Exception("Not yet parsed");
}
if (version != null)
return version;
if (version != null) {
return version;
}
String head = getUTF8();
final String head = getUTF8();
if (head.contains("<rsm:CrossIndustryDocument") //
|| head.contains("<CrossIndustryDocument") //
|| head.contains("<SCRDMCCBDACIDAMessageStructure") //
@@ -690,8 +696,9 @@ public class ZUGFeRDImporter {
} else if (head.contains("<rsm:CrossIndustryInvoice")) {
version = 2;
}
else
throw new Exception("ZUGFeRD version could not be determined");
else {
throw new Exception("ZUGFeRD version could not be determined");
}
return version;
}
@@ -797,6 +804,27 @@ public class ZUGFeRDImporter {
return null;
}
return getAddressFromNodeList(nl);
}
/**
* returns an instance of PostalTradeAddress for ShipToTradeParty section
* @return an instance of PostalTradeAddress
*/
public PostalTradeAddress getDeliveryTradePartyAddress() {
final NodeList nl;
try {
if (getVersion() == 1) {
nl = getNodeListByPath("//*[local-name() = 'CrossIndustryDocument']//*[local-name() = 'SpecifiedSupplyChainTradeTransaction']//*[local-name() = 'ApplicableSupplyChainTradeDelivery']//*[local-name() = 'ShipToTradeParty']//*[local-name() = 'PostalTradeAddress']");
} else {
nl = getNodeListByPath("//*[local-name() = 'CrossIndustryInvoice']//*[local-name() = 'SupplyChainTradeTransaction']//*[local-name() = 'ApplicableHeaderTradeDelivery']//*[local-name() = 'ShipToTradeParty']//*[local-name() = 'PostalTradeAddress']");
}
} catch (final Exception e) {
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
return null;
}
return getAddressFromNodeList(nl);
}