Skip to content

Commit

Permalink
Support for validation (Part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Oct 4, 2024
1 parent 67b3f3e commit 6560e10
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ZugferdMailReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Webklex\PHPIMAP\ClientManager;
use horstoeko\zugferd\ZugferdDocumentReader;
use horstoeko\zugferd\ZugferdDocumentPdfReader;
use horstoeko\zugferd\ZugferdKositValidator;
use horstoeko\zugferd\ZugferdXsdValidator;
use horstoeko\zugferdmail\config\ZugferdMailConfig;
use horstoeko\zugferdmail\config\ZugferdMailAccount;
Expand Down Expand Up @@ -199,6 +200,11 @@ protected function checkSingleMessageAttachment(ZugferdMailAccount $account, Fol
$this->raiseRuntimeExceptionIf($validator->validate()->validationFailed(), "XSD-Validation of document failed");
$this->addSuccessMessageToMessageBag('The document was successfully validated againt XSD scheme', $messageAdditionalData);
}
if ($this->config->getKositValidationEnabled()) {
$validator = new ZugferdKositValidator($document);
$this->raiseRuntimeExceptionIf($validator->validate()->hasValidationErrors(), "Validation against KosIT Validation failed");
$this->addSuccessMessageToMessageBag('The document was successfully validated with the KosIT validator', $messageAdditionalData);
}
$this->triggerHandlers($account, $folder, $message, $attachment, $document, ZugferdMailReaderRecognitionType::ZFMAIL_RECOGNITION_TYPE_PDF_CII);
} catch (Throwable $e) {
$this->addWarningMessageToMessageBag(sprintf("No ZUGFeRD compatible PDF found (%s)", $e->getMessage()), $messageAdditionalData);
Expand All @@ -215,6 +221,11 @@ protected function checkSingleMessageAttachment(ZugferdMailAccount $account, Fol
$this->raiseRuntimeExceptionIf($validator->validate()->validationFailed(), "XSD-Validation of document failed");
$this->addSuccessMessageToMessageBag('The document was successfully validated againt XSD scheme', $messageAdditionalData);
}
if ($this->config->getKositValidationEnabled()) {
$validator = new ZugferdKositValidator($document);
$this->raiseRuntimeExceptionIf($validator->validate()->hasValidationErrors(), "Validation against KosIT Validation failed");
$this->addSuccessMessageToMessageBag('The document was successfully validated with the KosIT validator', $messageAdditionalData);
}
$this->triggerHandlers($account, $folder, $message, $attachment, $document, ZugferdMailReaderRecognitionType::ZFMAIL_RECOGNITION_TYPE_XML_CII);
} catch (Throwable $e) {
$this->addWarningMessageToMessageBag(sprintf("No ZUGFeRD compatible XML found (%s)", $e->getMessage()), $messageAdditionalData);
Expand All @@ -234,6 +245,11 @@ protected function checkSingleMessageAttachment(ZugferdMailAccount $account, Fol
$this->raiseRuntimeExceptionIf($validator->validate()->validationFailed(), "XSD-Validation of document failed");
$this->addSuccessMessageToMessageBag('The document was successfully validated againt XSD scheme', $messageAdditionalData);
}
if ($this->config->getKositValidationEnabled()) {
$validator = new ZugferdKositValidator($document);
$this->raiseRuntimeExceptionIf($validator->validate()->hasValidationErrors(), "Validation against KosIT Validation failed");
$this->addSuccessMessageToMessageBag('The document was successfully validated with the KosIT validator', $messageAdditionalData);
}
$this->triggerHandlers($account, $folder, $message, $attachment, $document, ZugferdMailReaderRecognitionType::ZFMAIL_RECOGNITION_TYPE_XML_UBL);
} catch (Throwable $e) {
$this->addWarningMessageToMessageBag(sprintf("No UBL compatible XML found (%s)", $e->getMessage()), $messageAdditionalData);
Expand Down

0 comments on commit 6560e10

Please sign in to comment.