Merge branch 'add_extraction_methods' of https://github.com/aberndt-hub/mustangproject
This commit is contained in:
@@ -252,6 +252,250 @@ public class ZUGFeRDImporter {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ZUGFeRD Profile
|
||||
*/
|
||||
public String getZUGFeRDProfil() {
|
||||
switch (extractString("//GuidelineSpecifiedDocumentContextParameter//ID")) {
|
||||
case "urn:cen.eu:en16931:2017":
|
||||
case "urn:ferd:CrossIndustryDocument:invoice:1p0:comfort":
|
||||
return "COMFORT";
|
||||
case "urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic":
|
||||
case "urn:ferd:CrossIndustryDocument:invoice:1p0:basic":
|
||||
return "BASIC";
|
||||
case "urn:factur-x.eu:1p0:basicwl":
|
||||
return "BASIC WL";
|
||||
case "urn:factur-x.eu:1p0:minimum":
|
||||
return "MINIMUM";
|
||||
case "urn:ferd:CrossIndustryDocument:invoice:1p0:extended":
|
||||
case "urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended":
|
||||
return "EXTENDED";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Invoice Currency Code
|
||||
*/
|
||||
public String getInvoiceCurrencyCode() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//ApplicableSupplyChainTradeSettlement//InvoiceCurrencyCode");
|
||||
} else {
|
||||
return extractString("//ApplicableHeaderTradeSettlement//InvoiceCurrencyCode");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the IssuerAssigned ID
|
||||
*/
|
||||
public String getIssuerAssignedID() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//BuyerOrderReferencedDocument//ID");
|
||||
} else {
|
||||
return extractString("//BuyerOrderReferencedDocument//IssuerAssignedID");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the BuyerTradeParty ID
|
||||
*/
|
||||
public String getBuyerTradePartyID() {
|
||||
return extractString("//BuyerTradeParty//ID");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Issue Date()
|
||||
*/
|
||||
public String getIssueDate() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//HeaderExchangedDocument//IssueDateTime//DateTimeString");
|
||||
} else {
|
||||
return extractString("//ExchangedDocument//IssueDateTime//DateTimeString");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the TaxBasisTotalAmount
|
||||
*/
|
||||
public String getTaxBasisTotalAmount() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//SpecifiedTradeSettlementMonetarySummation//TaxBasisTotalAmount");
|
||||
} else {
|
||||
return extractString("//SpecifiedTradeSettlementHeaderMonetarySummation//TaxBasisTotalAmount");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the TaxTotalAmount
|
||||
*/
|
||||
public String getTaxTotalAmount() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//SpecifiedTradeSettlementMonetarySummation//TaxTotalAmount");
|
||||
} else {
|
||||
return extractString("//SpecifiedTradeSettlementHeaderMonetarySummation//TaxTotalAmount");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the RoundingAmount
|
||||
*/
|
||||
public String getRoundingAmount() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//SpecifiedTradeSettlementMonetarySummation//RoundingAmount");
|
||||
} else {
|
||||
return extractString("//SpecifiedTradeSettlementHeaderMonetarySummation//RoundingAmount");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the TotalPrepaidAmount
|
||||
*/
|
||||
public String getPaidAmount() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//SpecifiedTradeSettlementMonetarySummation//TotalPrepaidAmount");
|
||||
} else {
|
||||
return extractString("//SpecifiedTradeSettlementHeaderMonetarySummation//TotalPrepaidAmount");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SellerTradeParty GlobalID
|
||||
*/
|
||||
public String getSellerTradePartyGlobalID() {
|
||||
return extractString("//SellerTradeParty//GlobalID");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the BuyerTradeParty GlobalID
|
||||
*/
|
||||
public String getBuyerTradePartyGlobalID() {
|
||||
return extractString("//BuyerTradeParty//GlobalID");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the BuyerTradeParty SpecifiedTaxRegistration ID
|
||||
*/
|
||||
public String getBuyertradePartySpecifiedTaxRegistrationID() {
|
||||
return extractString("//BuyerTradeParty//SpecifiedTaxRegistration//ID");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the IncludedNote
|
||||
*/
|
||||
public String getIncludedNote() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//HeaderExchangedDocument//IncludedNote");
|
||||
} else {
|
||||
return extractString("//ExchangedDocument//IncludedNote");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the BuyerTradeParty Name
|
||||
*/
|
||||
public String getBuyerTradePartyName() {
|
||||
return extractString("//BuyerTradeParty//Name");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the line Total Amount
|
||||
*/
|
||||
public String getLineTotalAmount() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//SpecifiedTradeSettlementMonetarySummation//LineTotalAmount");
|
||||
} else {
|
||||
return extractString("//SpecifiedTradeSettlementHeaderMonetarySummation//LineTotalAmount");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Payment Terms
|
||||
*/
|
||||
public String getPaymentTerms() {
|
||||
return extractString("//SpecifiedTradePaymentTerms//Description");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Taxpoint Date
|
||||
*/
|
||||
public String getTaxPointDate() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//ActualDeliverySupplyChainEvent//OccurrenceDateTime//DateTimeString");
|
||||
} else {
|
||||
return extractString("//ActualDeliverySupplyChainEvent//OccurrenceDateTime//DateTimeString");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Invoice ID
|
||||
*/
|
||||
public String getInvoiceID() {
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
return extractString("//HeaderExchangedDocument//ID");
|
||||
} else {
|
||||
return extractString("//ExchangedDocument//ID");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the document code
|
||||
@@ -454,6 +698,28 @@ public class ZUGFeRDImporter {
|
||||
return s.hasNext() ? s.next() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
||||
* @return an instance of PostalTradeAddress
|
||||
*/
|
||||
public PostalTradeAddress getBuyerTradePartyAddress() {
|
||||
|
||||
NodeList nl = null;
|
||||
|
||||
try {
|
||||
if (getVersion() == 1) {
|
||||
nl = getNodeListByPath("//CrossIndustryDocument//SpecifiedSupplyChainTradeTransaction//ApplicableSupplyChainTradeAgreement//BuyerTradeParty//PostalTradeAddress");
|
||||
} else {
|
||||
nl = getNodeListByPath("//CrossIndustryInvoice//SupplyChainTradeTransaction//ApplicableHeaderTradeAgreement//BuyerTradeParty//PostalTradeAddress");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
return getAddressFromNodeList(nl);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
||||
* @return an instance of PostalTradeAddress
|
||||
@@ -471,9 +737,15 @@ public class ZUGFeRDImporter {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return address;
|
||||
return null;
|
||||
}
|
||||
|
||||
return getAddressFromNodeList(nl);
|
||||
}
|
||||
|
||||
private PostalTradeAddress getAddressFromNodeList(NodeList nl) {
|
||||
PostalTradeAddress address = new PostalTradeAddress();
|
||||
|
||||
if (nl != null) {
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
Node n = nl.item(i);
|
||||
@@ -484,25 +756,46 @@ public class ZUGFeRDImporter {
|
||||
if (nodeType==Node.ELEMENT_NODE){
|
||||
switch (n.getNodeName()) {
|
||||
case "ram:PostcodeCode":
|
||||
address.setPostCodeCode(n.getFirstChild().getNodeValue());
|
||||
address.setPostCodeCode("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setPostCodeCode(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
case "ram:LineOne":
|
||||
address.setLineOne(n.getFirstChild().getNodeValue());
|
||||
address.setLineOne("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setLineOne(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
case "ram:LineTwo":
|
||||
address.setLineTwo(n.getFirstChild().getNodeValue());
|
||||
address.setLineTwo("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setLineTwo(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
case "ram:LineThree":
|
||||
address.setLineThree(n.getFirstChild().getNodeValue());
|
||||
address.setLineThree("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setLineThree(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
case "ram:CityName":
|
||||
address.setCityName(n.getFirstChild().getNodeValue());
|
||||
address.setCityName("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setCityName(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
case "ram:CountryID":
|
||||
address.setCountryID(n.getFirstChild().getNodeValue());
|
||||
address.setCountryID("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setCountryID(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
case "ram:CountrySubDivisionName":
|
||||
address.setCountrySubDivisionName(n.getFirstChild().getNodeValue());
|
||||
address.setCountrySubDivisionName("");
|
||||
if (n.getFirstChild() != null) {
|
||||
address.setCountrySubDivisionName(n.getFirstChild().getNodeValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +805,6 @@ public class ZUGFeRDImporter {
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns a list of LineItems
|
||||
* @return a List of LineItem instances
|
||||
|
||||
Reference in New Issue
Block a user