diff --git a/README.md b/README.md index f4390e9..55d052f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,28 @@ if ($document instanceof CrossIndustryInvoice) { You can refer to the [tests](https://github.com/easybill/e-invoicing/tree/main/tests/Integration) in this repository for examples of using this library. +## Customization +This library offers some degree of customization. You may create a customized Reader, Transformer or Writer. +By default, the library does not trim whitespaces around values. This is true for values which do not end as enums. +If you want to add that the functionality to trim the values you may refer to this [test](https://github.com/easybill/e-invoicing/tree/main/tests/Integration/SerializerTest). + +```PHP + $transformer = new Transformer(ConfiguredSerializer::createWithHandlers([ + new TrimStringValueHandler(), + new CountryCodeEnumHandler(), + new CurrencyCodeEnumHandler(), + new DocumentTypeEnumHandler(), + new ReferenceQualifierEnumHandler(), + new UnitCodeEnumHandler(), + new MimeTypeEnumHandler(), + new ElectronicAddressSchemeIdentifierEnumHandler(), +])); +``` + + +This allows to register custom handlers, or even add handlers which the library offers but does not include by default (yet) +like the TrimStringValueHandler. + ## Considerations ### Limitations diff --git a/composer.json b/composer.json index 4515132..2dbce76 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,5 @@ { "name": "easybill/e-invoicing", - "version": "0.2.3", "description": "A package to read and create EN16931 e-invoices or CIUS like: XRechnung, ZUGFeRD etc.", "type": "library", "license": "MIT", @@ -48,7 +47,9 @@ "pestphp/pest": "^2.35", "phpstan/phpstan": "^1.12", "friendsofphp/php-cs-fixer": "^3.64", - "guzzlehttp/guzzle": "^7.9" + "guzzlehttp/guzzle": "^7.9", + "phpstan/phpstan-strict-rules": "^1.6", + "symfony/finder": "^7.1" }, "config": { "platform-check": false, diff --git a/composer.lock b/composer.lock index 2710b79..c3c8cc5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2fdb66387273df3d8a9ee0869283f74b", + "content-hash": "2d03aef16fc8a3518d07b12d8d5fd1d6", "packages": [ { "name": "doctrine/instantiator", @@ -316,16 +316,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.30.1", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "51b95ec8670af41009e2b2b56873bad96682413e" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e", - "reference": "51b95ec8670af41009e2b2b56873bad96682413e", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { @@ -357,24 +357,24 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2024-09-07T20:13:05+00:00" + "time": "2024-10-13T11:25:22+00:00" } ], "packages-dev": [ { "name": "brianium/paratest", - "version": "v7.4.3", + "version": "v7.4.8", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "64fcfd0e28a6b8078a19dbf9127be2ee645b92ec" + "reference": "cf16fcbb9b8107a7df6b97e497fc91e819774d8b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/64fcfd0e28a6b8078a19dbf9127be2ee645b92ec", - "reference": "64fcfd0e28a6b8078a19dbf9127be2ee645b92ec", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/cf16fcbb9b8107a7df6b97e497fc91e819774d8b", + "reference": "cf16fcbb9b8107a7df6b97e497fc91e819774d8b", "shasum": "" }, "require": { @@ -382,31 +382,30 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-simplexml": "*", - "fidry/cpu-core-counter": "^1.1.0", - "jean85/pretty-package-versions": "^2.0.5", - "php": "~8.2.0 || ~8.3.0", - "phpunit/php-code-coverage": "^10.1.11 || ^11.0.0", - "phpunit/php-file-iterator": "^4.1.0 || ^5.0.0", - "phpunit/php-timer": "^6.0.0 || ^7.0.0", - "phpunit/phpunit": "^10.5.9 || ^11.0.3", - "sebastian/environment": "^6.0.1 || ^7.0.0", - "symfony/console": "^6.4.3 || ^7.0.3", - "symfony/process": "^6.4.3 || ^7.0.3" + "fidry/cpu-core-counter": "^1.2.0", + "jean85/pretty-package-versions": "^2.0.6", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0", + "phpunit/php-code-coverage": "^10.1.16", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-timer": "^6.0.0", + "phpunit/phpunit": "^10.5.36", + "sebastian/environment": "^6.1.0", + "symfony/console": "^6.4.7 || ^7.1.5", + "symfony/process": "^6.4.7 || ^7.1.5" }, "require-dev": { "doctrine/coding-standard": "^12.0.0", "ext-pcov": "*", "ext-posix": "*", - "phpstan/phpstan": "^1.10.58", - "phpstan/phpstan-deprecation-rules": "^1.1.4", - "phpstan/phpstan-phpunit": "^1.3.15", - "phpstan/phpstan-strict-rules": "^1.5.2", - "squizlabs/php_codesniffer": "^3.9.0", - "symfony/filesystem": "^6.4.3 || ^7.0.3" + "phpstan/phpstan": "^1.12.6", + "phpstan/phpstan-deprecation-rules": "^1.2.1", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.1", + "squizlabs/php_codesniffer": "^3.10.3", + "symfony/filesystem": "^6.4.3 || ^7.1.5" }, "bin": [ "bin/paratest", - "bin/paratest.bat", "bin/paratest_for_phpstorm" ], "type": "library", @@ -443,7 +442,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.4.3" + "source": "https://github.com/paratestphp/paratest/tree/v7.4.8" }, "funding": [ { @@ -455,7 +454,7 @@ "type": "paypal" } ], - "time": "2024-02-20T07:24:02+00:00" + "time": "2024-10-15T12:45:19+00:00" }, { "name": "clue/ndjson-react", @@ -904,26 +903,26 @@ }, { "name": "filp/whoops", - "version": "2.15.4", + "version": "2.16.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" + "reference": "befcdc0e5dce67252aa6322d82424be928214fa2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", - "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", + "url": "https://api.github.com/repos/filp/whoops/zipball/befcdc0e5dce67252aa6322d82424be928214fa2", + "reference": "befcdc0e5dce67252aa6322d82424be928214fa2", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0 || ^8.0", + "php": "^7.1 || ^8.0", "psr/log": "^1.0.1 || ^2.0 || ^3.0" }, "require-dev": { - "mockery/mockery": "^0.9 || ^1.0", - "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3", - "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0" + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^4.0 || ^5.0" }, "suggest": { "symfony/var-dumper": "Pretty print complex values better with var-dumper available", @@ -963,7 +962,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.15.4" + "source": "https://github.com/filp/whoops/tree/2.16.0" }, "funding": [ { @@ -971,7 +970,7 @@ "type": "github" } ], - "time": "2023-11-03T12:00:00+00:00" + "time": "2024-09-25T12:00:00+00:00" }, { "name": "friendsofphp/php-cs-fixer", @@ -1204,16 +1203,16 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { @@ -1267,7 +1266,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.3" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -1283,7 +1282,7 @@ "type": "tidelift" } ], - "time": "2024-07-18T10:29:17+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", @@ -1522,16 +1521,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.2.0", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb", - "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { @@ -1574,29 +1573,29 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.2.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2024-09-15T16:40:33+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "nunomaduro/collision", - "version": "v8.4.0", + "version": "v8.5.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "e7d1aa8ed753f63fa816932bbc89678238843b4a" + "reference": "f5c101b929c958e849a633283adff296ed5f38f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/e7d1aa8ed753f63fa816932bbc89678238843b4a", - "reference": "e7d1aa8ed753f63fa816932bbc89678238843b4a", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/f5c101b929c958e849a633283adff296ed5f38f5", + "reference": "f5c101b929c958e849a633283adff296ed5f38f5", "shasum": "" }, "require": { - "filp/whoops": "^2.15.4", - "nunomaduro/termwind": "^2.0.1", + "filp/whoops": "^2.16.0", + "nunomaduro/termwind": "^2.1.0", "php": "^8.2.0", - "symfony/console": "^7.1.3" + "symfony/console": "^7.1.5" }, "conflict": { "laravel/framework": "<11.0.0 || >=12.0.0", @@ -1604,14 +1603,14 @@ }, "require-dev": { "larastan/larastan": "^2.9.8", - "laravel/framework": "^11.19.0", - "laravel/pint": "^1.17.1", - "laravel/sail": "^1.31.0", - "laravel/sanctum": "^4.0.2", - "laravel/tinker": "^2.9.0", - "orchestra/testbench-core": "^9.2.3", - "pestphp/pest": "^2.35.0 || ^3.0.0", - "sebastian/environment": "^6.1.0 || ^7.0.0" + "laravel/framework": "^11.28.0", + "laravel/pint": "^1.18.1", + "laravel/sail": "^1.36.0", + "laravel/sanctum": "^4.0.3", + "laravel/tinker": "^2.10.0", + "orchestra/testbench-core": "^9.5.3", + "pestphp/pest": "^2.36.0 || ^3.4.0", + "sebastian/environment": "^6.1.0 || ^7.2.0" }, "type": "library", "extra": { @@ -1673,36 +1672,35 @@ "type": "patreon" } ], - "time": "2024-08-03T15:32:23+00:00" + "time": "2024-10-15T16:06:32+00:00" }, { "name": "nunomaduro/termwind", - "version": "v2.1.0", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a" + "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/e5f21eade88689536c0cdad4c3cd75f3ed26e01a", - "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/42c84e4e8090766bbd6445d06cd6e57650626ea3", + "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^8.2", - "symfony/console": "^7.0.4" + "symfony/console": "^7.1.5" }, "require-dev": { - "ergebnis/phpstan-rules": "^2.2.0", - "illuminate/console": "^11.1.1", - "laravel/pint": "^1.15.0", - "mockery/mockery": "^1.6.11", - "pestphp/pest": "^2.34.6", - "phpstan/phpstan": "^1.10.66", - "phpstan/phpstan-strict-rules": "^1.5.2", - "symfony/var-dumper": "^7.0.4", + "illuminate/console": "^11.28.0", + "laravel/pint": "^1.18.1", + "mockery/mockery": "^1.6.12", + "pestphp/pest": "^2.36.0", + "phpstan/phpstan": "^1.12.6", + "phpstan/phpstan-strict-rules": "^1.6.1", + "symfony/var-dumper": "^7.1.5", "thecodingmachine/phpstan-strict-rules": "^1.0.0" }, "type": "library", @@ -1745,7 +1743,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.1.0" + "source": "https://github.com/nunomaduro/termwind/tree/v2.2.0" }, "funding": [ { @@ -1761,40 +1759,41 @@ "type": "github" } ], - "time": "2024-09-05T15:25:50+00:00" + "time": "2024-10-15T16:15:16+00:00" }, { "name": "pestphp/pest", - "version": "v2.35.1", + "version": "v2.36.0", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "b13acb630df52c06123588d321823c31fc685545" + "reference": "f8c88bd14dc1772bfaf02169afb601ecdf2724cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/b13acb630df52c06123588d321823c31fc685545", - "reference": "b13acb630df52c06123588d321823c31fc685545", + "url": "https://api.github.com/repos/pestphp/pest/zipball/f8c88bd14dc1772bfaf02169afb601ecdf2724cd", + "reference": "f8c88bd14dc1772bfaf02169afb601ecdf2724cd", "shasum": "" }, "require": { "brianium/paratest": "^7.3.1", - "nunomaduro/collision": "^7.10.0|^8.4.0", - "nunomaduro/termwind": "^1.15.1|^2.0.1", + "nunomaduro/collision": "^7.11.0|^8.4.0", + "nunomaduro/termwind": "^1.16.0|^2.1.0", "pestphp/pest-plugin": "^2.1.1", "pestphp/pest-plugin-arch": "^2.7.0", "php": "^8.1.0", - "phpunit/phpunit": "^10.5.17" + "phpunit/phpunit": "^10.5.36" }, "conflict": { - "phpunit/phpunit": ">10.5.17", + "filp/whoops": "<2.16.0", + "phpunit/phpunit": ">10.5.36", "sebastian/exporter": "<5.1.0", "webmozart/assert": "<1.11.0" }, "require-dev": { - "pestphp/pest-dev-tools": "^2.16.0", - "pestphp/pest-plugin-type-coverage": "^2.8.5", - "symfony/process": "^6.4.0|^7.1.3" + "pestphp/pest-dev-tools": "^2.17.0", + "pestphp/pest-plugin-type-coverage": "^2.8.7", + "symfony/process": "^6.4.0|^7.1.5" }, "bin": [ "bin/pest" @@ -1857,7 +1856,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.35.1" + "source": "https://github.com/pestphp/pest/tree/v2.36.0" }, "funding": [ { @@ -1869,7 +1868,7 @@ "type": "github" } ], - "time": "2024-08-20T21:41:50+00:00" + "time": "2024-10-15T15:30:56+00:00" }, { "name": "pestphp/pest-plugin", @@ -2307,16 +2306,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.4", + "version": "1.12.7", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "ffa517cb918591b93acc9b95c0bebdcd0e4538bd" + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ffa517cb918591b93acc9b95c0bebdcd0e4538bd", - "reference": "ffa517cb918591b93acc9b95c0bebdcd0e4538bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", "shasum": "" }, "require": { @@ -2361,7 +2360,56 @@ "type": "github" } ], - "time": "2024-09-19T07:58:01+00:00" + "time": "2024-10-18T11:12:07+00:00" + }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "daeec748b53de80a97498462513066834ec28f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/daeec748b53de80a97498462513066834ec28f8b", + "reference": "daeec748b53de80a97498462513066834ec28f8b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.12.4" + }, + "require-dev": { + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Extra strict and opinionated rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.6.1" + }, + "time": "2024-09-20T14:04:44+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2686,16 +2734,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.17", + "version": "10.5.36", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c1f736a473d21957ead7e94fcc029f571895abf5" + "reference": "aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1f736a473d21957ead7e94fcc029f571895abf5", - "reference": "c1f736a473d21957ead7e94fcc029f571895abf5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870", + "reference": "aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870", "shasum": "" }, "require": { @@ -2705,26 +2753,26 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.5", - "phpunit/php-file-iterator": "^4.0", - "phpunit/php-invoker": "^4.0", - "phpunit/php-text-template": "^3.0", - "phpunit/php-timer": "^6.0", - "sebastian/cli-parser": "^2.0", - "sebastian/code-unit": "^2.0", - "sebastian/comparator": "^5.0", - "sebastian/diff": "^5.0", - "sebastian/environment": "^6.0", - "sebastian/exporter": "^5.1", - "sebastian/global-state": "^6.0.1", - "sebastian/object-enumerator": "^5.0", - "sebastian/recursion-context": "^5.0", - "sebastian/type": "^4.0", - "sebastian/version": "^4.0" + "phpunit/php-code-coverage": "^10.1.16", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-invoker": "^4.0.0", + "phpunit/php-text-template": "^3.0.1", + "phpunit/php-timer": "^6.0.0", + "sebastian/cli-parser": "^2.0.1", + "sebastian/code-unit": "^2.0.0", + "sebastian/comparator": "^5.0.2", + "sebastian/diff": "^5.1.1", + "sebastian/environment": "^6.1.0", + "sebastian/exporter": "^5.1.2", + "sebastian/global-state": "^6.0.2", + "sebastian/object-enumerator": "^5.0.0", + "sebastian/recursion-context": "^5.0.0", + "sebastian/type": "^4.0.0", + "sebastian/version": "^4.0.1" }, "suggest": { "ext-soap": "To be able to generate mocks based on WSDL files" @@ -2767,7 +2815,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.17" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.36" }, "funding": [ { @@ -2783,7 +2831,7 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:39:01+00:00" + "time": "2024-10-08T15:36:51+00:00" }, { "name": "psr/container", @@ -3842,16 +3890,16 @@ }, { "name": "sebastian/comparator", - "version": "5.0.2", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53" + "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", - "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", + "reference": "a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e", "shasum": "" }, "require": { @@ -3862,7 +3910,7 @@ "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.4" + "phpunit/phpunit": "^10.5" }, "type": "library", "extra": { @@ -3907,7 +3955,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.2" + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.3" }, "funding": [ { @@ -3915,7 +3963,7 @@ "type": "github" } ], - "time": "2024-08-12T06:03:08+00:00" + "time": "2024-10-18T14:56:07+00:00" }, { "name": "sebastian/complexity", @@ -4590,16 +4638,16 @@ }, { "name": "symfony/console", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111" + "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/1eed7af6961d763e7832e874d7f9b21c3ea9c111", - "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111", + "url": "https://api.github.com/repos/symfony/console/zipball/0fa539d12b3ccf068a722bbbffa07ca7079af9ee", + "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee", "shasum": "" }, "require": { @@ -4663,7 +4711,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.4" + "source": "https://github.com/symfony/console/tree/v7.1.5" }, "funding": [ { @@ -4679,7 +4727,7 @@ "type": "tidelift" } ], - "time": "2024-08-15T22:48:53+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4906,16 +4954,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.1.2", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "92a91985250c251de9b947a14bb2c9390b1a562c" + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/92a91985250c251de9b947a14bb2c9390b1a562c", - "reference": "92a91985250c251de9b947a14bb2c9390b1a562c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/61fe0566189bf32e8cfee78335d8776f64a66f5a", + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a", "shasum": "" }, "require": { @@ -4952,7 +5000,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.2" + "source": "https://github.com/symfony/filesystem/tree/v7.1.5" }, "funding": [ { @@ -4968,7 +5016,7 @@ "type": "tidelift" } ], - "time": "2024-06-28T10:03:55+00:00" + "time": "2024-09-17T09:16:35+00:00" }, { "name": "symfony/finder", @@ -5577,16 +5625,16 @@ }, { "name": "symfony/process", - "version": "v7.1.3", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "7f2f542c668ad6c313dc4a5e9c3321f733197eca" + "reference": "5c03ee6369281177f07f7c68252a280beccba847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/7f2f542c668ad6c313dc4a5e9c3321f733197eca", - "reference": "7f2f542c668ad6c313dc4a5e9c3321f733197eca", + "url": "https://api.github.com/repos/symfony/process/zipball/5c03ee6369281177f07f7c68252a280beccba847", + "reference": "5c03ee6369281177f07f7c68252a280beccba847", "shasum": "" }, "require": { @@ -5618,7 +5666,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.3" + "source": "https://github.com/symfony/process/tree/v7.1.5" }, "funding": [ { @@ -5634,7 +5682,7 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:44:47+00:00" + "time": "2024-09-19T21:48:23+00:00" }, { "name": "symfony/service-contracts", @@ -5783,16 +5831,16 @@ }, { "name": "symfony/string", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b" + "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/6cd670a6d968eaeb1c77c2e76091c45c56bc367b", - "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b", + "url": "https://api.github.com/repos/symfony/string/zipball/d66f9c343fa894ec2037cc928381df90a7ad4306", + "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306", "shasum": "" }, "require": { @@ -5850,7 +5898,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.4" + "source": "https://github.com/symfony/string/tree/v7.1.5" }, "funding": [ { @@ -5866,7 +5914,7 @@ "type": "tidelift" } ], - "time": "2024-08-12T09:59:40+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "ta-tikoma/phpunit-architecture-test", diff --git a/phpstan.neon b/phpstan.neon index c2ef599..cca1641 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,9 @@ +includes: + - vendor/phpstan/phpstan-strict-rules/rules.neon + parameters: - level: 9 + level: max excludePaths: - tests/* paths: - - src \ No newline at end of file + - src diff --git a/src/CII/Models/Amount.php b/src/CII/Models/Amount.php index 2d6d79e..e056889 100644 --- a/src/CII/Models/Amount.php +++ b/src/CII/Models/Amount.php @@ -12,7 +12,7 @@ final class Amount { - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public string $value; diff --git a/src/CII/Models/BinaryObject.php b/src/CII/Models/BinaryObject.php index 6c28102..18b6060 100644 --- a/src/CII/Models/BinaryObject.php +++ b/src/CII/Models/BinaryObject.php @@ -5,21 +5,24 @@ namespace easybill\eInvoicing\CII\Models; use easybill\eInvoicing\Enums\MimeType; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlAttribute; +use JMS\Serializer\Annotation\XmlValue; final class BinaryObject { - #[JMS\Type(MimeType::class)] - #[JMS\XmlAttribute] - #[JMS\SerializedName('mimeCode')] + #[Type(MimeType::class)] + #[XmlAttribute] + #[SerializedName('mimeCode')] public MimeType $mimeCode; - #[JMS\Type('string')] - #[JMS\XmlAttribute] - #[JMS\SerializedName('filename')] + #[Type(StringValue::class)] + #[XmlAttribute] + #[SerializedName('filename')] public string $filename; - #[JMS\Type('string')] - #[JMS\XmlValue(cdata: false)] + #[Type(StringValue::class)] + #[XmlValue(cdata: false)] public string $value; } diff --git a/src/CII/Models/ClassCode.php b/src/CII/Models/ClassCode.php index 43e603b..ad8458d 100644 --- a/src/CII/Models/ClassCode.php +++ b/src/CII/Models/ClassCode.php @@ -11,12 +11,12 @@ final class ClassCode { - #[Type('string')] + #[Type(StringValue::class)] #[XmlAttribute] #[SerializedName('listID')] public ?string $listID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public string $value; diff --git a/src/CII/Models/CreditorFinancialAccount.php b/src/CII/Models/CreditorFinancialAccount.php index b54f99c..38cb83c 100644 --- a/src/CII/Models/CreditorFinancialAccount.php +++ b/src/CII/Models/CreditorFinancialAccount.php @@ -15,7 +15,7 @@ final class CreditorFinancialAccount #[SerializedName('IBANID')] public ?Id $ibanId = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('AccountName')] public ?string $AccountName = null; diff --git a/src/CII/Models/DateString.php b/src/CII/Models/DateString.php index ba93871..2d8d4a6 100644 --- a/src/CII/Models/DateString.php +++ b/src/CII/Models/DateString.php @@ -4,16 +4,18 @@ namespace easybill\eInvoicing\CII\Models; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlAttribute; +use JMS\Serializer\Annotation\XmlValue; final class DateString { - #[JMS\Type('integer')] - #[JMS\XmlAttribute] + #[Type('integer')] + #[XmlAttribute] public int $format; - #[JMS\Type('string')] - #[JMS\XmlValue(cdata: false)] + #[Type(StringValue::class)] + #[XmlValue(cdata: false)] public string $value; public static function create(int $format, string $value): self diff --git a/src/CII/Models/DateTimeString.php b/src/CII/Models/DateTimeString.php index 24ae0dc..3aac501 100644 --- a/src/CII/Models/DateTimeString.php +++ b/src/CII/Models/DateTimeString.php @@ -4,16 +4,18 @@ namespace easybill\eInvoicing\CII\Models; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlAttribute; +use JMS\Serializer\Annotation\XmlValue; final class DateTimeString { - #[JMS\Type('integer')] - #[JMS\XmlAttribute] + #[Type('integer')] + #[XmlAttribute] public int $format; - #[JMS\Type('string')] - #[JMS\XmlValue(cdata: false)] + #[Type(StringValue::class)] + #[XmlValue(cdata: false)] public string $value; public static function create(int $format, string $value): self diff --git a/src/CII/Models/DocumentContextParameter.php b/src/CII/Models/DocumentContextParameter.php index f05568c..4242d0e 100644 --- a/src/CII/Models/DocumentContextParameter.php +++ b/src/CII/Models/DocumentContextParameter.php @@ -10,7 +10,7 @@ final class DocumentContextParameter { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('ID')] public string $id; diff --git a/src/CII/Models/DocumentLineDocument.php b/src/CII/Models/DocumentLineDocument.php index 0eb29f1..3d3077c 100644 --- a/src/CII/Models/DocumentLineDocument.php +++ b/src/CII/Models/DocumentLineDocument.php @@ -13,7 +13,7 @@ #[AccessorOrder(order: 'custom', custom: ['lineId', 'notes'])] final class DocumentLineDocument { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('LineID')] public string $lineId; diff --git a/src/CII/Models/ExchangedDocument.php b/src/CII/Models/ExchangedDocument.php index 6ebd48d..ed609ea 100644 --- a/src/CII/Models/ExchangedDocument.php +++ b/src/CII/Models/ExchangedDocument.php @@ -12,12 +12,12 @@ final class ExchangedDocument { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('ID')] public string $id; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Name')] public ?string $name = null; diff --git a/src/CII/Models/HeaderTradeAgreement.php b/src/CII/Models/HeaderTradeAgreement.php index a13104f..272a71e 100644 --- a/src/CII/Models/HeaderTradeAgreement.php +++ b/src/CII/Models/HeaderTradeAgreement.php @@ -24,7 +24,7 @@ ])] final class HeaderTradeAgreement { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('BuyerReference')] public ?string $buyerReference = null; diff --git a/src/CII/Models/HeaderTradeSettlement.php b/src/CII/Models/HeaderTradeSettlement.php index c4a6f67..b4e02ae 100644 --- a/src/CII/Models/HeaderTradeSettlement.php +++ b/src/CII/Models/HeaderTradeSettlement.php @@ -12,12 +12,12 @@ final class HeaderTradeSettlement { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('CreditorReferenceID')] public ?string $creditorReferenceID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('PaymentReference')] public ?string $paymentReference = null; diff --git a/src/CII/Models/Id.php b/src/CII/Models/Id.php index 110a454..ad7e337 100644 --- a/src/CII/Models/Id.php +++ b/src/CII/Models/Id.php @@ -11,12 +11,12 @@ final class Id { - #[Type('string')] + #[Type(StringValue::class)] #[XmlAttribute] #[SerializedName('schemeID')] public ?string $schemeID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public string $value; diff --git a/src/CII/Models/Indicator.php b/src/CII/Models/Indicator.php index e17c729..3e7ea7e 100644 --- a/src/CII/Models/Indicator.php +++ b/src/CII/Models/Indicator.php @@ -4,12 +4,14 @@ namespace easybill\eInvoicing\CII\Models; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlElement; final class Indicator { - #[JMS\Type('boolean')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100')] - #[JMS\SerializedName('Indicator')] + #[Type('boolean')] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100')] + #[SerializedName('Indicator')] public bool $indicator; } diff --git a/src/CII/Models/LegalOrganization.php b/src/CII/Models/LegalOrganization.php index 40f25fd..df0c34d 100644 --- a/src/CII/Models/LegalOrganization.php +++ b/src/CII/Models/LegalOrganization.php @@ -15,7 +15,7 @@ final class LegalOrganization #[SerializedName('ID')] public Id $id; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('TradingBusinessName')] public ?string $tradingBusinessName = null; diff --git a/src/CII/Models/LogisticsServiceCharge.php b/src/CII/Models/LogisticsServiceCharge.php index 7a83594..54ccf1d 100644 --- a/src/CII/Models/LogisticsServiceCharge.php +++ b/src/CII/Models/LogisticsServiceCharge.php @@ -13,7 +13,7 @@ #[AccessorOrder(order: 'custom', custom: ['description', 'appliedAmount', 'tradeTaxes'])] final class LogisticsServiceCharge { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Description')] public string $description; diff --git a/src/CII/Models/Note.php b/src/CII/Models/Note.php index 9c49acb..cd1ca77 100644 --- a/src/CII/Models/Note.php +++ b/src/CII/Models/Note.php @@ -10,17 +10,17 @@ final class Note { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('ContentCode')] public ?string $contentCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Content')] public string $content; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('SubjectCode')] public ?string $subjectCode = null; diff --git a/src/CII/Models/ProcuringProject.php b/src/CII/Models/ProcuringProject.php index 780ebd1..04e2af9 100644 --- a/src/CII/Models/ProcuringProject.php +++ b/src/CII/Models/ProcuringProject.php @@ -10,12 +10,12 @@ final class ProcuringProject { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('ID')] public string $id; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Name')] public string $name; diff --git a/src/CII/Models/ProductCharacteristic.php b/src/CII/Models/ProductCharacteristic.php index 6516efd..5f339b3 100644 --- a/src/CII/Models/ProductCharacteristic.php +++ b/src/CII/Models/ProductCharacteristic.php @@ -10,12 +10,12 @@ final class ProductCharacteristic { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Description')] public string $description; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Value')] public string $value; diff --git a/src/CII/Models/Quantity.php b/src/CII/Models/Quantity.php index 3bdd61b..5d53a6f 100644 --- a/src/CII/Models/Quantity.php +++ b/src/CII/Models/Quantity.php @@ -17,7 +17,7 @@ final class Quantity #[SerializedName('unitCode')] public UnitCode $unitCode; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public string $value; diff --git a/src/CII/Models/ReferencedDocument.php b/src/CII/Models/ReferencedDocument.php index 4ea2065..2d5b842 100644 --- a/src/CII/Models/ReferencedDocument.php +++ b/src/CII/Models/ReferencedDocument.php @@ -27,7 +27,7 @@ final class ReferencedDocument #[SerializedName('TypeCode')] public ?DocumentType $typeCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Name')] public ?string $name = null; @@ -42,7 +42,7 @@ final class ReferencedDocument #[SerializedName('FormattedIssueDateTime')] public ?FormattedDateTime $formattedIssueDateTime = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('LineID')] public ?string $lineId = null; diff --git a/src/CII/Models/StringValue.php b/src/CII/Models/StringValue.php new file mode 100644 index 0000000..ef7c2fc --- /dev/null +++ b/src/CII/Models/StringValue.php @@ -0,0 +1,7 @@ +')] - #[JMS\XmlList(entry: 'CategoryTradeTax', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[Type('array')] + #[XmlList(entry: 'CategoryTradeTax', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $tradeTax = []; /** @param array $tradeTax */ diff --git a/src/CII/Models/TradeContact.php b/src/CII/Models/TradeContact.php index 8e102f1..3cdc6f6 100644 --- a/src/CII/Models/TradeContact.php +++ b/src/CII/Models/TradeContact.php @@ -10,12 +10,12 @@ final class TradeContact { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('PersonName')] public ?string $personName = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('DepartmentName')] public ?string $departmentName = null; diff --git a/src/CII/Models/TradeCountry.php b/src/CII/Models/TradeCountry.php index c8db6cc..a8689a1 100644 --- a/src/CII/Models/TradeCountry.php +++ b/src/CII/Models/TradeCountry.php @@ -10,7 +10,7 @@ final class TradeCountry { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('ID')] public string $id; diff --git a/src/CII/Models/TradeParty.php b/src/CII/Models/TradeParty.php index e98022b..105523e 100644 --- a/src/CII/Models/TradeParty.php +++ b/src/CII/Models/TradeParty.php @@ -23,12 +23,12 @@ final class TradeParty #[XmlList(entry: 'GlobalID', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $globalID = []; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Name')] public string $name; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Description')] public ?string $description = null; @@ -53,7 +53,7 @@ final class TradeParty #[SerializedName('URIUniversalCommunication')] public ?UniversalCommunication $uriUniversalCommunication = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('RoleCode')] public ?string $roleCode = null; diff --git a/src/CII/Models/TradePaymentTerms.php b/src/CII/Models/TradePaymentTerms.php index a8431a6..f25649c 100644 --- a/src/CII/Models/TradePaymentTerms.php +++ b/src/CII/Models/TradePaymentTerms.php @@ -4,22 +4,24 @@ namespace easybill\eInvoicing\CII\Models; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlElement; final class TradePaymentTerms { - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('Description')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('Description')] public ?string $description = null; - #[JMS\Type(DateTime::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('DueDateDateTime')] + #[Type(DateTime::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('DueDateDateTime')] public ?DateTime $dueDate = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('DirectDebitMandateID')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('DirectDebitMandateID')] public ?string $directDebitMandateID = null; } diff --git a/src/CII/Models/TradeProduct.php b/src/CII/Models/TradeProduct.php index 0e843d1..d53676e 100644 --- a/src/CII/Models/TradeProduct.php +++ b/src/CII/Models/TradeProduct.php @@ -18,22 +18,22 @@ final class TradeProduct #[SerializedName('GlobalID')] public ?Id $globalID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('SellerAssignedID')] public ?string $sellerAssignedID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('BuyerAssignedID')] public ?string $buyerAssignedID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Name')] public string $name; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Description')] public ?string $description = null; diff --git a/src/CII/Models/TradeSettlementFinancialCard.php b/src/CII/Models/TradeSettlementFinancialCard.php index 4bf7536..1284698 100644 --- a/src/CII/Models/TradeSettlementFinancialCard.php +++ b/src/CII/Models/TradeSettlementFinancialCard.php @@ -15,7 +15,7 @@ final class TradeSettlementFinancialCard #[SerializedName('ID')] public Id $id; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('CardholderName')] public ?string $cardholderName = null; diff --git a/src/CII/Models/TradeSettlementHeaderMonetarySummation.php b/src/CII/Models/TradeSettlementHeaderMonetarySummation.php index 9b6a173..d9fde53 100644 --- a/src/CII/Models/TradeSettlementHeaderMonetarySummation.php +++ b/src/CII/Models/TradeSettlementHeaderMonetarySummation.php @@ -4,59 +4,61 @@ namespace easybill\eInvoicing\CII\Models; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlElement; use JMS\Serializer\Annotation\XmlList; final class TradeSettlementHeaderMonetarySummation { - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('LineTotalAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('LineTotalAmount')] public ?Amount $lineTotalAmount = null; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('ChargeTotalAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('ChargeTotalAmount')] public ?Amount $chargeTotalAmount = null; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('AllowanceTotalAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('AllowanceTotalAmount')] public ?Amount $allowanceTotalAmount = null; /** * @var Amount[] */ - #[JMS\Type('array')] + #[Type('array')] #[XmlList(entry: 'TaxBasisTotalAmount', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $taxBasisTotalAmount = []; /** * @var Amount[] */ - #[JMS\Type('array')] + #[Type('array')] #[XmlList(entry: 'TaxTotalAmount', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $taxTotalAmount = []; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('RoundingAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('RoundingAmount')] public ?Amount $roundingAmount = null; /** * @var Amount[] */ - #[JMS\Type('array')] + #[Type('array')] #[XmlList(entry: 'GrandTotalAmount', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $grandTotalAmount = []; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('TotalPrepaidAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('TotalPrepaidAmount')] public ?Amount $totalPrepaidAmount = null; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('DuePayableAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('DuePayableAmount')] public Amount $duePayableAmount; } diff --git a/src/CII/Models/TradeSettlementPaymentMeans.php b/src/CII/Models/TradeSettlementPaymentMeans.php index 6dc6abb..b3b6415 100644 --- a/src/CII/Models/TradeSettlementPaymentMeans.php +++ b/src/CII/Models/TradeSettlementPaymentMeans.php @@ -10,12 +10,12 @@ final class TradeSettlementPaymentMeans { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('TypeCode')] public string $typeCode; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('Information')] public ?string $information = null; diff --git a/src/CII/Models/TradeTax.php b/src/CII/Models/TradeTax.php index c5150c4..901d6a1 100644 --- a/src/CII/Models/TradeTax.php +++ b/src/CII/Models/TradeTax.php @@ -5,69 +5,71 @@ namespace easybill\eInvoicing\CII\Models; use JMS\Serializer\Annotation\AccessorOrder; -use JMS\Serializer\Annotation as JMS; +use JMS\Serializer\Annotation\SerializedName; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\XmlElement; #[AccessorOrder(order: 'custom', custom: ['calculatedAmount', 'typeCode', 'exemptionReason', 'basisAmount', 'categoryCode', 'exemptionReasonCode', 'taxPointDate', 'dueDateTypeCode', 'rateApplicablePercent'])] final class TradeTax { - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('CalculatedAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('CalculatedAmount')] public ?Amount $calculatedAmount = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('TypeCode')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('TypeCode')] public string $typeCode; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('BasisAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('BasisAmount')] public ?Amount $basisAmount = null; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('LineTotalBasisAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('LineTotalBasisAmount')] public ?Amount $lineTotalBasisAmount = null; - #[JMS\Type(Amount::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('AllowanceChargeBasisAmount')] + #[Type(Amount::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('AllowanceChargeBasisAmount')] public ?Amount $allowanceChargeBasisAmount = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('ApplicablePercent')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('ApplicablePercent')] public ?string $applicablePercent = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('CategoryCode')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('CategoryCode')] public ?string $categoryCode = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('RateApplicablePercent')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('RateApplicablePercent')] public ?string $rateApplicablePercent = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('ExemptionReason')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('ExemptionReason')] public ?string $exemptionReason = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('ExemptionReasonCode')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('ExemptionReasonCode')] public ?string $exemptionReasonCode = null; - #[JMS\Type(Date::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('TaxPointDate')] + #[Type(Date::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('TaxPointDate')] public ?Date $taxPointDate = null; - #[JMS\Type('string')] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('DueDateTypeCode')] + #[Type(StringValue::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('DueDateTypeCode')] public ?string $dueDateTypeCode = null; public static function create( diff --git a/src/CII/Models/UniversalCommunication.php b/src/CII/Models/UniversalCommunication.php index bb94729..5e64652 100644 --- a/src/CII/Models/UniversalCommunication.php +++ b/src/CII/Models/UniversalCommunication.php @@ -10,7 +10,7 @@ final class UniversalCommunication { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('CompleteNumber')] public ?string $completeNumber = null; diff --git a/src/CII/Models/UriID.php b/src/CII/Models/UriID.php index 9ea4115..bdce2f3 100644 --- a/src/CII/Models/UriID.php +++ b/src/CII/Models/UriID.php @@ -17,7 +17,7 @@ final class UriID #[SerializedName('schemeID')] public ?ElectronicAddressScheme $schemeID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public string $value; diff --git a/src/ConfiguredSerializer.php b/src/ConfiguredSerializer.php index 9a28f20..a3457e8 100644 --- a/src/ConfiguredSerializer.php +++ b/src/ConfiguredSerializer.php @@ -10,9 +10,11 @@ use easybill\eInvoicing\Handlers\ElectronicAddressSchemeIdentifierEnumHandler; use easybill\eInvoicing\Handlers\MimeTypeEnumHandler; use easybill\eInvoicing\Handlers\ReferenceQualifierEnumHandler; +use easybill\eInvoicing\Handlers\StringValueHandler; use easybill\eInvoicing\Handlers\UnitCodeEnumHandler; use JMS\Serializer\DeserializationContext; use JMS\Serializer\Handler\HandlerRegistryInterface; +use JMS\Serializer\Handler\SubscribingHandlerInterface; use JMS\Serializer\SerializationContext; use JMS\Serializer\SerializerBuilder; use JMS\Serializer\SerializerInterface; @@ -28,6 +30,7 @@ public static function create(): self $serializer = SerializerBuilder::create() ->setDebug(true) ->configureHandlers(function (HandlerRegistryInterface $registry) { + $registry->registerSubscribingHandler(new StringValueHandler()); $registry->registerSubscribingHandler(new CountryCodeEnumHandler()); $registry->registerSubscribingHandler(new CurrencyCodeEnumHandler()); $registry->registerSubscribingHandler(new DocumentTypeEnumHandler()); @@ -41,6 +44,21 @@ public static function create(): self return new self($serializer); } + /** @param array $handlers */ + public static function createWithHandlers(array $handlers): self + { + $serializer = SerializerBuilder::create() + ->setDebug(true) + ->configureHandlers(function (HandlerRegistryInterface $registry) use ($handlers) { + foreach ($handlers as $handler) { + $registry->registerSubscribingHandler($handler); + } + }) + ->build() + ; + return new self($serializer); + } + public function serialize($data, string $format, ?SerializationContext $context = null, ?string $type = null): string { return $this->serializer->serialize($data, $format, $context, $type); diff --git a/src/Dtos/ReaderResult.php b/src/Dtos/ReaderResult.php index bd9046c..eb753ba 100644 --- a/src/Dtos/ReaderResult.php +++ b/src/Dtos/ReaderResult.php @@ -7,11 +7,11 @@ use easybill\eInvoicing\CII\Documents\CrossIndustryInvoice; use easybill\eInvoicing\UBL\Documents\UblAbstractDocument; -final class ReaderResult +final readonly class ReaderResult { private function __construct( - public ?\Throwable $throwable = null, - public null|CrossIndustryInvoice|UblAbstractDocument $document = null, + private ?\Throwable $throwable = null, + private null|CrossIndustryInvoice|UblAbstractDocument $document = null, ) {} public static function error(\Throwable $throwable): self diff --git a/src/Handlers/AbstractBackedEnumHandler.php b/src/Handlers/AbstractBackedEnumHandler.php index 8d56b4d..6a6fb6b 100644 --- a/src/Handlers/AbstractBackedEnumHandler.php +++ b/src/Handlers/AbstractBackedEnumHandler.php @@ -54,7 +54,7 @@ public function deserializeEnum(XmlDeserializationVisitor $visitor, \SimpleXMLEl $rBackingType = $rEnum->getBackingType(); return match ((string)$rBackingType) { - 'string' => $class::from((string)$data), + 'string' => $class::from(mb_trim((string)$data)), 'int' => $class::from((int)$data), default => throw new \BadMethodCallException('Unknown backing type'), }; diff --git a/src/Handlers/StringValueHandler.php b/src/Handlers/StringValueHandler.php new file mode 100644 index 0000000..e38cc68 --- /dev/null +++ b/src/Handlers/StringValueHandler.php @@ -0,0 +1,62 @@ +> */ + public static function getSubscribingMethods(): array + { + $methods = []; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, + 'format' => 'xml', + 'type' => CIIStringValue::class, + 'method' => 'deserializeString', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, + 'format' => 'xml', + 'type' => CIIStringValue::class, + 'method' => 'serializeString', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, + 'format' => 'xml', + 'type' => UBLStringValue::class, + 'method' => 'deserializeString', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, + 'format' => 'xml', + 'type' => UBLStringValue::class, + 'method' => 'serializeString', + ]; + + return $methods; + } + + /** @param array $type */ + public function serializeString(XmlSerializationVisitor $visitor, string $value, array $type): \DOMText + { + return $visitor->visitSimpleString($value, $type); + } + + public function deserializeString(XmlDeserializationVisitor $visitor, \SimpleXMLElement $value): string + { + return (string)$value; + } +} diff --git a/src/Handlers/TrimStringValueHandler.php b/src/Handlers/TrimStringValueHandler.php new file mode 100644 index 0000000..97a0d5a --- /dev/null +++ b/src/Handlers/TrimStringValueHandler.php @@ -0,0 +1,62 @@ +> */ + public static function getSubscribingMethods(): array + { + $methods = []; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, + 'format' => 'xml', + 'type' => CIIStringValue::class, + 'method' => 'deserializeString', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, + 'format' => 'xml', + 'type' => CIIStringValue::class, + 'method' => 'serializeString', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, + 'format' => 'xml', + 'type' => UBLStringValue::class, + 'method' => 'deserializeString', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, + 'format' => 'xml', + 'type' => UBLStringValue::class, + 'method' => 'serializeString', + ]; + + return $methods; + } + + /** @param array $type */ + public function serializeString(XmlSerializationVisitor $visitor, string $value, array $type): \DOMText + { + return $visitor->visitSimpleString(mb_trim($value), $type); + } + + public function deserializeString(XmlDeserializationVisitor $visitor, \SimpleXMLElement $value): string + { + return mb_trim((string)$value); + } +} diff --git a/src/Transformer.php b/src/Transformer.php index ba31464..9cf4387 100644 --- a/src/Transformer.php +++ b/src/Transformer.php @@ -9,7 +9,7 @@ final readonly class Transformer { - private function __construct( + public function __construct( private ConfiguredSerializer $serializer, ) {} diff --git a/src/UBL/Documents/UblAbstractDocument.php b/src/UBL/Documents/UblAbstractDocument.php index bc43d69..ebef7ff 100644 --- a/src/UBL/Documents/UblAbstractDocument.php +++ b/src/UBL/Documents/UblAbstractDocument.php @@ -17,6 +17,7 @@ use easybill\eInvoicing\UBL\Models\PaymentMeans; use easybill\eInvoicing\UBL\Models\PaymentTerms; use easybill\eInvoicing\UBL\Models\Period; +use easybill\eInvoicing\UBL\Models\StringValue; use easybill\eInvoicing\UBL\Models\TaxTotal; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; @@ -25,22 +26,22 @@ abstract class UblAbstractDocument { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('CustomizationID')] public ?string $customizationId = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ProfileID')] public ?string $profileId = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ID')] public ?string $id = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('IssueDate')] public ?string $issueDate = null; @@ -61,12 +62,12 @@ abstract class UblAbstractDocument #[SerializedName('TaxCurrencyCode')] public ?CurrencyCode $taxCurrencyCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('AccountingCost')] public ?string $accountingCost = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('BuyerReference')] public ?string $buyerReference = null; diff --git a/src/UBL/Documents/UblInvoice.php b/src/UBL/Documents/UblInvoice.php index 5503a9a..5c1bc14 100644 --- a/src/UBL/Documents/UblInvoice.php +++ b/src/UBL/Documents/UblInvoice.php @@ -7,6 +7,7 @@ use easybill\eInvoicing\Enums\DocumentType; use easybill\eInvoicing\UBL\Models\DocumentReference; use easybill\eInvoicing\UBL\Models\InvoiceLine; +use easybill\eInvoicing\UBL\Models\StringValue; use JMS\Serializer\Annotation\AccessorOrder; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; @@ -55,7 +56,7 @@ ])] final class UblInvoice extends UblAbstractDocument { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('DueDate')] public ?string $dueDate = null; @@ -65,7 +66,7 @@ final class UblInvoice extends UblAbstractDocument #[SerializedName('InvoiceTypeCode')] public ?DocumentType $invoiceTypeCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('TaxPointDate')] public ?string $taxPointDate = null; diff --git a/src/UBL/Models/AbstractDocumentLine.php b/src/UBL/Models/AbstractDocumentLine.php index 50cd2ff..141dca7 100644 --- a/src/UBL/Models/AbstractDocumentLine.php +++ b/src/UBL/Models/AbstractDocumentLine.php @@ -16,7 +16,7 @@ abstract class AbstractDocumentLine #[SerializedName('ID')] public ?Id $id = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Note')] public ?string $note = null; @@ -26,7 +26,7 @@ abstract class AbstractDocumentLine #[SerializedName('LineExtensionAmount')] public ?Amount $lineExtensionAmount = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('AccountingCost')] public ?string $accountingCost = null; diff --git a/src/UBL/Models/Address.php b/src/UBL/Models/Address.php index 2c3bfb6..ab094f7 100644 --- a/src/UBL/Models/Address.php +++ b/src/UBL/Models/Address.php @@ -11,27 +11,27 @@ final class Address { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('StreetName')] public ?string $streetName = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('AdditionalStreetName')] public ?string $additionalStreetName = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('CityName')] public ?string $cityName = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('PostalZone')] public ?string $postalZone = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('CountrySubentity')] public ?string $countrySubentity = null; diff --git a/src/UBL/Models/AddressLine.php b/src/UBL/Models/AddressLine.php index 94e975b..01af241 100644 --- a/src/UBL/Models/AddressLine.php +++ b/src/UBL/Models/AddressLine.php @@ -10,7 +10,7 @@ final class AddressLine { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Line')] public ?string $line = null; diff --git a/src/UBL/Models/AllowanceCharge.php b/src/UBL/Models/AllowanceCharge.php index 995acfc..63643c1 100644 --- a/src/UBL/Models/AllowanceCharge.php +++ b/src/UBL/Models/AllowanceCharge.php @@ -10,22 +10,22 @@ final class AllowanceCharge { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ChargeIndicator')] public ?string $chargeIndicator = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('AllowanceChargeReasonCode')] public ?string $allowanceChargeReasonCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('AllowanceChargeReason')] public ?string $allowanceChargeReason = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('MultiplierFactorNumeric')] public ?string $multiplierFactorNumeric = null; diff --git a/src/UBL/Models/Amount.php b/src/UBL/Models/Amount.php index d6a04a7..41a39a5 100644 --- a/src/UBL/Models/Amount.php +++ b/src/UBL/Models/Amount.php @@ -17,7 +17,7 @@ final class Amount #[SerializedName('currencyID')] public ?CurrencyCode $currencyID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/Contact.php b/src/UBL/Models/Contact.php index 96b43c7..a0962f4 100644 --- a/src/UBL/Models/Contact.php +++ b/src/UBL/Models/Contact.php @@ -10,17 +10,17 @@ final class Contact { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Name')] public ?string $name = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Telephone')] public ?string $telephone = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ElectronicMail')] public ?string $electronicMail = null; diff --git a/src/UBL/Models/Delivery.php b/src/UBL/Models/Delivery.php index 3c54d2d..97ada6f 100644 --- a/src/UBL/Models/Delivery.php +++ b/src/UBL/Models/Delivery.php @@ -10,10 +10,10 @@ final class Delivery { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ActualDeliveryDate')] - public ?string $endpointId = null; + public ?string $actualDeliveryDate = null; #[Type(DeliveryLocation::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] diff --git a/src/UBL/Models/DocumentReference.php b/src/UBL/Models/DocumentReference.php index 73d534d..cbbab96 100644 --- a/src/UBL/Models/DocumentReference.php +++ b/src/UBL/Models/DocumentReference.php @@ -16,7 +16,7 @@ final class DocumentReference #[SerializedName('ID')] public ?Id $id = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('IssueDate')] public ?string $issueDate = null; @@ -26,7 +26,7 @@ final class DocumentReference #[SerializedName('DocumentTypeCode')] public ?DocumentType $typeCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('DocumentDescription')] public ?string $documentDescription = null; diff --git a/src/UBL/Models/EmbeddedDocumentBinaryObject.php b/src/UBL/Models/EmbeddedDocumentBinaryObject.php index 38e2a92..653f30d 100644 --- a/src/UBL/Models/EmbeddedDocumentBinaryObject.php +++ b/src/UBL/Models/EmbeddedDocumentBinaryObject.php @@ -17,12 +17,12 @@ final class EmbeddedDocumentBinaryObject #[SerializedName('mimeCode')] public MimeType $mimeCode; - #[Type('string')] + #[Type(StringValue::class)] #[XmlAttribute] #[SerializedName('filename')] public string $filename; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public string $value; } diff --git a/src/UBL/Models/EndpointId.php b/src/UBL/Models/EndpointId.php index 2e47e85..61ced26 100644 --- a/src/UBL/Models/EndpointId.php +++ b/src/UBL/Models/EndpointId.php @@ -17,7 +17,7 @@ final class EndpointId #[SerializedName('schemeID')] public ?ElectronicAddressScheme $schemeID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/ExternalReference.php b/src/UBL/Models/ExternalReference.php index ce1a909..a590995 100644 --- a/src/UBL/Models/ExternalReference.php +++ b/src/UBL/Models/ExternalReference.php @@ -10,7 +10,7 @@ final class ExternalReference { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('URI')] public ?string $uri = null; diff --git a/src/UBL/Models/Id.php b/src/UBL/Models/Id.php index 46fae85..8cf45c9 100644 --- a/src/UBL/Models/Id.php +++ b/src/UBL/Models/Id.php @@ -11,12 +11,12 @@ final class Id { - #[Type('string')] + #[Type(StringValue::class)] #[XmlAttribute] #[SerializedName('schemeID')] public ?string $schemeID = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/Item.php b/src/UBL/Models/Item.php index 2bc1556..3207a2d 100644 --- a/src/UBL/Models/Item.php +++ b/src/UBL/Models/Item.php @@ -11,12 +11,12 @@ final class Item { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Description')] public ?string $description = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Name')] public ?string $name = null; diff --git a/src/UBL/Models/ItemClassificationCode.php b/src/UBL/Models/ItemClassificationCode.php index ea35dbe..4d6f9f5 100644 --- a/src/UBL/Models/ItemClassificationCode.php +++ b/src/UBL/Models/ItemClassificationCode.php @@ -11,12 +11,12 @@ final class ItemClassificationCode { - #[Type('string')] + #[Type(StringValue::class)] #[XmlAttribute] #[SerializedName('listID')] public ?string $listId = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/ItemProperty.php b/src/UBL/Models/ItemProperty.php index b19f605..d08a5f0 100644 --- a/src/UBL/Models/ItemProperty.php +++ b/src/UBL/Models/ItemProperty.php @@ -10,12 +10,12 @@ final class ItemProperty { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Name')] public ?string $name = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Value')] public ?string $value = null; diff --git a/src/UBL/Models/Note.php b/src/UBL/Models/Note.php index 279d7fa..70d06e2 100644 --- a/src/UBL/Models/Note.php +++ b/src/UBL/Models/Note.php @@ -9,7 +9,7 @@ final class Note { - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/OrderReference.php b/src/UBL/Models/OrderReference.php index 93c7e2f..7570709 100644 --- a/src/UBL/Models/OrderReference.php +++ b/src/UBL/Models/OrderReference.php @@ -10,12 +10,12 @@ final class OrderReference { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ID')] public ?string $id = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('SalesOrderID')] public ?string $salesOrderId = null; diff --git a/src/UBL/Models/PartyLegalEntity.php b/src/UBL/Models/PartyLegalEntity.php index 9021d22..66dec64 100644 --- a/src/UBL/Models/PartyLegalEntity.php +++ b/src/UBL/Models/PartyLegalEntity.php @@ -10,7 +10,7 @@ final class PartyLegalEntity { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('RegistrationName')] public ?string $registrationName = null; @@ -20,7 +20,7 @@ final class PartyLegalEntity #[SerializedName('CompanyID')] public ?Id $id = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('CompanyLegalForm')] public ?string $companyLegalForm = null; diff --git a/src/UBL/Models/PartyName.php b/src/UBL/Models/PartyName.php index 87b159e..aa34487 100644 --- a/src/UBL/Models/PartyName.php +++ b/src/UBL/Models/PartyName.php @@ -10,7 +10,7 @@ final class PartyName { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Name')] public ?string $name = null; diff --git a/src/UBL/Models/PartyTaxScheme.php b/src/UBL/Models/PartyTaxScheme.php index 3d19749..a7da223 100644 --- a/src/UBL/Models/PartyTaxScheme.php +++ b/src/UBL/Models/PartyTaxScheme.php @@ -10,7 +10,7 @@ final class PartyTaxScheme { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('CompanyID')] public ?string $companyId = null; diff --git a/src/UBL/Models/PayeeFinancialAccount.php b/src/UBL/Models/PayeeFinancialAccount.php index b932806..7534a66 100644 --- a/src/UBL/Models/PayeeFinancialAccount.php +++ b/src/UBL/Models/PayeeFinancialAccount.php @@ -15,7 +15,7 @@ final class PayeeFinancialAccount #[SerializedName('ID')] public ?Id $id = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Name')] public ?string $name = null; diff --git a/src/UBL/Models/PaymentMeans.php b/src/UBL/Models/PaymentMeans.php index 17f02eb..23600ff 100644 --- a/src/UBL/Models/PaymentMeans.php +++ b/src/UBL/Models/PaymentMeans.php @@ -15,7 +15,7 @@ final class PaymentMeans #[SerializedName('PaymentMeansCode')] public ?PaymentMeansCode $paymentMeansCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('InstructionNote')] public ?string $instructionNote = null; diff --git a/src/UBL/Models/PaymentMeansCode.php b/src/UBL/Models/PaymentMeansCode.php index 57dc111..9383c28 100644 --- a/src/UBL/Models/PaymentMeansCode.php +++ b/src/UBL/Models/PaymentMeansCode.php @@ -11,12 +11,12 @@ final class PaymentMeansCode { - #[Type('string')] + #[Type(StringValue::class)] #[XmlAttribute] #[SerializedName('name')] public ?string $name = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/PaymentTerms.php b/src/UBL/Models/PaymentTerms.php index a349186..859c38a 100644 --- a/src/UBL/Models/PaymentTerms.php +++ b/src/UBL/Models/PaymentTerms.php @@ -10,7 +10,7 @@ final class PaymentTerms { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('Note')] public ?string $note = null; diff --git a/src/UBL/Models/Period.php b/src/UBL/Models/Period.php index eb7f89e..b6e974e 100644 --- a/src/UBL/Models/Period.php +++ b/src/UBL/Models/Period.php @@ -10,17 +10,17 @@ final class Period { - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('StartDate')] public ?string $startDate = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('EndDate')] public ?string $endDate = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('DescriptionCode')] public ?string $descriptionCode = null; diff --git a/src/UBL/Models/Quantity.php b/src/UBL/Models/Quantity.php index 197618c..132e123 100644 --- a/src/UBL/Models/Quantity.php +++ b/src/UBL/Models/Quantity.php @@ -17,7 +17,7 @@ final class Quantity #[SerializedName('unitCode')] public ?UnitCode $unitCode = null; - #[Type('string')] + #[Type(StringValue::class)] #[XmlValue(cdata: false)] public ?string $value = null; } diff --git a/src/UBL/Models/StringValue.php b/src/UBL/Models/StringValue.php new file mode 100644 index 0000000..ed7b955 --- /dev/null +++ b/src/UBL/Models/StringValue.php @@ -0,0 +1,7 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 2016166 + 2015-01-09 + 2015-01-09 + 380 + #AAR#This is an example invoice based on data that is used in real business.Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + EUR + + + + Storkower Straße 207 + Berlin + 10369 + + DE + + + + DE37/302/30168 + + VAT + + + + XXX AG + 57151520 + + + + + + + 10202 + + + Storkower Straße 207 + Berlin + 10369 + + DE + + + + XXX AG + + + XXXX + + + + + 2016-09-06 + + + 30 + 2016166 + + DE12500105170648489890 + + + + 2221.84 + + 11693.87 + 2221.84 + + S + 19 + + VAT + + + + + + 11693.87 + 11693.87 + 13915.71 + 13915.71 + + + 1 + 1 + 12122.59 + + Neues DSL Portfolio 2016 + Festpreis + + 846 + + + S + 19 + + VAT + + + + + 12122.59 + + + + 2 + -1 + -606.13 + + Abzug + + 832 + + + S + 19 + + VAT + + + + + 606.13 + + + + 16 + 1 + 177.41 + + zzgl. + + 870 + + + S + 19 + + VAT + + + + + 1.5 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_business_example_02-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_business_example_02-ubl.xml new file mode 100644 index 0000000..8bf1795 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_business_example_02-ubl.xml @@ -0,0 +1,153 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + INV000013 + 2013-08-25 + 2013-05-10 + 380 + #REG#TEXT + EUR + + 2013-01-01 + 2013-04-01 + + + SUBSCR571 + + + + + Storkower Straße 207 + Berlin + 10369 + + DE + + + + DE1111111 + + VAT + + + + xxxx + 111111111 + + + + + + + 1111111111 + + + Anystreet, Building 1 + Anytown + 101 + + DE + + + + Buyercompany ltd + + + + + 30 + INV000013 + + DK1212341234123412 + + + + false + Rabatt + 0 + + S + 19 + + VAT + + + + + 1.9 + + 10 + 1.9 + + S + 19 + + VAT + + + + + + 10 + 10 + 11.9 + 0 + 0 + 11.9 + + + 1 + 1 + 1.26 + + BPW21 + + S + 19 + + VAT + + + + + 1.2605 + + + + 2 + 1 + 1.26 + + Poti 100k + + S + 19 + + VAT + + + + + 1.2605 + + + + 3 + 1 + 7.48 + + LCD Display 3.5 + + S + 19 + + VAT + + + + + 7.479 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_business_example_Z-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_business_example_Z-ubl.xml new file mode 100644 index 0000000..1faa1b2 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_business_example_Z-ubl.xml @@ -0,0 +1,159 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 2016166 + 2015-01-09 + 2015-01-09 + 380 + #AAR#This is an example invoice based on data that is used in real business.Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + EUR + + + + Storkower Straße 207 + Berlin + 10369 + + DE + + + + DE37/302/30168 + + VAT + + + + XXX AG + 57151520 + + + + + + + 10202 + + + Storkower Straße 207 + Berlin + 10369 + + DE + + + + XXX AG + + + XXXX + + + + + 2016-09-06 + + + 30 + 2016166 + + DE12500105170648489890 + + + + 0 + + 11693.87 + 0 + + Z + 0 + + VAT + + + + + + 11693.87 + 11693.87 + 11693.87 + 11693.87 + + + 1 + 1 + 12122.59 + + Neues DSL Portfolio 2016 + Festpreis + + 846 + + + Z + 0 + + VAT + + + + + 12122.59 + + + + 2 + -1 + -606.13 + + Abzug + + 832 + + + Z + 0 + + VAT + + + + + 606.13 + + + + 16 + 1 + 177.41 + + zzgl. + + 870 + + + Z + 0 + + VAT + + + + + 1.5 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example1-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example1-ubl.xml new file mode 100644 index 0000000..deaace8 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example1-ubl.xml @@ -0,0 +1,519 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 12115118 + 2015-01-09 + 2015-01-09 + 380 + #AAR#Alle leveringen zijn franco. Alle prijzen zijn incl. BTW. Betalingstermijn: 14 dagen netto. Prijswijzigingen voorbehouden. Op al onze aanbiedingen, leveringen en overeenkomsten zijn van toepassing in de algemene verkoop en leveringsvoorwaarden. Gedeponeerd bij de K.v.K. te Amsterdam 25-04-'85. + EUR + + + + Postbus 7l + Velsen-Noord + 1950 AB + + NL + + + + NL8200.98.395.B.01 + + VAT + + + + De Koksmaat + 57151520 + + + + + + + 10202 + + + POSTBUS 367 + HEEMSKERK + 1960 AJ + + NL + + + + ODIN 59 + + + Dhr. J BLOKKER + + + + + 30 + Deb. 10202 / Fact. 12115118 + + NL57 RABO 0107307510 + + + + 30 + Deb. 10202 / Fact. 12115118 + + NL57 RABO 0107307510 + + + + 20.73 + + 183.23 + 10.99 + + S + 6 + + VAT + + + + + 46.37 + 9.74 + + S + 21 + + VAT + + + + + + 229.6 + 229.6 + 250.33 + 250.33 + + + 1 + 2 + 19.9 + + PATAT FRITES 10MM 10KG + + 166022 + + + S + 6 + + VAT + + + + + 9.95 + + + + 2 + 1 + 9.85 + + KAAS 50PL. JONG BEL. 1KG + + 661813 + + + S + 6 + + VAT + + + + + 9.85 + + + + 3 + 1 + 8.29 + + POT KETCHUP 3 LT + + 438146 + + + S + 6 + + VAT + + + + + 8.29 + + + + 4 + 2 + 14.46 + + FRITESSAUS 3 LRR + + 438103 + + + S + 6 + + VAT + + + + + 7.23 + + + + 5 + 1 + 35 + + KOFFIE BLIK 3,5KG SNELF + + 666955 + + + S + 6 + + VAT + + + + + 35 + + + + 6 + 1 + 35 + + KOFFIE 3.5 KG BLIK STAND + + 664871 + + + S + 6 + + VAT + + + + + 35 + + + + 7 + 1 + 10.65 + + SUIKERKLONT + + 350257 + + + S + 6 + + VAT + + + + + 10.65 + + + + 8 + 1 + 1.55 + + 1 KG UL BLOKJES + + 350258 + + + S + 6 + + VAT + + + + + 1.55 + + + + 9 + 3 + 14.37 + + BLOCKNOTE A5 + + 999998 + + + S + 6 + + VAT + + + + + 4.79 + + + + 10 + 1 + 8.29 + + CHIPS NAT KLEIN ZAKJES + + 740810 + + + S + 6 + + VAT + + + + + 8.29 + + + + 11 + 2 + 16.58 + + CHIPS PAP KLEINE ZAKJES + + 740829 + + + S + 6 + + VAT + + + + + 8.29 + + + + 12 + 1 + 9.95 + + TR KL PAKJES APPELSAP + + 740828 + + + S + 6 + + VAT + + + + + 9.95 + + + + 13 + 2 + 3.3 + + PK CHOCOLADEMELK + + 740827 + + + S + 6 + + VAT + + + + + 1.65 + + + + 14 + 1 + 10.8 + + KRAT BIER + + 999996 + + + S + 21 + + VAT + + + + + 10.8 + + + + 15 + 1 + 3.9 + + STATIEGELD + + 999995 + + + S + 6 + + VAT + + + + + 3.9 + + + + 16 + 2 + 7.6 + + BLEEK 3 X 750 ML + + 102172 + + + S + 21 + + VAT + + + + + 3.8 + + + + 17 + 2 + 9.34 + + WC PAPIER + + 999994 + + + S + 21 + + VAT + + + + + 4.67 + + + + 18 + 1 + 18.63 + + BALPENNEN 50 ST BLAUW + + 999993 + + + S + 21 + + VAT + + + + + 18.63 + + + + 19 + 6 + 102.12 + + EM FRITUURVET + + 999992 + + + S + 6 + + VAT + + + + + 17.02 + + + + 20 + 6 + -109.98 + + FRITUUR VET 10 KG RETOUR + + 175137 + + + S + 6 + + VAT + + + + + 18.33 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example2-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example2-ubl.xml new file mode 100644 index 0000000..1a6cdb2 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example2-ubl.xml @@ -0,0 +1,432 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + TOSL108 + 2013-06-30 + 2013-07-20 + 380 + Ordered in our booth at the convention + 2013-06-30 + NOK + Project cost code 123 + + 2013-06-01 + 2013-06-30 + + + 123 + + + Contract321 + + + Doc1 + Timesheet + + SlZCRVJpMHhMalVOQ2lVTkNqRWdNQ0J2WW1vT3k2SlRaWDliY2dSVnhJVkcuLi50Ykxvc0NoVTJYUmY5eGIvb21zY2dUWS9sWEVoVWI= + + http://www.suppliersite.eu/sheet001.html + + + + + + + 1238764941386 + + + Main street 34 + Suite 123 + Big city + 303 + RegionA + + NO + + + + NO123456789MVA + + VAT + + + + Salescompany ltd. + 123456789 + + + Antonio Salesmacher + 46211230 + antonio@salescompany.no + + + + + + + 3456789012098 + + + Anystreet 8 + Back door + Anytown + 101 + RegionB + + NO + + + + NO987654321MVA + + VAT + + + + The Buyercompany + 987654321 + + + John Doe + 5121230 + john@buyercompany.no + + + + + + 2298740918237 + + + Ebeneser Scrooge AS + + + + + Tax handling company AS + + + Regent street + Front door + Newtown + 202 + RegionC + + NO + + + + NO967611265MVA + + VAT + + + + + 2013-06-15 + + 6754238987643 + + Deliverystreet 2 + Side door + DeliveryCity + 523427 + RegionD + + NO + + + + + + 30 + 0003434323213231 + + NO9386011117947 + + DNBANOKK + + + + + 30 + 0003434323213231 + + NO9386011117947 + + + + 2 % discount if paid within 2 days +Penalty percentage 10% from due date + + + false + 95 + Promotion discount + 100 + + S + 25 + + VAT + + + + + true + Freight + 100 + + S + 25 + + VAT + + + + + 365.28 + + 1460.5 + 365.13 + + S + 25 + + VAT + + + + + 1 + 0.15 + + S + 15 + + VAT + + + + + -25 + 0 + + E + 0 + Exempt New Means of Transport + + VAT + + + + + + 1436.5 + 1436.5 + 1801.78 + 100 + 100 + 1000 + 801.78 + + + 1 + Scratch on box + 1 + 1273 + BookingCode001 + + 2013-06-01 + 2013-06-01 + + + 1 + + + false + Damage + 12 + + + true + Testing + 12 + + + Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM: 3MB. Screen 1440x900 + Laptop computer + + JB007 + + + 1234567890128 + + + DE + + + 65434568 + + + S + 25 + + VAT + + + + Color + Black + + + + 1273 + 1498 + + false + 225 + 1498 + + + + + 2 + Cover is slightly damaged. + -1 + -3.96 + BookingCode002 + + 5 + + + Returned "Advanced computing" book + + JB008 + + + 1234567890135 + + + 65434567 + + + S + 15 + + VAT + + + + + 3.96 + 3.96 + + + + 3 + 2 + 4.96 + BookingCode003 + + 3 + + + "Computing for dummies" book + + JB009 + + + 1234567890142 + + + 65434566 + + + S + 15 + + VAT + + + + + 2.48 + 2.75 + + false + 0.275 + 2.75 + + + + + 4 + -1 + -25 + BookingCode004 + + 2 + + + Returned IBM 5150 desktop + + JB010 + + + 1234567890159 + + + 65434565 + + + E + 0 + + VAT + + + + + 25 + 25 + + + + 5 + 250 + 187.5 + BookingCode005 + + 4 + + + Network cable + + JB011 + + + 1234567890166 + + + 12344325 + + + S + 25 + + VAT + + + + Type + Cat5 + + + + 0.75 + 0.75 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example3-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example3-ubl.xml new file mode 100644 index 0000000..9970d26 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example3-ubl.xml @@ -0,0 +1,128 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + TOSL108 + 2013-04-10 + 2013-05-10 + 380 + Contract was established through our website + DKK + + 2013-01-01 + 2013-04-01 + + + SUBSCR571 + + + + + Main street 2, Building 4 + Big city + 54321 + + DK + + + + DK16356706 + + VAT + + + + SubscriptionSeller + DK16356706 + + + antonio@SubscriptionsSeller.dk + + + + + + + 5790000435975 + + + Anystreet, Building 1 + Anytown + 101 + + DK + + + + Buyercompany ltd + + + + + 30 + Payref1 + + DK1212341234123412 + + + + 30 + Payref1 + + DK1212341234123412 + + + + true + FC + Freight charge + 100 + + S + 25 + + VAT + + + + + 225 + + 900 + 225 + + S + 25 + + VAT + + + + + + 800 + 900 + 1125 + 100 + 1125 + + + 1 + 1 + 800 + + Subscription fee 1st quarter + Paper subscription + + S + 25 + + VAT + + + + + 800 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example4-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example4-ubl.xml new file mode 100644 index 0000000..6056416 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example4-ubl.xml @@ -0,0 +1,188 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + TOSL110 + 2013-04-10 + 2013-05-10 + 380 + Ordered through our website + DKK + + 123 + + + + + 5790000436101 + + + Main street 2, Building 4 + Big city + 54321 + + DK + + + + DK16356706 + + VAT + + + + SellerCompany + DK16356706 + + + Anthon Larsen + +4598989898 + Anthon@SellerCompany.dk + + + + + + + 5790000436057 + + + Anystreet, Building 1 + Anytown + 101 + + DK + + + + Buyercompany ltd + + + John Hansen + + + + + 2013-04-15 + + + Deliverystreet + Deliverycity + 9000 + + DK + + + + + + 30 + Payref1 + + DK1212341234123412 + + + + 30 + Payref1 + + DK1212341234123412 + + + + 675 + + 1500 + 375 + + S + 25 + + VAT + + + + + 2500 + 300 + + S + 12 + + VAT + + + + + + 4000 + 4000 + 4675 + 4675 + + + 1 + 1000 + 1000 + + Printing paper, 2mm + Printing paper + + JB007 + + + S + 25 + + VAT + + + + + 1 + + + + 2 + 100 + 500 + + Parker Pen, Black, model Sansa + Parker Pen + + JB008 + + + S + 25 + + VAT + + + + + 5 + + + + 3 + 500 + 2500 + + American Cookies + + JB009 + + + S + 12 + + VAT + + + + + 5 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example6-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example6-ubl.xml new file mode 100644 index 0000000..2edc692 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example6-ubl.xml @@ -0,0 +1,125 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + TOSL110 + 2013-04-10 + 2013-05-10 + 380 + DKK + + + + + DK + + + + DK123456789MVA + + VAT + + + + SellerCompany + + + + + + + + DK + + + + Buyercompany ltd + + + + + 675 + + 1500 + 375 + + S + 25 + + VAT + + + + + 2500 + 300 + + S + 12 + + VAT + + + + + + 4000 + 4000 + 4675 + 4675 + + + 1 + 1000 + 1000 + + Printing paper + + S + 25 + + VAT + + + + + 1 + + + + 2 + 100 + 500 + + Parker Pen + + S + 25 + + VAT + + + + + 5 + + + + 3 + 500 + 2500 + + American Cookies + + S + 12 + + VAT + + + + + 5 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example7-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example7-ubl.xml new file mode 100644 index 0000000..9f9b11c --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example7-ubl.xml @@ -0,0 +1,148 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + INVOICE_test_7 + 2013-05-13 + 380 + Testscenario 7 + SEK + + 2013-01-01 + 2013-12-31 + + + Order_9988_x + + + + + 5532331183 + + + Civic Service Centre + + + Main street 2, Building 4 + Big city + 54321 + + SE + + + + The Sellercompany Incorporated + + + Anthon Larsen + 4698989898 + Anthon@SellerCompany.se + + + + + + + Anystreet 8 + Back door + Anytown + 101 + RegionB + + SE + + + + THe Buyercompany + + + 3150bdn + 5121230 + john@buyercompany.no + + + + + 30 + + SE1212341234123412 + + SEXDABCD + + + + + 30 + + SE1212341234123412 + + + + Payment within 30 days + + + 0 + + 3200 + 0 + + O + Tax + + VAT + + + + + + 3200 + 3200 + 3200 + 3200 + + + 1 + 1 + 2500 + + 1 + + + Weight-based tax, vehicles >3000 KGM + Road tax + + RT3000 + + + O + + VAT + + + + + 2500 + + + + 2 + 1 + 700 + + Annual registration fee + Road Register fee + + REG + + + O + + VAT + + + + + 700 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example8-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example8-ubl.xml new file mode 100644 index 0000000..540dcb1 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example8-ubl.xml @@ -0,0 +1,405 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 1100512149 + 2014-11-10 + 2014-11-24 + 380 + Periodieke afrekening +U vindt een toelichting op uw factuur via www.enexis.nl/factuur_grootzakelijk +Op alle diensten en overeenkomsten zijn de algemene voorwaarden aansluiting en +transport grootverbruik elektriciteit, respectievelijk gas van toepassing +www.enexis.nl + EUR + + 2014-08-01 + 2014-08-31 + + + 871694831000290806 + 130 + + + + + Enexis + + + Magistratenlaan 116 + 'S-HERTOGENBOSCH + 5223MB + + NL + + + + NL809561074B01 + + VAT + + + + Enexis B.V. + 17131139 + + + klantenservice.zakelijk@enexis.nl + + + + + + + 1081119 + + + Bedrijfslaan 4 + ONDERNEMERSTAD + 9999 XX + + NL + + + + Klant + + + + + + + Bedrijfslaan 4, + ONDERNEMERSTAD + 9999 XX + + NL + + + + + + 30 + 1100512149 + + NL28RBOS0420242228 + + + + 30 + 1100512149 + + NL28RBOS0420242228 + + + + Enexis brengt wettelijke rente in rekening over te laat betaalde +facturen. Kijk voor informatie op www.enexis.nl/rentenota + + + 190.87 + + 908.91 + 190.87 + + S + 21 + + VAT + + + + + + 908.91 + 908.91 + 1099.78 + 1099.78 + + + 1 + 16000 + 140.8 + + Getransporteerde kWh’s + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 0.0088 + 0.0088 + + + + 2 + 16000 + 16.16 + + Systeemdiensten + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 0.00101 + 0.00101 + + + + 3 + 132 + 167.64 + + Contract transportvermogen + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 15.24 + 15.24 + + + + 4 + 58 + 88.74 + + Maximaal afgenomen vermogen + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 1.53 + 1.53 + + + + 5 + 1 + 36.75 + + Vastrecht Transportdienst + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 441 + 441 + + + + 6 + 1 + 56.5 + + Vastrecht Aansluitdienst + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 678 + 678 + + + + 7 + 1 + 83.34 + + Huur Transformatoren + + S + 21 + + VAT + + + + + 83.34 + 83.34 + + + + 8 + 1 + 190.31 + + Huur Schakelinstallaties + + S + 21 + + VAT + + + + + 190.31 + 190.31 + + + + 9 + 1 + 64.21 + + Huur Overige Apparaten + + S + 21 + + VAT + + + + + 64.21 + 64.21 + + + + 10 + 1 + 64.46 + + Huur Meterdiensten + + S + 21 + + VAT + + + + + 64.46 + 64.46 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/CII_example9-ubl.xml b/tests/Integration/Examples/UBL/Converted/CII_example9-ubl.xml new file mode 100644 index 0000000..746f561 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/CII_example9-ubl.xml @@ -0,0 +1,122 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 20150483 + 2015-04-01 + 2015-04-15 + 380 + Vriendelijk verzoeken wij u ervoor te zorgen dat het bedrag voor de vervaldatum op onze rekening staat onder vermelding van +het factuurnummer. Het bankrekeningnummer is 37.78.15.500, Rabobank, t.n.v. Bluem te Amersfoort. Reclames gaarne binnen +10 dagen. Gelieve bij navraag en correspondentie uw firma naam en factuurnummer vermelden. + + EUR + + iExpress 20110412 + + + + + Lindeboomseweg 41 + Amersfoort + 3825 AL + + NL + + + + NL809163160B01 + + VAT + + + + Bluem BV + 32081330 Amersfoort + + + 033-4549055 + info@bluem.nl + + + + + + + Henry Dunantweg 42 + Alphen aan den Rijn + 2402 NR + + NL + + + + Provide Verzekeringen + + + + + 30 + 2015 0483 0000 0000 + + NL13RABO0377815500 + + RABONL2U + + + + + 30 + 2015 0483 0000 0000 + + NL13RABO0377815500 + + + + 30.87 + + 147 + 30.87 + + S + 21 + + VAT + + + + + + 147 + 147 + 177.87 + 177.87 + + + 1 + 3 + 147 + + 2016-04-01 + 2016-04-01 + + + IExpress licentiekosten + + S + 21 + + VAT + + + + Verbruikscategorie + Start + + + + 49 + 49 + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/EN16931_AbweichenderZahlungsempf-ubl.xml b/tests/Integration/Examples/UBL/Converted/EN16931_AbweichenderZahlungsempf-ubl.xml new file mode 100644 index 0000000..2f1f2c5 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/EN16931_AbweichenderZahlungsempf-ubl.xml @@ -0,0 +1,179 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 471102 + 2018-03-05 + 380 + Rechnung gemäß Bestellung vom 01.03.2018. + #REG#Lieferant GmbH + Lieferantenstraße 20 + 80333 München + Deutschland + Geschäftsführer: Hans Muster + Handelsregisternummer: H A 123 + + EUR + + + + 4000001123452 + + + Lieferantenstraße 20 + München + 80333 + + DE + + + + 201/113/40209 + + FC + + + + DE123456789 + + VAT + + + + Lieferant GmbH + + + + + + + GE2020211 + + + Kundenstraße 15 + Frankfurt + 69876 + + DE + + + + Kunden AG Mitte + + + + + + 4711 + + + Factoring GmbH + + + + 2018-03-05 + + + 58 + + DE12123456781234567890 + + + + Zahlbar innerhalb 30 Tagen netto bis 04.04.2018, 3% Skonto innerhalb 10 Tagen bis + 15.03.2018 + + + + 56.87 + + 275 + 19.25 + + S + 7 + + VAT + + + + + 198 + 37.62 + + S + 19 + + VAT + + + + + + 473 + 473 + 529.87 + 0 + 0 + 0 + 529.87 + + + 1 + 20 + 198 + + Trennblätter A4 + + TB100A4 + + + 4012345001235 + + + S + 19 + + VAT + + + + + 9.9 + + false + 0 + 9.9 + + + + + 2 + 50 + 275 + + Joghurt Banane + + ARNR2 + + + 4000050986428 + + + S + 7 + + VAT + + + + + 5.5 + + false + 0 + 5.5 + + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/EN16931_Einfach-ubl.xml b/tests/Integration/Examples/UBL/Converted/EN16931_Einfach-ubl.xml new file mode 100644 index 0000000..b292f61 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/EN16931_Einfach-ubl.xml @@ -0,0 +1,156 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 471102 + 2018-03-05 + 380 + Rechnung gemäß Bestellung vom 01.03.2018. + EUR + + + + 4000001123452 + + + Lieferantenstraße 20 + München + 80333 + + DE + + + + 201/113/40209 + + FC + + + + DE123456789 + + VAT + + + + Lieferant GmbH + + + + + + + GE2020211 + + + Kundenstraße 15 + Frankfurt + 69876 + + DE + + + + Kunden AG Mitte + + + + + 2018-03-05 + + + Zahlbar innerhalb 30 Tagen netto bis 04.04.2018, 3% Skonto innerhalb 10 Tagen bis 15.03.2018 + + + 56.87 + + 275 + 19.25 + + S + 7 + + VAT + + + + + 198 + 37.62 + + S + 19 + + VAT + + + + + + 473 + 473 + 529.87 + 0 + 0 + 0 + 529.87 + + + 1 + 20 + 198 + + Trennblätter A4 + + TB100A4 + + + 4012345001235 + + + S + 19 + + VAT + + + + + 9.9 + + false + 0 + 9.9 + + + + + 2 + 50 + 275 + + Joghurt Banane + + ARNR2 + + + 4000050986428 + + + S + 7 + + VAT + + + + + 5.5 + + false + 0 + 5.5 + + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/EN16931_Gutschrift-ubl.xml b/tests/Integration/Examples/UBL/Converted/EN16931_Gutschrift-ubl.xml new file mode 100644 index 0000000..7aabba3 --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/EN16931_Gutschrift-ubl.xml @@ -0,0 +1,171 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 471102 + 2018-03-05 + 389 + Rechnung gemäß Bestellung vom 01.03.2018. + #REG#Lieferant GmbH + Lieferantenstraße 20 + 80333 München + Deutschland + Geschäftsführer: Hans Muster + Handelsregisternummer: H A 123 + + EUR + + + + 4000001123452 + + + Lieferantenstraße 20 + München + 80333 + + DE + + + + 201/113/40209 + + FC + + + + DE123456789 + + VAT + + + + Lieferant GmbH + + + + + + + GE2020211 + + + Kundenstraße 15 + Frankfurt + 69876 + + DE + + + + DE136695976 + + VAT + + + + Kunden AG Mitte + + + + + 2018-03-05 + + + Der Betrag wird ihrem Kundenkonto gutgeschrieben und mit der nächsten Rechnung + verrechnet. + + + + 56.87 + + 275 + 19.25 + + S + 7 + + VAT + + + + + 198 + 37.62 + + S + 19 + + VAT + + + + + + 473 + 473 + 529.87 + 0 + 0 + 0 + 529.87 + + + 1 + 20 + 198 + + Trennblätter A4 + + TB100A4 + + + 4012345001235 + + + S + 19 + + VAT + + + + + 9.9 + + false + 0 + 9.9 + + + + + 2 + 50 + 275 + + Joghurt Banane + + ARNR2 + + + 4000050986428 + + + S + 7 + + VAT + + + + + 5.5 + + false + 0 + 5.5 + + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/Converted/EN16931_Innergemeinschaftliche_Lieferungen-ubl.xml b/tests/Integration/Examples/UBL/Converted/EN16931_Innergemeinschaftliche_Lieferungen-ubl.xml new file mode 100644 index 0000000..9e68fec --- /dev/null +++ b/tests/Integration/Examples/UBL/Converted/EN16931_Innergemeinschaftliche_Lieferungen-ubl.xml @@ -0,0 +1,218 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 47110818 + 2018-10-31 + 2018-11-30 + 389 + #REG#Mitglieder der Geschäftsleitung: + Geschäftsführerin: Johanna Musterfrau + Prokuristin: Isabell Herrlich + HRB Berlin 13086 + + EUR + + 2018-10-01 + 2018-10-31 + + + + + 12345676 + + + 153 Victoria Street + London + SW1B 3BN + + GB + + + + GB123456789 + + VAT + + + + Global Supplies Ltd. + + + + + + + 75969813 + + + Pappelallee 15 + Hof 3 + Leipzig + 12345 + + DE + + + + DE123456789 + + VAT + + + + Metallbau Leipzig GmbH & Co. KG + + + + + + 432156789 + + + Global Supplies Financial Services + + + + + Global Supplies Financial Services + + + Friedrichstraße 165 + Berlin + 12345 + + DE + + + + DE987654321 + + VAT + + + + + + 75969815 + + Eichenpromenade 37 + Tor 1 + Metallstadt + 12347 + + DE + + + + + + Metallbau Leipzig GmbH & Co. KG + + + + + 58 + + DE12 1234 4321 9876 00 + Global Supplies Financial Services + + + + 0 + + 2000 + 0 + + K + 0 + Mehrwertsteuerbefreiung für die innergemeinschaftliche Lieferung von Waren und + Dienstleistungen in der EU + + + VAT + + + + + + 2000 + 2000 + 2000 + 2000 + + + 1 + 10 + 1000 + + 2018-10-01 + 2018-10-31 + + + Stahlcoil + + Toolbox 0815 + + + CO-123/V2A + + + DE + + + K + 0 + + VAT + + + + + 100 + 1 + + false + 0 + 1000 + + + + + 2 + 10 + 1000 + + 2018-10-01 + 2018-10-31 + + + Stoßfänger + + BR-4529-ZF + + + IM-712/A2A + + + DE + + + K + 0 + + VAT + + + + + 100 + 1 + + false + 0 + 1000 + + + + \ No newline at end of file diff --git a/tests/Integration/ReaderTest.php b/tests/Integration/ReaderTest.php index d3905e7..f0b6fa8 100644 --- a/tests/Integration/ReaderTest.php +++ b/tests/Integration/ReaderTest.php @@ -12,8 +12,8 @@ test( 'test if the reader can process the provided xml', - function (string $exampleFilePath, callable $asserter) { - $xml = file_get_contents($exampleFilePath); + function (string $filePath, callable $asserter) { + $xml = file_get_contents($filePath); expect($xml)->not->toBeFalse(); @@ -23,8 +23,8 @@ function (string $exampleFilePath, callable $asserter) { }, )->with([ [ - 'example' => __DIR__ . '/Examples/Reader/Broken.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/Broken.xml', + function (ReaderResult $readerResult) { expect($readerResult->isError()) ->toBeTrue() ->and($readerResult->getError()) @@ -33,8 +33,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/InvalidFormat.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/InvalidFormat.xml', + function (ReaderResult $readerResult) { expect($readerResult->isError()) ->toBeTrue() ->and($readerResult->getError()) @@ -48,8 +48,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/PeppolInvoice.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/PeppolInvoice.xml', + function (ReaderResult $readerResult) { expect($readerResult->isSuccess()) ->toBeTrue() ->and($readerResult->getDocument()) @@ -58,8 +58,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/PeppolCredit.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/PeppolCredit.xml', + function (ReaderResult $readerResult) { expect($readerResult->isSuccess()) ->toBeTrue() ->and($readerResult->getDocument()) @@ -68,8 +68,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/XRechnungCII.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/XRechnungCII.xml', + function (ReaderResult $readerResult) { expect($readerResult->isSuccess()) ->toBeTrue() ->and($readerResult->getDocument()) @@ -78,8 +78,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/XRechnungUBL.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/XRechnungUBL.xml', + function (ReaderResult $readerResult) { expect($readerResult->isSuccess()) ->toBeTrue() ->and($readerResult->getDocument()) @@ -88,8 +88,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/ZUGFeRD.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/ZUGFeRD.xml', + function (ReaderResult $readerResult) { expect($readerResult->isSuccess()) ->toBeTrue() ->and($readerResult->getDocument()) @@ -98,8 +98,8 @@ function (string $exampleFilePath, callable $asserter) { }, ], [ - 'example' => __DIR__ . '/Examples/Reader/ublinvoice-invlidID.xml', - 'asserter' => function (ReaderResult $readerResult) { + __DIR__ . '/Examples/Reader/ublinvoice-invlidID.xml', + function (ReaderResult $readerResult) { expect($readerResult->isError()) ->toBeTrue() ->and($readerResult->getError()) diff --git a/tests/Integration/SerializerTest.php b/tests/Integration/SerializerTest.php new file mode 100644 index 0000000..4ff3177 --- /dev/null +++ b/tests/Integration/SerializerTest.php @@ -0,0 +1,43 @@ +exchangedDocument = new ExchangedDocument(); + $invoice->exchangedDocumentContext = new ExchangedDocumentContext(); + $invoice->exchangedDocumentContext->documentContextParameter = new DocumentContextParameter(); + $invoice->exchangedDocumentContext->documentContextParameter->id = ' urn:cen.eu:en16931:2017'; + $invoice->exchangedDocument->id = ' 471102 '; + + $transformer = new Transformer(ConfiguredSerializer::createWithHandlers([ + new TrimStringValueHandler(), + ])); + + $xml = $transformer->transformToXml($invoice); + $result = Reader::create()->read($xml); + + expect($result->isSuccess()) + ->toBeTrue() + ->and($result->getDocument()) + ->toBeInstanceOf(CrossIndustryInvoice::class) + ->and($result->getDocument()->exchangedDocumentContext->documentContextParameter->id) + ->toEqual('urn:cen.eu:en16931:2017') + ->and($result->getDocument()->exchangedDocument->id) + ->toEqual('471102') + ; + } +); diff --git a/tests/Integration/UBLTest.php b/tests/Integration/UBLTest.php index 830bc98..470a456 100644 --- a/tests/Integration/UBLTest.php +++ b/tests/Integration/UBLTest.php @@ -43,6 +43,7 @@ use easybill\eInvoicing\UBL\Models\TaxScheme; use easybill\eInvoicing\UBL\Models\TaxSubtotal; use easybill\eInvoicing\UBL\Models\TaxTotal; +use Symfony\Component\Finder\Finder; test( 'Allows building a valid XRechnung 3.0 document with a simple structure', @@ -301,3 +302,37 @@ function (string $pathToXmlExample) { __DIR__ . '/Examples/UBL/Vat-category-S.xml', __DIR__ . '/Examples/UBL/vat-category-Z.xml', ]); + +test( + 'That reading converted CII examples to UBL is successful', + function (string $pathToXmlExample) { + $xml = file_get_contents($pathToXmlExample); + + expect($xml)->not->toBeFalse(); + + $xml = $this->fixUblRootNode($xml); + + $reader = Reader::create()->read($xml); + + expect($reader->isSuccess())->toBeTrue(); + expect($reader->getDocument())->toBeInstanceOf(UblAbstractDocument::class); + + $document = $reader->getDocument(); + + assert($document instanceof UblAbstractDocument); + + $xmlFromObject = Transformer::create()->transformToXml($document); + + $this->assertSame($this->reformatXml($xml), $this->reformatXml($xmlFromObject)); + } +)->with(function () { + $finder = (new Finder()) + ->files() + ->name('*.xml') + ->in(__DIR__ . '/Examples/UBL/Converted') + ; + + foreach ($finder as $file) { + yield $file->getFilename() => [$file->getRealPath()]; + } +});