corrected some unit tests

This commit is contained in:
jstaerk
2024-11-29 16:13:00 +01:00
parent 3dc00f3071
commit c10e32aa52
3 changed files with 97 additions and 77 deletions

View File

@@ -18,15 +18,17 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
/** /**
* BIC, I believe it's optional * BIC, I believe it's optional
*/ */
protected String BIC=null; protected String BIC = null;
/** /**
* the "name" of the bank account (holder) * the "name" of the bank account (holder)
*/ */
protected String accountName=null; protected String accountName = null;
/*** /***
* bean constructor * bean constructor
*/ */
public BankDetails() { } public BankDetails() {
}
/*** /***
* constructor for IBAN only :-) * constructor for IBAN only :-)
@@ -35,6 +37,7 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
public BankDetails(String IBAN) { public BankDetails(String IBAN) {
this.IBAN = IBAN; this.IBAN = IBAN;
} }
/*** /***
* constructor for normal use :-) * constructor for normal use :-)
* @param IBAN the IBAN as string * @param IBAN the IBAN as string
@@ -58,6 +61,7 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
* identify the IBAN. Of course you will specify your own IBAN in full length but * identify the IBAN. Of course you will specify your own IBAN in full length but
* if you deduct from a customer's account you may e.g. leave out the first or last * if you deduct from a customer's account you may e.g. leave out the first or last
* digits so that nobody spying on the invoice gets to know the complete number * digits so that nobody spying on the invoice gets to know the complete number
*
* @param IBAN the "IBAN ID", i.e. the IBAN or parts of it * @param IBAN the "IBAN ID", i.e. the IBAN or parts of it
* @return fluent setter * @return fluent setter
*/ */
@@ -84,31 +88,33 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
return this; return this;
} }
/***
* getOwn... methods will be removed in the future in favor of Tradeparty (e.g. Sender) class /*
* */ I'd really like to get rid of all those getOwn... methods some time but in this case they are in the interface :-(
// @Override */
// @Deprecated @Override
// @JsonIgnore @Deprecated
// public String getOwnBIC() { @JsonIgnore
// return getBIC(); public String getOwnBIC() {
// } return getBIC();
// }
// @Override
// @Deprecated @Override
// @JsonIgnore @Deprecated
// public String getOwnIBAN() { @JsonIgnore
// return getIBAN(); public String getOwnIBAN() {
// } return getIBAN();
}
/** /**
* set Holder * set Holder
*
* @param name account name (usually account holder if != sender) * @param name account name (usually account holder if != sender)
* @return fluent setter * @return fluent setter
*/ */
public BankDetails setAccountName(String name) { public BankDetails setAccountName(String name) {
accountName=name; accountName = name;
return this; return this;
} }
@@ -118,5 +124,4 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
} }
} }

View File

@@ -347,11 +347,7 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
if (settlement instanceof IZUGFeRDTradeSettlementDebit) { if (settlement instanceof IZUGFeRDTradeSettlementDebit) {
return ((IZUGFeRDTradeSettlementDebit) settlement).getIBAN(); return ((IZUGFeRDTradeSettlementDebit) settlement).getIBAN();
} }
if (settlement instanceof BankDetails) {
return ((BankDetails) settlement).getIBAN();
}
if (settlement instanceof IZUGFeRDTradeSettlementPayment) { if (settlement instanceof IZUGFeRDTradeSettlementPayment) {
return ((IZUGFeRDTradeSettlementPayment) settlement).getOwnIBAN(); return ((IZUGFeRDTradeSettlementPayment) settlement).getOwnIBAN();
} }
} }

View File

@@ -275,8 +275,9 @@ public class ZUGFeRDInvoiceImporter {
} }
public void setID(String id) { public void setID(String id) {
String ud=id; String ud = id;
} }
/*** /***
* This will parse a XML into the given invoice object * This will parse a XML into the given invoice object
* @param zpp the invoice to be altered * @param zpp the invoice to be altered
@@ -306,51 +307,51 @@ public class ZUGFeRDInvoiceImporter {
} }
//UBL... //UBL...
XPathExpression shipExUBL = xpath.compile("//*[local-name()=\"Delivery\"]"); XPathExpression shipExUBL = xpath.compile("//*[local-name()=\"Delivery\"]");
Node deliveryNode = (Node) shipExUBL.evaluate(getDocument(), XPathConstants.NODE); Node deliveryNode = (Node) shipExUBL.evaluate(getDocument(), XPathConstants.NODE);
if (deliveryNode != null) { if (deliveryNode != null) {
TradeParty delivery=new TradeParty(); TradeParty delivery = new TradeParty();
NodeMap nodeMap = new NodeMap(deliveryNode).getAsNodeMap("DeliveryLocation").get(); new NodeMap(deliveryNode).getAsNodeMap("DeliveryLocation").ifPresent(
deliveryLocationNodeMap -> {
if (nodeMap != null) { deliveryLocationNodeMap.getNode("ID").ifPresent(s -> {
nodeMap.getNode("ID").ifPresent(s -> { SchemedID sID = new SchemedID().setScheme(s.getAttributes().getNamedItem("schemeID").getTextContent()).setId(s.getTextContent());
SchemedID sID = new SchemedID().setScheme(s.getAttributes().getNamedItem("schemeID").getTextContent()).setId(s.getTextContent()); delivery.addGlobalID(sID);
delivery.addGlobalID(sID); });
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("StreetName").ifPresent(t -> delivery.setStreet(t));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("CityName").ifPresent(t -> delivery.setLocation(t));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("PostalZone").ifPresent(t -> delivery.setZIP(t));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsNodeMap("Country").ifPresent(t -> t.getAsString("IdentificationCode").ifPresent(u -> delivery.setCountry(u)));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsNodeMap("AddressLine").ifPresent(t -> t.getAsString("Line").ifPresent(u -> delivery.setAdditionalAddressExtension(u)));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
}); });
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("StreetName").ifPresent(t -> delivery.setStreet(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("CityName").ifPresent(t -> delivery.setLocation(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("PostalZone").ifPresent(t -> delivery.setZIP(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsNodeMap("Country").ifPresent(t -> t.getAsString("IdentificationCode").ifPresent(u -> delivery.setCountry(u)));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsNodeMap("AddressLine").ifPresent(t -> t.getAsString("Line").ifPresent(u -> delivery.setAdditionalAddressExtension(u)));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
}
NodeMap partyMap = new NodeMap(deliveryNode).getAsNodeMap("DeliveryParty").get(); new NodeMap(deliveryNode).getAsNodeMap("DeliveryParty").ifPresent(partyMap -> {
if (partyMap!=null) { partyMap.getAsNodeMap("PartyName").ifPresent(s -> {
partyMap.getAsNodeMap("PartyName").ifPresent(s->{s.getAsString("Name").ifPresent(t->delivery.setName(t));}); s.getAsString("Name").ifPresent(t -> delivery.setName(t));
} });
});
String street, name, additionalStreet, city, postal, countrySubentity, line, country = null; String street, name, additionalStreet, city, postal, countrySubentity, line, country = null;
/* /*
String idx = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"ID\"]"); String idx = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"ID\"]");
@@ -507,16 +508,34 @@ public class ZUGFeRDInvoiceImporter {
subjectCode = XMLTools.trimOrNull(includedNodeChilds.item(issueDateChildIndex)); subjectCode = XMLTools.trimOrNull(includedNodeChilds.item(issueDateChildIndex));
} }
} }
switch (subjectCode){ switch (subjectCode) {
case "AAI": includedNotes.add(IncludedNote.generalNote(content)); break; case "AAI":
case "REG": includedNotes.add(IncludedNote.regulatoryNote(content)); break; includedNotes.add(IncludedNote.generalNote(content));
case "ABL": includedNotes.add(IncludedNote.legalNote(content)); break; break;
case "CUS": includedNotes.add(IncludedNote.customsNote(content)); break; case "REG":
case "SUR": includedNotes.add(IncludedNote.sellerNote(content)); break; includedNotes.add(IncludedNote.regulatoryNote(content));
case "TXD": includedNotes.add(IncludedNote.taxNote(content)); break; break;
case "ACY": includedNotes.add(IncludedNote.introductionNote(content)); break; case "ABL":
case "AAK": includedNotes.add(IncludedNote.discountBonusNote(content)); break; includedNotes.add(IncludedNote.legalNote(content));
default: includedNotes.add(IncludedNote.unspecifiedNote(content)); break; break;
case "CUS":
includedNotes.add(IncludedNote.customsNote(content));
break;
case "SUR":
includedNotes.add(IncludedNote.sellerNote(content));
break;
case "TXD":
includedNotes.add(IncludedNote.taxNote(content));
break;
case "ACY":
includedNotes.add(IncludedNote.introductionNote(content));
break;
case "AAK":
includedNotes.add(IncludedNote.discountBonusNote(content));
break;
default:
includedNotes.add(IncludedNote.unspecifiedNote(content));
break;
} }
} }
zpp.addNotes(includedNotes); zpp.addNotes(includedNotes);
@@ -732,8 +751,8 @@ public class ZUGFeRDInvoiceImporter {
// if ((paymentMeansChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("DirectDebitMandateID"))) { // if ((paymentMeansChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("DirectDebitMandateID"))) {
// directDebitMandateID = paymentTermChilds.item(paymentTermChildIndex).getTextContent(); // directDebitMandateID = paymentTermChilds.item(paymentTermChildIndex).getTextContent();
// } // }
if((paymentMeansChilds.item(meansChildIndex).getLocalName() != null) if ((paymentMeansChilds.item(meansChildIndex).getLocalName() != null)
&& (paymentMeansChilds.item(meansChildIndex).getLocalName().equals("PaymentMandate"))){ && (paymentMeansChilds.item(meansChildIndex).getLocalName().equals("PaymentMandate"))) {
NodeList paymentMandateChilds = paymentMeansChilds.item(meansChildIndex).getChildNodes(); NodeList paymentMandateChilds = paymentMeansChilds.item(meansChildIndex).getChildNodes();
for (int paymentMandateChildIndex = 0; paymentMandateChildIndex < paymentMandateChilds.getLength(); paymentMandateChildIndex++) { for (int paymentMandateChildIndex = 0; paymentMandateChildIndex < paymentMandateChilds.getLength(); paymentMandateChildIndex++) {
if ((paymentMandateChilds.item(paymentMandateChildIndex).getLocalName() != null) && (paymentMandateChilds.item(paymentMandateChildIndex).getLocalName().equals("ID"))) { if ((paymentMandateChilds.item(paymentMandateChildIndex).getLocalName() != null) && (paymentMandateChilds.item(paymentMandateChildIndex).getLocalName().equals("ID"))) {
@@ -777,8 +796,8 @@ public class ZUGFeRDInvoiceImporter {
zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]|//*[local-name()=\"AccountingSupplierParty\"]/*[local-name()=\"Party\"]/*[local-name()=\"PartyName\"]").trim()); zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]|//*[local-name()=\"AccountingSupplierParty\"]/*[local-name()=\"Party\"]/*[local-name()=\"PartyName\"]").trim());
String rounding=extractString("//*[local-name()=\"SpecifiedTradeSettlementHeaderMonetarySummation\"]/*[local-name()=\"RoundingAmount\"]|//*[local-name()=\"LegalMonetaryTotal\"]/*[local-name()=\"Party\"]/*[local-name()=\"PayableRoundingAmount\"]"); String rounding = extractString("//*[local-name()=\"SpecifiedTradeSettlementHeaderMonetarySummation\"]/*[local-name()=\"RoundingAmount\"]|//*[local-name()=\"LegalMonetaryTotal\"]/*[local-name()=\"Party\"]/*[local-name()=\"PayableRoundingAmount\"]");
if ((rounding!=null)&&(!rounding.isEmpty())) { if ((rounding != null) && (!rounding.isEmpty())) {
zpp.setRoundingAmount(new BigDecimal(rounding.trim())); zpp.setRoundingAmount(new BigDecimal(rounding.trim()));
} }
@@ -855,7 +874,7 @@ public class ZUGFeRDInvoiceImporter {
reason = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex)); reason = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
} else if (chargeChildName.equals("ReasonCode") || chargeChildName.equals("AllowanceChargeReasonCode")) { } else if (chargeChildName.equals("ReasonCode") || chargeChildName.equals("AllowanceChargeReasonCode")) {
reasonCode = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex)); reasonCode = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
} else if (chargeChildName.equals("CategoryTradeTax")||chargeChildName.equals("TaxCategory")) { } else if (chargeChildName.equals("CategoryTradeTax") || chargeChildName.equals("TaxCategory")) {
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes(); NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) { for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
String taxItemName = taxChilds.item(taxChildIndex).getLocalName(); String taxItemName = taxChilds.item(taxChildIndex).getLocalName();