Skip to content

Commit

Permalink
Added Peppol PINT Singapore 1.1.0 rules
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jul 25, 2024
1 parent 8c12280 commit d12ce7c
Show file tree
Hide file tree
Showing 31 changed files with 13,500 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ I hope that with the introduction of PINT, the versioning problem will be solved
* Added Peppol PINT rules 1.0.2
* Added Peppol PINT A-NZ 1.0.1 rules (billing and self-billing)
* Added Peppol PINT Japan 1.0.2 rules
* Added Peppol PINT Singapore 1.1.0 rules
* v3.1.11 - 2024-07-02
* Added Peppol May 2024 release (Billing 3.0.17 and Upgrade 3.0.13)
* Added Peppol A-NZ-PEPPOL 1.0.11 rules
Expand Down
Binary file not shown.
Binary file not shown.
56 changes: 34 additions & 22 deletions phive-rules-peppol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@
</configuration>
</execution>
-->
<!--
<execution>
<id>bis-aunz</id>
<goals>
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>src/test/resources/external/rule-source/aunz-peppol/1.0.11</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/peppol-aunz/1.0.11/xslt</xsltDirectory>
</configuration>
</execution>
-->
<!--
<execution>
<id>bis-sg</id>
<goals>
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>src/test/resources/external/rule-source/sg-peppol/2023.12</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/peppol-sg/2023.12/xslt</xsltDirectory>
</configuration>
</execution>
-->
<!--
<execution>
<id>pint</id>
Expand Down Expand Up @@ -173,51 +197,39 @@
</configuration>
</execution>
-->
<!--
<!--
<execution>
<id>reporting-eusr</id>
<id>pint-sg</id>
<goals>
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>src/test/resources/external/rule-source/reporting/eusr/1.1.5</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/reporting/eusr/1.1.5/xslt</xsltDirectory>
<schematronDirectory>src/test/resources/external/rule-source/pint-sg/1.1.0</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/pint-sg/1.1.0/xslt</xsltDirectory>
</configuration>
</execution>
-->
<!--
<execution>
<id>reporting-tsr</id>
<goals>
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>src/test/resources/external/rule-source/reporting/tsr/1.0.5</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/reporting/tsr/1.0.5/xslt</xsltDirectory>
</configuration>
</execution>
-->
<!--
<execution>
<id>aunz-peppol</id>
<id>reporting-eusr</id>
<goals>
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>src/test/resources/external/rule-source/aunz-peppol/1.0.11</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/peppol-aunz/1.0.11/xslt</xsltDirectory>
<schematronDirectory>src/test/resources/external/rule-source/reporting/eusr/1.1.5</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/reporting/eusr/1.1.5/xslt</xsltDirectory>
</configuration>
</execution>
-->
<!--
<execution>
<id>sg-peppol</id>
<id>reporting-tsr</id>
<goals>
<goal>convert</goal>
</goals>
<configuration>
<schematronDirectory>src/test/resources/external/rule-source/sg-peppol/2023.12</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/peppol-sg/2023.12/xslt</xsltDirectory>
<schematronDirectory>src/test/resources/external/rule-source/reporting/tsr/1.0.5</schematronDirectory>
<xsltDirectory>src/main/resources/external/schematron/reporting/tsr/1.0.5/xslt</xsltDirectory>
</configuration>
</execution>
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static void initStandard (@Nonnull final IValidationExecutorSetRegistry <
PeppolValidationPintAUNZ.init (aRegistry);
PeppolValidationPintJP.init (aRegistry);
PeppolValidationPintMY.init (aRegistry);
PeppolValidationPintSG.init (aRegistry);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (C) 2014-2024 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.phive.peppol;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.io.resource.ClassPathResource;
import com.helger.diver.api.version.VESID;
import com.helger.phive.api.executorset.IValidationExecutorSetRegistry;
import com.helger.phive.api.executorset.ValidationExecutorSet;
import com.helger.phive.api.executorset.status.IValidationExecutorSetStatus;
import com.helger.phive.api.executorset.status.ValidationExecutorSetStatus;
import com.helger.phive.xml.schematron.SchematronNamespaceBeautifier;
import com.helger.phive.xml.schematron.ValidationExecutorSchematron;
import com.helger.phive.xml.source.IValidationSourceXML;
import com.helger.phive.xml.xsd.ValidationExecutorXSD;
import com.helger.ubl21.UBL21Marshaller;
import com.helger.xml.namespace.MapBasedNamespaceContext;

/**
* Peppol Singapore validation configuration
*
* @author Philip Helger
*/
@Immutable
public final class PeppolValidationPintSG
{
@Nonnull
private static ClassLoader _getCL ()
{
return PeppolValidationPintSG.class.getClassLoader ();
}

private static final String BASE_PATH = "external/schematron/pint-sg/";
private static final String GROUP_ID = "org.peppol.pint.sg";

// 1.0.1
public static final VESID VID_OPENPEPPOL_SG_PINT_UBL_INVOICE_1_1_0 = new VESID (GROUP_ID, "invoice", "1.1.0");
public static final VESID VID_OPENPEPPOL_SG_PINT_UBL_CREDIT_NOTE_1_1_0 = new VESID (GROUP_ID, "creditnote", "1.1.0");

private PeppolValidationPintSG ()
{}

@Nonnull
private static IValidationExecutorSetStatus _createStatus (final boolean bIsDeprecated)
{
return ValidationExecutorSetStatus.createDeprecatedNow (bIsDeprecated);
}

public static void init (@Nonnull final IValidationExecutorSetRegistry <IValidationSourceXML> aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");

final MapBasedNamespaceContext aNSCtxInvoice = PeppolValidation.createUBLNSContext (UBL21Marshaller.invoice ()
.getRootElementNamespaceURI ());
final MapBasedNamespaceContext aNSCtxCreditNote = PeppolValidation.createUBLNSContext (UBL21Marshaller.creditNote ()
.getRootElementNamespaceURI ());

// For better error messages (merge both)
SchematronNamespaceBeautifier.addMappings (aNSCtxCreditNote);

final boolean bNotDeprecated = false;

// 1.0.1
{
final String sBaseBilling = BASE_PATH + "1.1.0/xslt/";
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_OPENPEPPOL_SG_PINT_UBL_INVOICE_1_1_0,
"Peppol PINT Singapore Invoice (UBL) 1.1.0",
_createStatus (bNotDeprecated),
ValidationExecutorXSD.create (UBL21Marshaller.getAllInvoiceXSDs ()),
ValidationExecutorSchematron.createXSLT (new ClassPathResource (sBaseBilling +
"PINT-UBL-validation-preprocessed-inv.xslt",
_getCL ()),
aNSCtxInvoice),
ValidationExecutorSchematron.createXSLT (new ClassPathResource (sBaseBilling +
"PINT-jurisdiction-aligned-rules-inv.xslt",
_getCL ()),
aNSCtxInvoice)));
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_OPENPEPPOL_SG_PINT_UBL_CREDIT_NOTE_1_1_0,
"Peppol PINT Singapore Credit Note (UBL) 1.1.0",
_createStatus (bNotDeprecated),
ValidationExecutorXSD.create (UBL21Marshaller.getAllCreditNoteXSDs ()),
ValidationExecutorSchematron.createXSLT (new ClassPathResource (sBaseBilling +
"PINT-UBL-validation-preprocessed-cn.xslt",
_getCL ()),
aNSCtxInvoice),
ValidationExecutorSchematron.createXSLT (new ClassPathResource (sBaseBilling +
"PINT-jurisdiction-aligned-rules-cn.xslt",
_getCL ()),
aNSCtxInvoice)));
}
}
}
Loading

0 comments on commit d12ce7c

Please sign in to comment.