Skip to content

Commit

Permalink
[26331] sort biller ean to be last in ean list on pdf bill
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed May 23, 2024
1 parent 5231274 commit 0293c73
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,15 @@ private String getEanList() {
}
}
}
List<String> billerEans = new ArrayList<String>();
expr = xPath.compile("/request/payload/body/tiers_garant/biller"); //$NON-NLS-1$
result = expr.evaluate(domDocument, XPathConstants.NODESET);
NodeList billerElements = (NodeList) result;
for (int i = 0; i < billerElements.getLength(); i++) {
Node billerElement = billerElements.item(i);
if (billerElement instanceof Element) {
eanSet.add(((Element) billerElement).getAttribute("ean_party")); //$NON-NLS-1$
billerEans.add(((Element) billerElement).getAttribute("ean_party"));
}
}
expr = xPath.compile("/request/payload/body/tiers_payant/biller"); //$NON-NLS-1$
Expand All @@ -707,16 +709,25 @@ private String getEanList() {
Node billerElement = billerElements.item(i);
if (billerElement instanceof Element) {
eanSet.add(((Element) billerElement).getAttribute("ean_party")); //$NON-NLS-1$
billerEans.add(((Element) billerElement).getAttribute("ean_party"));
}
}

StringBuilder eanList = new StringBuilder();
String[] eanArray = eanSet.toArray(new String[eanSet.size()]);
for (int i = 0; i < eanArray.length; i++) {
List<String> eanStringList = new ArrayList<>(eanSet);
if (!billerEans.isEmpty()) {
eanStringList.sort((s1, s2) -> {
if (billerEans.contains(s1)) {
return 1;
}
return -1;
});
}
for (int i = 0; i < eanStringList.size(); i++) {
if (i > 0) {
eanList.append(StringUtils.SPACE);
}
eanList.append(i + 1).append("/").append(eanArray[i]); //$NON-NLS-1$
eanList.append(i + 1).append("/").append(eanStringList.get(i)); //$NON-NLS-1$
}
return eanList.toString();
} catch (XPathExpressionException e) {
Expand Down

0 comments on commit 0293c73

Please sign in to comment.