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

@@ -23,10 +23,12 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
* the "name" of the bank account (holder)
*/
protected String accountName = null;
/***
* bean constructor
*/
public BankDetails() { }
public BankDetails() {
}
/***
* constructor for IBAN only :-)
@@ -35,6 +37,7 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
public BankDetails(String IBAN) {
this.IBAN = IBAN;
}
/***
* constructor for normal use :-)
* @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
* 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
*
* @param IBAN the "IBAN ID", i.e. the IBAN or parts of it
* @return fluent setter
*/
@@ -84,26 +88,28 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
return this;
}
/***
* getOwn... methods will be removed in the future in favor of Tradeparty (e.g. Sender) class
* */
// @Override
// @Deprecated
// @JsonIgnore
// public String getOwnBIC() {
// return getBIC();
// }
//
// @Override
// @Deprecated
// @JsonIgnore
// public String getOwnIBAN() {
// return getIBAN();
// }
/*
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
@JsonIgnore
public String getOwnBIC() {
return getBIC();
}
@Override
@Deprecated
@JsonIgnore
public String getOwnIBAN() {
return getIBAN();
}
/**
* set Holder
*
* @param name account name (usually account holder if != sender)
* @return fluent setter
*/
@@ -118,5 +124,4 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
}
}

View File

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

View File

@@ -277,6 +277,7 @@ public class ZUGFeRDInvoiceImporter {
public void setID(String id) {
String ud = id;
}
/***
* This will parse a XML into the given invoice object
* @param zpp the invoice to be altered
@@ -306,51 +307,51 @@ public class ZUGFeRDInvoiceImporter {
}
//UBL...
XPathExpression shipExUBL = xpath.compile("//*[local-name()=\"Delivery\"]");
Node deliveryNode = (Node) shipExUBL.evaluate(getDocument(), XPathConstants.NODE);
if (deliveryNode != null) {
TradeParty delivery = new TradeParty();
NodeMap nodeMap = new NodeMap(deliveryNode).getAsNodeMap("DeliveryLocation").get();
new NodeMap(deliveryNode).getAsNodeMap("DeliveryLocation").ifPresent(
deliveryLocationNodeMap -> {
if (nodeMap != null) {
nodeMap.getNode("ID").ifPresent(s -> {
deliveryLocationNodeMap.getNode("ID").ifPresent(s -> {
SchemedID sID = new SchemedID().setScheme(s.getAttributes().getNamedItem("schemeID").getTextContent()).setId(s.getTextContent());
delivery.addGlobalID(sID);
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("StreetName").ifPresent(t -> delivery.setStreet(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("CityName").ifPresent(t -> delivery.setLocation(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("PostalZone").ifPresent(t -> delivery.setZIP(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsNodeMap("Country").ifPresent(t -> t.getAsString("IdentificationCode").ifPresent(u -> delivery.setCountry(u)));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsNodeMap("AddressLine").ifPresent(t -> t.getAsString("Line").ifPresent(u -> delivery.setAdditionalAddressExtension(u)));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
deliveryLocationNodeMap.getAsNodeMap("Address").ifPresent(s -> {
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
});
}
});
NodeMap partyMap = new NodeMap(deliveryNode).getAsNodeMap("DeliveryParty").get();
if (partyMap!=null) {
partyMap.getAsNodeMap("PartyName").ifPresent(s->{s.getAsString("Name").ifPresent(t->delivery.setName(t));});
}
new NodeMap(deliveryNode).getAsNodeMap("DeliveryParty").ifPresent(partyMap -> {
partyMap.getAsNodeMap("PartyName").ifPresent(s -> {
s.getAsString("Name").ifPresent(t -> delivery.setName(t));
});
});
String street, name, additionalStreet, city, postal, countrySubentity, line, country = null;
/*
String idx = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"ID\"]");
@@ -508,15 +509,33 @@ public class ZUGFeRDInvoiceImporter {
}
}
switch (subjectCode) {
case "AAI": includedNotes.add(IncludedNote.generalNote(content)); break;
case "REG": includedNotes.add(IncludedNote.regulatoryNote(content)); break;
case "ABL": includedNotes.add(IncludedNote.legalNote(content)); 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;
case "AAI":
includedNotes.add(IncludedNote.generalNote(content));
break;
case "REG":
includedNotes.add(IncludedNote.regulatoryNote(content));
break;
case "ABL":
includedNotes.add(IncludedNote.legalNote(content));
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);