Skip to content

Commit

Permalink
Added support for CII D22B XML Schema validation
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Dec 5, 2024
1 parent eaedfc1 commit 3d26bed
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ I hope that with the introduction of PINT, the versioning problem will be solved
* Added Peppol PINT JP Self Billing 1.0.1 release
* 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
* v3.2.1 - 2024-10-09
* Added support for EN 16931 rules v1.3.13 format and deprecated v1.3.11
* v3.2.0 - 2024-09-16
Expand Down
5 changes: 5 additions & 0 deletions phive-rules-cii/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<artifactId>ph-cii-d16b</artifactId>
<version>${ph-cii.version}</version>
</dependency>
<dependency>
<groupId>com.helger.cii</groupId>
<artifactId>ph-cii-d22b</artifactId>
<version>${ph-cii.version}</version>
</dependency>
<dependency>
<groupId>com.helger.phive.rules</groupId>
<artifactId>phive-rules-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.concurrent.Immutable;

import com.helger.cii.d16b.CCIID16B;
import com.helger.cii.d22b.CCIID22B;
import com.helger.commons.ValueEnforcer;
import com.helger.diver.api.coord.DVRCoordinate;
import com.helger.phive.api.executorset.IValidationExecutorSetRegistry;
Expand All @@ -38,20 +39,38 @@ public final class CIIValidation
{
public static final String GROUP_ID = "un.unece.uncefact";
public static final String VERSION_D16B = "D16B";
public static final String VERSION_D22B = "D22B";

public static final DVRCoordinate VID_CII_D16B_CROSSINDUSTRYINVOICE = PhiveRulesHelper.createCoordinate (GROUP_ID,
"crossindustryinvoice",
VERSION_D16B);
public static final DVRCoordinate VID_CII_D22B_CROSSINDUSTRYINVOICE = PhiveRulesHelper.createCoordinate (GROUP_ID,
"crossindustryinvoice",
VERSION_D22B);

private CIIValidation ()
{}

/**
* Register all supported CII validation execution sets to the provided
* registry.
*
* @param aRegistry
* The registry to add the artefacts to. May not be <code>null</code>.
* @since 3.2.2
*/
public static void initCII (@Nonnull final IValidationExecutorSetRegistry <IValidationSourceXML> aRegistry)
{
initCIID16B (aRegistry);
initCIID22B (aRegistry);
}

/**
* Register all standard CII D16B validation execution sets to the provided
* registry.
*
* @param aRegistry
* The registry to add the artefacts. May not be <code>null</code>.
* The registry to add the artefacts to. May not be <code>null</code>.
*/
public static void initCIID16B (@Nonnull final IValidationExecutorSetRegistry <IValidationSourceXML> aRegistry)
{
Expand All @@ -65,4 +84,25 @@ public static void initCIID16B (@Nonnull final IValidationExecutorSetRegistry <I
PhiveRulesHelper.createSimpleStatus (bNotDeprecated),
ValidationExecutorXSD.create (CCIID16B.getXSDResource ())));
}

/**
* Register all standard CII D22B validation execution sets to the provided
* registry.
*
* @param aRegistry
* The registry to add the artefacts to. May not be <code>null</code>.
* @since 3.2.2
*/
public static void initCIID22B (@Nonnull final IValidationExecutorSetRegistry <IValidationSourceXML> aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");

final boolean bNotDeprecated = false;

// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_CII_D22B_CROSSINDUSTRYINVOICE,
"CII CrossIndustryInvoice " + VERSION_D22B,
PhiveRulesHelper.createSimpleStatus (bNotDeprecated),
ValidationExecutorXSD.create (CCIID22B.getXSDResource ())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class CTestFiles
public static final ValidationExecutorSetRegistry <IValidationSourceXML> VES_REGISTRY = new ValidationExecutorSetRegistry <> ();
static
{
CIIValidation.initCIID16B (VES_REGISTRY);
CIIValidation.initCII (VES_REGISTRY);
}

private CTestFiles ()
Expand All @@ -51,7 +51,8 @@ private CTestFiles ()
public static ICommonsList <PhiveTestFile> getAllTestFiles ()
{
final ICommonsList <PhiveTestFile> ret = new CommonsArrayList <> ();
for (final DVRCoordinate aESID : new DVRCoordinate [] { CIIValidation.VID_CII_D16B_CROSSINDUSTRYINVOICE })
for (final DVRCoordinate aESID : new DVRCoordinate [] { CIIValidation.VID_CII_D16B_CROSSINDUSTRYINVOICE,
CIIValidation.VID_CII_D22B_CROSSINDUSTRYINVOICE })
for (final IReadableResource aRes : getAllMatchingTestFiles (aESID))
{
assertTrue ("Not existing test file: " + aRes.getPath (), aRes.exists ());
Expand All @@ -70,6 +71,10 @@ public static ICommonsList <? extends IReadableResource> getAllMatchingTestFiles
{
return new CommonsArrayList <> (CIITestFiles.D16B_FILES, ClassPathResource::new);
}
if (aVESID.equals (CIIValidation.VID_CII_D22B_CROSSINDUSTRYINVOICE))
{
return new CommonsArrayList <> (CIITestFiles.D22B_FILES, ClassPathResource::new);
}

throw new IllegalArgumentException ("Invalid VESID: " + aVESID);
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<jaxb-plugin.artifact>jaxb-maven-plugin</jaxb-plugin.artifact>
<jaxb-plugin.version>4.0.8</jaxb-plugin.version>
<peppol-commons.version>9.6.0</peppol-commons.version>
<ph-cii.version>3.0.2</ph-cii.version>
<ph-cii.version>3.1.0</ph-cii.version>
<ph-ebinterface.version>7.1.0</ph-ebinterface.version>
<ph-fatturapa.version>2.0.2</ph-fatturapa.version>
<ph-jaxb-plugin.version>4.0.3</ph-jaxb-plugin.version>
Expand Down

0 comments on commit 3d26bed

Please sign in to comment.