diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..cf2d4c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,77 @@ +## Composer +.idea +composer.phar +/vendor/ + + +## Linux +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + + +## macOS +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +## Windows +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Generated XML files from tests +/tests/*.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..f753d94 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# php-zatca-xml diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..654edfc --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "saleh7/php-zatca-xml", + "description": "this package handle the stage 2 of zatca for integration the tax and simpilified tax invoices.", + "keywords": [ + "zatca", + "Saleh7", + "invoice", + "fatoora", + "ublinvoice", + "ubl invoice", + "zatca-xml", + "electronic invoice", + "digital invoice", + "xml", + "government", + "saudiarabia", + "saudi arabia", + "zakat and tax", + "xml invoice" + ], + "homepage": "https://github.com/Saleh7/php-zatca-xml", + "license": "MIT", + "require": { + "php": "^7.4||^8.1", + "sabre/xml": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "autoload": { + "psr-4": { + "Saleh7\\Zatca\\": ["src"], + "Saleh7\\Zatca\\Tests\\": ["tests"] + } + }, + "scripts": { + "test": "vendor/bin/phpunit", + "phpcs": "vendor/bin/phpcs -n --standard=phpcs.xml ./src/" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..db134c5 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1878 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "d7ead57962e04272e8d6cec1fbbf4adb", + "packages": [ + { + "name": "sabre/uri", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/uri.git", + "reference": "0ab547f34cf15a735e976a285ffc0cfcc27a3f82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/0ab547f34cf15a735e976a285ffc0cfcc27a3f82", + "reference": "0ab547f34cf15a735e976a285ffc0cfcc27a3f82", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.9", + "phpstan/phpstan": "^1.8", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\Uri\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "Functions for making sense out of URIs.", + "homepage": "http://sabre.io/uri/", + "keywords": [ + "rfc3986", + "uri", + "url" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/uri/issues", + "source": "https://github.com/fruux/sabre-uri" + }, + "time": "2022-09-26T06:12:15+00:00" + }, + { + "name": "sabre/xml", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/xml.git", + "reference": "5051b30416b60f52395007c7069acbd010edd2a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/5051b30416b60f52395007c7069acbd010edd2a7", + "reference": "5051b30416b60f52395007c7069acbd010edd2a7", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "lib-libxml": ">=2.6.20", + "php": "^7.4 || ^8.0", + "sabre/uri": ">=2.0,<4.0.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.9", + "phpstan/phpstan": "^1.8", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Deserializer/functions.php", + "lib/Serializer/functions.php" + ], + "psr-4": { + "Sabre\\Xml\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Markus Staab", + "email": "markus.staab@redaxo.de", + "role": "Developer" + } + ], + "description": "sabre/xml is an XML library that you may not hate.", + "homepage": "https://sabre.io/xml/", + "keywords": [ + "XMLReader", + "XMLWriter", + "dom", + "xml" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/xml/issues", + "source": "https://github.com/fruux/sabre-xml" + }, + "time": "2022-09-26T08:40:11+00:00" + } + ], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:15:36+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2022-03-03T13:19:32+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.15.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2" + }, + "time": "2022-11-12T15:38:23+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.23", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.14", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-12-28T12:41:10+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.5.27", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.5", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^3.2", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.5-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2022-12-09T07:31:23+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-09-14T12:41:17+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-04-03T09:37:03+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-09-14T06:03:37+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-02-14T08:28:10+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.6", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:17:30+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:45:17+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-09-12T14:47:03+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2021-07-28T10:34:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^7.4||^8.1" + }, + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/example.php b/example.php new file mode 100644 index 0000000..5cdeb4b --- /dev/null +++ b/example.php @@ -0,0 +1,183 @@ +setReferencedSignatureID("urn:oasis:names:specification:ubl:signature:Invoice") + ->setID('urn:oasis:names:specification:ubl:signature:1'); + +// UBLDocumentSignatures +$ublDecoment = (new \Saleh7\Zatca\UBLDocumentSignatures) + ->setSignatureInformation($sign); + +$extensionContent = (new \Saleh7\Zatca\ExtensionContent) + ->setUBLDocumentSignatures($ublDecoment); + +// UBLExtension +$UBLExtension[] = (new \Saleh7\Zatca\UBLExtension) + ->setExtensionURI('urn:oasis:names:specification:ubl:dsig:enveloped:xades') + ->setExtensionContent($extensionContent); + +$UBLExtensions = (new \Saleh7\Zatca\UBLExtensions) + ->setUBLExtensions($UBLExtension); + +$Signature = (new \Saleh7\Zatca\Signature) + ->setId("urn:oasis:names:specification:ubl:signature:Invoice") + ->setSignatureMethod("urn:oasis:names:specification:ubl:dsig:enveloped:xades"); +// invoiceType object +$invoiceType = (new \Saleh7\Zatca\InvoiceType()) + ->setInvoice('Invoice') // Invoice / Simplified + ->setInvoiceType('Invoice'); // Invoice / Debit / Credit + +// AdditionalDocumentReference +$AdditionalDocumentReferences = []; +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('ICV') + ->setUUID(23); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('PIH') + ->setPreviousInvoiceHash('NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ=='); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('QR'); + +// Tax scheme +$taxScheme = (new \Saleh7\Zatca\TaxScheme()) + ->setId("VAT"); + +// Party Tax Scheme +$partyTaxScheme = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme) + ->setCompanyId('311111111101113'); + +// party Tax Scheme Customer +$partyTaxSchemeCustomer = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme); + +// Address +$address = (new \Saleh7\Zatca\Address()) + ->setStreetName('الامير سلطان') + ->setBuildingNumber(2322) + ->setPlotIdentification(2223) + ->setCitySubdivisionName('الرياض') + ->setCityName('الرياض | Riyadh') + ->setPostalZone('23333') + ->setCountry('SA'); + +// Legal Entity +$legalEntity = (new \Saleh7\Zatca\LegalEntity()) + ->setRegistrationName('Acme Widget’s LTD'); + +// Delivery +$delivery = (new \Saleh7\Zatca\Delivery()) + ->setActualDeliveryDate("2022-09-07"); + +// Party supplier Company +$supplierCompany = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("CRN") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxScheme) + ->setPostalAddress($address); + +// Party supplier Customer +$supplierCustomer = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("NAT") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxSchemeCustomer) + ->setPostalAddress($address); + +// Payment Means +$clientPaymentMeans = (new \Saleh7\Zatca\PaymentMeans()) + ->setPaymentMeansCode("10"); + +// Tax Category +$taxCategory = (new \Saleh7\Zatca\TaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Invoice Line(s) +$allowanceCharges = []; +$allowanceCharges[] = (new \Saleh7\Zatca\AllowanceCharge()) +->setChargeIndicator(false) +->setAllowanceChargeReason('discount') +->setAmount(0.00) +->setTaxCategory($taxCategory); + +// Tax Sub Total +$taxSubTotal = (new \Saleh7\Zatca\TaxSubTotal()) + ->setTaxableAmount(4) + ->setTaxAmount(0.6) + ->setTaxCategory($taxCategory); + +// Tax Total +$taxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->addTaxSubTotal($taxSubTotal) + ->setTaxAmount(0.6); + +// Legal Monetary Total +$legalMonetaryTotal = (new \Saleh7\Zatca\LegalMonetaryTotal()) + ->setLineExtensionAmount(4) + ->setTaxExclusiveAmount(4) + ->setTaxInclusiveAmount(4.60) + ->setPrepaidAmount(0) + ->setPayableAmount(4.60) + ->setAllowanceTotalAmount(0); + +// Classified Tax Category +$classifiedTax = (new \Saleh7\Zatca\ClassifiedTaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Item Product +$productItem = (new \Saleh7\Zatca\Item()) + ->setName('قلم رصاص') + ->setClassifiedTaxCategory($classifiedTax); + +// Price +$price = (new \Saleh7\Zatca\Price()) + ->setUnitCode(\Saleh7\Zatca\UnitCode::UNIT) + ->setPriceAmount(2); + +// Invoice Line tax totals +$lineTaxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.60) + ->setRoundingAmount(4.60); + +// Invoice Line(s) +$invoiceLines = []; +$invoiceLines[] = (new \Saleh7\Zatca\InvoiceLine()) + ->setUnitCode("PCE") + ->setId(1) + ->setItem($productItem) + ->setLineExtensionAmount(4) + ->setPrice($price) + ->setTaxTotal($lineTaxTotal) + ->setInvoicedQuantity(2); + +// Invoice +$invoice = (new \Saleh7\Zatca\Invoice()) + ->setUBLExtensions($UBLExtensions) + ->setUUID('3cf5ee18-ee25-44ea-a444-2c37ba7f28be') + ->setId('SME00023') + ->setIssueDate(new \DateTime()) + ->setIssueTime(new \DateTime()) + ->setInvoiceType($invoiceType) + ->Signature($Signature) + ->setAdditionalDocumentReferences($AdditionalDocumentReferences) + ->setDelivery($delivery) + ->setAllowanceCharges($allowanceCharges) + ->setPaymentMeans($clientPaymentMeans) + ->setTaxTotal($taxTotal) + ->setInvoiceLines($invoiceLines) + ->setLegalMonetaryTotal($legalMonetaryTotal) + ->setAccountingCustomerParty($supplierCustomer) + ->setAccountingSupplierParty($supplierCompany); + +// Generator Invoice +$generatorXml = new \Saleh7\Zatca\GeneratorInvoice(); +$outputXML = $generatorXml->invoice($invoice); +header("Content-Type: application/xml; charset=utf-8"); +echo $outputXML; diff --git a/src/AdditionalDocumentReference.php b/src/AdditionalDocumentReference.php new file mode 100644 index 0000000..8de24ed --- /dev/null +++ b/src/AdditionalDocumentReference.php @@ -0,0 +1,102 @@ +id = $id; + return $this; + } + + /** + * @param string $id + * @return AdditionalDocumentReference + */ + public function setUUID(?string $UUID): AdditionalDocumentReference + { + $this->UUID = $UUID; + return $this; + } + + /** + * @param string $documentType + * @return AdditionalDocumentReference + */ + public function setDocumentType(string $documentType): AdditionalDocumentReference + { + $this->documentType = $documentType; + return $this; + } + + /** + * @param string $previousInvoiceHash + * @return AdditionalDocumentReference + */ + public function setPreviousInvoiceHash(string $previousInvoiceHash): AdditionalDocumentReference + { + $this->previousInvoiceHash = $previousInvoiceHash; + return $this; + } + + /** + * @param Attachment $attachment + * @return AdditionalDocumentReference + */ + public function setAttachment(Attachment $attachment): AdditionalDocumentReference + { + $this->attachment = $attachment; + return $this; + } + /** + * The xmlSerialize method is called during xml writing. + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::CBC . 'ID' => $this->id + ]); + if ($this->UUID !== null) { + $writer->write([ + Schema::CBC . 'UUID' => $this->UUID + ]); + } + if ($this->documentType !== null) { + $writer->write([ + Schema::CAC . 'DocumentType' => $this->documentType + ]); + } + if ($this->previousInvoiceHash !== null) { + $writer->write([ + 'name' => Schema::CAC . 'Attachment', + 'value' => [ + 'name' => Schema::CBC . 'EmbeddedDocumentBinaryObject', + 'value' => $this->previousInvoiceHash, + 'attributes' => [ + 'mimeCode' => 'text/plain' + ] + ], + ]); + } + if ($this->attachment !== null) { + $writer->write([ + Schema::CAC . 'Attachment' => $this->attachment + ]); + } + } +} diff --git a/src/Address.php b/src/Address.php new file mode 100644 index 0000000..3947feb --- /dev/null +++ b/src/Address.php @@ -0,0 +1,163 @@ +streetName = $streetName; + return $this; + } + + /** + * @param string $additionalStreetName + * @return Address + */ + public function setAdditionalStreetName(?string $additionalStreetName): Address + { + $this->additionalStreetName = $additionalStreetName; + return $this; + } + + /** + * @param string $buildingNumber + * @return Address + */ + public function setBuildingNumber(?string $buildingNumber): Address + { + $this->buildingNumber = $buildingNumber; + return $this; + } + + /** + * @param string $plotIdentification + * @return Address + */ + public function setPlotIdentification(?string $plotIdentification): Address + { + $this->plotIdentification = $plotIdentification; + return $this; + } + + /** + * @param string $cityName + * @return Address + */ + public function setCityName(?string $cityName): Address + { + $this->cityName = $cityName; + return $this; + } + + /** + * @param string $postalZone + * @return Address + */ + public function setPostalZone(?string $postalZone): Address + { + $this->postalZone = $postalZone; + return $this; + } + + /** + * @param string $country + * @return Address + */ + public function setCountry(?string $country): Address + { + $this->country = $country; + return $this; + } + + /** + * @param string $countrySubentity + * @return Address + */ + public function setCountrySubentity(?string $countrySubentity): Address + { + $this->countrySubentity = $countrySubentity; + return $this; + } + /** + * @param string $citySubdivisionName + * @return Address + */ + public function setCitySubdivisionName(?string $citySubdivisionName): Address + { + $this->citySubdivisionName = $citySubdivisionName; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->streetName !== null) { + $writer->write([ + Schema::CBC . 'StreetName' => $this->streetName + ]); + } + if ($this->buildingNumber !== null) { + $writer->write([ + Schema::CBC . 'BuildingNumber' => $this->buildingNumber + ]); + } + if ($this->plotIdentification !== null) { + $writer->write([ + Schema::CBC . 'PlotIdentification' => $this->plotIdentification + ]); + } + if ($this->countrySubentity !== null) { + $writer->write([ + Schema::CBC . 'CountrySubentity' => $this->countrySubentity + ]); + } + if ($this->citySubdivisionName !== null) { + $writer->write([ + Schema::CBC . 'CitySubdivisionName' => $this->citySubdivisionName + ]); + } + if ($this->additionalStreetName !== null) { + $writer->write([ + Schema::CBC . 'AdditionalStreetName' => $this->additionalStreetName + ]); + } + + if ($this->cityName !== null) { + $writer->write([ + Schema::CBC . 'CityName' => $this->cityName, + ]); + } + if ($this->postalZone !== null) { + $writer->write([ + Schema::CBC . 'PostalZone' => $this->postalZone, + ]); + } + if ($this->country !== null) { + $writer->write([ + Schema::CAC . 'Country' => [Schema::CBC . 'IdentificationCode' => $this->country], + ]); + } + } +} diff --git a/src/AllowanceCharge.php b/src/AllowanceCharge.php new file mode 100644 index 0000000..1ad8b0a --- /dev/null +++ b/src/AllowanceCharge.php @@ -0,0 +1,226 @@ +chargeIndicator; + } + + /** + * @param bool $chargeIndicator + * @return AllowanceCharge + */ + public function setChargeIndicator(bool $chargeIndicator): AllowanceCharge + { + $this->chargeIndicator = $chargeIndicator; + return $this; + } + + /** + * @return int + */ + public function getAllowanceChargeReasonCode(): ?int + { + return $this->allowanceChargeReasonCode; + } + + /** + * @param int $allowanceChargeReasonCode + * @return AllowanceCharge + */ + public function setAllowanceChargeReasonCode(?int $allowanceChargeReasonCode): AllowanceCharge + { + $this->allowanceChargeReasonCode = $allowanceChargeReasonCode; + return $this; + } + + /** + * @return string + */ + public function getAllowanceChargeReason(): ?string + { + return $this->allowanceChargeReason; + } + + /** + * @param string $allowanceChargeReason + * @return AllowanceCharge + */ + public function setAllowanceChargeReason(?string $allowanceChargeReason): AllowanceCharge + { + $this->allowanceChargeReason = $allowanceChargeReason; + return $this; + } + + /** + * @return int + */ + public function getMultiplierFactorNumeric(): ?int + { + return $this->multiplierFactorNumeric; + } + + /** + * @param int $multiplierFactorNumeric + * @return AllowanceCharge + */ + public function setMultiplierFactorNumeric(?int $multiplierFactorNumeric): AllowanceCharge + { + $this->multiplierFactorNumeric = $multiplierFactorNumeric; + return $this; + } + + /** + * @return float + */ + public function getBaseAmount(): ?float + { + return $this->baseAmount; + } + + /** + * @param float $baseAmount + * @return AllowanceCharge + */ + public function setBaseAmount(?float $baseAmount): AllowanceCharge + { + $this->baseAmount = $baseAmount; + return $this; + } + + /** + * @return float + */ + public function getAmount(): ?float + { + return $this->amount; + } + + /** + * @param float $amount + * @return AllowanceCharge + */ + public function setAmount(?float $amount): AllowanceCharge + { + $this->amount = $amount; + return $this; + } + + /** + * @return TaxCategory + */ + public function getTaxCategory(): ?TaxCategory + { + return $this->taxCategory; + } + + /** + * @param TaxCategory $taxCategory + * @return AllowanceCharge + */ + public function setTaxCategory(?TaxCategory $taxCategory): AllowanceCharge + { + $this->taxCategory = $taxCategory; + return $this; + } + + /** + * @return TaxCategory + */ + public function getTaxtotal(): ?TaxTotal + { + return $this->taxTotal; + } + + /** + * @param TaxTotal $taxTotal + * @return AllowanceCharge + */ + public function setTaxtotal(?TaxTotal $taxTotal): AllowanceCharge + { + $this->taxTotal = $taxTotal; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::CBC . 'ChargeIndicator' => $this->chargeIndicator ? 'true' : 'false', + ]); + + if ($this->allowanceChargeReasonCode !== null) { + $writer->write([ + Schema::CBC . 'AllowanceChargeReasonCode' => $this->allowanceChargeReasonCode + ]); + } + + if ($this->allowanceChargeReason !== null) { + $writer->write([ + Schema::CBC . 'AllowanceChargeReason' => $this->allowanceChargeReason + ]); + } + + if ($this->multiplierFactorNumeric !== null) { + $writer->write([ + Schema::CBC . 'MultiplierFactorNumeric' => $this->multiplierFactorNumeric + ]); + } + + $writer->write([ + [ + 'name' => Schema::CBC . 'Amount', + 'value' => number_format($this->amount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + ]); + + if ($this->taxCategory !== null) { + $writer->write([ + Schema::CAC . 'TaxCategory' => $this->taxCategory + ]); + } + + if ($this->taxTotal !== null) { + $writer->write([ + Schema::CAC . 'TaxTotal' => $this->taxTotal + ]); + } + + if ($this->baseAmount !== null) { + $writer->write([ + [ + 'name' => Schema::CBC . 'BaseAmount', + 'value' => $this->baseAmount, + 'attributes' => [ + 'currencyID' => Generator::$currencyID + ] + ] + ]); + } + } +} diff --git a/src/Attachment.php b/src/Attachment.php new file mode 100755 index 0000000..d858803 --- /dev/null +++ b/src/Attachment.php @@ -0,0 +1,83 @@ +filePath)) !== false) { + return $mime_type; + } + + throw new Exception('Could not determine mime_type of '.$this->filePath); + } + + /** + * @return string + */ + public function getFilePath(): ?string + { + return $this->filePath; + } + + /** + * @param string $filePath + * @return Attachment + */ + public function setFilePath(string $filePath): Attachment + { + $this->filePath = $filePath; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + * @return void + */ + public function validate() + { + if ($this->filePath === null) { + throw new InvalidArgumentException('Missing filePath'); + } + + if (file_exists($this->filePath) === false) { + throw new InvalidArgumentException('Attachment at filePath does not exist'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $fileContents = base64_encode(file_get_contents($this->filePath)); + $mimeType = $this->getFileMimeType(); + + $this->validate(); + + $writer->write([ + 'name' => Schema::CBC . 'EmbeddedDocumentBinaryObject', + 'value' => $fileContents, + 'attributes' => [ + 'mimeCode' => $mimeType, + 'filename' => basename($this->filePath) + ] + ]); + } +} diff --git a/src/BillingReference.php b/src/BillingReference.php new file mode 100644 index 0000000..ab2850f --- /dev/null +++ b/src/BillingReference.php @@ -0,0 +1,32 @@ +id = $id; + return $this; + } + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->id !== null) { + $writer->write([ Schema::CAC . 'InvoiceDocumentReference' => [ Schema::CBC . 'ID' => $this->id ] ]); + } + } +} diff --git a/src/ClassifiedTaxCategory.php b/src/ClassifiedTaxCategory.php new file mode 100644 index 0000000..decff19 --- /dev/null +++ b/src/ClassifiedTaxCategory.php @@ -0,0 +1,209 @@ +id)) { + return $this->id; + } + + if ($this->getPercent() !== null) { + if ($this->getPercent() >= 15) { + return 'S'; + } elseif ($this->getPercent() <= 15 && $this->getPercent() >= 6) { + return 'AA'; + } else { + return 'Z'; + } + } + + return null; + } + + /** + * @param string $id + * @return ClassifiedTaxCategory + */ + public function setId(?string $id): ClassifiedTaxCategory + { + $this->id = $id; + return $this; + } + + /** + * @return string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param string $name + * @return ClassifiedTaxCategory + */ + public function setName(?string $name): ClassifiedTaxCategory + { + $this->name = $name; + return $this; + } + + /** + * @return float + */ + public function getPercent(): ?float + { + return $this->percent; + } + + /** + * @param float $percent + * @return ClassifiedTaxCategory + */ + public function setPercent(?float $percent): ClassifiedTaxCategory + { + $this->percent = $percent; + return $this; + } + + /** + * @return TaxScheme + */ + public function getTaxScheme(): ?TaxScheme + { + return $this->taxScheme; + } + + /** + * @param TaxScheme $taxScheme + * @return ClassifiedTaxCategory + */ + public function setTaxScheme(?TaxScheme $taxScheme): ClassifiedTaxCategory + { + $this->taxScheme = $taxScheme; + return $this; + } + + /** + * @return string + */ + public function getSchemeID(): ?string + { + return $this->schemeID; + } + + /** + * @param string $id + * @return ClassifiedTaxCategory + */ + public function setSchemeID(?string $id): ClassifiedTaxCategory + { + $this->schemeID = $id; + return $this; + } + + /** + * @return string + */ + public function getSchemeName(): ?string + { + return $this->schemeName; + } + + /** + * @param string $name + * @return ClassifiedTaxCategory + */ + public function setSchemeName(?string $name): ClassifiedTaxCategory + { + $this->schemeName = $name; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + * @return void + */ + public function validate() + { + if ($this->getId() === null) { + throw new InvalidArgumentException('Missing taxcategory id'); + } + + if ($this->getPercent() === null) { + throw new InvalidArgumentException('Missing taxcategory percent'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $this->validate(); + + $schemeAttributes = []; + if ($this->schemeID !== null) { + $schemeAttributes['schemeID'] = $this->schemeID; + } + if ($this->schemeName !== null) { + $schemeAttributes['schemeName'] = $this->schemeName; + } + + $writer->write([ + [ + 'name' => Schema::CBC . 'ID', + 'value' => $this->getId(), + 'attributes' => $schemeAttributes + + ], + Schema::CBC . 'Percent' => number_format($this->percent, 2, '.', ''), + ]); + + if ($this->name !== null) { + $writer->write([ + Schema::CBC . 'Name' => $this->name, + ]); + } + + if ($this->taxExemptionReasonCode !== null) { + $writer->write([ + Schema::CBC . 'TaxExemptionReasonCode' => $this->taxExemptionReasonCode, + Schema::CBC . 'TaxExemptionReason' => $this->taxExemptionReason, + ]); + } + + if ($this->taxScheme !== null) { + $writer->write([Schema::CAC . 'TaxScheme' => $this->taxScheme]); + } else { + $writer->write([ + Schema::CAC . 'TaxScheme' => null, + ]); + } + } +} diff --git a/src/Contract.php b/src/Contract.php new file mode 100755 index 0000000..5d22650 --- /dev/null +++ b/src/Contract.php @@ -0,0 +1,41 @@ +id; + } + + /** + * @param string $id + * @return Contract + */ + public function setId(string $id): Contract + { + $this->id = $id; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->id !== null) { + $writer->write([ Schema::CBC . 'ID' => $this->id ]); + } + } +} diff --git a/src/Delivery.php b/src/Delivery.php new file mode 100644 index 0000000..e956f4e --- /dev/null +++ b/src/Delivery.php @@ -0,0 +1,68 @@ +actualDeliveryDate = $actualDeliveryDate; + return $this; + } + + /** + * @param DateTime $latestDeliveryDate + * @return Delivery + */ + public function setLatestDeliveryDate($latestDeliveryDate): Delivery + { + $this->latestDeliveryDate = $latestDeliveryDate; + return $this; + } + + /** + * @param Address $deliveryLocation + * @return Delivery + */ + public function setDeliveryLocation($deliveryLocation): Delivery + { + $this->deliveryLocation = $deliveryLocation; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->latestDeliveryDate != null) { + $writer->write([ + Schema::CBC . 'LatestDeliveryDate' => $this->latestDeliveryDate + ]); + } + if ($this->actualDeliveryDate != null) { + $writer->write([ + Schema::CBC . 'ActualDeliveryDate' => $this->actualDeliveryDate + ]); + } + if ($this->deliveryLocation != null) { + $writer->write([ + Schema::CAC . 'DeliveryLocation' => [ Schema::CAC . 'Address' => $this->deliveryLocation ] + ]); + } + } +} diff --git a/src/ExtensionContent.php b/src/ExtensionContent.php new file mode 100755 index 0000000..a62e6d4 --- /dev/null +++ b/src/ExtensionContent.php @@ -0,0 +1,34 @@ +UBLDocumentSignatures = $UBLDocumentSignatures; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::SIG . 'UBLDocumentSignatures' => $this->UBLDocumentSignatures + ]); + } +} diff --git a/src/GeneratorInvoice.php b/src/GeneratorInvoice.php new file mode 100644 index 0000000..7efa6f3 --- /dev/null +++ b/src/GeneratorInvoice.php @@ -0,0 +1,27 @@ +namespaceMap = [ + 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2' => '', + 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2' => 'cac', + 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2' => 'cbc', + 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2' => 'ext' + ]; + + return $xmlService->write('Invoice', [ + $invoice + ]); + } +} diff --git a/src/Invoice.php b/src/Invoice.php new file mode 100644 index 0000000..5e74ebf --- /dev/null +++ b/src/Invoice.php @@ -0,0 +1,445 @@ +UBLExtensions = $UBLExtensions; + return $this; + } + /** + * @param mixed $id + * @return Invoice + */ + public function setId(?string $id): Invoice + { + $this->id = $id; + return $this; + } + + /** + * @param mixed $UUID + * @return Invoice + */ + public function setUUID(?string $UUID): Invoice + { + $this->UUID = $UUID; + return $this; + } + + /** + * @param DateTime $issueDate + * @return Invoice + */ + public function setIssueDate(DateTime $issueDate): Invoice + { + $this->issueDate = $issueDate; + return $this; + } + + /** + * @param DateTime $issueDate + * @return Invoice + */ + public function setIssueTime(DateTime $issueTime): Invoice + { + $this->issueTime = $issueTime; + return $this; + } + + /** + * @param InvoiceType $invoiceType + * @return Invoice + */ + public function setInvoiceType(InvoiceType $invoiceType): Invoice + { + $this->invoiceType = $invoiceType; + return $this; + } + + /** + * @param mixed $currencyCode + * @return Invoice + */ + public function setInvoiceCurrencyCode(string $currencyCode = 'SAR'): Invoice + { + $this->invoiceCurrencyCode = $currencyCode; + return $this; + } + /** + * @param mixed $currencyCode + * @return Invoice + */ + public function setTaxCurrencyCode(string $currencyCode = 'SAR'): Invoice + { + $this->taxCurrencyCode = $currencyCode; + return $this; + } + /** + * @param OrderReference $orderReference + * @return OrderReference + */ + public function setOrderReference(OrderReference $orderReference): Invoice + { + $this->orderReference = $orderReference; + return $this; + } + + /** + * @param BillingReference $billingReference + * @return BillingReference + */ + public function setBillingReference(BillingReference $billingReference): Invoice + { + $this->billingReference = $billingReference; + return $this; + } + + /** + * @param string $contract + * @return Invoice + */ + public function setContract(Contract $contract): Invoice + { + $this->contract = $contract; + return $this; + } + + /** + * @param AdditionalDocumentReference[] $additionalDocumentReferences + * @return Invoice + */ + public function setAdditionalDocumentReferences(array $additionalDocumentReferences): Invoice + { + $this->additionalDocumentReferences = $additionalDocumentReferences; + return $this; + } + + /** + * @param Party $accountingSupplierParty + * @return Invoice + */ + public function setAccountingSupplierParty(Party $accountingSupplierParty): Invoice + { + $this->accountingSupplierParty = $accountingSupplierParty; + return $this; + } + + /** + * @param Party $accountingCustomerParty + * @return Invoice + */ + public function setAccountingCustomerParty(Party $accountingCustomerParty): Invoice + { + $this->accountingCustomerParty = $accountingCustomerParty; + return $this; + } + + /** + * @param Delivery $delivery + * @return Invoice + */ + public function setDelivery(Delivery $delivery): Invoice + { + $this->delivery = $delivery; + return $this; + } + + /** + * @param PaymentMeans $paymentMeans + * @return Invoice + */ + public function setPaymentMeans(PaymentMeans $paymentMeans): Invoice + { + $this->paymentMeans = $paymentMeans; + return $this; + } + + /** + * @param AllowanceCharge[] $allowanceCharges + * @return Invoice + */ + public function setAllowanceCharges(array $allowanceCharges): Invoice + { + $this->allowanceCharges = $allowanceCharges; + return $this; + } + + /** + * @param Signature + * @return Invoice + */ + public function Signature(Signature $signature): Invoice + { + $this->signature = $signature; + return $this; + } + + /** + * @param mixed $currencyCode + * @return Invoice + */ + public function setDocumentCurrencyCode(string $currencyCode = 'SAR'): Invoice + { + $this->documentCurrencyCode = $currencyCode; + return $this; + } + + /** + * @param string $note + * @return Invoice + */ + public function setNote(string $note) + { + $this->note = $note; + return $this; + } + + /** + * @param TaxTotal $taxTotal + * @return Invoice + */ + public function setTaxTotal(TaxTotal $taxTotal): Invoice + { + $this->taxTotal = $taxTotal; + return $this; + } + + /** + * @param LegalMonetaryTotal $legalMonetaryTotal + * @return Invoice + */ + public function setLegalMonetaryTotal(LegalMonetaryTotal $legalMonetaryTotal): Invoice + { + $this->legalMonetaryTotal = $legalMonetaryTotal; + return $this; + } + + /** + * @param InvoiceLine[] $invoiceLines + * @return Invoice + */ + public function setInvoiceLines(array $invoiceLines): Invoice + { + $this->invoiceLines = $invoiceLines; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @return void + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + */ + public function validate() + { + if ($this->id === null) { + throw new InvalidArgumentException('Missing invoice id'); + } + + + if (!$this->issueDate instanceof DateTime) { + throw new InvalidArgumentException('Invalid invoice issueDate'); + } + + if (!$this->issueTime instanceof DateTime) { + throw new InvalidArgumentException('Invalid invoice issueTime'); + } + + if ($this->accountingSupplierParty === null) { + throw new InvalidArgumentException('Missing invoice accountingSupplierParty'); + } + + if ($this->accountingCustomerParty === null) { + throw new InvalidArgumentException('Missing invoice accountingCustomerParty'); + } + + if ($this->additionalDocumentReferences === null) { + throw new InvalidArgumentException('Missing invoice additionalDocumentReferences'); + } + + if ($this->invoiceLines === null) { + throw new InvalidArgumentException('Missing invoice lines'); + } + + if ($this->legalMonetaryTotal === null) { + throw new InvalidArgumentException('Missing invoice LegalMonetaryTotal'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $this->validate(); + // UBLExtensions + + if ($this->UBLExtensions !== null) { + $writer->write([ + Schema::EXT . 'UBLExtensions' => $this->UBLExtensions + ]); + } + // profileID + if ($this->profileID !== null) { + $writer->write( [ Schema::CBC . 'ProfileID' => $this->profileID ] ); + } + // id + if ($this->id !== null) { + $writer->write( [ Schema::CBC . 'ID' => $this->id ] ); + } + // UUID + if ($this->UUID !== null) { + $writer->write( [ Schema::CBC . 'UUID' => $this->UUID ] ); + } + // issueDate + if ($this->issueDate !== null) { + $writer->write( [ Schema::CBC . 'IssueDate' => $this->issueDate->format('Y-m-d') ] ); + } + // issueTime + if ($this->issueTime !== null) { + $writer->write( [ Schema::CBC . 'IssueTime' => $this->issueTime->format('H:i:s') ] ); + } + // invoiceType + if($this->invoiceType !== null){ + $writer->write([$this->invoiceType + ] + ); + } + // note + if ($this->note !== null) { + $writer->write( [ Schema::CBC . 'Note' => $this->note ] ); + } + // DocumentCurrencyCode + if($this->invoiceCurrencyCode !== null){ + $writer->write([Schema::CBC . 'DocumentCurrencyCode' => $this->invoiceCurrencyCode]); + } + // taxCurrencyCode + if($this->taxCurrencyCode !== null){ + $writer->write( [ Schema::CBC . 'TaxCurrencyCode' => $this->taxCurrencyCode ] ); + } + // OrderReference + if ($this->orderReference != null) { + $writer->write( [ Schema::CAC . 'OrderReference' => $this->orderReference ] ); + } + // BillingReference + if ($this->billingReference != null) { + $writer->write( [ Schema::CAC . 'BillingReference' => $this->billingReference ] ); + } + // ContractDocumentReference + if ($this->contract !== null) { + $writer->write([ + Schema::CAC . 'ContractDocumentReference' => $this->contract, + ]); + } + // AdditionalDocumentReference + if($this->additionalDocumentReferences !== null){ + foreach ($this->additionalDocumentReferences as $additionalDocumentReference) { + $writer->write([ + Schema::CAC . 'AdditionalDocumentReference' => $additionalDocumentReference + ]); + } + } + // Signature + if ($this->signature !== null) { + $writer->write([ + Schema::CAC . "Signature" => $this->signature + ]); + } + // AccountingSupplierParty / Party + if ($this->accountingSupplierParty != null) { + $writer->write( [ Schema::CAC . 'AccountingSupplierParty' => [ + Schema::CAC . "Party" => $this->accountingSupplierParty + ] ] ); + } + // AccountingCustomerParty / Party + if ($this->accountingCustomerParty != null) { + $writer->write( [ Schema::CAC . 'AccountingCustomerParty' => [ + Schema::CAC . "Party" => $this->accountingCustomerParty + ] ] ); + } + // Delivery + if ($this->delivery != null) { + $writer->write( [ Schema::CAC . 'Delivery' => $this->delivery ] ); + } + // PaymentMeans + if ($this->paymentMeans !== null) { + $writer->write( [ Schema::CAC . 'PaymentMeans' => $this->paymentMeans ] ); + } + // AllowanceCharge + if ($this->allowanceCharges !== null) { + foreach ($this->allowanceCharges as $allowanceCharge) { + $writer->write([ + Schema::CAC . 'AllowanceCharge' => $allowanceCharge + ]); + } + } + // TaxTotal + if ($this->taxTotal !== null) { + + if ($this->taxTotal->taxAmount !== null) { + $writer->write( [ Schema::CAC . 'TaxTotal' => [ + Schema::CBC . "TaxAmount" => [ + 'value' => number_format($this->taxTotal->taxAmount, 1, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ]]]] ); + } + + $writer->write([ + Schema::CAC . 'TaxTotal' => $this->taxTotal + ]); + } + // LegalMonetaryTotal + if ($this->legalMonetaryTotal !== null) { + $writer->write([ + Schema::CAC . 'LegalMonetaryTotal' => $this->legalMonetaryTotal + ]); + } + // InvoiceLine + if($this->invoiceLines){ + foreach ($this->invoiceLines as $invoiceLine) { + $writer->write([ + Schema::CAC . 'InvoiceLine' => $invoiceLine + ]); + } + } + } +} diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php new file mode 100644 index 0000000..77a943b --- /dev/null +++ b/src/InvoiceLine.php @@ -0,0 +1,286 @@ +id; + } + + /** + * @param string $id + * @return InvoiceLine + */ + public function setId(?string $id): InvoiceLine + { + $this->id = $id; + return $this; + } + + /** + * @return float + */ + public function getInvoicedQuantity(): ?float + { + return $this->invoicedQuantity; + } + + /** + * @param float $invoicedQuantity + * @return InvoiceLine + */ + public function setInvoicedQuantity(?float $invoicedQuantity): InvoiceLine + { + $this->invoicedQuantity = $invoicedQuantity; + return $this; + } + + /** + * @return float + */ + public function getLineExtensionAmount(): ?float + { + return $this->lineExtensionAmount; + } + + /** + * @param float $lineExtensionAmount + * @return InvoiceLine + */ + public function setLineExtensionAmount(?float $lineExtensionAmount): InvoiceLine + { + $this->lineExtensionAmount = $lineExtensionAmount; + return $this; + } + + /** + * @return TaxTotal + */ + public function getTaxTotal(): ?TaxTotal + { + return $this->taxTotal; + } + + /** + * @param TaxTotal $taxTotal + * @return InvoiceLine + */ + public function setTaxTotal(?TaxTotal $taxTotal): InvoiceLine + { + $this->taxTotal = $taxTotal; + return $this; + } + + /** + * @return string + */ + public function getNote(): ?string + { + return $this->note; + } + + /** + * @param string $note + * @return InvoiceLine + */ + public function setNote(?string $note): InvoiceLine + { + $this->note = $note; + return $this; + } + + /** + * @return InvoicePeriod + */ + public function getInvoicePeriod(): ?InvoicePeriod + { + return $this->invoicePeriod; + } + + /** + * @param InvoicePeriod $invoicePeriod + * @return InvoiceLine + */ + public function setInvoicePeriod(?InvoicePeriod $invoicePeriod) + { + $this->invoicePeriod = $invoicePeriod; + return $this; + } + + /** + * @return Item + */ + public function getItem(): ?Item + { + return $this->item; + } + + /** + * @param Item $item + * @return InvoiceLine + */ + public function setItem(Item $item): InvoiceLine + { + $this->item = $item; + return $this; + } + + /** + * @return Price + */ + public function getPrice(): ?Price + { + return $this->price; + } + + /** + * @param Price $price + * @return InvoiceLine + */ + public function setPrice(?Price $price): InvoiceLine + { + $this->price = $price; + return $this; + } + + /** + * @return string + */ + public function getUnitCode(): ?string + { + return $this->unitCode; + } + + /** + * @param string $unitCode + * @return InvoiceLine + */ + public function setUnitCode(?string $unitCode): InvoiceLine + { + $this->unitCode = $unitCode; + return $this; + } + + /** + * @return string + */ + public function getAccountingCostCode(): ?string + { + return $this->accountingCostCode; + } + + /** + * @param string $accountingCostCode + * @return InvoiceLine + */ + public function setAccountingCostCode(?string $accountingCostCode): InvoiceLine + { + $this->accountingCostCode = $accountingCostCode; + return $this; + } + + /** + * @return string + */ + public function getAccountingCost(): ?string + { + return $this->accountingCost; + } + + /** + * @param string $accountingCost + * @return InvoiceLine + */ + public function setAccountingCost(?string $accountingCost): InvoiceLine + { + $this->accountingCost = $accountingCost; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::CBC . 'ID' => $this->id + ]); + + if (!empty($this->getNote())) { + $writer->write([ + Schema::CBC . 'Note' => $this->getNote() + ]); + } + + $writer->write([ + [ + 'name' => Schema::CBC . 'InvoicedQuantity', + 'value' => number_format($this->invoicedQuantity, 6, '.', ''), + 'attributes' => [ + 'unitCode' => $this->unitCode + ] + ], + [ + 'name' => Schema::CBC . 'LineExtensionAmount', + 'value' => number_format($this->lineExtensionAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ] + ]); + if ($this->accountingCostCode !== null) { + $writer->write([ + Schema::CBC . 'AccountingCostCode' => $this->accountingCostCode + ]); + } + if ($this->accountingCost !== null) { + $writer->write([ + Schema::CBC . 'AccountingCost' => $this->accountingCost + ]); + } + if ($this->invoicePeriod !== null) { + $writer->write([ + Schema::CAC . 'InvoicePeriod' => $this->invoicePeriod + ]); + } + if ($this->taxTotal !== null) { + $writer->write([ + Schema::CAC . 'TaxTotal' => $this->taxTotal + ]); + } + $writer->write([ + Schema::CAC . 'Item' => $this->item, + ]); + + if ($this->price !== null) { + $writer->write([ + Schema::CAC . 'Price' => $this->price + ]); + } else { + $writer->write([ + Schema::CAC . 'TaxScheme' => null, + ]); + } + } +} diff --git a/src/InvoiceType.php b/src/InvoiceType.php new file mode 100644 index 0000000..268b666 --- /dev/null +++ b/src/InvoiceType.php @@ -0,0 +1,88 @@ +invoice = $invoice; + return $this; + } + + /** + * @param mixed $invoiceType + * @return InvoiceType + */ + public function setInvoiceType(?string $invoiceType): InvoiceType + { + $this->invoiceType = $invoiceType; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if($this->invoiceType == 'Invoice'){ + $invoiceTypeCode = InvoiceTypeCode::INVOICE; + }elseif ($this->invoiceType == 'Debit') { + $invoiceTypeCode = InvoiceTypeCode::DEBIT_NOTE; + }elseif ($this->invoiceType == 'Credit') { + $invoiceTypeCode = InvoiceTypeCode::CREDIT_NOTE; + } + + // Invoice + if($this->invoice == 'Invoice'){ + if($this->invoiceType == 'Invoice'){ + $invoiceType = InvoiceTypeCode::TAX_INVOICE; + }elseif ($this->invoiceType == 'Debit') { + $invoiceType = InvoiceTypeCode::TAX_DEBIT_NOTE; + }elseif ($this->invoiceType == 'Credit') { + $invoiceType = InvoiceTypeCode::TAX_CREDIT_NOTE; + } + $writer->write([ + [ + "name" => Schema::CBC . 'InvoiceTypeCode', + "value" => $invoiceTypeCode, + "attributes" => [ + "name" => $invoiceType + ] + ], + ]); + } + // Simplified + if($this->invoice == 'Simplified'){ + if($this->invoiceType == 'Invoice'){ + $invoiceType = InvoiceTypeCode::SIMPLIFIED_INVOICE; + }elseif ($this->invoiceType == 'Debit') { + $invoiceType = InvoiceTypeCode::SIMPLIFIED_DEBIT_NOTE; + }elseif ($this->invoiceType == 'Credit') { + $invoiceType = InvoiceTypeCode::SIMPLIFIED_CREDIT_NOTE; + } + $writer->write([ + [ + "name" => Schema::CBC . 'InvoiceTypeCode', + "value" => $invoiceTypeCode, + "attributes" => [ + "name" => $invoiceType + ] + ], + ]); + } + } +} diff --git a/src/InvoiceTypeCode.php b/src/InvoiceTypeCode.php new file mode 100755 index 0000000..894b592 --- /dev/null +++ b/src/InvoiceTypeCode.php @@ -0,0 +1,17 @@ +description = $description; + return $this; + } + + /** + * @param mixed $name + * @return Item + */ + public function setName(?string $name): Item + { + $this->name = $name; + return $this; + } + + /** + * @return mixed + */ + public function getSellersItemIdentification(): ?string + { + return $this->sellersItemIdentification; + } + + /** + * @param mixed $sellersItemIdentification + * @return Item + */ + public function setSellersItemIdentification(?string $sellersItemIdentification): Item + { + $this->sellersItemIdentification = $sellersItemIdentification; + return $this; + } + + /** + * @return mixed + */ + public function getBuyersItemIdentification(): ?string + { + return $this->buyersItemIdentification; + } + + /** + * @param mixed $buyersItemIdentification + * @return Item + */ + public function setBuyersItemIdentification(?string $buyersItemIdentification): Item + { + $this->buyersItemIdentification = $buyersItemIdentification; + return $this; + } + + /** + * @return ClassifiedTaxCategory + */ + public function getClassifiedTaxCategory(): ?ClassifiedTaxCategory + { + return $this->classifiedTaxCategory; + } + + /** + * @param ClassifiedTaxCategory $classifiedTaxCategory + * @return Item + */ + public function setClassifiedTaxCategory(?ClassifiedTaxCategory $classifiedTaxCategory): Item + { + $this->classifiedTaxCategory = $classifiedTaxCategory; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::CBC . 'Name' => $this->name + ]); + if ($this->description !== null) { + $writer->write([ + Schema::CBC . 'Description' => $this->description, + ]); + } + if (!empty($this->getBuyersItemIdentification())) { + $writer->write([ + Schema::CAC . 'BuyersItemIdentification' => [ + Schema::CBC . 'ID' => $this->buyersItemIdentification + ], + ]); + } + + if (!empty($this->getSellersItemIdentification())) { + $writer->write([ + Schema::CAC . 'SellersItemIdentification' => [ + Schema::CBC . 'ID' => $this->sellersItemIdentification + ], + ]); + } + + if (!empty($this->getClassifiedTaxCategory())) { + $writer->write([ + Schema::CAC . 'ClassifiedTaxCategory' => $this->getClassifiedTaxCategory() + ]); + } + } +} diff --git a/src/LegalEntity.php b/src/LegalEntity.php new file mode 100755 index 0000000..82cb117 --- /dev/null +++ b/src/LegalEntity.php @@ -0,0 +1,33 @@ +registrationName = $registrationName; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->registrationName !== null) { + $writer->write( [ Schema::CBC . 'RegistrationName' => $this->registrationName ] ); + } + } +} diff --git a/src/LegalMonetaryTotal.php b/src/LegalMonetaryTotal.php new file mode 100644 index 0000000..38ec4b8 --- /dev/null +++ b/src/LegalMonetaryTotal.php @@ -0,0 +1,133 @@ +lineExtensionAmount = $lineExtensionAmount; + return $this; + } + + /** + * @param float $taxExclusiveAmount + * @return LegalMonetaryTotal + */ + public function setTaxExclusiveAmount(?float $taxExclusiveAmount): LegalMonetaryTotal + { + $this->taxExclusiveAmount = $taxExclusiveAmount; + return $this; + } + + /** + * @param float $taxInclusiveAmount + * @return LegalMonetaryTotal + */ + public function setTaxInclusiveAmount(?float $taxInclusiveAmount): LegalMonetaryTotal + { + $this->taxInclusiveAmount = $taxInclusiveAmount; + return $this; + } + + /** + * @param float $allowanceTotalAmount + * @return LegalMonetaryTotal + */ + public function setAllowanceTotalAmount(?float $allowanceTotalAmount): LegalMonetaryTotal + { + $this->allowanceTotalAmount = $allowanceTotalAmount; + return $this; + } + + /** + * @param float $payableAmount + * @return LegalMonetaryTotal + */ + public function setPayableAmount(?float $payableAmount): LegalMonetaryTotal + { + $this->payableAmount = $payableAmount; + return $this; + } + + /** + * @param float $prepaidAmount + * @return LegalMonetaryTotal + */ + public function setPrepaidAmount(?float $prepaidAmount): LegalMonetaryTotal + { + $this->prepaidAmount = $prepaidAmount; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + [ + 'name' => Schema::CBC . 'LineExtensionAmount', + 'value' => number_format($this->lineExtensionAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + + ], + [ + 'name' => Schema::CBC . 'TaxExclusiveAmount', + 'value' => number_format($this->taxExclusiveAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + + ], + [ + 'name' => Schema::CBC . 'TaxInclusiveAmount', + 'value' => number_format($this->taxInclusiveAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + + ], + [ + 'name' => Schema::CBC . 'AllowanceTotalAmount', + 'value' => number_format($this->allowanceTotalAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + + ], + [ + 'name' => Schema::CBC . 'PrepaidAmount', + 'value' => number_format($this->prepaidAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + [ + 'name' => Schema::CBC . 'PayableAmount', + 'value' => number_format($this->payableAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + ]); + } +} diff --git a/src/OrderReference.php b/src/OrderReference.php new file mode 100755 index 0000000..f555d0b --- /dev/null +++ b/src/OrderReference.php @@ -0,0 +1,47 @@ +id = $id; + return $this; + } + + /** + * @param string $salesOrderId + * @return OrderReference + */ + public function setSalesOrderId(string $salesOrderId): OrderReference + { + $this->salesOrderId = $salesOrderId; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->id !== null) { + $writer->write([ Schema::CBC . 'ID' => $this->id ]); + } + if ($this->salesOrderId !== null) { + $writer->write([ Schema::CBC . 'SalesOrderID' => $this->salesOrderId ]); + } + } +} diff --git a/src/Party.php b/src/Party.php new file mode 100644 index 0000000..5698007 --- /dev/null +++ b/src/Party.php @@ -0,0 +1,99 @@ +partyIdentification = $partyIdentification; + return $this; + } + + /** + * @param string $partyIdentificationId + * @return Party + */ + public function setPartyIdentificationId(?string $partyIdentificationId): Party + { + $this->partyIdentificationId = $partyIdentificationId; + return $this; + } + + /** + * @param Address $postalAddress + * @return Party + */ + public function setPostalAddress(?Address $postalAddress): Party + { + $this->postalAddress = $postalAddress; + return $this; + } + + /** + * @param PartyTaxScheme $partyTaxScheme + * @return Party + */ + public function setPartyTaxScheme(PartyTaxScheme $partyTaxScheme) + { + $this->partyTaxScheme = $partyTaxScheme; + return $this; + } + + /** + * @param LegalEntity $legalEntity + * @return Party + */ + public function setLegalEntity(?LegalEntity $legalEntity): Party + { + $this->legalEntity = $legalEntity; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + + if ($this->partyIdentification !== null) { + $writer->write([ + 'name' => Schema::CAC . 'PartyIdentification', + 'value' => [ + "name" => Schema::CBC . 'ID', + "value" => $this->partyIdentification, + "attributes" => [ + "schemeID" => "$this->partyIdentificationId" + ] + ] + ]); + } + // PostalAddress + if ($this->postalAddress !== null) { + $writer->write( [ Schema::CAC . 'PostalAddress' => $this->postalAddress ] ); + } + //partyTaxScheme + if ($this->partyTaxScheme !== null) { + $writer->write( [ Schema::CAC . 'PartyTaxScheme' => $this->partyTaxScheme ] ); + } + // PartyLegalEntity + if ($this->legalEntity !== null) { + $writer->write( [ Schema::CAC . 'PartyLegalEntity' => $this->legalEntity ] ); + } + } +} diff --git a/src/PartyTaxScheme.php b/src/PartyTaxScheme.php new file mode 100755 index 0000000..1123d55 --- /dev/null +++ b/src/PartyTaxScheme.php @@ -0,0 +1,65 @@ +companyId = $companyId; + return $this; + } + + /** + * @param TaxScheme $taxScheme + * @return PartyTaxScheme + */ + public function setTaxScheme(TaxScheme $taxScheme): PartyTaxScheme + { + $this->taxScheme = $taxScheme; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @return void + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + */ + public function validate() + { + if ($this->taxScheme === null) { + throw new InvalidArgumentException('Missing TaxScheme'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + if ($this->companyId !== null) { + $writer->write([ + Schema::CBC . 'CompanyID' => $this->companyId + ]); + } + if ($this->taxScheme !== null) { + $writer->write([ + Schema::CAC . 'TaxScheme' => $this->taxScheme + ]); + } + } +} diff --git a/src/PaymentMeans.php b/src/PaymentMeans.php new file mode 100644 index 0000000..ce9c020 --- /dev/null +++ b/src/PaymentMeans.php @@ -0,0 +1,78 @@ +paymentMeansCode = $paymentMeansCode; + return $this; + } + + /** + * @param string $instructionNote + * @return PaymentMeans + */ + public function setInstructionNote(?string $instructionNote): PaymentMeans + { + $this->instructionNote = $instructionNote; + return $this; + } + + /** + * @param string $paymentId + * @return PaymentMeans + */ + public function setPaymentId(?string $paymentId): PaymentMeans + { + $this->paymentId = $paymentId; + return $this; + } + + /** + * @param mixed $payeeFinancialAccount + * @return PaymentMeans + */ + public function setPayeeFinancialAccount(PaymentMeans $payeeFinancialAccount): PaymentMeans + { + $this->payeeFinancialAccount = $payeeFinancialAccount; + return $this; + } + + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::CBC . 'PaymentMeansCode' => $this->paymentMeansCode + ]); + + if ($this->instructionNote !== null) { + $writer->write([ + Schema::CBC . 'InstructionNote' => $this->instructionNote + ]); + } + + if ($this->paymentId !== null) { + $writer->write([ + Schema::CBC . 'PaymentID' => $this->paymentId + ]); + } + + if ($this->payeeFinancialAccount !== null) { + $writer->write([ + Schema::CAC . 'PayeeFinancialAccount' => $this->payeeFinancialAccount + ]); + } + } +} diff --git a/src/Price.php b/src/Price.php new file mode 100644 index 0000000..fe17f18 --- /dev/null +++ b/src/Price.php @@ -0,0 +1,73 @@ +priceAmount = $priceAmount; + return $this; + } + + /** + * @param float $baseQuantity + * @return Price + */ + public function setBaseQuantity(?float $baseQuantity): Price + { + $this->baseQuantity = $baseQuantity; + return $this; + } + + /** + * @param string $unitCode + * See also: src/UnitCode.php + * @return Price + */ + public function setUnitCode(?string $unitCode): Price + { + $this->unitCode = $unitCode; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + [ + 'name' => Schema::CBC . 'PriceAmount', + 'value' => number_format($this->priceAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + ]); + if ($this->baseQuantity !== null) { + $writer->write( + [ + 'name' => Schema::CBC . 'BaseQuantity', + 'value' => number_format($this->baseQuantity, 2, '.', ''), + 'attributes' => [ + 'unitCode' => $this->unitCode + ] + ] + ); + } + } +} diff --git a/src/Schema.php b/src/Schema.php new file mode 100644 index 0000000..eda194c --- /dev/null +++ b/src/Schema.php @@ -0,0 +1,12 @@ +id = $id; + return $this; + } + + /** + * @param string $method + * @return Signature + */ + public function setSignatureMethod(string $method): Signature + { + $this->signatureMethod = $method; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::CBC . "ID" => $this->id, + Schema::CBC . "SignatureMethod" => $this->signatureMethod + ]); + } +} diff --git a/src/SignatureInformation.php b/src/SignatureInformation.php new file mode 100644 index 0000000..238b8db --- /dev/null +++ b/src/SignatureInformation.php @@ -0,0 +1,45 @@ +id = $id; + return $this; + } + + /** + * @param string $referencedSignatureID + * @return SignatureInformation + */ + public function setReferencedSignatureID(string $referencedSignatureID): SignatureInformation + { + $this->referencedSignatureID = $referencedSignatureID; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + [Schema::CBC . 'ID' => $this->id], + [Schema::SBC . 'ReferencedSignatureID' => $this->referencedSignatureID] + ]); + } +} diff --git a/src/TaxCategory.php b/src/TaxCategory.php new file mode 100644 index 0000000..ce4f886 --- /dev/null +++ b/src/TaxCategory.php @@ -0,0 +1,215 @@ + TaxCategory::UNCL5305, + 'schemeAgencyID' => '6' + ]; + private $name; + private $percent; + private $taxScheme; + private $taxSchemeAttributes = [ + 'schemeID' => TaxCategory::UNCL5153, + 'schemeAgencyID' => '6' + ]; + private $taxExemptionReason; + private $taxExemptionReasonCode; + + public const UNCL5305 = 'UN/ECE 5305'; + public const UNCL5153 = 'UN/ECE 5153'; + + /** + * @return string + */ + public function getId(): ?string + { + if (!empty($this->id)) { + return $this->id; + } + + if ($this->getPercent() !== null) { + if ($this->getPercent() >= 15) { + return 'S'; + } elseif ($this->getPercent() <= 15 && $this->getPercent() >= 6) { + return 'AA'; + } else { + return 'Z'; + } + } + + return null; + } + + /** + * @param string $id + * @param array $attributes + * @return TaxCategory + */ + public function setId(?string $id, $attributes = null): TaxCategory + { + $this->id = $id; + if (isset($attributes)) { + $this->idAttributes = $attributes; + } + return $this; + } + + /** + * @param string $name + * @return TaxCategory + */ + public function setName(?string $name): TaxCategory + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getPercent(): ?float + { + return $this->percent; + } + + /** + * @param string $percent + * @return TaxCategory + */ + public function setPercent(?float $percent): TaxCategory + { + $this->percent = $percent; + return $this; + } + + /** + * @return string + */ + public function getTaxScheme(): ?TaxScheme + { + return $this->taxScheme; + } + + /** + * @param TaxScheme $taxScheme + * @param array $attributes + * @return TaxCategory + */ + public function setTaxScheme(?TaxScheme $taxScheme, $attributes = null): TaxCategory + { + $this->taxScheme = $taxScheme; + if (isset($attributes)) { + $this->taxSchemeAttributes = $attributes; + } + return $this; + } + + /** + * @return string + */ + public function getTaxExemptionReason(): ?string + { + return $this->taxExemptionReason; + } + + /** + * @param string $taxExemptionReason + * @return TaxCategory + */ + public function setTaxExemptionReason(?string $taxExemptionReason): TaxCategory + { + $this->taxExemptionReason = $taxExemptionReason; + return $this; + } + + /** + * @param string $taxExemptionReason + * @return TaxCategory + */ + public function setTaxExemptionReasonCode(?string $taxExemptionReasonCode): TaxCategory + { + $this->taxExemptionReasonCode = $taxExemptionReasonCode; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + * @return void + */ + public function validate() + { + if ($this->getId() === null) { + throw new InvalidArgumentException('Missing taxcategory id'); + } + + if ($this->getPercent() === null) { + throw new InvalidArgumentException('Missing taxcategory percent'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $this->validate(); + + $writer->write([ + [ + 'name' => Schema::CBC . 'ID', + 'value' => $this->getId(), + 'attributes' => $this->idAttributes, + ], + ]); + + if ($this->name !== null) { + $writer->write([ + Schema::CBC . 'Name' => $this->name, + ]); + } + $writer->write([ + Schema::CBC . 'Percent' => number_format($this->percent, 0, '.', ''), + ]); + + if ($this->taxExemptionReasonCode !== null) { + $writer->write([ + Schema::CBC . 'TaxExemptionReasonCode' => $this->taxExemptionReasonCode, + ]); + } + + if ($this->taxExemptionReason !== null) { + $writer->write([ + Schema::CBC . 'TaxExemptionReason' => $this->taxExemptionReason, + ]); + } + + if ($this->taxScheme !== null) { + $writer->write([ + [ + 'name' => Schema::CAC . 'TaxScheme', + 'value' => [ Schema::CBC . 'ID' => [ + "value" => $this->getTaxScheme()->id, + 'attributes' => $this->taxSchemeAttributes + ] + ]] + ]); + + } else { + $writer->write([ + Schema::CAC . 'TaxScheme' => null, + ]); + } + } +} diff --git a/src/TaxScheme.php b/src/TaxScheme.php new file mode 100644 index 0000000..ae51d7a --- /dev/null +++ b/src/TaxScheme.php @@ -0,0 +1,60 @@ +id = $id; + return $this; + } + + /** + * @param string $taxTypeCode + * @return TaxScheme + */ + public function setTaxTypeCode(?string $taxTypeCode) + { + $this->taxTypeCode = $taxTypeCode; + return $this; + } + + /** + * @param string $name + * @return TaxScheme + */ + public function setName(?string $name) + { + $this->name = $name; + return $this; + } + + public function xmlSerialize(Writer $writer): void + { + + if ($this->id !== null) { + $writer->write( [ Schema::CBC . 'ID' => $this->id ] ); + } + if ($this->taxTypeCode !== null) { + $writer->write([ + Schema::CBC . 'TaxTypeCode' => $this->taxTypeCode + ]); + } + if ($this->name !== null) { + $writer->write([ + Schema::CBC . 'Name' => $this->name + ]); + } + } +} diff --git a/src/TaxSubTotal.php b/src/TaxSubTotal.php new file mode 100755 index 0000000..266edb4 --- /dev/null +++ b/src/TaxSubTotal.php @@ -0,0 +1,113 @@ +taxableAmount = $taxableAmount; + return $this; + } + + /** + * @param mixed $taxAmount + * @return TaxSubTotal + */ + public function setTaxAmount(?float $taxAmount): TaxSubTotal + { + $this->taxAmount = $taxAmount; + return $this; + } + + /** + * @param TaxCategory $taxCategory + * @return TaxSubTotal + */ + public function setTaxCategory(TaxCategory $taxCategory): TaxSubTotal + { + $this->taxCategory = $taxCategory; + return $this; + } + + /** + * @param float $percent + * @return TaxSubTotal + */ + public function setPercent(?float $percent): TaxSubTotal + { + $this->percent = $percent; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + * @return void + */ + public function validate() + { + if ($this->taxableAmount === null) { + throw new InvalidArgumentException('Missing taxsubtotal taxableAmount'); + } + + if ($this->taxAmount === null) { + throw new InvalidArgumentException('Missing taxsubtotal taxamount'); + } + + if ($this->taxCategory === null) { + throw new InvalidArgumentException('Missing taxsubtotal taxcategory'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $this->validate(); + + $writer->write([ + [ + 'name' => Schema::CBC . 'TaxableAmount', + 'value' => number_format($this->taxableAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + [ + 'name' => Schema::CBC . 'TaxAmount', + 'value' => number_format($this->taxAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ] + ]); + + if ($this->percent !== null) { + $writer->write([ + Schema::CBC . 'Percent' => $this->percent + ]); + } + + $writer->write([ + Schema::CAC . 'TaxCategory' => $this->taxCategory + ]); + } +} diff --git a/src/TaxTotal.php b/src/TaxTotal.php new file mode 100644 index 0000000..d5b3b20 --- /dev/null +++ b/src/TaxTotal.php @@ -0,0 +1,93 @@ +taxAmount = $taxAmount; + return $this; + } + + /** + * @param mixed $taxAmount + * @return TaxTotal + */ + public function setRoundingAmount(?float $roundingAmount): TaxTotal + { + $this->roundingAmount = $roundingAmount; + return $this; + } + + /** + * @param TaxSubTotal $taxSubTotal + * @return TaxTotal + */ + public function addTaxSubTotal(TaxSubTotal $taxSubTotal): TaxTotal + { + $this->taxSubTotals[] = $taxSubTotal; + return $this; + } + + /** + * The validate function that is called during xml writing to valid the data of the object. + * + * @throws InvalidArgumentException An error with information about required data that is missing to write the XML + * @return void + */ + public function validate() + { + if ($this->taxAmount === null) { + throw new InvalidArgumentException('Missing taxtotal taxamount'); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $this->validate(); + + $writer->write([ + [ + 'name' => Schema::CBC . 'TaxAmount', + 'value' => number_format($this->taxAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + ]); + if ($this->roundingAmount !== null) { + $writer->write([ + [ + 'name' => Schema::CBC . 'RoundingAmount', + 'value' => number_format($this->roundingAmount, 2, '.', ''), + 'attributes' => [ + 'currencyID' => GeneratorInvoice::$currencyID + ] + ], + ]); + } + + + foreach ($this->taxSubTotals as $taxSubTotal) { + $writer->write([Schema::CAC . 'TaxSubtotal' => $taxSubTotal]); + } + } +} diff --git a/src/UBLDocumentSignatures.php b/src/UBLDocumentSignatures.php new file mode 100755 index 0000000..1b7463a --- /dev/null +++ b/src/UBLDocumentSignatures.php @@ -0,0 +1,34 @@ +signatureInformation = $signatureInformation; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + Schema::SAC . 'SignatureInformation' => $this->signatureInformation + ]); + } +} diff --git a/src/UBLExtension.php b/src/UBLExtension.php new file mode 100755 index 0000000..d1bd683 --- /dev/null +++ b/src/UBLExtension.php @@ -0,0 +1,61 @@ +extensionURI; + } + + /** + * @param string $uri + * @return UBLExtension + */ + public function setExtensionURI(string $uri): UBLExtension + { + $this->extensionURI = $uri; + return $this; + } + + /** + * @return ExtensionContent + */ + public function getExtensionContent(): ExtensionContent + { + return $this->extensionContent; + } + + /** + * @param ExtensionContent $extensionContent + * @return UBLExtension + */ + public function setExtensionContent(ExtensionContent $extensionContent): UBLExtension + { + $this->extensionContent = $extensionContent; + return $this; + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $writer->write([ + [Schema::EXT . 'ExtensionURI' => $this->extensionURI], + [Schema::EXT . 'ExtensionContent' => $this->extensionContent] + ]); + } +} diff --git a/src/UBLExtensions.php b/src/UBLExtensions.php new file mode 100755 index 0000000..c8d2041 --- /dev/null +++ b/src/UBLExtensions.php @@ -0,0 +1,53 @@ +UBLExtensions; + } + + /** + * @param UBLExtension[] $UBLExtensions + * @return UBLExtensions + */ + public function setUBLExtensions(array $UBLExtensions): UBLExtensions + { + $this->UBLExtensions = $UBLExtensions; + return $this; + } + + private function validator() + { + if ($this->UBLExtensions === null) { + throw new InvalidArgumentException("Messing UBL Extension"); + } + } + + /** + * The xmlSerialize method is called during xml writing. + * + * @param Writer $writer + * @return void + */ + public function xmlSerialize(Writer $writer): void + { + $this->validator(); + foreach ($this->UBLExtensions as $UBLExtension) { + $writer->write([ + Schema::EXT . 'UBLExtension' => $UBLExtension + ]); + } + } +} diff --git a/src/UnitCode.php b/src/UnitCode.php new file mode 100755 index 0000000..a29d0b2 --- /dev/null +++ b/src/UnitCode.php @@ -0,0 +1,12 @@ +setReferencedSignatureID("urn:oasis:names:specification:ubl:signature:Invoice") + ->setID('urn:oasis:names:specification:ubl:signature:1'); + +// UBLDocumentSignatures +$ublDecoment = (new \Saleh7\Zatca\UBLDocumentSignatures) + ->setSignatureInformation($sign); + +$extensionContent = (new \Saleh7\Zatca\ExtensionContent) + ->setUBLDocumentSignatures($ublDecoment); + +// UBLExtension +$UBLExtension[] = (new \Saleh7\Zatca\UBLExtension) + ->setExtensionURI('urn:oasis:names:specification:ubl:dsig:enveloped:xades') + ->setExtensionContent($extensionContent); + +$UBLExtensions = (new \Saleh7\Zatca\UBLExtensions) + ->setUBLExtensions($UBLExtension); + +$Signature = (new \Saleh7\Zatca\Signature) + ->setId("urn:oasis:names:specification:ubl:signature:Invoice") + ->setSignatureMethod("urn:oasis:names:specification:ubl:dsig:enveloped:xades"); +// invoiceType object +$invoiceType = (new \Saleh7\Zatca\InvoiceType()) + ->setInvoice('Invoice') // Invoice / Simplified + ->setInvoiceType('Credit'); // Invoice / Debit / Credit +// invoiceType object +$inType = (new \Saleh7\Zatca\BillingReference()) + ->setId('SME00002'); + +// invoiceType object +$Contact = (new \Saleh7\Zatca\Contract()) + ->setId('15'); + + +$AdditionalDocumentReferences = []; + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('ICV') + ->setUUID(23); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('PIH') + ->setPreviousInvoiceHash('NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ=='); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('QR'); + +// Tax scheme +$taxScheme = (new \Saleh7\Zatca\TaxScheme()) + ->setId("VAT"); + +$partyTaxScheme = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme) + ->setCompanyId('311111111101113'); + +$partyTaxSchemeCustomer = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme); + +$address = (new \Saleh7\Zatca\Address()) + ->setStreetName('الامير سلطان') + ->setBuildingNumber(2322) + ->setPlotIdentification(2223) + ->setCitySubdivisionName('الرياض') + ->setCityName('الرياض | Riyadh') + ->setPostalZone('23333') + ->setCountry('SA'); + +$legalEntity = (new \Saleh7\Zatca\LegalEntity()) + ->setRegistrationName('Acme Widget’s LTD'); + +$delivery = (new \Saleh7\Zatca\Delivery()) + ->setActualDeliveryDate("2022-09-07"); + +$supplierCompany = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("CRN") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxScheme) + ->setPostalAddress($address); + +$supplierCustomer = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("NAT") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxSchemeCustomer) + ->setPostalAddress($address); + +$clientPaymentMeans = (new \Saleh7\Zatca\PaymentMeans()) + ->setInstructionNote("CANCELLATION_OR_TERMINATION") + ->setPaymentMeansCode("10"); + + +$taxCategory = (new \Saleh7\Zatca\TaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Invoice Line(s) +$allowanceCharges = []; +$allowanceCharges[] = (new \Saleh7\Zatca\AllowanceCharge()) +->setChargeIndicator(false) +->setAllowanceChargeReason('discount') +->setAmount(0.00) +->setTaxCategory($taxCategory); + +$lineTaxTotalOne = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.6); + +$taxSubTotal = (new \Saleh7\Zatca\TaxSubTotal()) + ->setTaxableAmount(4) + ->setTaxAmount(0.6) + ->setTaxCategory($taxCategory); + +$taxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->addTaxSubTotal($taxSubTotal) + ->setTaxAmount(0.6); + +$legalMonetaryTotal = (new \Saleh7\Zatca\LegalMonetaryTotal()) + ->setLineExtensionAmount(4) + ->setTaxExclusiveAmount(4) + ->setTaxInclusiveAmount(4.60) + ->setPrepaidAmount(0) + ->setPayableAmount(4.60) + ->setAllowanceTotalAmount(0); + + +$classifiedTax = (new \Saleh7\Zatca\ClassifiedTaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Product +$productItem = (new \Saleh7\Zatca\Item()) + ->setName('قلم رصاص') + ->setClassifiedTaxCategory($classifiedTax); +// Price +$price = (new \Saleh7\Zatca\Price()) + ->setUnitCode(\Saleh7\Zatca\UnitCode::UNIT) + ->setPriceAmount(2); + +// Invoice Line tax totals +$lineTaxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.60) + ->setRoundingAmount(4.60); +// Invoice Line(s) +$invoiceLines = []; +$invoiceLines[] = (new \Saleh7\Zatca\InvoiceLine()) + ->setUnitCode("PCE") + ->setId(1) + ->setItem($productItem) + ->setLineExtensionAmount(4) + ->setPrice($price) + ->setTaxTotal($lineTaxTotal) + ->setInvoicedQuantity(2); +// Invoice object +$invoice = (new \Saleh7\Zatca\Invoice()) + ->setUBLExtensions($UBLExtensions) + ->setUUID('3cf5ee18-ee25-44ea-a444-2c37ba7f28be') + ->setId('SME00023') + ->setIssueDate(new \DateTime()) + ->setIssueTime(new \DateTime()) + ->setInvoiceType($invoiceType) + ->Signature($Signature) + // ->setContract($Contact) + ->setBillingReference($inType) + ->setAdditionalDocumentReferences($AdditionalDocumentReferences) + ->setDelivery($delivery) + ->setAllowanceCharges($allowanceCharges) + ->setPaymentMeans($clientPaymentMeans) + ->setTaxTotal($taxTotal) + ->setInvoiceLines($invoiceLines) + ->setLegalMonetaryTotal($legalMonetaryTotal) + ->setAccountingCustomerParty($supplierCustomer) + ->setAccountingSupplierParty($supplierCompany); + +$generatorXml = new \Saleh7\Zatca\GeneratorInvoice(); +$outputXML = $generatorXml->invoice($invoice); +header("Content-Type: application/xml; charset=utf-8"); +echo $outputXML; +?> diff --git a/tests/debitTest.php b/tests/debitTest.php new file mode 100644 index 0000000..89a7423 --- /dev/null +++ b/tests/debitTest.php @@ -0,0 +1,183 @@ +setReferencedSignatureID("urn:oasis:names:specification:ubl:signature:Invoice") + ->setID('urn:oasis:names:specification:ubl:signature:1'); + +// UBLDocumentSignatures +$ublDecoment = (new \Saleh7\Zatca\UBLDocumentSignatures) + ->setSignatureInformation($sign); + +$extensionContent = (new \Saleh7\Zatca\ExtensionContent) + ->setUBLDocumentSignatures($ublDecoment); + +// UBLExtension +$UBLExtension[] = (new \Saleh7\Zatca\UBLExtension) + ->setExtensionURI('urn:oasis:names:specification:ubl:dsig:enveloped:xades') + ->setExtensionContent($extensionContent); + +$UBLExtensions = (new \Saleh7\Zatca\UBLExtensions) + ->setUBLExtensions($UBLExtension); + +$Signature = (new \Saleh7\Zatca\Signature) + ->setId("urn:oasis:names:specification:ubl:signature:Invoice") + ->setSignatureMethod("urn:oasis:names:specification:ubl:dsig:enveloped:xades"); +// invoiceType object +$invoiceType = (new \Saleh7\Zatca\InvoiceType()) + ->setInvoice('Invoice') // Invoice / Simplified + ->setInvoiceType('Debit'); // Invoice / Debit / Credit +// invoiceType object +$inType = (new \Saleh7\Zatca\BillingReference()) + ->setId('SME00002'); + +// invoiceType object +$Contact = (new \Saleh7\Zatca\Contract()) + ->setId('15'); + + +$AdditionalDocumentReferences = []; + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('ICV') + ->setUUID(23); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('PIH') + ->setPreviousInvoiceHash('NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ=='); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('QR'); + +// Tax scheme +$taxScheme = (new \Saleh7\Zatca\TaxScheme()) + ->setId("VAT"); + +$partyTaxScheme = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme) + ->setCompanyId('311111111101113'); + +$partyTaxSchemeCustomer = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme); + +$address = (new \Saleh7\Zatca\Address()) + ->setStreetName('الامير سلطان') + ->setBuildingNumber(2322) + ->setPlotIdentification(2223) + ->setCitySubdivisionName('الرياض') + ->setCityName('الرياض | Riyadh') + ->setPostalZone('23333') + ->setCountry('SA'); + +$legalEntity = (new \Saleh7\Zatca\LegalEntity()) + ->setRegistrationName('Acme Widget’s LTD'); + +$delivery = (new \Saleh7\Zatca\Delivery()) + ->setActualDeliveryDate("2022-09-07"); + +$supplierCompany = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("CRN") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxScheme) + ->setPostalAddress($address); + +$supplierCustomer = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("NAT") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxSchemeCustomer) + ->setPostalAddress($address); + +$clientPaymentMeans = (new \Saleh7\Zatca\PaymentMeans()) + ->setInstructionNote("CANCELLATION_OR_TERMINATION") + ->setPaymentMeansCode("10"); + + +$taxCategory = (new \Saleh7\Zatca\TaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Invoice Line(s) +$allowanceCharges = []; +$allowanceCharges[] = (new \Saleh7\Zatca\AllowanceCharge()) +->setChargeIndicator(false) +->setAllowanceChargeReason('discount') +->setAmount(0.00) +->setTaxCategory($taxCategory); + +$lineTaxTotalOne = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.6); + +$taxSubTotal = (new \Saleh7\Zatca\TaxSubTotal()) + ->setTaxableAmount(4) + ->setTaxAmount(0.6) + ->setTaxCategory($taxCategory); + +$taxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->addTaxSubTotal($taxSubTotal) + ->setTaxAmount(0.6); + +$legalMonetaryTotal = (new \Saleh7\Zatca\LegalMonetaryTotal()) + ->setLineExtensionAmount(4) + ->setTaxExclusiveAmount(4) + ->setTaxInclusiveAmount(4.60) + ->setPrepaidAmount(0) + ->setPayableAmount(4.60) + ->setAllowanceTotalAmount(0); + + +$classifiedTax = (new \Saleh7\Zatca\ClassifiedTaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Product +$productItem = (new \Saleh7\Zatca\Item()) + ->setName('قلم رصاص') + ->setClassifiedTaxCategory($classifiedTax); +// Price +$price = (new \Saleh7\Zatca\Price()) + ->setUnitCode(\Saleh7\Zatca\UnitCode::UNIT) + ->setPriceAmount(2); + +// Invoice Line tax totals +$lineTaxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.60) + ->setRoundingAmount(4.60); +// Invoice Line(s) +$invoiceLines = []; +$invoiceLines[] = (new \Saleh7\Zatca\InvoiceLine()) + ->setUnitCode("PCE") + ->setId(1) + ->setItem($productItem) + ->setLineExtensionAmount(4) + ->setPrice($price) + ->setTaxTotal($lineTaxTotal) + ->setInvoicedQuantity(2); +// Invoice object +$invoice = (new \Saleh7\Zatca\Invoice()) + ->setUBLExtensions($UBLExtensions) + ->setUUID('3cf5ee18-ee25-44ea-a444-2c37ba7f28be') + ->setId('SME00023') + ->setIssueDate(new \DateTime()) + ->setIssueTime(new \DateTime()) + ->setInvoiceType($invoiceType) + ->Signature($Signature) + // ->setContract($Contact) + ->setBillingReference($inType) + ->setAdditionalDocumentReferences($AdditionalDocumentReferences) + ->setDelivery($delivery) + ->setAllowanceCharges($allowanceCharges) + ->setPaymentMeans($clientPaymentMeans) + ->setTaxTotal($taxTotal) + ->setInvoiceLines($invoiceLines) + ->setLegalMonetaryTotal($legalMonetaryTotal) + ->setAccountingCustomerParty($supplierCustomer) + ->setAccountingSupplierParty($supplierCompany); + +$generatorXml = new \Saleh7\Zatca\GeneratorInvoice(); +$outputXML = $generatorXml->invoice($invoice); +header("Content-Type: application/xml; charset=utf-8"); +echo $outputXML; + +?> diff --git a/tests/invoiceTest.php b/tests/invoiceTest.php new file mode 100644 index 0000000..84b31fc --- /dev/null +++ b/tests/invoiceTest.php @@ -0,0 +1,180 @@ +setReferencedSignatureID("urn:oasis:names:specification:ubl:signature:Invoice") + ->setID('urn:oasis:names:specification:ubl:signature:1'); + +// UBLDocumentSignatures +$ublDecoment = (new \Saleh7\Zatca\UBLDocumentSignatures) + ->setSignatureInformation($sign); + +$extensionContent = (new \Saleh7\Zatca\ExtensionContent) + ->setUBLDocumentSignatures($ublDecoment); + +// UBLExtension +$UBLExtension[] = (new \Saleh7\Zatca\UBLExtension) + ->setExtensionURI('urn:oasis:names:specification:ubl:dsig:enveloped:xades') + ->setExtensionContent($extensionContent); + +$UBLExtensions = (new \Saleh7\Zatca\UBLExtensions) + ->setUBLExtensions($UBLExtension); + +$Signature = (new \Saleh7\Zatca\Signature) + ->setId("urn:oasis:names:specification:ubl:signature:Invoice") + ->setSignatureMethod("urn:oasis:names:specification:ubl:dsig:enveloped:xades"); +// invoiceType object +$invoiceType = (new \Saleh7\Zatca\InvoiceType()) + ->setInvoice('Invoice') // Invoice / Simplified + ->setInvoiceType('Invoice'); // Invoice / Debit / Credit +// invoiceType object +$inType = (new \Saleh7\Zatca\BillingReference()) + ->setId('Invoice'); + +// invoiceType object +$Contact = (new \Saleh7\Zatca\Contract()) + ->setId('15'); + + +$AdditionalDocumentReferences = []; + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('ICV') + ->setUUID(23); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('PIH') + ->setPreviousInvoiceHash('NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ=='); + +$AdditionalDocumentReferences[] = (new \Saleh7\Zatca\AdditionalDocumentReference()) + ->setId('QR'); + +// Tax scheme +$taxScheme = (new \Saleh7\Zatca\TaxScheme()) + ->setId("VAT"); + +$partyTaxScheme = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme) + ->setCompanyId('311111111101113'); + +$partyTaxSchemeCustomer = (new \Saleh7\Zatca\PartyTaxScheme()) + ->setTaxScheme($taxScheme); + +$address = (new \Saleh7\Zatca\Address()) + ->setStreetName('الامير سلطان') + ->setBuildingNumber(2322) + ->setPlotIdentification(2223) + ->setCitySubdivisionName('الرياض') + ->setCityName('الرياض | Riyadh') + ->setPostalZone('23333') + ->setCountry('SA'); + +$legalEntity = (new \Saleh7\Zatca\LegalEntity()) + ->setRegistrationName('Acme Widget’s LTD'); + +$delivery = (new \Saleh7\Zatca\Delivery()) + ->setActualDeliveryDate("2022-09-07"); + +$supplierCompany = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("CRN") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxScheme) + ->setPostalAddress($address); + +$supplierCustomer = (new \Saleh7\Zatca\Party()) + ->setPartyIdentification("311111111111113") + ->setPartyIdentificationId("NAT") + ->setLegalEntity($legalEntity) + ->setPartyTaxScheme($partyTaxSchemeCustomer) + ->setPostalAddress($address); + +$clientPaymentMeans = (new \Saleh7\Zatca\PaymentMeans()) + ->setPaymentMeansCode("10"); + + +$taxCategory = (new \Saleh7\Zatca\TaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Invoice Line(s) +$allowanceCharges = []; +$allowanceCharges[] = (new \Saleh7\Zatca\AllowanceCharge()) +->setChargeIndicator(false) +->setAllowanceChargeReason('discount') +->setAmount(0.00) +->setTaxCategory($taxCategory); + +$lineTaxTotalOne = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.6); + +$taxSubTotal = (new \Saleh7\Zatca\TaxSubTotal()) + ->setTaxableAmount(4) + ->setTaxAmount(0.6) + ->setTaxCategory($taxCategory); + +$taxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->addTaxSubTotal($taxSubTotal) + ->setTaxAmount(0.6); + +$legalMonetaryTotal = (new \Saleh7\Zatca\LegalMonetaryTotal()) + ->setLineExtensionAmount(4) + ->setTaxExclusiveAmount(4) + ->setTaxInclusiveAmount(4.60) + ->setPrepaidAmount(0) + ->setPayableAmount(4.60) + ->setAllowanceTotalAmount(0); + + +$classifiedTax = (new \Saleh7\Zatca\ClassifiedTaxCategory()) + ->setPercent(15) + ->setTaxScheme($taxScheme); + +// Product +$productItem = (new \Saleh7\Zatca\Item()) + ->setName('قلم رصاص') + ->setClassifiedTaxCategory($classifiedTax); +// Price +$price = (new \Saleh7\Zatca\Price()) + ->setUnitCode(\Saleh7\Zatca\UnitCode::UNIT) + ->setPriceAmount(2); + +// Invoice Line tax totals +$lineTaxTotal = (new \Saleh7\Zatca\TaxTotal()) + ->setTaxAmount(0.60) + ->setRoundingAmount(4.60); +// Invoice Line(s) +$invoiceLines = []; +$invoiceLines[] = (new \Saleh7\Zatca\InvoiceLine()) + ->setUnitCode("PCE") + ->setId(1) + ->setItem($productItem) + ->setLineExtensionAmount(4) + ->setPrice($price) + ->setTaxTotal($lineTaxTotal) + ->setInvoicedQuantity(2); +// Invoice object +$invoice = (new \Saleh7\Zatca\Invoice()) + ->setUBLExtensions($UBLExtensions) + ->setUUID('3cf5ee18-ee25-44ea-a444-2c37ba7f28be') + ->setId('SME00023') + ->setIssueDate(new \DateTime()) + ->setIssueTime(new \DateTime()) + ->setInvoiceType($invoiceType) + ->Signature($Signature) + // ->setContract($Contact) + // ->setBillingReference($inType) + ->setAdditionalDocumentReferences($AdditionalDocumentReferences) + ->setDelivery($delivery) + ->setAllowanceCharges($allowanceCharges) + ->setPaymentMeans($clientPaymentMeans) + ->setTaxTotal($taxTotal) + ->setInvoiceLines($invoiceLines) + ->setLegalMonetaryTotal($legalMonetaryTotal) + ->setAccountingCustomerParty($supplierCustomer) + ->setAccountingSupplierParty($supplierCompany); + +$generatorXml = new \Saleh7\Zatca\GeneratorInvoice(); +$outputXML = $generatorXml->invoice($invoice); +header("Content-Type: application/xml; charset=utf-8"); +echo $outputXML;