From 735d0e6688a8bad871a1d1a7d8daa4f30c4c03e2 Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Tue, 12 Sep 2023 16:46:32 +0200 Subject: [PATCH] Avoid counting Reporting Docs for Reporting --- .../phase4/peppol/Phase4PeppolSender.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/phase4-peppol-client/src/main/java/com/helger/phase4/peppol/Phase4PeppolSender.java b/phase4-peppol-client/src/main/java/com/helger/phase4/peppol/Phase4PeppolSender.java index 8d72b9d46..fa8c132f2 100644 --- a/phase4-peppol-client/src/main/java/com/helger/phase4/peppol/Phase4PeppolSender.java +++ b/phase4-peppol-client/src/main/java/com/helger/phase4/peppol/Phase4PeppolSender.java @@ -86,6 +86,7 @@ import com.helger.smpclient.url.IPeppolURLProvider; import com.helger.smpclient.url.PeppolURLProvider; import com.helger.xml.serialize.read.DOMReader; +import com.helper.peppol.reporting.api.PeppolReportingHelper; import com.helper.peppol.reporting.api.PeppolReportingItem; import com.helper.peppol.reporting.api.backend.PeppolReportingBackend; import com.helper.peppol.reporting.api.backend.PeppolReportingBackendException; @@ -955,20 +956,30 @@ public final void createAndStorePeppolReportingItemAfterSending (@Nonnull @Nonem if (PeppolReportingBackend.getBackendService () == null) throw new Phase4PeppolException ("No Peppol Reporting Backend is available. Cannot store Reporting Items"); - try + // Filter out document types on Reporting + if (PeppolReportingHelper.isDocumentTypeEligableForReporting (m_aDocTypeID)) { - LOGGER.info ("Creating Peppol Reporting Item and storing it"); + try + { + LOGGER.info ("Creating Peppol Reporting Item and storing it"); - // Create reporting item - final PeppolReportingItem aReportingItem = createPeppolReportingItemAfterSending (sEndUserID); + // Create reporting item + final PeppolReportingItem aReportingItem = createPeppolReportingItemAfterSending (sEndUserID); - // Store it in configured backend - PeppolReportingBackend.withBackendDo (AS4Configuration.getConfig (), - aBackend -> aBackend.storeReportingItem (aReportingItem)); + // Store it in configured backend + PeppolReportingBackend.withBackendDo (AS4Configuration.getConfig (), + aBackend -> aBackend.storeReportingItem (aReportingItem)); + } + catch (final PeppolReportingBackendException ex) + { + throw new Phase4PeppolException ("Failed to store Peppol Reporting Item", ex); + } } - catch (final PeppolReportingBackendException ex) + else { - throw new Phase4PeppolException ("Failed to store Peppol Reporting Item", ex); + LOGGER.info ("The Document Type ID is not eligible for Peppol Reporting: '" + + m_aDocTypeID.getURIEncoded () + + "'"); } } }