Skip to content

Commit

Permalink
Method to get EndpointID for supplier
Browse files Browse the repository at this point in the history
This can be used as an unique identifier for each supplier,
e.g. as EndUserID when reporting end user statistics to
OpenPEPPOL
  • Loading branch information
hermanwh committed Jan 16, 2024
1 parent 5dcaf11 commit 0d03b22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package peppol.bis.invoice3.api;

import org.eaxy.Document;
import org.eaxy.Element;
import peppol.bis.invoice3.domain.BillingCommon;
import peppol.bis.invoice3.domain.CreditNote;
import peppol.bis.invoice3.domain.Invoice;
Expand Down Expand Up @@ -85,6 +86,14 @@ public String getCustomerCountryIdentifier() {
throw new RuntimeException("Mandatory property missing in document: AccountingCustomerParty -> Party -> PostalAddress -> Country -> IdentificationCode");
}

public String getSupplierEndpointID() {
if (this.object instanceof Document) {
Element element = ((Document) this.object).find("AccountingSupplierParty", "Party", "EndpointID").single();
return element.attr("schemeID").trim() + ":" + element.text().trim();
}
throw new RuntimeException("Mandatory property missing in document: AccountingSupplierParty -> Party -> EndpointID");
}

public String prettyPrint() {
return XML_FIRST_LINE + (this.object instanceof BillingCommon ? ((BillingCommon) this.object).xmlRoot() : ((Document) this.object).getRootElement()).toIndentedXML();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void test() throws IOException {
PeppolBillingApi<Document> peppolBillingApi = new PeppolBillingApi<>(document);
assertEquals("NO", peppolBillingApi.getCustomerCountryIdentifier());
assertEquals("NO", peppolBillingApi.getSupplierCountryIdentifier());
assertEquals("0192:123456785", peppolBillingApi.getSupplierEndpointID());
}
}

Expand Down

0 comments on commit 0d03b22

Please sign in to comment.