Skip to content

Commit

Permalink
Upgrade Factur-x xsd to v1.0.07
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Clutier authored and Benjamin Dieleman committed Oct 28, 2024
1 parent f4c74fb commit b55e16c
Show file tree
Hide file tree
Showing 33 changed files with 20,913 additions and 6,504 deletions.
5 changes: 3 additions & 2 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Reader
{
public const FACTURX_FILENAME = 'factur-x.xml';

public const ALLOWED_FILENAMES = ['factur-x.xml', 'zugferd-invoice.xml'];

public array $smalotPdfParserCfg = [];
public ?\Smalot\PdfParser\Config $smalotPdfParserConfig = null;

Expand All @@ -23,7 +25,6 @@ class Reader
* @param bool $validateXsd validates Factur-X XML against official XSD and throws exception if validation failed
*
* @throws \Exception
*
* @return string
*/
public function extractXML(string $pdfBinary, bool $validateXsd = true): string
Expand All @@ -38,7 +39,7 @@ public function extractXML(string $pdfBinary, bool $validateXsd = true): string
$facturxLength = null;
foreach ($filespec as $spec) {
$specDetails = $spec->getDetails();
if (static::FACTURX_FILENAME == $specDetails['F']) {
if (in_array($specDetails['F'], static::ALLOWED_FILENAMES)) {
$found = true;
if (!empty($specDetails['EF']) && isset($specDetails['EF']['F']) && isset($specDetails['EF']['F']['Length'])) {
$facturxLength = $specDetails['EF']['F']['Length']; // Get file size
Expand Down
10 changes: 5 additions & 5 deletions src/XsdValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
class XsdValidator
{
public const XSD_FILENAMES = [
ProfileHandler::PROFILE_FACTURX_MINIMUM => 'factur-x/minimum/FACTUR-X_MINIMUM.xsd',
ProfileHandler::PROFILE_FACTURX_BASICWL => 'factur-x/basic-wl/FACTUR-X_BASIC-WL.xsd',
ProfileHandler::PROFILE_FACTURX_BASIC => 'factur-x/basic/FACTUR-X_BASIC.xsd',
ProfileHandler::PROFILE_FACTURX_EN16931 => 'factur-x/en16931/FACTUR-X_EN16931.xsd',
ProfileHandler::PROFILE_FACTURX_EXTENDED => 'factur-x/extended/FACTUR-X_EXTENDED.xsd',
ProfileHandler::PROFILE_FACTURX_MINIMUM => 'factur-x/minimum/Factur-X_1.0.07_MINIMUM.xsd',
ProfileHandler::PROFILE_FACTURX_BASICWL => 'factur-x/basic-wl/Factur-X_1.0.07_BASICWL.xsd',
ProfileHandler::PROFILE_FACTURX_BASIC => 'factur-x/basic/Factur-X_1.0.07_BASIC.xsd',
ProfileHandler::PROFILE_FACTURX_EN16931 => 'factur-x/en16931/Factur-X_1.0.07_EN16931.xsd',
ProfileHandler::PROFILE_FACTURX_EXTENDED => 'factur-x/extended/Factur-X_1.0.07_EXTENDED.xsd',
ProfileHandler::PROFILE_ZUGFERD => 'zugferd/ZUGFeRD1p0.xsd',
];

Expand Down
Loading

0 comments on commit b55e16c

Please sign in to comment.