Merge branch 'master' into feature/optimize_pom.xml_1

This commit is contained in:
Frank Langelage
2025-10-07 22:12:06 +02:00
committed by GitHub
30 changed files with 864 additions and 159 deletions

View File

@@ -14,6 +14,7 @@ public class ValidationContext {
private String profile = null;
private String signature = null;
private boolean isValid = true;
private boolean hasPDF = false;
protected Logger logger;
private String filename;
@@ -22,6 +23,14 @@ public class ValidationContext {
results = new Vector<>();
}
public void setHasPDF() {
hasPDF=true;
}
public boolean hasPDF() {
return hasPDF;
}
public void addResultItem(ValidationResultItem vr) throws IrrecoverableValidationError {
results.add(vr);

View File

@@ -374,6 +374,14 @@ public class XMLValidator extends Validator {
addUnsupportedProfileResultItem();
}
}
} else {
// no CII -> has to be UBL
if (context.hasPDF()) {
final ValidationResultItem vri = new ValidationResultItem(ESeverity.error, "Factur-X/ZUGFeRD and Order-X are always strictly CII only, no UBL allowed.").setSection(17)
.setPart(EPart.fx);
context.addResultItem(vri);
}
}
if (xsltFilename != null) {
@@ -536,12 +544,15 @@ public class XMLValidator extends Validator {
}
ESeverity severity;
Node failNode = currentFailNode.getAttributes().getNamedItem("flag");
String failVal = failNode == null ? null : failNode.getNodeValue();
if (defaultSeverity == ESeverity.notice) {
severity = defaultSeverity;
} else if (currentFailNode.getAttributes().getNamedItem("flag") != null
&& "warning".equals(currentFailNode.getAttributes().getNamedItem("flag").getNodeValue())) {
} else if ("warning".equals(failVal)) {
// the XR issues warnings with flag=warning
severity = ESeverity.warning;
} else if ("information".equals(failVal)) {
severity = ESeverity.notice;
} else {
severity = ESeverity.error;
}

View File

@@ -121,6 +121,7 @@ public class ZUGFeRDValidator {
// Avoid reading again from file
pdfv.setFilenameAndContents(contextFilename, content);
context.setHasPDF();
optionsRecognized = true;
finalStringResult.append("<pdf>");
try {

View File

@@ -202,7 +202,7 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
assertThat(res).valueByXPath("count(//notice)")
.asInt()
.isEqualTo(0);
.isEqualTo(1);
assertThat(res).valueByXPath("/validation/summary/@status")
.asString()
.isEqualTo("valid");// expect to be valid because XR notices are, well, only notices
@@ -216,14 +216,14 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
assertThat(res).valueByXPath("count(//error)")
.asInt()
.isEqualTo(5);
.isEqualTo(4);
assertThat(res).valueByXPath("count(//warning)")
.asInt()
.isEqualTo(1);
assertThat(res).valueByXPath("count(//notice)")
.asInt()
.isEqualTo(0); // 12 notices RE XRechnung 3.0
.isEqualTo(1); // 12 notices RE XRechnung 3.0
assertThat(res).valueByXPath("/validation/summary/@status")
.asString()
.isEqualTo("invalid");// expect to be valid

View File

@@ -102,6 +102,32 @@
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>Zeitlose Dienstleistung</ram:LineID>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:Name>Zeitlose Dienstleistung</ram:Name>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>0.00</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="XPP">1</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>7</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount>0.00</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>04011000-12345-03</ram:BuyerReference>
<ram:SellerTradeParty>