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 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
|
* @return the document code
|
||||||
@@ -454,6 +698,28 @@ public class ZUGFeRDImporter {
|
|||||||
return s.hasNext() ? s.next() : "";
|
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
|
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
||||||
* @return an instance of PostalTradeAddress
|
* @return an instance of PostalTradeAddress
|
||||||
@@ -471,9 +737,15 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return address;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return getAddressFromNodeList(nl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PostalTradeAddress getAddressFromNodeList(NodeList nl) {
|
||||||
|
PostalTradeAddress address = new PostalTradeAddress();
|
||||||
|
|
||||||
if (nl != null) {
|
if (nl != null) {
|
||||||
for (int i = 0; i < nl.getLength(); i++) {
|
for (int i = 0; i < nl.getLength(); i++) {
|
||||||
Node n = nl.item(i);
|
Node n = nl.item(i);
|
||||||
@@ -484,25 +756,46 @@ public class ZUGFeRDImporter {
|
|||||||
if (nodeType==Node.ELEMENT_NODE){
|
if (nodeType==Node.ELEMENT_NODE){
|
||||||
switch (n.getNodeName()) {
|
switch (n.getNodeName()) {
|
||||||
case "ram:PostcodeCode":
|
case "ram:PostcodeCode":
|
||||||
address.setPostCodeCode(n.getFirstChild().getNodeValue());
|
address.setPostCodeCode("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setPostCodeCode(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ram:LineOne":
|
case "ram:LineOne":
|
||||||
address.setLineOne(n.getFirstChild().getNodeValue());
|
address.setLineOne("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setLineOne(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ram:LineTwo":
|
case "ram:LineTwo":
|
||||||
address.setLineTwo(n.getFirstChild().getNodeValue());
|
address.setLineTwo("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setLineTwo(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ram:LineThree":
|
case "ram:LineThree":
|
||||||
address.setLineThree(n.getFirstChild().getNodeValue());
|
address.setLineThree("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setLineThree(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ram:CityName":
|
case "ram:CityName":
|
||||||
address.setCityName(n.getFirstChild().getNodeValue());
|
address.setCityName("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setCityName(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ram:CountryID":
|
case "ram:CountryID":
|
||||||
address.setCountryID(n.getFirstChild().getNodeValue());
|
address.setCountryID("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setCountryID(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "ram:CountrySubDivisionName":
|
case "ram:CountrySubDivisionName":
|
||||||
address.setCountrySubDivisionName(n.getFirstChild().getNodeValue());
|
address.setCountrySubDivisionName("");
|
||||||
|
if (n.getFirstChild() != null) {
|
||||||
|
address.setCountrySubDivisionName(n.getFirstChild().getNodeValue());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -512,7 +805,6 @@ public class ZUGFeRDImporter {
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a list of LineItems
|
* returns a list of LineItems
|
||||||
* @return a List of LineItem instances
|
* @return a List of LineItem instances
|
||||||
|
|||||||
@@ -207,6 +207,24 @@ public class ZF2Test extends MustangReaderTestCase {
|
|||||||
|
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals(zi.getAmount(), "571.04");
|
assertEquals(zi.getAmount(), "571.04");
|
||||||
|
assertEquals(zi.getInvoiceID(), "RE-20170509/505");
|
||||||
|
assertEquals(zi.getZUGFeRDProfil(), "COMFORT");
|
||||||
|
assertEquals(zi.getInvoiceCurrencyCode(), "EUR");
|
||||||
|
assertEquals(zi.getIssuerAssignedID(),"");
|
||||||
|
assertEquals(zi.getIssueDate(), "20170509");
|
||||||
|
assertEquals(zi.getTaxPointDate(), "20170507");
|
||||||
|
assertEquals(zi.getPaymentTerms(), "Zahlbar ohne Abzug bis zum 30.05.2017");
|
||||||
|
assertEquals(zi.getLineTotalAmount(), "496.00");
|
||||||
|
assertEquals(zi.getTaxBasisTotalAmount(), "496.00");
|
||||||
|
assertEquals(zi.getTaxTotalAmount(),"75.04");
|
||||||
|
assertEquals(zi.getRoundingAmount(), "");
|
||||||
|
assertEquals(zi.getPaidAmount(), "0.00");
|
||||||
|
assertEquals(zi.getBuyerTradePartyName(), "Theodor Est");
|
||||||
|
assertEquals(zi.getBuyerTradePartyGlobalID(), "");
|
||||||
|
assertEquals(zi.getSellerTradePartyGlobalID(), "");
|
||||||
|
assertEquals(zi.getBuyerTradePartyID(), "DE999999999");
|
||||||
|
assertEquals(zi.getBuyertradePartySpecifiedTaxRegistrationID(), "DE999999999");
|
||||||
|
assertEquals(zi.getIncludedNote(), "");
|
||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
assertEquals(zi.getDocumentCode(),"380");
|
assertEquals(zi.getDocumentCode(),"380");
|
||||||
assertEquals(zi.getReference(),"AB321");
|
assertEquals(zi.getReference(),"AB321");
|
||||||
@@ -215,6 +233,13 @@ public class ZF2Test extends MustangReaderTestCase {
|
|||||||
assertEquals(zi.getIBAN(),getTradeSettlementPayment()[0].getOwnIBAN());
|
assertEquals(zi.getIBAN(),getTradeSettlementPayment()[0].getOwnIBAN());
|
||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
assertEquals(zi.getForeignReference(), getNumber());
|
assertEquals(zi.getForeignReference(), getNumber());
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getPostcodeCode(), "88802");
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getLineOne(), "Bahnstr. 42");
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getLineTwo(), null);
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getLineThree(), null);
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getCountrySubDivisionName(), null);
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getCountryID(), "DE");
|
||||||
|
assertEquals(zi.getBuyerTradePartyAddress().getCityName(), "Spielkreis");
|
||||||
assertEquals(zi.getSellerTradePartyAddress().getPostcodeCode(), "12345");
|
assertEquals(zi.getSellerTradePartyAddress().getPostcodeCode(), "12345");
|
||||||
assertEquals(zi.getSellerTradePartyAddress().getLineOne(), "Ecke 12");
|
assertEquals(zi.getSellerTradePartyAddress().getLineOne(), "Ecke 12");
|
||||||
assertEquals(zi.getSellerTradePartyAddress().getLineTwo(), null);
|
assertEquals(zi.getSellerTradePartyAddress().getLineTwo(), null);
|
||||||
|
|||||||
Reference in New Issue
Block a user