Skip to content

Commit

Permalink
Added Zugferd 2.2 XML validation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Dec 5, 2024
1 parent c6c7d30 commit abf59f5
Show file tree
Hide file tree
Showing 76 changed files with 382,414 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ I hope that with the introduction of PINT, the versioning problem will be solved
* Deprecated Simplerinvoicing Invoice 2.0.3.8, Simplerinvoicing 2.0 G-Account extension 1.0.8 and NLCIUS-CII 1.0.3.7
* Added Simplerinvoicing Invoice 2.0.3.10, Simplerinvoicing 2.0 G-Account extension 1.0.10 and NLCIUS-CII 1.0.3.9
* Added support for CII D22B XML Schema validation
* Added support for ZuGFERD 2.2 - all profiles (XML only)
* Added support for ZuGFERD 2.3.2 - all profiles (XML only)
* v3.2.1 - 2024-10-09
* Added support for EN 16931 rules v1.3.13 format and deprecated v1.3.11
Expand Down
1 change: 1 addition & 0 deletions phive-rules-zugferd/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
zugferd22en/
ZF232_EN/
14 changes: 12 additions & 2 deletions phive-rules-zugferd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<groupId>com.helger.phive.rules</groupId>
<artifactId>phive-rules-api</artifactId>
</dependency>
<dependency>
<groupId>com.helger.phive.rules</groupId>
<artifactId>phive-rules-en16931</artifactId>
</dependency>
<dependency>
<groupId>com.helger.cii</groupId>
<artifactId>ph-cii-d16b</artifactId>
Expand All @@ -88,6 +92,12 @@
<artifactId>jaxb-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -117,8 +127,8 @@
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>${basedir}/src/test/resources/external/rule-source/2.3.2</schematronDirectory>
<xsltDirectory>${basedir}/src/main/resources/external/schematron/2.3.2</xsltDirectory>
<schematronDirectory>${basedir}/src/test/resources/external/rule-source/2.2</schematronDirectory>
<xsltDirectory>${basedir}/src/main/resources/external/schematron/2.2</xsltDirectory>
<schematronPattern>*.sch</schematronPattern>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.helger.phive.api.executorset.IValidationExecutorSetRegistry;
import com.helger.phive.api.executorset.ValidationExecutorSet;
import com.helger.phive.api.executorset.ValidationExecutorSetAlias;
import com.helger.phive.api.executorset.status.IValidationExecutorSetStatus;
import com.helger.phive.en16931.EN16931Validation;
import com.helger.phive.rules.api.PhiveRulesCIIHelper;
import com.helger.phive.rules.api.PhiveRulesHelper;
import com.helger.phive.xml.source.IValidationSourceXML;
Expand All @@ -45,6 +47,23 @@ public final class ZugferdValidation
public static final String GROUP_ID_ZUGFERD = "de.zugferd";
public static final String GROUP_ID_FACTUR_X = "fr.factur-x";

// v2.2
public static final DVRCoordinate VID_ZUGFERD_2_2_MINIMUM = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
EZugferdProfile.MINIMUM.getArtifactID (),
"2.2");
public static final DVRCoordinate VID_ZUGFERD_2_2_BASIC_WL = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
EZugferdProfile.BASIC_WL.getArtifactID (),
"2.2");
public static final DVRCoordinate VID_ZUGFERD_2_2_BASIC = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
EZugferdProfile.BASIC.getArtifactID (),
"2.2");
public static final DVRCoordinate VID_ZUGFERD_2_2_EN16931 = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
EZugferdProfile.EN16931.getArtifactID (),
"2.2");
public static final DVRCoordinate VID_ZUGFERD_2_2_EXTENDED = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
EZugferdProfile.EXTENDED.getArtifactID (),
"2.2");

// v2.3.2
public static final DVRCoordinate VID_ZUGFERD_2_3_2_MINIMUM = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
EZugferdProfile.MINIMUM.getArtifactID (),
Expand All @@ -66,7 +85,8 @@ public final class ZugferdValidation
private static final ICommonsMap <DVRVersion, DVRVersion> ZUGFERD_TO_FACTURX_MAP = new CommonsHashMap <> ();
static
{
ZUGFERD_TO_FACTURX_MAP.put (DVRVersion.parseOrNull ("2.3.2"), DVRVersion.parseOrNull ("1.7.2"));
ZUGFERD_TO_FACTURX_MAP.put (DVRVersion.parseOrNull ("2.2"), DVRVersion.parseOrNull ("1.0.6"));
ZUGFERD_TO_FACTURX_MAP.put (DVRVersion.parseOrNull ("2.3.2"), DVRVersion.parseOrNull ("1.0.7-2"));
}

private ZugferdValidation ()
Expand Down Expand Up @@ -106,14 +126,65 @@ private static void _registerFacturXAlias (@Nonnull final IValidationExecutorSet
* @param aRegistry
* The registry to add the artefacts. May not be <code>null</code>.
*/
@SuppressWarnings ("deprecation")
public static void initZugferd (@Nonnull final IValidationExecutorSetRegistry <IValidationSourceXML> aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");

// final boolean bDeprecated = true;
final boolean bNotDeprecated = false;

// Zugferd 2.3.2 / Factur-X 1.07.2
// Zugferd 2.2 / Factur-X 1.0.6
for (final EZugferdProfile eProfile : EZugferdProfile.values ())
{
final String sZugferdVersion = "2.2";
final String sFilenameSuffix = eProfile == EZugferdProfile.BASIC_WL ? "BASIC-WL" : eProfile.getFilenameSuffix ();

final var aVESchematron = PhiveRulesCIIHelper.createXSLT_CII_D16B (new ClassPathResource ("/external/schematron/" +
sZugferdVersion +
"/Factur-X_" +
sFilenameSuffix +
".xslt",
_getCL ()));

// Register as Zugferd
final DVRCoordinate aVESID = PhiveRulesHelper.createCoordinate (GROUP_ID_ZUGFERD,
eProfile.getArtifactID (),
sZugferdVersion);
final String sDisplayName = "ZUGFeRD " + sZugferdVersion + " (" + eProfile.getDisplayName () + ")";
final IValidationExecutorSetStatus aStatus = PhiveRulesHelper.createSimpleStatus (bNotDeprecated);
final ValidationExecutorSet <IValidationSourceXML> aVES;
if (eProfile == EZugferdProfile.EN16931)
{
// Based on 1.3.7-SNAPSHOT
aVES = ValidationExecutorSet.createDerived (aRegistry.getOfID (EN16931Validation.VID_CII_137),
aVESID,
sDisplayName,
aStatus,
aVESchematron);
}
else
{
aVES = ValidationExecutorSet.create (aVESID,
sDisplayName,
aStatus,
ValidationExecutorXSD.create (new ClassPathResource ("/external/schemas/" +
sZugferdVersion +
"/" +
eProfile.getFolderName () +
"/Factur-X_" +
sFilenameSuffix +
".xsd",
_getCL ())),
aVESchematron);
}
aRegistry.registerValidationExecutorSet (aVES);

// Also register alias as Factur-X
_registerFacturXAlias (aRegistry, aVES);
}

// Zugferd 2.3.2 / Factur-X 1.0.7-2
for (final EZugferdProfile eProfile : EZugferdProfile.values ())
{
final String sZugferdVersion = "2.3.2";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
targetNamespace="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
elementFormDefault="qualified">
<xs:import namespace="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" schemaLocation="FACTUR-X_BASIC_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd"/>
<xs:import namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" schemaLocation="FACTUR-X_BASIC_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd"/>
<xs:import namespace="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" schemaLocation="FACTUR-X_BASIC_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd"/>
<xs:element name="CrossIndustryInvoice" type="rsm:CrossIndustryInvoiceType"/>
<xs:complexType name="CrossIndustryInvoiceType">
<xs:sequence>
<xs:element name="ExchangedDocumentContext" type="ram:ExchangedDocumentContextType"/>
<xs:element name="ExchangedDocument" type="ram:ExchangedDocumentType"/>
<xs:element name="SupplyChainTradeTransaction" type="ram:SupplyChainTradeTransactionType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Loading

0 comments on commit abf59f5

Please sign in to comment.