Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ZUGFeRD/mustangproject
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaerk committed Jul 18, 2024
2 parents 5b00818 + be7bded commit a2d3194
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
Expand Down Expand Up @@ -209,7 +211,7 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx

xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]");
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
String IBAN = null, BIC = null;
List<BankDetails> bankDetails = new ArrayList<>();

for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
// nodes.item(i).getTextContent())) {
Expand Down Expand Up @@ -244,6 +246,7 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx
NodeList paymentMeansChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes();
for (int paymentMeansChildIndex = 0; paymentMeansChildIndex < paymentMeansChilds
.getLength(); paymentMeansChildIndex++) {
String IBAN = null, BIC = null;
if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds
.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialAccount"))) {
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
Expand All @@ -266,6 +269,13 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx
}
}
}
if (IBAN != null) {
BankDetails bd = new BankDetails(IBAN);
if (BIC != null) {
bd.setBIC(BIC);
}
bankDetails.add(bd);
}
}
}
}
Expand All @@ -289,7 +299,11 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx
.getLength(); paymentTermChildIndex++) {
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds
.item(paymentTermChildIndex).getLocalName().equals("ID"))) {
IBAN = paymentTermChilds.item(paymentTermChildIndex).getTextContent();
String IBAN = paymentTermChilds.item(paymentTermChildIndex).getTextContent();
if (IBAN != null) {
BankDetails bd = new BankDetails(IBAN);
bankDetails.add(bd);
}
}
}
}
Expand All @@ -298,13 +312,7 @@ public Invoice extractInto(Invoice zpp) throws XPathExpressionException, ParseEx

zpp.setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate)
.setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number);
if (IBAN != null) {
BankDetails bd = new BankDetails(IBAN);
if (BIC != null) {
bd.setBIC(BIC);
}
zpp.getSender().addBankDetails(bd);
}
bankDetails.forEach(bankDetail -> zpp.getSender().addBankDetails(bankDetail));

if (buyerOrderIssuerAssignedID != null) {
zpp.setBuyerOrderReferencedDocumentID(buyerOrderIssuerAssignedID);
Expand Down

0 comments on commit a2d3194

Please sign in to comment.