module for peppol added
authorKilian <ksaffran@dks.lu>
Fri, 24 Feb 2023 07:30:50 +0000 (08:30 +0100)
committerKilian <ksaffran@dks.lu>
Fri, 24 Feb 2023 07:30:50 +0000 (08:30 +0100)
126 files changed:
htdocs/custom/peppol/COPYING [new file with mode: 0644]
htdocs/custom/peppol/ChangeLog.md [new file with mode: 0644]
htdocs/custom/peppol/README.md [new file with mode: 0644]
htdocs/custom/peppol/admin/about.php [new file with mode: 0644]
htdocs/custom/peppol/admin/setup.php [new file with mode: 0644]
htdocs/custom/peppol/class/actions_peppol.class.php [new file with mode: 0644]
htdocs/custom/peppol/composer.json [new file with mode: 0644]
htdocs/custom/peppol/core/modules/modPeppol.class.php [new file with mode: 0644]
htdocs/custom/peppol/img/object_peppol.png [new file with mode: 0644]
htdocs/custom/peppol/img/object_peppol_over.png [new file with mode: 0644]
htdocs/custom/peppol/img/peppol-logo-600x145.png [new file with mode: 0644]
htdocs/custom/peppol/langs/en_US/peppol.lang [new file with mode: 0644]
htdocs/custom/peppol/langs/fr_FR/peppol.lang [new file with mode: 0644]
htdocs/custom/peppol/lib/Peppol Code Lists - Participant identifier schemes v8.0.json [new file with mode: 0644]
htdocs/custom/peppol/lib/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.csv [new file with mode: 0644]
htdocs/custom/peppol/lib/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.json [new file with mode: 0644]
htdocs/custom/peppol/lib/PeppolCodeLists.csv [new file with mode: 0644]
htdocs/custom/peppol/lib/peppol.lib.php [new file with mode: 0644]
htdocs/custom/peppol/modulebuilder.txt [new file with mode: 0644]
htdocs/custom/peppol/myobject_contact.php [new file with mode: 0644]
htdocs/custom/peppol/peppolindex.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/autoload.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/ClassLoader.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/InstalledVersions.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/LICENSE [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/autoload_classmap.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/autoload_namespaces.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/autoload_psr4.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/autoload_real.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/autoload_static.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/installed.json [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/installed.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/composer/platform_check.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/.editorconfig [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/.gitattributes [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/.github/workflows/ci.yml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/.gitignore [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/.phan/config.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/CONTRIBUTING.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/LICENSE [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/README.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/composer.json [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/composer.lock [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/favicon.png [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/creating-custom-presets.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/eu-einvoicing-concepts.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/importing-exporting-and-validating.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/installation.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/your-first-invoice.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/index.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/logo-white.svg [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/logo.svg [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/reference/.gitignore [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/mkdocs.yml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/phpunit.xml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/scripts/build-docs.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/AllowanceOrCharge.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Attachment.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Attribute.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Delivery.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Exceptions/ValidationException.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Identifier.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Invoice.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/InvoiceLine.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/InvoiceReference.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Models/InvoiceTotals.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Models/VatBreakdown.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Party.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Card.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Mandate.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Payment.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Transfer.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/AbstractPreset.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusAtGov.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusAtNat.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusEsFace.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusIt.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/Peppol.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Readers/AbstractReader.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Readers/UblReader.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AllowanceOrChargeTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AttachmentsTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AttributesTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/BuyerAccountingReferenceTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/ClassificationIdentifiersTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/IdentifiersTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/InvoiceValidationTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PeriodTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PostalAddressTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PrecedingInvoiceReferencesTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/VatTrait.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Writers/AbstractWriter.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Writers/UblWriter.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/AttachmentTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/IntegrationTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-allowance.xml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-base.xml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-vat-s.xml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/InvoiceLineTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/InvoiceTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Models/InvoiceTotalsTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/PartyTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Payments/PaymentTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Readers/UblReaderTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Readers/peppol-example.xml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AllowanceOrChargeTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AttachmentsTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AttributesTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/ClassificationIdentifiersTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/IdentifiersTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/InvoiceValidationTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/VatTraitTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Writers/UblWriterTest.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/.editorconfig [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/.gitattributes [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/.github/workflows/ci.yml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/.gitignore [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/.phan/config.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/LICENSE [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/README.md [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/composer.json [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/phpunit.xml [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/src/UXML.php [new file with mode: 0644]
htdocs/custom/peppol/vendor/josemmo/uxml/tests/UXMLTest.php [new file with mode: 0644]
scripts/cron/cron_run_jobs.php
scripts/emailings/mailing-send.php

diff --git a/htdocs/custom/peppol/COPYING b/htdocs/custom/peppol/COPYING
new file mode 100644 (file)
index 0000000..94a0453
--- /dev/null
@@ -0,0 +1,621 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
diff --git a/htdocs/custom/peppol/ChangeLog.md b/htdocs/custom/peppol/ChangeLog.md
new file mode 100644 (file)
index 0000000..008c751
--- /dev/null
@@ -0,0 +1,50 @@
+# CHANGELOG PEPPOL FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
+
+## 1.0.8
+
+Fix: multicurrency_code could be empty or null
+
+## 1.0.7
+
+Dev (ro)
+MultiCurrency support
+Do not create empty fields (cac:Attachment) if dolibarr don't make invoice share link
+Add Subdivision data (country code)
+
+## 1.0.6
+
+Fix date error (day -1 on some case)
+
+## 1.0.5
+
+New mass action on invoice list : export multiple files in a zip archive
+
+## 1.0.4 - 20220324
+
+* auto join only pdf and xml files to mails (not jpeg or png preview)
+* remove peppol main menu (no use)
+* don't try to join peppol files on others modules than customer invoices
+
+## 1.0.2 - 20220317
+
+* auto join pdf and xml peppol file to mails
+
+## 1.0.1 - 20220221
+
+* Fix buyer full id (name + address)
+
+## 1.0.0 - 20220215
+
+First public release !
+
+## 0.3 - 2022 02 08
+
+First semi-public release
+
+## 0.2
+
+Firsts semi-public tests
+
+## 0.1
+
+Initial version
diff --git a/htdocs/custom/peppol/README.md b/htdocs/custom/peppol/README.md
new file mode 100644 (file)
index 0000000..8d47651
--- /dev/null
@@ -0,0 +1,29 @@
+# PEPPOL FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
+
+## What is PEPPOL ?
+
+(from wikipedia : https://en.wikipedia.org/wiki/PEPPOL)
+
+PEPPOL (Pan-European Public Procurement Online) is a set of specifications maintained by the OpenPEPPOL non-profit organisation with the aim of standardizing cross-border, electronically supported procurement procedures. It features, among other things, electronic invoicing. In addition to specifications PEPPOL consists of a delivery network.
+
+It started off as a development project with the same name under the European union Competitiveness and Innovation Programme from May 2008 to August 2012. The EU funded the PEPPOL programme by over 15 million Euros.
+
+The goal of the project was to solve interoperability issues in electronic public procurement by aligning business processes using common standards, addressing common legal issues and developing open source technologies. Agreement on the common standards for document content and on the technical aspects was reached through consensus amongst all consortium members.
+
+After the project ended the OpenPEPPOL Association was founded in Belgium to continue the work on the framework.
+
+## Features
+
+With that plugin your dolibarr could produce PEPPOL invoices !
+
+Other external modules are available on [Dolistore.com](https://www.dolistore.com).
+
+## Licenses
+
+### Main code
+
+GPLv3 or (at your option) any later version. See file COPYING for more information.
+
+### Documentation
+
+All texts and readmes are licensed under GFDL.
diff --git a/htdocs/custom/peppol/admin/about.php b/htdocs/custom/peppol/admin/about.php
new file mode 100644 (file)
index 0000000..d5f8bc3
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/* Copyright (C) 2004-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file    peppol/admin/about.php
+ * \ingroup peppol
+ * \brief   About page of module Peppol.
+ */
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+// Libraries
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once '../lib/peppol.lib.php';
+
+// Translations
+$langs->loadLangs(array("errors", "admin", "peppol@peppol"));
+
+// Access control
+if (!$user->admin) accessforbidden();
+
+// Parameters
+$action = GETPOST('action', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
+
+/*
+ * Actions
+ */
+
+// None
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$page_name = "PeppolAbout";
+llxHeader('', $langs->trans($page_name));
+
+// Subheader
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
+
+print load_fiche_titre($langs->trans($page_name), $linkback, 'object_peppol@peppol');
+
+// Configuration header
+$head = peppolAdminPrepareHead();
+print dol_get_fiche_head($head, 'about', '', 0, 'peppol@peppol');
+
+dol_include_once('/peppol/core/modules/modPeppol.class.php');
+$tmpmodule = new modPeppol($db);
+print $tmpmodule->getDescLong();
+
+// Page end
+print dol_get_fiche_end();
+llxFooter();
+$db->close();
diff --git a/htdocs/custom/peppol/admin/setup.php b/htdocs/custom/peppol/admin/setup.php
new file mode 100644 (file)
index 0000000..28715ee
--- /dev/null
@@ -0,0 +1,730 @@
+<?php
+/* Copyright (C) 2004-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file    peppol/admin/setup.php
+ * \ingroup peppol
+ * \brief   Peppol setup page.
+ */
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
+       $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+}
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
+       $i--; $j--;
+}
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
+       $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+}
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
+       $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+}
+// Try main.inc.php using relative path
+if (!$res && file_exists("../../main.inc.php")) {
+       $res = @include "../../main.inc.php";
+}
+if (!$res && file_exists("../../../main.inc.php")) {
+       $res = @include "../../../main.inc.php";
+}
+if (!$res) {
+       die("Include of main fails");
+}
+
+global $langs, $user;
+// Libraries
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
+require_once '../lib/peppol.lib.php';
+//require_once "../class/myclass.class.php";
+
+// Translations
+$langs->loadLangs(array("admin", "peppol@peppol"));
+
+// Access control
+$hookmanager->initHooks(array('peppolsetup', 'globalsetup'));
+
+// Access control
+if (!$user->admin) {
+       accessforbidden();
+}
+
+// Parameters
+$action = GETPOST('action', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09');   // Used by actions_setmoduleoptions.inc.php
+
+$value = GETPOST('value', 'alpha');
+$label = GETPOST('label', 'alpha');
+$scandir = GETPOST('scan_dir', 'alpha');
+$type = 'myobject';
+
+$arrayofparameters = array(
+       // 'PEPPOL_XMLINSIDE'=>array('type'=>'yesno','css'=>'minwidth200', 'enabled'=>1),
+       //'PEPPOL_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
+       //'PEPPOL_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
+       //'PEPPOL_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
+       //'PEPPOL_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
+       //'PEPPOL_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
+       //'PEPPOL_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
+       //'PEPPOL_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1),
+       //'PEPPOL_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
+);
+
+$error = 0;
+$setupnotempty = 0;
+$useFormSetup = 0;
+// Convert arrayofparameter into a formSetup object
+if (!empty($arrayofparameters) && $useFormSetup && (float) DOL_VERSION >= 15) {
+       require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
+       $formSetup = new FormSetup($db);
+
+       // you can use the param convertor
+       $formSetup->addItemsFromParamsArray($arrayofparameters);
+
+       // or use the new system see exemple as follow (or use both because you can ;-) )
+
+       /*
+       // Hôte
+       $item = $formSetup->newItem('NO_PARAM_JUST_TEXT');
+       $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'];
+       $item->cssClass = 'minwidth500';
+
+       // Setup conf PEPPOL_MYPARAM1 as a simple string input
+       $item = $formSetup->newItem('PEPPOL_MYPARAM1');
+
+       // Setup conf PEPPOL_MYPARAM1 as a simple textarea input but we replace the text of field title
+       $item = $formSetup->newItem('PEPPOL_MYPARAM2');
+       $item->nameText = $item->getNameText().' more html text ';
+
+       // Setup conf PEPPOL_MYPARAM3
+       $item = $formSetup->newItem('PEPPOL_MYPARAM3');
+       $item->setAsThirdpartyType();
+
+       // Setup conf PEPPOL_MYPARAM4 : exemple of quick define write style
+       $formSetup->newItem('PEPPOL_MYPARAM4')->setAsYesNo();
+
+       // Setup conf PEPPOL_MYPARAM5
+       $formSetup->newItem('PEPPOL_MYPARAM5')->setAsEmailTemplate('thirdparty');
+
+       // Setup conf PEPPOL_MYPARAM6
+       $formSetup->newItem('PEPPOL_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled
+
+       // Setup conf PEPPOL_MYPARAM7
+       $formSetup->newItem('PEPPOL_MYPARAM7')->setAsProduct();
+       */
+
+       $setupnotempty = count($formSetup->items);
+}
+
+
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+
+if ($action == 'updateMask') {
+       $maskconst = GETPOST('maskconst', 'alpha');
+       $maskvalue = GETPOST('maskvalue', 'alpha');
+
+       if ($maskconst) {
+               $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
+               if (!($res > 0)) {
+                       $error++;
+               }
+       }
+
+       if (!$error) {
+               setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+       } else {
+               setEventMessages($langs->trans("Error"), null, 'errors');
+       }
+} elseif ($action == 'specimen') {
+       $modele = GETPOST('module', 'alpha');
+       $tmpobjectkey = GETPOST('object');
+
+       $tmpobject = new $tmpobjectkey($db);
+       $tmpobject->initAsSpecimen();
+
+       // Search template files
+       $file = ''; $classname = ''; $filefound = 0;
+       $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+       foreach ($dirmodels as $reldir) {
+               $file = dol_buildpath($reldir."core/modules/peppol/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
+               if (file_exists($file)) {
+                       $filefound = 1;
+                       $classname = "pdf_".$modele;
+                       break;
+               }
+       }
+
+       if ($filefound) {
+               require_once $file;
+
+               $module = new $classname($db);
+
+               if ($module->write_file($tmpobject, $langs) > 0) {
+                       header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
+                       return;
+               } else {
+                       setEventMessages($module->error, null, 'errors');
+                       dol_syslog($module->error, LOG_ERR);
+               }
+       } else {
+               setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+               dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+       }
+} elseif ($action == 'setmod') {
+       // TODO Check if numbering module chosen can be activated by calling method canBeActivated
+       $tmpobjectkey = GETPOST('object');
+       if (!empty($tmpobjectkey)) {
+               $constforval = 'PEPPOL_'.strtoupper($tmpobjectkey)."_ADDON";
+               dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
+       }
+} elseif ($action == 'set') {
+// Activate a model
+       $ret = addDocumentModel($value, $type, $label, $scandir);
+} elseif ($action == 'del') {
+       $ret = delDocumentModel($value, $type);
+       if ($ret > 0) {
+               $tmpobjectkey = GETPOST('object');
+               if (!empty($tmpobjectkey)) {
+                       $constforval = 'PEPPOL_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
+                       if ($conf->global->$constforval == "$value") {
+                               dolibarr_del_const($db, $constforval, $conf->entity);
+               }
+       }
+}
+} elseif ($action == 'setdoc') {
+// Set or unset default model
+       $tmpobjectkey = GETPOST('object');
+       if (!empty($tmpobjectkey)) {
+               $constforval = 'PEPPOL_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
+               if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
+                       // The constant that was read before the new set
+                       // We therefore requires a variable to have a coherent view
+                       $conf->global->$constforval = $value;
+               }
+
+               // We disable/enable the document template (into llx_document_model table)
+               $ret = delDocumentModel($value, $type);
+               if ($ret > 0) {
+                       $ret = addDocumentModel($value, $type, $label, $scandir);
+               }
+       }
+} elseif ($action == 'unsetdoc') {
+       $tmpobjectkey = GETPOST('object');
+       if (!empty($tmpobjectkey)) {
+               $constforval = 'PEPPOL_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
+               dolibarr_del_const($db, $constforval, $conf->entity);
+       }
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$help_url = '';
+
+$page_name = "PeppolSetup";
+llxHeader('', $langs->trans($page_name), $help_url);
+
+// Subheader
+$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
+
+print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
+
+// Configuration header
+$head = peppolAdminPrepareHead();
+print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "peppol@peppol");
+
+// Setup page goes here
+echo '<span class="opacitymedium">'.$langs->trans("PeppolSetupPage").'</span><br><br>';
+
+
+if ($action == 'edit') {
+       if ($useFormSetup && (float) DOL_VERSION >= 15) {
+               print $formSetup->generateOutput(true);
+       } else {
+       print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
+       print '<input type="hidden" name="token" value="'.newToken().'">';
+       print '<input type="hidden" name="action" value="update">';
+
+       print '<table class="noborder centpercent">';
+       print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+               foreach ($arrayofparameters as $constname => $val) {
+                       if ($val['enabled']==1) {
+                               $setupnotempty++;
+               print '<tr class="oddeven"><td>';
+                               $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+                               print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
+                               print '</td><td>';
+
+                               if ($val['type'] == 'textarea') {
+                                       print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
+                                       print $conf->global->{$constname};
+                                       print "</textarea>\n";
+                               } elseif ($val['type']== 'html') {
+                                       require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+                                       $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+                                       $doleditor->Create();
+                               } elseif ($val['type'] == 'yesno') {
+                                       print $form->selectyesno($constname, $conf->global->{$constname}, 1);
+                               } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+                                       include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+                                       $formmail = new FormMail($db);
+
+                                       $tmp = explode(':', $val['type']);
+                                       $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
+                                       //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
+                                       $arrayofmessagename = array();
+                                       if (is_array($formmail->lines_model)) {
+                                               foreach ($formmail->lines_model as $modelmail) {
+                                                       //var_dump($modelmail);
+                                                       $moreonlabel = '';
+                                                       if (!empty($arrayofmessagename[$modelmail->label])) {
+                                                               $moreonlabel = ' <span class="opacitymedium">(' . $langs->trans("SeveralLangugeVariatFound") . ')</span>';
+                                                       }
+                                                       // The 'label' is the key that is unique if we exclude the language
+                                                       $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
+                                               }
+                                       }
+                                       print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+                               } elseif (preg_match('/category:/', $val['type'])) {
+                                       require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+                                       require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+                                       $formother = new FormOther($db);
+
+                                       $tmp = explode(':', $val['type']);
+                                       print img_picto('', 'category', 'class="pictofixedwidth"');
+                                       print $formother->select_categories($tmp[1],  $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
+                               } elseif (preg_match('/thirdparty_type/', $val['type'])) {
+                                       require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+                                       $formcompany = new FormCompany($db);
+                                       print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
+                               } elseif ($val['type'] == 'securekey') {
+                                       print '<input required="required" type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : $conf->global->{$constname}).'" size="40">';
+                                       if (!empty($conf->use_javascript_ajax)) {
+                                               print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
+                                       }
+                                       if (!empty($conf->use_javascript_ajax)) {
+                                               print "\n".'<script type="text/javascript">';
+                                               print '$(document).ready(function () {
+                        $("#generate_token'.$constname.'").click(function() {
+                               $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
+                                     action: \'getrandompassword\',
+                                     generic: true
+                                       },
+                                       function(token) {
+                                              $("#'.$constname.'").val(token);
+                                       });
+                         });
+                    });';
+                                               print '</script>';
+                                       }
+                               } elseif ($val['type'] == 'product') {
+                                       if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+                                               $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+                                               $form->select_produits($selected, $constname, '', 0);
+                                       }
+                               } else {
+                                       print '<input name="'.$constname.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
+                               }
+                               print '</td></tr>';
+                       }
+       }
+       print '</table>';
+
+       print '<br><div class="center">';
+       print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
+       print '</div>';
+
+       print '</form>';
+       }
+       print '<br>';
+} else {
+       if ($useFormSetup && (float) DOL_VERSION >= 15) {
+               if (!empty($formSetup->items)) {
+                       print $formSetup->generateOutput();
+               }
+       } else {
+               if (!empty($arrayofparameters)) {
+               print '<table class="noborder centpercent">';
+               print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+                       foreach ($arrayofparameters as $constname => $val) {
+                               if ($val['enabled']==1) {
+                       $setupnotempty++;
+                                       print '<tr class="oddeven"><td>';
+                                       $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+                                       print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
+                                       print '</td><td>';
+
+                                       if ($val['type'] == 'textarea') {
+                                               print dol_nl2br($conf->global->{$constname});
+                                       } elseif ($val['type']== 'html') {
+                                               print  $conf->global->{$constname};
+                                       } elseif ($val['type'] == 'yesno') {
+                                               print ajax_constantonoff($constname);
+                                       } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+                                               include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+                                               $formmail = new FormMail($db);
+
+                                               $tmp = explode(':', $val['type']);
+
+                                               $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+                                               if ($template<0) {
+                                                       setEventMessages(null, $formmail->errors, 'errors');
+                                               }
+                                               print $langs->trans($template->label);
+                                       } elseif (preg_match('/category:/', $val['type'])) {
+                                               $c = new Categorie($db);
+                                               $result = $c->fetch($conf->global->{$constname});
+                                               if ($result < 0) {
+                                                       setEventMessages(null, $c->errors, 'errors');
+                                               } elseif ($result > 0 ) {
+                                                       $ways = $c->print_all_ways(' &gt;&gt; ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
+                                                       $toprint = array();
+                                                       foreach ($ways as $way) {
+                                                               $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
+                                                       }
+                                                       print '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
+                                               }
+                                       } elseif (preg_match('/thirdparty_type/', $val['type'])) {
+                                               if ($conf->global->{$constname}==2) {
+                                                       print $langs->trans("Prospect");
+                                               } elseif ($conf->global->{$constname}==3) {
+                                                       print $langs->trans("ProspectCustomer");
+                                               } elseif ($conf->global->{$constname}==1) {
+                                                       print $langs->trans("Customer");
+                                               } elseif ($conf->global->{$constname}==0) {
+                                                       print $langs->trans("NorProspectNorCustomer");
+                                               }
+                                       } elseif ($val['type'] == 'product') {
+                                               $product = new Product($db);
+                                               $resprod = $product->fetch($conf->global->{$constname});
+                                               if ($resprod > 0) {
+                                                       print $product->ref;
+                                               } elseif ($resprod < 0) {
+                                                       setEventMessages(null, $object->errors, "errors");
+                                               }
+                                       } else {
+                                               print $conf->global->{$constname};
+                                       }
+                                       print '</td></tr>';
+                               }
+               }
+
+               print '</table>';
+               }
+       }
+
+       if ($setupnotempty) {
+               print '<div class="tabsAction">';
+               print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
+               print '</div>';
+       } else {
+               print '<br>'.$langs->trans("NothingToSetup");
+       }
+}
+
+
+$moduledir = 'peppol';
+$myTmpObjects = array();
+$myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
+
+
+foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
+       if ($myTmpObjectKey == 'MyObject') {
+               continue;
+       }
+       if ($myTmpObjectArray['includerefgeneration']) {
+               /*
+                * Orders Numbering model
+                */
+               $setupnotempty++;
+
+               print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
+
+               print '<table class="noborder centpercent">';
+               print '<tr class="liste_titre">';
+               print '<td>'.$langs->trans("Name").'</td>';
+               print '<td>'.$langs->trans("Description").'</td>';
+               print '<td class="nowrap">'.$langs->trans("Example").'</td>';
+               print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
+               print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
+               print '</tr>'."\n";
+
+               clearstatcache();
+
+               foreach ($dirmodels as $reldir) {
+                       $dir = dol_buildpath($reldir."core/modules/".$moduledir);
+
+                       if (is_dir($dir)) {
+                               $handle = opendir($dir);
+                               if (is_resource($handle)) {
+                                       while (($file = readdir($handle)) !== false) {
+                                               if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
+                                                       $file = substr($file, 0, dol_strlen($file) - 4);
+
+                                                       require_once $dir.'/'.$file.'.php';
+
+                                                       $module = new $file($db);
+
+                                                       // Show modules according to features level
+                                                       if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
+                                                               continue;
+                                                       }
+                                                       if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
+                                                               continue;
+                                                       }
+
+                                                       if ($module->isEnabled()) {
+                                                               dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
+
+                                                               print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
+                                                               print $module->info();
+                                                               print '</td>';
+
+                                                               // Show example of numbering model
+                                                               print '<td class="nowrap">';
+                                                               $tmp = $module->getExample();
+                                                               if (preg_match('/^Error/', $tmp)) {
+                                                                       $langs->load("errors");
+                                                                       print '<div class="error">'.$langs->trans($tmp).'</div>';
+                                                               } elseif ($tmp == 'NotConfigured') {
+                                                                       print $langs->trans($tmp);
+                                                               } else {
+                                                                       print $tmp;
+                                                               }
+                                                               print '</td>'."\n";
+
+                                                               print '<td class="center">';
+                                                               $constforvar = 'PEPPOL_'.strtoupper($myTmpObjectKey).'_ADDON';
+                                                               if ($conf->global->$constforvar == $file) {
+                                                                       print img_picto($langs->trans("Activated"), 'switch_on');
+                                                               } else {
+                                                                       print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&object='.strtolower($myTmpObjectKey).'&value='.urlencode($file).'">';
+                                                                       print img_picto($langs->trans("Disabled"), 'switch_off');
+                                                                       print '</a>';
+                                                               }
+                                                               print '</td>';
+
+                                                               $mytmpinstance = new $myTmpObjectKey($db);
+                                                               $mytmpinstance->initAsSpecimen();
+
+                                                               // Info
+                                                               $htmltooltip = '';
+                                                               $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+
+                                                               $nextval = $module->getNextValue($mytmpinstance);
+                                                               if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+                                                                       $htmltooltip .= ''.$langs->trans("NextValue").': ';
+                                                                       if ($nextval) {
+                                                                               if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
+                                                                                       $nextval = $langs->trans($nextval);
+                                                                               }
+                                                                                       $htmltooltip .= $nextval.'<br>';
+                                                                       } else {
+                                                                               $htmltooltip .= $langs->trans($module->error).'<br>';
+                                                                       }
+                                                               }
+
+                                                               print '<td class="center">';
+                                                               print $form->textwithpicto('', $htmltooltip, 1, 0);
+                                                               print '</td>';
+
+                                                               print "</tr>\n";
+                                                       }
+                                               }
+                                       }
+                                       closedir($handle);
+                               }
+                       }
+               }
+               print "</table><br>\n";
+       }
+
+       if ($myTmpObjectArray['includedocgeneration']) {
+               /*
+                * Document templates generators
+                */
+               $setupnotempty++;
+               $type = strtolower($myTmpObjectKey);
+
+               print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
+
+               // Load array def with activated templates
+               $def = array();
+               $sql = "SELECT nom";
+               $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
+               $sql .= " WHERE type = '".$db->escape($type)."'";
+               $sql .= " AND entity = ".$conf->entity;
+               $resql = $db->query($sql);
+               if ($resql) {
+                       $i = 0;
+                       $num_rows = $db->num_rows($resql);
+                       while ($i < $num_rows) {
+                               $array = $db->fetch_array($resql);
+                               array_push($def, $array[0]);
+                               $i++;
+                       }
+               } else {
+                       dol_print_error($db);
+               }
+
+               print "<table class=\"noborder\" width=\"100%\">\n";
+               print "<tr class=\"liste_titre\">\n";
+               print '<td>'.$langs->trans("Name").'</td>';
+               print '<td>'.$langs->trans("Description").'</td>';
+               print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
+               print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
+               print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
+               print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
+               print "</tr>\n";
+
+               clearstatcache();
+
+               foreach ($dirmodels as $reldir) {
+                       foreach (array('', '/doc') as $valdir) {
+                               $realpath = $reldir."core/modules/".$moduledir.$valdir;
+                               $dir = dol_buildpath($realpath);
+
+                               if (is_dir($dir)) {
+                                       $handle = opendir($dir);
+                                       if (is_resource($handle)) {
+                                               while (($file = readdir($handle)) !== false) {
+                                                       $filelist[] = $file;
+                                               }
+                                               closedir($handle);
+                                               arsort($filelist);
+
+                                               foreach ($filelist as $file) {
+                                                       if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
+                                                               if (file_exists($dir.'/'.$file)) {
+                                                                       $name = substr($file, 4, dol_strlen($file) - 16);
+                                                                       $classname = substr($file, 0, dol_strlen($file) - 12);
+
+                                                                       require_once $dir.'/'.$file;
+                                                                       $module = new $classname($db);
+
+                                                                       $modulequalified = 1;
+                                                                       if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
+                                                                               $modulequalified = 0;
+                                                                       }
+                                                                       if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
+                                                                               $modulequalified = 0;
+                                                                       }
+
+                                                                       if ($modulequalified) {
+                                                                               print '<tr class="oddeven"><td width="100">';
+                                                                               print (empty($module->name) ? $name : $module->name);
+                                                                               print "</td><td>\n";
+                                                                               if (method_exists($module, 'info')) {
+                                                                                       print $module->info($langs);
+                                                                               } else {
+                                                                                       print $module->description;
+                                                                               }
+                                                                               print '</td>';
+
+                                                                               // Active
+                                                                               if (in_array($name, $def)) {
+                                                                                       print '<td class="center">'."\n";
+                                                                                       print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
+                                                                                       print img_picto($langs->trans("Enabled"), 'switch_on');
+                                                                                       print '</a>';
+                                                                                       print '</td>';
+                                                                               } else {
+                                                                                       print '<td class="center">'."\n";
+                                                                                       print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+                                                                                       print "</td>";
+                                                                               }
+
+                                                                               // Default
+                                                                               print '<td class="center">';
+                                                                               $constforvar = 'PEPPOL_'.strtoupper($myTmpObjectKey).'_ADDON';
+                                                                               if ($conf->global->$constforvar == $name) {
+                                                                                       //print img_picto($langs->trans("Default"), 'on');
+                                                                                       // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
+                                                                                       print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
+                                                                               } else {
+                                                                                       print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&object='.urlencode(strtolower($myTmpObjectKey)).'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+                                                                               }
+                                                                               print '</td>';
+
+                                                                               // Info
+                                                                               $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+                                                                               $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
+                                                                               if ($module->type == 'pdf') {
+                                                                                       $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+                                                                               }
+                                                                               $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+                                                                               $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+                                                                               $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+                                                                               $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+
+                                                                               print '<td class="center">';
+                                                                               print $form->textwithpicto('', $htmltooltip, 1, 0);
+                                                                               print '</td>';
+
+                                                                               // Preview
+                                                                               print '<td class="center">';
+                                                                               if ($module->type == 'pdf') {
+                                                                                       print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&object='.$myTmpObjectKey.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
+                                                                               } else {
+                                                                                       print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+                                                                               }
+                                                                               print '</td>';
+
+                                                                               print "</tr>\n";
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               print '</table>';
+       }
+}
+
+if (empty($setupnotempty)) {
+       print '<br>'.$langs->trans("NothingToSetup");
+}
+
+// Page end
+print dol_get_fiche_end();
+
+llxFooter();
+$db->close();
diff --git a/htdocs/custom/peppol/class/actions_peppol.class.php b/htdocs/custom/peppol/class/actions_peppol.class.php
new file mode 100644 (file)
index 0000000..eac7168
--- /dev/null
@@ -0,0 +1,614 @@
+<?php
+/* Copyright (C) 2021-2022 Éric Seigne <eric.seigne@cap-rel.fr>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file    peppol/class/actions_peppol.class.php
+ * \ingroup peppol
+ * \brief   Example hook overload.
+ *
+ * Put detailed description here.
+ */
+dol_include_once('/peppol/lib/peppol.lib.php');
+
+require_once __DIR__ . '/../vendor/autoload.php';
+include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
+
+use Einvoicing\Identifier;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\Party;
+use Einvoicing\Presets;
+use Einvoicing\Writers\UblWriter;
+use Einvoicing\Exceptions\ValidationException;
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Attachment;
+use Einvoicing\Delivery;
+
+/**
+ * Class ActionsPeppol
+ */
+class ActionsPeppol
+{
+    /**
+     * @var DoliDB Database handler.
+     */
+    public $db;
+
+    /**
+     * @var string Error code (or message)
+     */
+    public $error = '';
+
+    /**
+     * @var array Errors
+     */
+    public $errors = array();
+
+
+    /**
+     * @var array Hook results. Propagated to $hookmanager->resArray for later reuse
+     */
+    public $results = array();
+
+    /**
+     * @var string String displayed by executeHook() immediately after return
+     */
+    public $resprints;
+
+
+    /**
+     * Constructor
+     *
+     *  @param         DoliDB          $db      Database handler
+     */
+    public function __construct($db)
+    {
+        $this->db = $db;
+    }
+
+
+    /**
+     * Execute action
+     *
+     * @param  array                   $parameters             Array of parameters
+     * @param  CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+     * @param  string                  $action         'add', 'update', 'view'
+     * @return int                                             <0 if KO,
+     *                                                         =0 if OK but we want to process standard actions too,
+     *                                                         >0 if OK and we want to replace standard actions.
+     */
+    public function getNomUrl($parameters, &$object, &$action)
+    {
+        global $db, $langs, $conf, $user;
+        $this->resprints = '';
+        return 0;
+    }
+
+    /**
+     * Overloading the doActions function : replacing the parent's function with the one below
+     *
+     * @param   array           $parameters     Hook metadatas (context, etc...)
+     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+     * @param   string          $action         Current action (if set). Generally create or edit or null
+     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
+     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
+     */
+    public function doActions($parameters, &$object, &$action, $hookmanager)
+    {
+        global $conf, $user, $langs;
+
+        $error = 0; // Error counter
+
+        /* print_r($parameters); print_r($object); echo "action: " . $action; */
+        if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {      // do something only for the context 'somecontext1' or 'somecontext2'
+            // Do what you want here...
+            // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values.
+        }
+
+        if (!$error) {
+            $this->results = array('myreturn' => 999);
+            $this->resprints = 'A text to show';
+            return 0; // or return 1 to replace standard code
+        } else {
+            $this->errors[] = 'Error message';
+            return -1;
+        }
+    }
+
+
+    /**
+     * Overloading the doMassActions function : replacing the parent's function with the one below
+     *
+     * @param   array           $parameters     Hook metadatas (context, etc...)
+     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+     * @param   string          $action         Current action (if set). Generally create or edit or null
+     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
+     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
+     */
+    public function doMassActions($parameters, &$object, &$action, $hookmanager)
+    {
+        global $conf, $user, $langs, $db;
+
+        $error = 0; // Error counter
+        dol_syslog(get_class($this).'::doMassActions peppol' . json_encode($parameters));
+
+        // print_r($parameters); print_r($object); echo "action: " . $action;
+        if (in_array($parameters['currentcontext'], array('invoicelist'))) {           // do something only for the context 'somecontext1' or 'somecontext2'
+            if ($parameters['massaction'] == "peppolZip") {
+                $obj = new Facture($db);
+
+                $destdir = stripslashes($parameters['diroutputmassaction']);
+                if (!is_dir($destdir)) {
+                    dol_syslog(get_class($this).'::doMassActions make directory ' . $destdir);
+                    mkdir($destdir, 0700, true);
+                }
+                $zipname = $destdir . '/archive-peppol.zip';
+                $zip = new ZipArchive();
+                if ($zip->open($zipname, ZipArchive::CREATE|ZipArchive::OVERWRITE)) {
+                    dol_syslog(get_class($this).'::doMassActions zip destination is ' . $zipname);
+                    foreach ($parameters['toselect'] as $objectid) {
+                        // Do action on each object id
+                        if ($obj->fetch($objectid) > 0) {
+                            $fic = $conf->facture->dir_output.'/'.$obj->ref . "/" . $obj->ref ."_peppol.xml";
+                            if (file_exists($fic)) {
+                                // print "<p> on ajoute $fic </p>";
+                                $zip->addFile($fic, basename($fic));
+                            }
+                        }
+                    }
+                    $zip->close();
+
+                    ///Then download the zipped file.
+                    header('Content-Type: application/zip');
+                    header('Content-disposition: attachment; filename='.basename($zipname));
+                    header('Content-Length: ' . filesize($zipname));
+                    readfile($zipname);
+                    exit;
+                }
+            }
+        }
+
+        if (!$error) {
+            $this->results = array('myreturn' => 999);
+            $this->resprints = 'A text to show';
+            return 0; // or return 1 to replace standard code
+        } else {
+            $this->errors[] = 'Error message';
+            return -1;
+        }
+    }
+
+
+    /**
+     * Overloading the addMoreMassActions function : replacing the parent's function with the one below
+     *
+     * @param   array           $parameters     Hook metadatas (context, etc...)
+     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+     * @param   string          $action         Current action (if set). Generally create or edit or null
+     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
+     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
+     */
+    public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
+    {
+        global $conf, $user, $langs;
+        $langs->load("peppol@peppol");
+        dol_syslog(get_class($this).'::addMoreMassActions peppol' . json_encode($parameters));
+
+        $error = 0; // Error counter
+        $disabled = 0;
+
+        // print_r($parameters); print_r($object); echo "action: " . $action;
+        //method=addMoreMassActions action= context=searchform:leftblock:toprightmenu:main:invoicelist
+        if (in_array($parameters['currentcontext'], array('invoicelist'))) {           // do something only for the context 'somecontext1' or 'somecontext2'
+            dol_syslog(get_class($this).'::addMoreMassActions peppol 2');
+            $this->resprints = '<option value="peppolZip"'.($disabled ? ' disabled="disabled"' : '').'>'.$langs->trans("PeppolMassActionZip").'</option>';
+        }
+
+        if (!$error) {
+            return 0; // or return 1 to replace standard code
+        } else {
+            $this->errors[] = 'Error message';
+            return -1;
+        }
+    }
+
+
+
+    /**
+     * Execute action
+     *
+     * @param  array   $parameters     Array of parameters
+     * @param   Object $object                 Object output on PDF
+     * @param   string $action         'add', 'update', 'view'
+     * @return  int                            <0 if KO,
+     *                                         =0 if OK but we want to process standard actions too,
+     *                                     >0 if OK and we want to replace standard actions.
+     */
+    public function beforePDFCreation($parameters, &$object, &$action)
+    {
+        global $conf, $user, $langs;
+        global $hookmanager;
+
+        $outputlangs = $langs;
+
+        $ret = 0;
+        $deltemp = array();
+        dol_syslog(get_class($this).'::executeHooks action='.$action);
+
+        /* print_r($parameters); print_r($object); echo "action: " . $action; */
+        if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {          // do something only for the context 'somecontext1' or 'somecontext2'
+        }
+
+        return $ret;
+    }
+
+    /**
+     * Execute action
+     *
+     * @param  array   $parameters     Array of parameters
+     * @param   Object $pdfhandler     PDF builder handler
+     * @param   string $action         'add', 'update', 'view'
+     * @return  int                        <0 if KO,
+     *                                  =0 if OK but we want to process standard actions too,
+     *                                  >0 if OK and we want to replace standard actions.
+     */
+    public function afterPDFCreation($parameters, &$pdfhandler, &$action)
+    {
+        if (!is_subclass_of($pdfhandler, 'ModelePDFFactures')) {
+            return 0;
+        }
+        // print "<pre>";
+        // print json_encode($parameters['object']->getLastMainDocLink('facture'));
+        // print "</pre>";
+        // exit;
+        // print json_encode($parameters['object']);
+        // exit;
+
+        global $conf, $user, $langs;
+        global $hookmanager;
+        global $mysoc;
+
+        $outputlangs = $langs;
+
+        $ret = 0;
+        $deltemp = array();
+        dol_syslog(get_class($this).'::executeHooks peppol action='.$action);
+
+        // print(json_encode($parameters['object']));
+        // exit;
+        //print_r($object); echo "action: " . $action;
+        // exit;
+        // if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {
+        //     // do something only for the context 'somecontext1' or 'somecontext2'
+        // }
+
+        $note_pub = $parameters['object']->note_public ? $parameters['object']->note_public : "note";
+        $ladate = new DateTime(dol_print_date($parameters['object']->date, 'dayrfc'));
+        $ladatepaiement = new DateTime(dol_print_date($parameters['object']->date_lim_reglement, 'dayrfc'));
+        $currency = $parameters['object']->multicurrency_code ?? '';
+
+        $delivery = new Delivery();
+        $delivery->setDate($ladate)
+                 ->setCountry($parameters['object']->thirdparty->country_code)
+                 ->setAddress([$parameters['object']->thirdparty->address])
+                 ->setCity($parameters['object']->thirdparty->town)
+                 ->setSubdivision($parameters['object']->thirdparty->country_code . '-' . $parameters['object']->thirdparty->state_code)
+                 ->setPostalCode($parameters['object']->thirdparty->zip);
+
+        // Create PEPPOL invoice instance
+        $inv = new Invoice(Presets\Peppol::class);
+        $inv->setNumber($parameters['object']->ref)
+            ->setIssueDate($ladate)
+            ->setDelivery($delivery)
+            ->setDueDate($ladatepaiement);
+
+               if($currency != '') {
+                       $inv->setCurrency($currency);
+               }
+
+        // Set seller
+        $seller = new Party();
+        //->setElectronicAddress(new Identifier('9482348239847239874', '0088')) //TODO ?
+        $seller
+            ->setElectronicAddress(new Identifier($mysoc->tva_intra, peppolGetIdentifierSchemeFromVatNumber($mysoc->tva_intra)))
+            // ->setCompanyId(new Identifier($mysoc->tva_intra, peppolGetIdentifierSchemeFromVatNumber($mysoc->tva_intra)))
+            // ->setTaxRegistrationId(new Identifier($mysoc->tva_intra, peppolGetIdentifierSchemeFromVatNumber($mysoc->tva_intra)))
+            ->setName($mysoc->name)
+            ->setTradingName($mysoc->name)
+            ->setVatNumber($mysoc->tva_intra)
+            ->setAddress([$mysoc->address])
+            ->setPostalCode($mysoc->zip)
+            ->setCity($mysoc->town)
+            ->setSubdivision($mysoc->country_code . '-' . $mysoc->state_code)
+            ->setCountry($mysoc->country_code);
+        $inv->setSeller($seller);
+
+        // Set buyer
+        $buyer = new Party();
+        //->setElectronicAddress(new Identifier($parameters['object']->thirdparty->idprof1, '0208')) //TODO
+        $buyer
+            // ->setCompanyId(new Identifier($parameters['object']->thirdparty->tva_intra, peppolGetIdentifierSchemeFromVatNumber($parameters['object']->thirdparty->tva_intra))) //TODO ?
+            ->setVatNumber($parameters['object']->thirdparty->tva_intra)
+            ->setElectronicAddress(new Identifier($parameters['object']->thirdparty->tva_intra, peppolGetIdentifierSchemeFromVatNumber($parameters['object']->thirdparty->tva_intra))) //TODO ?
+            ->setName($parameters['object']->thirdparty->name)
+            ->setTradingName($parameters['object']->thirdparty->name)
+            ->setAddress([$parameters['object']->thirdparty->address])
+            ->setPostalCode($parameters['object']->thirdparty->zip)
+            ->setCity($parameters['object']->thirdparty->town)
+            ->setSubdivision($parameters['object']->thirdparty->country_code . '-' . $parameters['object']->thirdparty->state_code)
+            ->setCountry($parameters['object']->thirdparty->country_code);
+        // dol_syslog('peppol idBuyer=' . json_encode($buyer));
+
+
+        //BT-24 roumanie
+        if ($currency == "RON") {
+            $inv->setSpecification("urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.0");
+            $delivery->setSubdivision($parameters['object']->thirdparty->country_code . '-' . $parameters['object']->thirdparty->state_code);
+                       $seller->setSubdivision($mysoc->country_code . '-' . $mysoc->state_code);
+            $buyer->setSubdivision($parameters['object']->thirdparty->country_code . '-' . $parameters['object']->thirdparty->state_code);
+        }
+
+        //20220217 - add more informations about buyer if private person
+        if ($parameters['object']->thirdparty->typent_code == 'TE_PRIVATE') {
+            $buyer->setContactName($parameters['object']->thirdparty->name);
+            $buyer->setContactPhone($parameters['object']->thirdparty->phone);
+            $buyer->setContactEmail($parameters['object']->thirdparty->email);
+        }
+
+        $inv->setBuyer($buyer);
+
+        //TODO
+        $buyerReference = "no buyer ref.";
+        if ($parameters['object']->ref_client != "") {
+            $buyerReference = $parameters['object']->ref_client;
+        }
+        $inv->setBuyerReference($buyerReference);
+
+        $purchaseOrderRef = "no order ref.";
+        dol_syslog(' ********************************** peppol recheche du bon de commande');
+        if (isset($parameters['object']->linkedObjectsIds['commande'])) {
+            $purchaseOrderRef = "ref cmd: " . array_keys($parameters['object']->linkedObjectsIds['commande'])[0];
+        }
+        $inv->setPurchaseOrderReference($purchaseOrderRef);
+
+        //multi taux de tva ou pas il faut collecter les infos pour faire le recap global a la fin
+        $tabTVA = [];
+
+        // Add products lines
+        $numligne = 1;
+        foreach ($parameters['object']->lines as $line) {
+            // print_r($line);
+            $libelle = $line->libelle ? $line->libelle : "libre";
+            $subprice = amount_to_float($line->subprice ? $line->subprice : 0.00);
+            $totalline = amount_to_float($line->total_ttc ? $line->total_ttc : 0.00);
+            $qty = $line->qty ? $line->qty : 0;
+            $tva_tx = $line->tva_tx ? $line->tva_tx : 0.00;
+            $description = $line->desc ? $line->desc : "";
+            $lineref = $line->ref ? $line->ref : "0000";
+            $lineproductref = $line->product_ref ? $line->product_ref : "0000";
+
+            $tabTVA[$line->tva_tx]['totalHT']  += $line->total_ht;
+            $tabTVA[$line->tva_tx]['totalTVA'] += $line->total_tva;
+
+            $numligne++;
+
+            $pepppolLine = (new InvoiceLine())
+                    ->setName($libelle)
+                    ->setDescription($description)
+                    ->setId($lineref)
+                    ->setPrice($subprice, 1)
+                    ->setVatRate($tva_tx)
+                    ->setQuantity($qty);
+            if ($tva_tx == 0) {
+                //Asso et autres non assujetis à la TVA
+                // $pepppolLine
+                //     ->setVatCategory('O')
+                //     ->setVatExemptionReasonCode('VATEX-EU-O')
+                //     ->setVatExemptionReason('Not subject to VAT');
+
+                //Voir la liste https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5305/
+                // et https://docs.peppol.eu/poacc/billing/3.0/codelist/vatex/
+                $pepppolLine
+                    ->setVatCategory('K')
+                    ->setVatExemptionReasonCode('VATEX-EU-IC')
+                    ->setVatExemptionReason('VAT exempt for EEA intra-community supply of goods and services ');
+            } else {
+                //VAT normale
+            }
+
+            if ($line->remise_percent != "") {
+                dol_syslog("  peppol line add remise : " . $line->remise_percent);
+                $pepppolLine->addAllowance((new AllowanceOrCharge())->setReason('Remise')->markAsPercentage()->setAmount($line->remise_percent));
+            }
+            dol_syslog("  peppol line : " . json_encode($pepppolLine));
+
+            $inv->addLine($pepppolLine);
+        }
+
+        // //Multi taux de tva eventuel ?
+        // foreach ($tabTVA as $k => $v) {
+        //     $code = "S";
+        //     if ($k == 0) {
+        //         $code = 'E';
+        //     }
+        //     $inv->setVatCategory($code);
+        //     // $inv->addDocumentTax($code, "VAT", $v['totalHT'], $v['totalTVA'], $k);
+        // }
+
+
+
+        $embeddedAttachment = (new Attachment())
+            ->setId(new Identifier($parameters['object']->ref))
+            ->setFilename($parameters['object']->ref . '.pdf')
+            ->setMimeCode('application/pdf')
+            ->setContents(file_get_contents($conf->facture->dir_output.'/'.$parameters['object']->ref . "/" . $parameters['object']->ref . '.pdf'));
+               $inv->addAttachment($embeddedAttachment);
+
+        if (!empty($parameters['object']->getLastMainDocLink('facture'))) {
+            $externalAttachment = (new Attachment())
+            ->setId(new Identifier($parameters['object']->ref . '-online'))
+            ->setDescription('A link to PDF invoice')
+            ->setExternalUrl($parameters['object']->getLastMainDocLink('facture'));
+            $inv->addAttachment($externalAttachment);
+        }
+
+        try {
+            $inv->validate();
+            //XML with PDF inside
+            // if ($conf->global->PEPPOL_XMLINSIDE) {
+            $dest = $conf->facture->dir_output.'/'.$parameters['object']->ref . "/" . $parameters['object']->ref ."_peppol.xml";
+            dol_syslog("  save peppol XML to $dest");
+            // Export invoice to a UBL document
+            // header('Content-Type: text/xml');
+            $writer = new UblWriter();
+            $xml = $writer->export($inv);
+            file_put_contents($dest, $xml);
+            // }
+        } catch (ValidationException $e) {
+            dol_syslog(get_class($this).'::executeHooks peppol error: '.$e);
+        }
+
+        dol_syslog(get_class($this).'::executeHooks peppol end action='.$action);
+
+        return $ret;
+    }
+
+
+
+    /**
+     * Overloading the loadDataForCustomReports function : returns data to complete the customreport tool
+     *
+     * @param   array           $parameters     Hook metadatas (context, etc...)
+     * @param   string          $action         Current action (if set). Generally create or edit or null
+     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
+     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
+     */
+    public function loadDataForCustomReports($parameters, &$action, $hookmanager)
+    {
+        global $conf, $user, $langs;
+        $langs->load("peppol@peppol");
+
+        $this->results = array();
+
+        $head = array();
+        $h = 0;
+
+        if ($parameters['tabfamily'] == 'peppol') {
+            $head[$h][0] = dol_buildpath('/module/index.php', 1);
+            $head[$h][1] = $langs->trans("Home");
+            $head[$h][2] = 'home';
+            $h++;
+
+            $this->results['title'] = $langs->trans("Peppol");
+            $this->results['picto'] = 'peppol@peppol';
+        }
+
+        $head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
+        $head[$h][1] = $langs->trans("CustomReports");
+        $head[$h][2] = 'customreports';
+
+        $this->results['head'] = $head;
+
+        return 1;
+    }
+
+
+
+    /**
+     * Overloading the restrictedArea function : check permission on an object
+     *
+     * @param   array           $parameters     Hook metadatas (context, etc...)
+     * @param   string          $action         Current action (if set). Generally create or edit or null
+     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
+     * @return  int                                            <0 if KO,
+     *                                                         =0 if OK but we want to process standard actions too,
+     *                                                 >0 if OK and we want to replace standard actions.
+     */
+    public function restrictedArea($parameters, &$action, $hookmanager)
+    {
+        global $user;
+
+        if ($parameters['features'] == 'myobject') {
+            if ($user->rights->peppol->myobject->read) {
+                $this->results['result'] = 1;
+                return 1;
+            } else {
+                $this->results['result'] = 0;
+                return 1;
+            }
+        }
+
+        return 0;
+    }
+
+
+    /**
+     * getFormMail : auto join pdf and peppol files
+     */
+    public function getFormMail($parameters, &$object, &$action, $hookmanager)
+    {
+        global $conf,$langs,$db;
+
+        //fix : don't join peppol files in other cases than customer invoices
+        if ($object->param['models'] !== "facture_send") {
+            return 0;
+        }
+
+        $id = str_replace('inv', '', $object->trackid);
+
+        $obj = new Facture($db);
+        $obj->fetch($id);
+
+        $keytoavoidconflict = '';
+        if (versioncompare(versiondolibarrarray(), array(4,0,-3)) >= 0) {
+            $keytoavoidconflict = empty($parameters['trackid']) ? '' : '-'.$parameters['trackid'];
+        }
+
+        if ((GETPOST('action', 'aZ09') == 'presend' && GETPOST('mode') == 'init') || (GETPOST('modelmailselected', 'int') && ! GETPOST('removedfile', 'alpha'))) {
+            $listofpaths = (! empty($_SESSION["listofpaths".$keytoavoidconflict])) ? explode(';', $_SESSION["listofpaths".$keytoavoidconflict]) : array();
+            $listofnames = (! empty($_SESSION["listofnames".$keytoavoidconflict])) ? explode(';', $_SESSION["listofnames".$keytoavoidconflict]) : array();
+            $listofmimes = (! empty($_SESSION["listofmimes".$keytoavoidconflict])) ? explode(';', $_SESSION["listofmimes".$keytoavoidconflict]) : array();
+
+            $path = $conf->facture->dir_output.'/'.$obj->ref . "/";
+            $fileList = dol_dir_list($path, 'files', 0);
+            foreach ($fileList as $fileParams) {
+                $file = $fileParams['fullname'];
+                $pdforxml = '/(xml|pdf)$/';
+                if (! in_array($file, $listofpaths) && preg_match($pdforxml, $file, $matches) == 1) {
+                    //exclude SPECIMEN files from list
+                    if (preg_match('/SPECIMEN/', $file, $matches) == 1) {
+                        dol_syslog("exclude specimen file from file list");
+                    } else {
+                        $listofpaths[] = $file;
+                        $listofnames[] = basename($file);
+                        $listofmimes[] = dol_mimetype($file);
+                    }
+                }
+            }
+
+            // Now we saved back content of files to have into attachment
+            $_SESSION["listofpaths".$keytoavoidconflict]=join(';', $listofpaths);
+            $_SESSION["listofnames".$keytoavoidconflict]=join(';', $listofnames);
+            $_SESSION["listofmimes".$keytoavoidconflict]=join(';', $listofmimes);
+        }
+
+        return 0;
+    }
+
+    /* Add here any other hooked methods... */
+}
diff --git a/htdocs/custom/peppol/composer.json b/htdocs/custom/peppol/composer.json
new file mode 100644 (file)
index 0000000..11892fe
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "config": {
+        "vendor-dir" : "vendor"
+    },
+    "require": {
+        "josemmo/einvoicing": "^0.1.6"
+    }
+}
diff --git a/htdocs/custom/peppol/core/modules/modPeppol.class.php b/htdocs/custom/peppol/core/modules/modPeppol.class.php
new file mode 100644 (file)
index 0000000..3f16589
--- /dev/null
@@ -0,0 +1,485 @@
+<?php
+/* Copyright (C) 2004-2018  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2018-2019  Nicolas ZABOURI         <info@inovea-conseil.com>
+ * Copyright (C) 2019-2020  Frédéric France         <frederic.france@netlogic.fr>
+ * Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ *     \defgroup   peppol     Module Peppol
+ *  \brief      Peppol module descriptor.
+ *
+ *  \file       htdocs/peppol/core/modules/modPeppol.class.php
+ *  \ingroup    peppol
+ *  \brief      Description and activation file for module Peppol
+ */
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
+
+/**
+ *  Description and activation class for module Peppol
+ */
+class modPeppol extends DolibarrModules
+{
+       /**
+        * Constructor. Define names, constants, directories, boxes, permissions
+        *
+        * @param DoliDB $db Database handler
+        */
+       public function __construct($db)
+       {
+               global $langs, $conf;
+               $this->db = $db;
+
+               // Id for module (must be unique).
+               // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
+               $this->numero = 436180; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module
+
+               // Key text used to identify module (for permissions, menus, etc...)
+               $this->rights_class = 'peppol';
+
+               // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
+               // It is used to group modules by family in module setup page
+               $this->family = "financial";
+
+               // Module position in the family on 2 digits ('01', '10', '20', ...)
+               $this->module_position = '90';
+
+               // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
+               //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
+               // Module label (no space allowed), used if translation string 'ModulePeppolName' not found (Peppol is name of module).
+               $this->name = preg_replace('/^mod/i', '', get_class($this));
+
+               // Module description, used if translation string 'ModulePeppolDesc' not found (Peppol is name of module).
+               $this->description = "PeppolDescription";
+               // Used only if file README.md and README-LL.md not found.
+               $this->descriptionlong = "PeppolDescription";
+
+               // Author
+               $this->editor_name = 'CAP-REL';
+               $this->editor_url = 'https://cap-rel.fr';
+
+               // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
+               $this->version = '1.0.8';
+               // Url to the file with your last numberversion of this module
+               $this->url_last_version = 'https://cap-rel.fr/dolibarr/peppol.txt';
+
+               // Key used in llx_const table to save module status enabled/disabled (where PEPPOL is value of property name of module in uppercase)
+               $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
+
+               // Name of image file used for this module.
+               // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
+               // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
+               // To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
+               $this->picto = 'peppol@peppol';
+
+               // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
+               $this->module_parts = array(
+                       // Set this to 1 if module has its own trigger directory (core/triggers)
+                       'triggers' => 0,
+                       // Set this to 1 if module has its own login method file (core/login)
+                       'login' => 0,
+                       // Set this to 1 if module has its own substitution function file (core/substitutions)
+                       'substitutions' => 0,
+                       // Set this to 1 if module has its own menus handler directory (core/menus)
+                       'menus' => 0,
+                       // Set this to 1 if module overwrite template dir (core/tpl)
+                       'tpl' => 0,
+                       // Set this to 1 if module has its own barcode directory (core/modules/barcode)
+                       'barcode' => 0,
+                       // Set this to 1 if module has its own models directory (core/modules/xxx)
+                       'models' => 0,
+                       // Set this to 1 if module has its own printing directory (core/modules/printing)
+                       'printing' => 0,
+                       // Set this to 1 if module has its own theme directory (theme)
+                       'theme' => 0,
+                       // Set this to relative path of css file if module has its own css file
+                       'css' => array(
+                               //    '/peppol/css/peppol.css.php',
+                       ),
+                       // Set this to relative path of js file if module must load a js on all pages
+                       'js' => array(
+                               //   '/peppol/js/peppol.js.php',
+                       ),
+                       // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
+                       'hooks' => array(
+                               'pdfgeneration',
+                               'formmail',
+                               'invoicelist',
+                               'doMassActions'
+                               // 'odtgeneration',
+                               //   'data' => array(
+                               //       'hookcontext1',
+                               //       'hookcontext2',
+                               //   ),
+                               //   'entity' => '0',
+                       ),
+                       // Set this to 1 if features of module are opened to external users
+                       'moduleforexternal' => 0,
+               );
+
+               // Data directories to create when module is enabled.
+               // Example: this->dirs = array("/peppol/temp","/peppol/subdir");
+               $this->dirs = array("/peppol/temp");
+
+               // Config pages. Put here list of php page, stored into peppol/admin directory, to use to setup module.
+               $this->config_page_url = array("setup.php@peppol");
+
+               // Dependencies
+               // A condition to hide module
+               $this->hidden = false;
+               // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
+               $this->depends = array('always1' => "modSociete", 'always2' => "modFacture");
+               $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
+               $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
+
+               // The language file dedicated to your module
+               $this->langfiles = array("peppol@peppol");
+
+               // Prerequisites
+               //Note eric: php 7.1 pour module xml peppol externe
+               $this->phpmin = array(7, 1); // Minimum version of PHP required by module
+               $this->need_dolibarr_version = array(10, -3); // Minimum version of Dolibarr required by module
+
+               // Messages at activation
+               $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+               $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+               //$this->automatic_activation = array('FR'=>'PeppolWasAutomaticallyActivatedBecauseOfYourCountryChoice');
+               //$this->always_enabled = true;                                                         // If true, can't be disabled
+
+               // Constants
+               // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
+               // Example: $this->const=array(1 => array('PEPPOL_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
+               //                             2 => array('PEPPOL_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
+               // );
+               $this->const = array();
+
+               // Some keys to add into the overwriting translation tables
+               /*$this->overwrite_translation = array(
+                       'en_US:ParentCompany'=>'Parent company or reseller',
+                       'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
+               )*/
+
+               if (!isset($conf->peppol) || !isset($conf->peppol->enabled)) {
+                       $conf->peppol = new stdClass();
+                       $conf->peppol->enabled = 0;
+               }
+
+               // Array to add new pages in new tabs
+               $this->tabs = array();
+               // Example:
+               // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@peppol:$user->rights->peppol->read:/peppol/mynewtab1.php?id=__ID__');                                          // To add a new tab identified by code tabname1
+               // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@peppol:$user->rights->othermodule->read:/peppol/mynewtab2.php?id=__ID__',         // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
+               // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');                                                                                                                                   // To remove an existing tab identified by code tabname
+               //
+               // Where objecttype can be
+               // 'categories_x'         to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
+               // 'contact'          to add a tab in contact view
+               // 'contract'         to add a tab in contract view
+               // 'group'            to add a tab in group view
+               // 'intervention'     to add a tab in intervention view
+               // 'invoice'          to add a tab in customer invoice view
+               // 'invoice_supplier' to add a tab in supplier invoice view
+               // 'member'           to add a tab in fundation member view
+               // 'opensurveypoll'       to add a tab in opensurvey poll view
+               // 'order'            to add a tab in customer order view
+               // 'order_supplier'   to add a tab in supplier order view
+               // 'payment'              to add a tab in payment view
+               // 'payment_supplier' to add a tab in supplier payment view
+               // 'product'          to add a tab in product view
+               // 'propal'           to add a tab in propal view
+               // 'project'          to add a tab in project view
+               // 'stock'            to add a tab in stock view
+               // 'thirdparty'       to add a tab in third party view
+               // 'user'             to add a tab in user view
+
+               // Dictionaries
+               $this->dictionaries = array();
+               /* Example:
+               $this->dictionaries=array(
+                       'langs'=>'peppol@peppol',
+                       // List of tables we want to see into dictonnary editor
+                       'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"),
+                       // Label of tables
+                       'tablib'=>array("Table1", "Table2", "Table3"),
+                       // Request to select fields
+                       'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),
+                       // Sort order
+                       'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
+                       // List of fields (result of select to show dictionary)
+                       'tabfield'=>array("code,label", "code,label", "code,label"),
+                       // List of fields (list of fields to edit a record)
+                       'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
+                       // List of fields (list of fields for insert)
+                       'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
+                       // Name of columns with primary key (try to always name it 'rowid')
+                       'tabrowid'=>array("rowid", "rowid", "rowid"),
+                       // Condition to show each dictionary
+                       'tabcond'=>array($conf->peppol->enabled, $conf->peppol->enabled, $conf->peppol->enabled)
+               );
+               */
+
+               // Boxes/Widgets
+               // Add here list of php file(s) stored in peppol/core/boxes that contains a class to show a widget.
+               $this->boxes = array(
+                       //  0 => array(
+                       //      'file' => 'peppolwidget1.php@peppol',
+                       //      'note' => 'Widget provided by Peppol',
+                       //      'enabledbydefaulton' => 'Home',
+                       //  ),
+                       //  ...
+               );
+
+               // Cronjobs (List of cron jobs entries to add when module is enabled)
+               // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
+               $this->cronjobs = array(
+                       //  0 => array(
+                       //      'label' => 'MyJob label',
+                       //      'jobtype' => 'method',
+                       //      'class' => '/peppol/class/myobject.class.php',
+                       //      'objectname' => 'MyObject',
+                       //      'method' => 'doScheduledJob',
+                       //      'parameters' => '',
+                       //      'comment' => 'Comment',
+                       //      'frequency' => 2,
+                       //      'unitfrequency' => 3600,
+                       //      'status' => 0,
+                       //      'test' => '$conf->peppol->enabled',
+                       //      'priority' => 50,
+                       //  ),
+               );
+               // Example: $this->cronjobs=array(
+               //    0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->peppol->enabled', 'priority'=>50),
+               //    1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->peppol->enabled', 'priority'=>50)
+               // );
+
+               // Permissions provided by this module
+               $this->rights = array();
+               $r = 0;
+               // Add here entries to declare new permissions
+               /* BEGIN MODULEBUILDER PERMISSIONS */
+               $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+               $this->rights[$r][1] = 'Read objects of Peppol'; // Permission label
+               $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->peppol->level1->level2)
+               $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->peppol->level1->level2)
+               $r++;
+               $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+               $this->rights[$r][1] = 'Create/Update objects of Peppol'; // Permission label
+               $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->peppol->level1->level2)
+               $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->peppol->level1->level2)
+               $r++;
+               $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+               $this->rights[$r][1] = 'Delete objects of Peppol'; // Permission label
+               $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->peppol->level1->level2)
+               $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->peppol->level1->level2)
+               $r++;
+               /* END MODULEBUILDER PERMISSIONS */
+
+               // Main menu entries to add
+               $this->menu = array();
+               $r = 0;
+               // Add here entries to declare new menus
+               /* BEGIN MODULEBUILDER TOPMENU */
+               // $this->menu[$r++] = array(
+               //      'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+               //      'type'=>'top', // This is a Top menu entry
+               //      'titre'=>'ModulePeppolName',
+               //      'mainmenu'=>'peppol',
+               //      'leftmenu'=>'',
+               //      'url'=>'/peppol/peppolindex.php',
+               //      'langs'=>'peppol@peppol', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+               //      'position'=>1000 + $r,
+               //      'enabled'=>'$conf->peppol->enabled', // Define condition to show or hide menu entry. Use '$conf->peppol->enabled' if entry must be visible if module is enabled.
+               //      'perms'=>'1', // Use 'perms'=>'$user->rights->peppol->myobject->read' if you want your menu with a permission rules
+               //      'target'=>'',
+               //      'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+               // );
+               /* END MODULEBUILDER TOPMENU */
+               /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
+               $this->menu[$r++]=array(
+                       'fk_menu'=>'fk_mainmenu=peppol',      // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+                       'type'=>'left',                          // This is a Top menu entry
+                       'titre'=>'MyObject',
+                       'mainmenu'=>'peppol',
+                       'leftmenu'=>'myobject',
+                       'url'=>'/peppol/peppolindex.php',
+                       'langs'=>'peppol@peppol',               // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+                       'position'=>1000+$r,
+                       'enabled'=>'$conf->peppol->enabled',  // Define condition to show or hide menu entry. Use '$conf->peppol->enabled' if entry must be visible if module is enabled.
+                       'perms'=>'$user->rights->peppol->myobject->read',                                       // Use 'perms'=>'$user->rights->peppol->level1->level2' if you want your menu with a permission rules
+                       'target'=>'',
+                       'user'=>2,                                              // 0=Menu for internal users, 1=external users, 2=both
+               );
+               $this->menu[$r++]=array(
+                       'fk_menu'=>'fk_mainmenu=peppol,fk_leftmenu=myobject',       // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+                       'type'=>'left',                                 // This is a Left menu entry
+                       'titre'=>'List_MyObject',
+                       'mainmenu'=>'peppol',
+                       'leftmenu'=>'peppol_myobject_list',
+                       'url'=>'/peppol/myobject_list.php',
+                       'langs'=>'peppol@peppol',               // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+                       'position'=>1000+$r,
+                       'enabled'=>'$conf->peppol->enabled',  // Define condition to show or hide menu entry. Use '$conf->peppol->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+                       'perms'=>'$user->rights->peppol->myobject->read',                                       // Use 'perms'=>'$user->rights->peppol->level1->level2' if you want your menu with a permission rules
+                       'target'=>'',
+                       'user'=>2,                                              // 0=Menu for internal users, 1=external users, 2=both
+               );
+               $this->menu[$r++]=array(
+                       'fk_menu'=>'fk_mainmenu=peppol,fk_leftmenu=myobject',       // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+                       'type'=>'left',                                 // This is a Left menu entry
+                       'titre'=>'New_MyObject',
+                       'mainmenu'=>'peppol',
+                       'leftmenu'=>'peppol_myobject_new',
+                       'url'=>'/peppol/myobject_card.php?action=create',
+                       'langs'=>'peppol@peppol',               // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+                       'position'=>1000+$r,
+                       'enabled'=>'$conf->peppol->enabled',  // Define condition to show or hide menu entry. Use '$conf->peppol->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+                       'perms'=>'$user->rights->peppol->myobject->write',                                      // Use 'perms'=>'$user->rights->peppol->level1->level2' if you want your menu with a permission rules
+                       'target'=>'',
+                       'user'=>2,                                              // 0=Menu for internal users, 1=external users, 2=both
+               );
+               END MODULEBUILDER LEFTMENU MYOBJECT */
+               // Exports profiles provided by this module
+               $r = 1;
+               /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
+               /*
+               $langs->load("peppol@peppol");
+               $this->export_code[$r]=$this->rights_class.'_'.$r;
+               $this->export_label[$r]='MyObjectLines';        // Translation key (used only if key ExportDataset_xxx_z not found)
+               $this->export_icon[$r]='myobject@peppol';
+               // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
+               $keyforclass = 'MyObject'; $keyforclassfile='/peppol/class/myobject.class.php'; $keyforelement='myobject@peppol';
+               include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+               //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
+               //unset($this->export_fields_array[$r]['t.fieldtoremove']);
+               //$keyforclass = 'MyObjectLine'; $keyforclassfile='/peppol/class/myobject.class.php'; $keyforelement='myobjectline@peppol'; $keyforalias='tl';
+               //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+               $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@peppol';
+               include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+               //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline@peppol';
+               //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+               //$this->export_dependencies_array[$r] = array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
+               //$this->export_special_array[$r] = array('t.field'=>'...');
+               //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
+               //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
+               $this->export_sql_start[$r]='SELECT DISTINCT ';
+               $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'myobject as t';
+               //$this->export_sql_end[$r]  =' LEFT JOIN '.MAIN_DB_PREFIX.'myobject_line as tl ON tl.fk_myobject = t.rowid';
+               $this->export_sql_end[$r] .=' WHERE 1 = 1';
+               $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
+               $r++; */
+               /* END MODULEBUILDER EXPORT MYOBJECT */
+
+               // Imports profiles provided by this module
+               $r = 1;
+               /* BEGIN MODULEBUILDER IMPORT MYOBJECT */
+               /*
+                $langs->load("peppol@peppol");
+                $this->export_code[$r]=$this->rights_class.'_'.$r;
+                $this->export_label[$r]='MyObjectLines';       // Translation key (used only if key ExportDataset_xxx_z not found)
+                $this->export_icon[$r]='myobject@peppol';
+                $keyforclass = 'MyObject'; $keyforclassfile='/peppol/class/myobject.class.php'; $keyforelement='myobject@peppol';
+                include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+                $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@peppol';
+                include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+                //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
+                $this->export_sql_start[$r]='SELECT DISTINCT ';
+                $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'myobject as t';
+                $this->export_sql_end[$r] .=' WHERE 1 = 1';
+                $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
+                $r++; */
+               /* END MODULEBUILDER IMPORT MYOBJECT */
+       }
+
+       /**
+        *  Function called when module is enabled.
+        *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
+        *  It also creates data directories
+        *
+        *  @param      string  $options    Options when enabling module ('', 'noboxes')
+        *  @return     int                     1 if OK, 0 if KO
+        */
+       public function init($options = '')
+       {
+               global $conf, $langs;
+
+               $result = $this->_load_tables('/peppol/sql/');
+               if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
+
+               // Create extrafields during init
+               //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+               //$extrafields = new ExtraFields($this->db);
+               //$result1=$extrafields->addExtraField('peppol_myattr1', "New Attr 1 label", 'boolean', 1,  3, 'thirdparty',   0, 0, '', '', 1, '', 0, 0, '', '', 'peppol@peppol', '$conf->peppol->enabled');
+               //$result2=$extrafields->addExtraField('peppol_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project',      0, 0, '', '', 1, '', 0, 0, '', '', 'peppol@peppol', '$conf->peppol->enabled');
+               //$result3=$extrafields->addExtraField('peppol_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'peppol@peppol', '$conf->peppol->enabled');
+               //$result4=$extrafields->addExtraField('peppol_myattr4', "New Attr 4 label", 'select',  1,  3, 'thirdparty',   0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'peppol@peppol', '$conf->peppol->enabled');
+               //$result5=$extrafields->addExtraField('peppol_myattr5', "New Attr 5 label", 'text',    1, 10, 'user',         0, 0, '', '', 1, '', 0, 0, '', '', 'peppol@peppol', '$conf->peppol->enabled');
+
+               // Permissions
+               $this->remove($options);
+
+               $sql = array();
+
+               // Document templates
+               $moduledir = 'peppol';
+               $myTmpObjects = array();
+               $myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
+
+               foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
+                       if ($myTmpObjectKey == 'MyObject') continue;
+                       if ($myTmpObjectArray['includerefgeneration']) {
+                               $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/peppol/template_myobjects.odt';
+                               $dirodt = DOL_DATA_ROOT.'/doctemplates/peppol';
+                               $dest = $dirodt.'/template_myobjects.odt';
+
+                               if (file_exists($src) && !file_exists($dest))
+                               {
+                                       require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+                                       dol_mkdir($dirodt);
+                                       $result = dol_copy($src, $dest, 0, 0);
+                                       if ($result < 0)
+                                       {
+                                               $langs->load("errors");
+                                               $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
+                                               return 0;
+                                       }
+                               }
+
+                               $sql = array_merge($sql, array(
+                                       "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
+                                       "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")",
+                                       "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
+                                       "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")"
+                               ));
+                       }
+               }
+
+               return $this->_init($sql, $options);
+       }
+
+       /**
+        *  Function called when module is disabled.
+        *  Remove from database constants, boxes and permissions from Dolibarr database.
+        *  Data directories are not deleted
+        *
+        *  @param      string  $options    Options when enabling module ('', 'noboxes')
+        *  @return     int                 1 if OK, 0 if KO
+        */
+       public function remove($options = '')
+       {
+               $sql = array();
+               return $this->_remove($sql, $options);
+       }
+}
diff --git a/htdocs/custom/peppol/img/object_peppol.png b/htdocs/custom/peppol/img/object_peppol.png
new file mode 100644 (file)
index 0000000..300bd22
Binary files /dev/null and b/htdocs/custom/peppol/img/object_peppol.png differ
diff --git a/htdocs/custom/peppol/img/object_peppol_over.png b/htdocs/custom/peppol/img/object_peppol_over.png
new file mode 100644 (file)
index 0000000..5684ee5
Binary files /dev/null and b/htdocs/custom/peppol/img/object_peppol_over.png differ
diff --git a/htdocs/custom/peppol/img/peppol-logo-600x145.png b/htdocs/custom/peppol/img/peppol-logo-600x145.png
new file mode 100644 (file)
index 0000000..300bd22
Binary files /dev/null and b/htdocs/custom/peppol/img/peppol-logo-600x145.png differ
diff --git a/htdocs/custom/peppol/langs/en_US/peppol.lang b/htdocs/custom/peppol/langs/en_US/peppol.lang
new file mode 100644 (file)
index 0000000..8ac80c2
--- /dev/null
@@ -0,0 +1,53 @@
+# Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+#
+# Generic
+#
+
+# Module label 'ModulePeppolName'
+ModulePeppolName = Peppol
+# Module description 'ModulePeppolDesc'
+ModulePeppolDesc = Peppol description
+
+#
+# Admin page
+#
+PeppolSetup = Peppol setup
+Settings = Settings
+PeppolSetupPage = Peppol setup page
+PEPPOL_XMLINSIDE = XML Inside PDF ?
+PEPPOL_XMLINSIDETooltip = In that case peppol plugin produce a PDF with embedded XML, disable this function to get a full XML file
+PEPPOL_MYPARAM2=My param 2
+PEPPOL_MYPARAM2Tooltip=My param 2 tooltip
+
+
+#
+# About page
+#
+About = About
+PeppolAbout = About Peppol
+PeppolAboutPage = Peppol about page
+
+#
+# Sample page
+#
+MyPageName = My page name
+
+#
+# Sample widget
+#
+MyWidget = My widget
+MyWidgetDescription = My widget description
diff --git a/htdocs/custom/peppol/langs/fr_FR/peppol.lang b/htdocs/custom/peppol/langs/fr_FR/peppol.lang
new file mode 100644 (file)
index 0000000..5fdcb05
--- /dev/null
@@ -0,0 +1,50 @@
+# Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+#
+# Générique
+#
+
+# Module label 'ModulePeppolName'
+ModulePeppolName = Peppol
+# Module description 'ModulePeppolDesc'
+ModulePeppolDesc = Description de Peppol
+
+#
+# Page d'administration
+#
+PeppolSetup = Configuration du module Peppol
+Settings = Réglages
+PeppolSetupPage = Page de configuration du module Peppol
+
+#
+# Page À propos
+#
+About = À propos
+PeppolAbout = À propos de Peppol
+PeppolAboutPage = Page à propos de Peppol
+
+#
+# Page d'exemple
+#
+MyPageName = Nom de ma page
+
+#
+# Box d'exemple
+#
+MyWidget = Mon widget
+MyWidgetDescription = Description de mon widget
+
+PeppolMassActionZip = Créer un ZIP avec tous les fichiers Peppol
diff --git a/htdocs/custom/peppol/lib/Peppol Code Lists - Participant identifier schemes v8.0.json b/htdocs/custom/peppol/lib/Peppol Code Lists - Participant identifier schemes v8.0.json
new file mode 100644 (file)
index 0000000..7a69b0e
--- /dev/null
@@ -0,0 +1,972 @@
+{
+  "version":"8",
+  "entry-count":88,
+  "values":[
+    {
+      "schemeid":"FR:SIRENE",
+      "iso6523":"0002",
+      "country":"FR",
+      "scheme-name":"System Information et Repertoire des Entreprise et des Etablissements: SIRENE",
+      "issuing-agency":"Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.)",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"FR:SIRENE",
+      "display":"The 9 figure code number (SIREN) is written in groups of 3 characters. Example: 784 301 772\nThe 14 figure code number is written in 3 groups of 3 characters and a single group of 5. Example: 784 301 772 00025",
+      "examples":"784301772\n78430177200025",
+      "validation-rules":"RegEx: [0-9]{9}([0-9]{5})?\nCheck digits: Luhn Algorithm",
+      "usage":"1.1.1 - Changed from FR:SIRET to FR:SIRENE (see ISU Jira ISU-231)"
+    },
+    {
+      "schemeid":"SE:ORGNR",
+      "iso6523":"0007",
+      "country":"SE",
+      "scheme-name":"Organisationsnummer",
+      "issuing-agency":"The National Tax Board",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"SE:ORGNR",
+      "display":"Single group of 10 digits.",
+      "examples":"2120000787",
+      "validation-rules":"RegEx: [0-9]{10}\nCheck digits: Luhn Algorithm"
+    },
+    {
+      "schemeid":"FR:SIRET",
+      "iso6523":"0009",
+      "country":"FR",
+      "scheme-name":"SIRET-CODE",
+      "issuing-agency":"DU PONT DE NEMOURS",
+      "initial-release":"1.1.1",
+      "state":"active",
+      "structure":"FR:SIRET",
+      "display":"In four groups, Groups 1 - 3 = three digits each, Group 4 = five digits",
+      "examples":"78430177200025",
+      "validation-rules":"RegEx: [0-9]{14}"
+    },
+    {
+      "schemeid":"FI:OVT",
+      "iso6523":"0037",
+      "country":"FI",
+      "scheme-name":"LY-tunnus",
+      "issuing-agency":"National Board of Taxes, (Verohallitus)",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"FI:OVT",
+      "display":"None",
+      "examples":"0037:00371234567800001\n0037:1234567800001",
+      "validation-rules":"RegEx: 0037[0-9]{8}[0-9A-Z]{0,5}\nCheck Digit: mod11 of 8-digit OrgCode (weights 2, 4, 8, 5, 10, 9, 7 [right to left] or 7, 9, 10, 5, 8, 4, 2, 1 [left to right])",
+      "usage":"OVT identifier conforming to standard ISO6523.   \n- Constant 0037 (Finnish tax administration organisation code)\n- Finnish local tax ID, 8 characters with initial zero and no hyphen\n+K4:K5"
+    },
+    {
+      "schemeid":"DUNS",
+      "iso6523":"0060",
+      "country":"international",
+      "scheme-name":"Data Universal Numbering System (D-U-N-S Number)",
+      "issuing-agency":"Dun and Bradstreet Ltd",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"DUNS",
+      "display":"IIIIIIIIC where all characters are the digits 0, to 9, I = an identification digit and C = the check digit. When the prefix (P) is added the display requirement will be eleven digits, PPIIIIIIIIC.",
+      "examples":"812810734",
+      "validation-rules":"RegEx: [0-9]{9}",
+      "usage":"Check digits were removed to get a bigger number area\nUPIK search to validate DUNS numbers\n\"D&B Direct 2.0\" API available"
+    },
+    {
+      "schemeid":"GLN",
+      "iso6523":"0088",
+      "country":"international",
+      "scheme-name":"Global Location Number",
+      "issuing-agency":"GS1 GLN",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"GLN",
+      "display":"None",
+      "examples":"1548079098355",
+      "validation-rules":"RegEx: [0-9]{13}\nCheck Digit: mod10 (weights 1, 3)",
+      "usage":"GLN-13 are the only supports supported atm"
+    },
+    {
+      "schemeid":"DK:P",
+      "iso6523":"0096",
+      "country":"DK",
+      "scheme-name":"DANISH CHAMBER OF COMMERCE Scheme",
+      "issuing-agency":"Danish Chamber of Commerce",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"DK:P",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9]{17}\nCheck Digits: mod97"
+    },
+    {
+      "schemeid":"IT:FTI",
+      "iso6523":"0097",
+      "country":"IT",
+      "scheme-name":"FTI - Ediforum Italia",
+      "issuing-agency":"FTI - Ediforum Italia",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"IT:FTI",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9]{11,16}\nThe check digit algorithm is the one published in the Gazzetta Ufficiale no 345 of December 29 1976.",
+      "usage":"We couldn't find the checksum algorithm in the scanned PDF of 1976\nProposed to deprecate"
+    },
+    {
+      "schemeid":"NL:KVK",
+      "iso6523":"0106",
+      "country":"NL",
+      "scheme-name":"Vereniging van Kamers van Koophandel en Fabrieken in Nederland (Association of\nChambers of Commerce and Industry in the Netherlands), Scheme",
+      "issuing-agency":"Vereniging van Kamers van Koophandel en Fabrieken in Nederland",
+      "initial-release":"1.1.2",
+      "state":"active",
+      "structure":"NL:KVK",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9]{17}\nCheck Digits: mod97",
+      "usage":"Real numbers seem to be 8 characters"
+    },
+    {
+      "schemeid":"EU:NAL",
+      "iso6523":"0130",
+      "country":"international",
+      "scheme-name":"Directorates of the European Commission",
+      "issuing-agency":"European Commission, Information Directorate, Data Transmission Service",
+      "initial-release":"4",
+      "state":"active",
+      "structure":"EU:NAL",
+      "display":"None",
+      "usage":"Requested by TICC-10 and TICC-11;\nin SML since 2019-08-23"
+    },
+    {
+      "schemeid":"IT:SIA",
+      "iso6523":"0135",
+      "country":"IT",
+      "scheme-name":"SIA Object Identifiers",
+      "issuing-agency":"SIA-Società Interbancaria per l'Automazione S.p.A.",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"IT:SIA",
+      "display":"None",
+      "usage":"Propose to deprecate"
+    },
+    {
+      "schemeid":"IT:SECETI",
+      "iso6523":"0142",
+      "country":"IT",
+      "scheme-name":"SECETI Object Identifiers",
+      "issuing-agency":"Servizi Centralizzati SECETI S.p.A.",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"IT:SECETI",
+      "display":"None",
+      "usage":"Propose to deprecate"
+    },
+    {
+      "schemeid":"AU:ABN",
+      "iso6523":"0151",
+      "country":"AU",
+      "scheme-name":"Australian Business Number (ABN) Scheme",
+      "issuing-agency":"Australian Taxation Office",
+      "initial-release":"5",
+      "state":"active",
+      "structure":"AU:ABN",
+      "display":"It is displayed as follows: -, XX XXX XXX XXX",
+      "examples":"51 824 753 556",
+      "validation-rules":"RegEx: [0-9]{11}\nCheck number: mod 89 (weights)\n* Subtract 1 from the first (left-most) digit of the ABN to give a new 11 digit number\n* Multiply each of the digits in this new number by a \"weighting factor\" based on its position as shown in the table below\n*Sum the resulting 11 products\n* Divide the sum total by 89, noting the remainder\n* If the remainder is zero the number is a valid ABN\nWeight: 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19",
+      "usage":"https://abr.business.gov.au/Help/AbnFormat"
+    },
+    {
+      "schemeid":"CH:UIDB",
+      "iso6523":"0183",
+      "country":"CH",
+      "scheme-name":"Swiss Unique Business Identification Number (UIDB)",
+      "issuing-agency":"Swiss Federal Statistical Office (FSO)",
+      "initial-release":"5",
+      "state":"active",
+      "structure":"CH:UIDB",
+      "display":"There is no requirements. As suggested in the standards eCH-0097 (http://www.ech.ch) the transmission of the UID is without any separator.\nFor display reason is suggested to use this format CHE-XXX.XXX.XXP minus-character ('-') after 'CHE' and separator dot-character ('.') after 6th and 9th character",
+      "validation-rules":"RegEx: CHE[0-9]{9}\nCheck number: mod11 (weights: 5, 4, 3, 2, 7, 6, 5, 4)",
+      "usage":"Also called \"Numéro d'identification suisse des enterprises (IDE)\""
+    },
+    {
+      "schemeid":"DK:DIGST",
+      "iso6523":"0184",
+      "country":"DK",
+      "scheme-name":"DIGSTORG",
+      "issuing-agency":"DIGSTORG",
+      "initial-release":"1.2.1",
+      "state":"active",
+      "structure":"DK:DIGST",
+      "display":"Group of 10 digits",
+      "validation-rules":"RegEx: [0-9]{8}([0-9]{2})?"
+    },
+    {
+      "schemeid":"NL:OINO",
+      "iso6523":"0190",
+      "country":"NL",
+      "scheme-name":"Organisatie-identificatienummer (OIN)",
+      "issuing-agency":"Logius",
+      "initial-release":"2",
+      "state":"active",
+      "structure":"NL:OINO",
+      "display":"In one group of 20 digits",
+      "examples":"00000001820029336000",
+      "validation-rules":"RegEx: [0-9]{20}",
+      "usage":"Get all OINs from http://portaal.digikoppeling.nl/registers/"
+    },
+    {
+      "schemeid":"EE:CC",
+      "iso6523":"0191",
+      "country":"EE",
+      "scheme-name":"Company code",
+      "issuing-agency":"Centre of Registers and Information Systems of the Ministry of Justice",
+      "initial-release":"2",
+      "state":"active",
+      "structure":"EE:CC",
+      "display":"None",
+      "examples":"10137025",
+      "validation-rules":"RegEx: [1789][0-9]{7}\nCheckDigit as last char.\nPython code to check:\ndef calc_check_digit(number):\n    \"\"\"Calculate the check digit.\"\"\"\n    check = sum(((i % 9) + 1) * int(n)\n                for i, n in enumerate(number[:-1])) % 11\n    if check == 10:\n        check = sum((((i + 2) % 9) + 1) * int(n)\n                    for i, n in enumerate(number[:-1])) % 11\n    return str(check % 10)",
+      "usage":"See https://ariregister.rik.ee/index?lang=eng"
+    },
+    {
+      "schemeid":"NO:ORG",
+      "iso6523":"0192",
+      "country":"NO",
+      "scheme-name":"Organisasjonsnummer",
+      "issuing-agency":"The Brønnøysund Register Centre",
+      "initial-release":"2",
+      "state":"active",
+      "structure":"NO:ORG",
+      "display":"None",
+      "examples":"745707327",
+      "validation-rules":"RegEx: [0-9]{9}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3)"
+    },
+    {
+      "schemeid":"UBLBE",
+      "iso6523":"0193",
+      "country":"BE",
+      "scheme-name":"UBL.BE Party Identifier",
+      "issuing-agency":"UBL.BE",
+      "initial-release":"3",
+      "state":"active",
+      "structure":"UBLBE",
+      "display":"None",
+      "validation-rules":"RegEx: .{4,50}"
+    },
+    {
+      "schemeid":"SG:UEN",
+      "iso6523":"0195",
+      "country":"SG",
+      "scheme-name":"Singapore Nationwide E-Invoice Framework",
+      "issuing-agency":"lnfocomm Media Development Authority",
+      "initial-release":"4",
+      "state":"active",
+      "structure":"SG:UEN",
+      "display":"None, except all fields are left justified",
+      "validation-rules":"RegEx: [a-z]{2}[a-z]{3}([0-9]{8}|[0-9]{9}|[RST][0-9]{2}[a-z]{2}[0-9]{4})[0-9a-z]",
+      "usage":"https://www.uen.gov.sg/ueninternet/faces/pages/admin/aboutUEN.jspx?_afrLoop=1018044967911865&_afrWindowMode=0&_adf.ctrl-state=fdr4mq9l0_26"
+    },
+    {
+      "schemeid":"IS:KTNR",
+      "iso6523":"0196",
+      "country":"IS",
+      "scheme-name":"Icelandic identifier",
+      "issuing-agency":"Icelandic National Registry",
+      "initial-release":"4",
+      "state":"active",
+      "structure":"IS:KTNR",
+      "display":"Whole string: nnnnnnnnnn\nCommonly displayed with hyphen between Y2 and R1, e.g. nnnnnn-nnnn",
+      "validation-rules":"RegEx: [0-9]{10}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3, 2)"
+    },
+    {
+      "schemeid":"DK:ERST",
+      "iso6523":"0198",
+      "country":"DK",
+      "scheme-name":"ERSTORG",
+      "issuing-agency":"The Danish Business Authority",
+      "initial-release":"5",
+      "state":"active",
+      "structure":"DK:ERST",
+      "display":"10 characters, no space or other separator",
+      "validation-rules":"RegEx: DK[0-9]{8}\nCheck digit: mod11 (weights 2, 7, 6, 5, 4, 3, 2, 1)"
+    },
+    {
+      "schemeid":"LEI",
+      "iso6523":"0199",
+      "country":"international",
+      "scheme-name":"Legal Entity Identifier (LEI)",
+      "issuing-agency":"As of December 2018, there are 33 LEI issuing organizations in the world.",
+      "initial-release":"5",
+      "state":"active",
+      "structure":"LEI",
+      "display":"The entire 20 character code (including the check digits)",
+      "validation-rules":"RegEx: [A-Z0-9]{18}[0-9]{2}\nCheck digit: mod97-10"
+    },
+    {
+      "schemeid":"LT:LEC",
+      "iso6523":"0200",
+      "country":"LT",
+      "scheme-name":"Legal entity code",
+      "issuing-agency":"State Enterprise Centre of Registers",
+      "initial-release":"5",
+      "state":"active",
+      "structure":"LT:LEC",
+      "display":"None",
+      "examples":"111963319",
+      "validation-rules":"RegEx: [0-9]{9}\nCheck number: see text"
+    },
+    {
+      "schemeid":"IT:CUUO",
+      "iso6523":"0201",
+      "country":"IT",
+      "scheme-name":"Codice Univoco Unità Organizzativa iPA",
+      "issuing-agency":"Agenzia per l’Italia digitale",
+      "initial-release":"6",
+      "state":"active",
+      "structure":"IT:CUUO",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9a-zA-Z]{6}\nNo checkdigit",
+      "usage":"\"Alphanumeric characters\""
+    },
+    {
+      "schemeid":"DE:LWID",
+      "iso6523":"0204",
+      "country":"DE",
+      "scheme-name":"Leitweg-ID",
+      "issuing-agency":"Koordinierungsstelle für IT-Standards (KoSIT)",
+      "initial-release":"6",
+      "state":"active",
+      "structure":"DE:LWID",
+      "display":"Whole string",
+      "validation-rules":"RegEx: [0-9]{2,12}(\\-[0-9A-Z]{0,30})?\\-[0-9]{2}",
+      "usage":"The fine grained part is optional"
+    },
+    {
+      "schemeid":"BE:EN",
+      "iso6523":"0208",
+      "country":"BE",
+      "scheme-name":"Numero d'entreprise / ondernemingsnummer / Unternehmensnummer",
+      "issuing-agency":"Banque-Carrefour des Entreprises (BCE) / Kruispuntbank van Ondernemingen (KBO) / Zentrale Datenbank der Unternehmen (ZOU)\nService public fédéral Economie, P.M.E. Classes moyennes et Energie",
+      "initial-release":"7",
+      "state":"active",
+      "structure":"BE:EN",
+      "display":"The identification number can be displayed in the following ways:\nFor enterprise numbers:\n- a group of four digits, then two groups of three digits, each group separated by a dot. Example: 1234.456.789\n- one digit, then three groups of three digits, each separated by a dot. Example: 1.234.456.789\nFor establishment unit numbers:\n- one digit, then three groups of three digits, each separated by a dot. Example: 2.123.456.789",
+      "validation-rules":"RegEx: 0[0-9]{9}\nCheck digit: mod97\nSee https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/be/vat.py"
+    },
+    {
+      "schemeid":"GS1",
+      "iso6523":"0209",
+      "country":"international",
+      "scheme-name":"GS1 identification keys",
+      "issuing-agency":"GS1",
+      "initial-release":"7.5",
+      "state":"active",
+      "structure":"GS1",
+      "display":"None",
+      "examples":"414541000099999325412345678901234567890",
+      "validation-rules":"See document \"GS1 Application Standard for usage of ISO/IEC 6523 International Code Designator (ICD) 0209\""
+    },
+    {
+      "schemeid":"IT:CFI",
+      "iso6523":"0210",
+      "country":"IT",
+      "scheme-name":"CODICE FISCALE",
+      "issuing-agency":"Agenzia delle Entrate",
+      "initial-release":"7.5",
+      "state":"active",
+      "structure":"IT:CFI",
+      "validation-rules":"Character Repertoire : A to Z (upper case) and 0 to 9"
+    },
+    {
+      "schemeid":"IT:IVA",
+      "iso6523":"0211",
+      "country":"IT",
+      "scheme-name":"PARTITA IVA",
+      "issuing-agency":"Agenzia delle Entrate",
+      "initial-release":"7.5",
+      "state":"active",
+      "structure":"IT:IVA",
+      "validation-rules":"RegEx: IT[0-9]{11}\nfirst 7: company identifiers\nnext 3: province of residence (between \"001\" and \"100\"; or \"120\", \"121\", \"888\" \"999\")\nLast: check digit\nCheck digit: Luhn"
+    },
+    {
+      "schemeid":"FI:ORG",
+      "iso6523":"0212",
+      "country":"FI",
+      "scheme-name":"Finnish Organization Identifier",
+      "issuing-agency":"State Treasury of Finland / Valtiokonttori",
+      "initial-release":"7.5",
+      "state":"active",
+      "structure":"FI:ORG",
+      "display":"Shall be presented as string so that leading zeros have to be present.\nHyphen shall be present between last two digits.",
+      "validation-rules":"Character Repertoire: digits 0-9 and hyphen \"-\""
+    },
+    {
+      "schemeid":"FI:VAT",
+      "iso6523":"0213",
+      "country":"FI",
+      "scheme-name":"Finnish Organization Value Add Tax Identifier",
+      "issuing-agency":"State Treasury of Finland / Valtiokonttori",
+      "initial-release":"7.5",
+      "state":"active",
+      "structure":"FI:VAT",
+      "display":"Shall be presented as string so that leading zeros have to be present. Two first characters have always fixed value FI.",
+      "validation-rules":"Character Repertoire: digits 0-9 and FI"
+    },
+    {
+      "schemeid":"DK:CPR",
+      "iso6523":"9901",
+      "country":"DK",
+      "scheme-name":"Danish Ministry of the Interior and Health",
+      "issuing-agency":"Danish Ministry of the Interior and Health",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"DK:CPR",
+      "display":"None",
+      "usage":"Personal identifier"
+    },
+    {
+      "schemeid":"DK:CVR",
+      "iso6523":"9902",
+      "country":"DK",
+      "scheme-name":"The Danish Commerce and Companies Agency",
+      "issuing-agency":"The Danish Commerce and Companies Agency",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"DK:CVR",
+      "examples":"13585628",
+      "validation-rules":"RegEx: [1-9][0-9]{7}\nCheck digit: mod11 (weights, 2, 7, 6, 5, 4, 3, 2, 1)"
+    },
+    {
+      "schemeid":"DK:SE",
+      "iso6523":"9904",
+      "country":"DK",
+      "scheme-name":"Danish Ministry of Taxation, Central Customs and Tax Administration",
+      "issuing-agency":"Danish Ministry of Taxation, Central Customs and Tax Administration",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"DK:SE",
+      "examples":"DK26769388",
+      "validation-rules":"RegEx: DK[0-9]{8}\nTaks: validate Check digit: mod11 (weights 2, 7, 6, 5, 4, 3, 2, 1)"
+    },
+    {
+      "schemeid":"DK:VANS",
+      "iso6523":"9905",
+      "country":"DK",
+      "scheme-name":"Danish VANS providers",
+      "issuing-agency":"Danish VANS providers",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"DK:VANS",
+      "examples":"DK26769388",
+      "usage":"Propose to deprecate (only 7 identifiers, only IBM - all look like test)"
+    },
+    {
+      "schemeid":"IT:VAT",
+      "iso6523":"9906",
+      "country":"IT",
+      "scheme-name":"Ufficio responsabile gestione partite IVA",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"IT:VAT",
+      "examples":"IT06363391001",
+      "validation-rules":"RegEx: IT[0-9]{11}\nfirst 7: company identifiers\nnext 3: province of residence (between \"001\" and \"100\"; or \"120\", \"121\", \"888\" \"999\")\nLast: check digit\nCheck digit: Luhn"
+    },
+    {
+      "schemeid":"IT:CF",
+      "iso6523":"9907",
+      "country":"IT",
+      "scheme-name":"TAX Authority",
+      "issuing-agency":"TAX Authority",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"IT:CF",
+      "examples":"RSSBBR69C48F839A",
+      "validation-rules":"RegEx: [0-9]{11} (company identification)\nfirst 7: company identifiers\nnext 3: province of residence (between \"001\" and \"100\"; or \"120\", \"121\", \"888\" \"999\")\nLast: check digit\nCheck digit: Luhn\n\nRegEx: [A-Z]{6}[0-9LMNPQRSTUV]{2}[ABCDEHLMPRST][0-9LMNPQRSTUV]{2}[A-Z][0-9LMNPQRSTUV]{3}[A-Z] (personal identification)\nCheck digit: https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/it/codicefiscale.py",
+      "usage":"NOTE: The \"CF\" is a Fiscal Code that can be \"personal\" or for a \"legal entity\".\nThe CF for legal entities is like the Italian VAT code (IT:VAT)"
+    },
+    {
+      "schemeid":"NO:ORGNR",
+      "iso6523":"9908",
+      "country":"NO",
+      "scheme-name":"Enhetsregisteret ved Bronnoysundregisterne",
+      "issuing-agency":"The Brønnøysund Register Centre",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"NO:ORGNR",
+      "validation-rules":"RegEx: [0-9]{9}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3)",
+      "usage":"Same as 0192"
+    },
+    {
+      "schemeid":"NO:VAT",
+      "iso6523":"9909",
+      "country":"NO",
+      "scheme-name":"Norwegian VAT number",
+      "issuing-agency":"Enhetsregisteret ved Bronnoysundregisterne",
+      "initial-release":"1.0.0",
+      "state":"deprecated",
+      "deprecation-release":"1.1.0",
+      "structure":"NO:VAT",
+      "examples":"990399123MVA",
+      "validation-rules":"RegEx: NO[0-9]{9}MVA\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3)",
+      "usage":"Numerical part is the OrgNumber"
+    },
+    {
+      "schemeid":"HU:VAT",
+      "iso6523":"9910",
+      "country":"HU",
+      "scheme-name":"Hungary VAT number",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"HU:VAT",
+      "validation-rules":"RegEx: HU[0-9]{8}\nCheck digit: https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/hu/anum.py"
+    },
+    {
+      "schemeid":"EU:VAT",
+      "iso6523":"9912",
+      "country":"international",
+      "scheme-name":"National ministries of Economy",
+      "initial-release":"1.0.0",
+      "state":"deprecated",
+      "deprecation-release":"1.1.0",
+      "structure":"EU:VAT",
+      "validation-rules":"RegEx: [A-Z]{2}[A-Z0-9]{,20}",
+      "usage":"Proposed to undeprecate; longest known is 18 chars (incl. country code)\nDeprecated in 1.1.0"
+    },
+    {
+      "schemeid":"EU:REID",
+      "iso6523":"9913",
+      "country":"international",
+      "scheme-name":"Business Registers Network",
+      "issuing-agency":"Business Registers Network",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"EU:REID",
+      "usage":"Proposed to deprecate"
+    },
+    {
+      "schemeid":"AT:VAT",
+      "iso6523":"9914",
+      "country":"AT",
+      "scheme-name":"Österreichische Umsatzsteuer-Identifikationsnummer",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"AT:VAT",
+      "examples":"ATU12345678"
+    },
+    {
+      "schemeid":"AT:GOV",
+      "iso6523":"9915",
+      "country":"AT",
+      "scheme-name":"Österreichisches Verwaltungs bzw. Organisationskennzeichen",
+      "initial-release":"1.0.0",
+      "state":"active",
+      "structure":"AT:GOV",
+      "examples":"b",
+      "validation-rules":"RegEx: [A-Z][A-Z0-9]*",
+      "usage":"No entity behind id"
+    },
+    {
+      "schemeid":"AT:CID",
+      "iso6523":"9916",
+      "country":"AT",
+      "scheme-name":"Firmenidentifikationsnummer der Statistik Austria",
+      "initial-release":"1.0.0",
+      "state":"deprecated",
+      "deprecation-release":"1.0.2",
+      "structure":"AT:CID"
+    },
+    {
+      "schemeid":"IS:KT",
+      "iso6523":"9917",
+      "country":"IS",
+      "scheme-name":"Icelandic National Registry",
+      "initial-release":"1.0.0",
+      "state":"deprecated",
+      "deprecation-release":"4",
+      "structure":"IS:KT",
+      "display":"Whole string: nnnnnnnnnn\nCommonly displayed with hyphen between Y2 and R1, e.g. nnnnnn-nnnn",
+      "validation-rules":"RegEx: [0-9]{10}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3, 2)",
+      "usage":"In favour of 0196"
+    },
+    {
+      "schemeid":"IBAN",
+      "iso6523":"9918",
+      "country":"international",
+      "scheme-name":"SOCIETY FOR WORLDWIDE INTERBANK FINANCIAL, TELECOMMUNICATION S.W.I.F.T",
+      "issuing-agency":"SOCIETY FOR WORLDWIDE INTERBANK FINANCIAL, TELECOMMUNICATION S.W.I.F.T",
+      "initial-release":"1.0.1",
+      "state":"active",
+      "structure":"IBAN"
+    },
+    {
+      "schemeid":"AT:KUR",
+      "iso6523":"9919",
+      "country":"AT",
+      "scheme-name":"Kennziffer des Unternehmensregisters",
+      "initial-release":"1.0.2",
+      "state":"active",
+      "structure":"AT:KUR",
+      "usage":"Propose to deprecated"
+    },
+    {
+      "schemeid":"ES:VAT",
+      "iso6523":"9920",
+      "country":"ES",
+      "scheme-name":"Agencia Española de Administración Tributaria",
+      "issuing-agency":"Agencia Española de Administración Tributaria",
+      "initial-release":"1.0.2",
+      "state":"active",
+      "structure":"ES:VAT"
+    },
+    {
+      "schemeid":"IT:IPA",
+      "iso6523":"9921",
+      "country":"IT",
+      "scheme-name":"Indice delle Pubbliche Amministrazioni",
+      "issuing-agency":"Indice delle Pubbliche Amministrazioni",
+      "initial-release":"1.1.0",
+      "state":"deprecated",
+      "deprecation-release":"6",
+      "structure":"IT:IPA",
+      "usage":"Propose to deprecate; not used in BIS 3"
+    },
+    {
+      "schemeid":"AD:VAT",
+      "iso6523":"9922",
+      "country":"AD",
+      "scheme-name":"Andorra VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"AD:VAT"
+    },
+    {
+      "schemeid":"AL:VAT",
+      "iso6523":"9923",
+      "country":"AL",
+      "scheme-name":"Albania VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"AL:VAT"
+    },
+    {
+      "schemeid":"BA:VAT",
+      "iso6523":"9924",
+      "country":"BA",
+      "scheme-name":"Bosnia and Herzegovina VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"BA:VAT"
+    },
+    {
+      "schemeid":"BE:VAT",
+      "iso6523":"9925",
+      "country":"BE",
+      "scheme-name":"Belgium VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"BE:VAT"
+    },
+    {
+      "schemeid":"BG:VAT",
+      "iso6523":"9926",
+      "country":"BG",
+      "scheme-name":"Bulgaria VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"BG:VAT"
+    },
+    {
+      "schemeid":"CH:VAT",
+      "iso6523":"9927",
+      "country":"CH",
+      "scheme-name":"Switzerland VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"CH:VAT"
+    },
+    {
+      "schemeid":"CY:VAT",
+      "iso6523":"9928",
+      "country":"CY",
+      "scheme-name":"Cyprus VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"CY:VAT"
+    },
+    {
+      "schemeid":"CZ:VAT",
+      "iso6523":"9929",
+      "country":"CZ",
+      "scheme-name":"Czech Republic VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"CZ:VAT"
+    },
+    {
+      "schemeid":"DE:VAT",
+      "iso6523":"9930",
+      "country":"DE",
+      "scheme-name":"Germany VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"DE:VAT"
+    },
+    {
+      "schemeid":"EE:VAT",
+      "iso6523":"9931",
+      "country":"EE",
+      "scheme-name":"Estonia VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"EE:VAT"
+    },
+    {
+      "schemeid":"GB:VAT",
+      "iso6523":"9932",
+      "country":"GB",
+      "scheme-name":"United Kingdom VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"GB:VAT"
+    },
+    {
+      "schemeid":"GR:VAT",
+      "iso6523":"9933",
+      "country":"GR",
+      "scheme-name":"Greece VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"GR:VAT"
+    },
+    {
+      "schemeid":"HR:VAT",
+      "iso6523":"9934",
+      "country":"HR",
+      "scheme-name":"Croatia VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"HR:VAT"
+    },
+    {
+      "schemeid":"IE:VAT",
+      "iso6523":"9935",
+      "country":"IE",
+      "scheme-name":"Ireland VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"IE:VAT"
+    },
+    {
+      "schemeid":"LI:VAT",
+      "iso6523":"9936",
+      "country":"LI",
+      "scheme-name":"Liechtenstein VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"LI:VAT"
+    },
+    {
+      "schemeid":"LT:VAT",
+      "iso6523":"9937",
+      "country":"LT",
+      "scheme-name":"Lithuania VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"LT:VAT"
+    },
+    {
+      "schemeid":"LU:VAT",
+      "iso6523":"9938",
+      "country":"LU",
+      "scheme-name":"Luxemburg VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"LU:VAT"
+    },
+    {
+      "schemeid":"LV:VAT",
+      "iso6523":"9939",
+      "country":"LV",
+      "scheme-name":"Latvia VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"LV:VAT"
+    },
+    {
+      "schemeid":"MC:VAT",
+      "iso6523":"9940",
+      "country":"MC",
+      "scheme-name":"Monaco VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"MC:VAT"
+    },
+    {
+      "schemeid":"ME:VAT",
+      "iso6523":"9941",
+      "country":"ME",
+      "scheme-name":"Montenegro VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"ME:VAT"
+    },
+    {
+      "schemeid":"MK:VAT",
+      "iso6523":"9942",
+      "country":"MK",
+      "scheme-name":"Macedonia, the former Yugoslav Republic of VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"MK:VAT"
+    },
+    {
+      "schemeid":"MT:VAT",
+      "iso6523":"9943",
+      "country":"MT",
+      "scheme-name":"Malta VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"MT:VAT"
+    },
+    {
+      "schemeid":"NL:VAT",
+      "iso6523":"9944",
+      "country":"NL",
+      "scheme-name":"Netherlands VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"NL:VAT"
+    },
+    {
+      "schemeid":"PL:VAT",
+      "iso6523":"9945",
+      "country":"PL",
+      "scheme-name":"Poland VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"PL:VAT"
+    },
+    {
+      "schemeid":"PT:VAT",
+      "iso6523":"9946",
+      "country":"PT",
+      "scheme-name":"Portugal VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"PT:VAT"
+    },
+    {
+      "schemeid":"RO:VAT",
+      "iso6523":"9947",
+      "country":"RO",
+      "scheme-name":"Romania VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"RO:VAT"
+    },
+    {
+      "schemeid":"RS:VAT",
+      "iso6523":"9948",
+      "country":"RS",
+      "scheme-name":"Serbia VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"RS:VAT"
+    },
+    {
+      "schemeid":"SI:VAT",
+      "iso6523":"9949",
+      "country":"SI",
+      "scheme-name":"Slovenia VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"SI:VAT"
+    },
+    {
+      "schemeid":"SK:VAT",
+      "iso6523":"9950",
+      "country":"SK",
+      "scheme-name":"Slovakia VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"SK:VAT"
+    },
+    {
+      "schemeid":"SM:VAT",
+      "iso6523":"9951",
+      "country":"SM",
+      "scheme-name":"San Marino VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"SM:VAT"
+    },
+    {
+      "schemeid":"TR:VAT",
+      "iso6523":"9952",
+      "country":"TR",
+      "scheme-name":"Turkey VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"TR:VAT"
+    },
+    {
+      "schemeid":"VA:VAT",
+      "iso6523":"9953",
+      "country":"VA",
+      "scheme-name":"Holy See (Vatican City State) VAT number",
+      "initial-release":"1.1.0",
+      "state":"active",
+      "structure":"VA:VAT"
+    },
+    {
+      "schemeid":"NL:OIN",
+      "iso6523":"9954",
+      "country":"NL",
+      "scheme-name":"Dutch Originator's Identification Number",
+      "initial-release":"1.1.3",
+      "state":"deprecated",
+      "deprecation-release":"2",
+      "structure":"NL:OIN",
+      "usage":"Deprecated by 0190"
+    },
+    {
+      "schemeid":"SE:VAT",
+      "iso6523":"9955",
+      "country":"SE",
+      "scheme-name":"Swedish VAT number",
+      "initial-release":"1.2.0",
+      "state":"active",
+      "structure":"SE:VAT"
+    },
+    {
+      "schemeid":"BE:CBE",
+      "iso6523":"9956",
+      "country":"BE",
+      "scheme-name":"Belgian Crossroad Bank of Enterprise number",
+      "issuing-agency":"Belgian Crossroad Bank of Enterprises",
+      "initial-release":"1.2.1",
+      "state":"deprecated",
+      "deprecation-release":"7.4",
+      "structure":"BE:CBE",
+      "examples":"0899965307",
+      "validation-rules":"RegEx: 0[0-9]{9}\nCheck digit: mod97\nSee https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/be/vat.py"
+    },
+    {
+      "schemeid":"FR:VAT",
+      "iso6523":"9957",
+      "country":"FR",
+      "scheme-name":"French VAT number",
+      "initial-release":"1.2.1",
+      "state":"active",
+      "structure":"FR:VAT"
+    },
+    {
+      "schemeid":"DE:LID",
+      "iso6523":"9958",
+      "country":"DE",
+      "scheme-name":"German Leitweg ID",
+      "initial-release":"3",
+      "state":"deprecated",
+      "deprecation-release":"6",
+      "structure":"DE:LID",
+      "usage":"Replaced by 0204"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/htdocs/custom/peppol/lib/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.csv b/htdocs/custom/peppol/lib/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.csv
new file mode 100644 (file)
index 0000000..30043f2
--- /dev/null
@@ -0,0 +1,39 @@
+AD;9922;
+AL;9923;
+AT;9914;
+BA;9924;
+BE;9925;
+BG;9926;
+CH;9927;
+CY;9928;
+CZ;9929;
+DE;9930;
+EE;9931;
+ES;9920;
+FI;0213;
+FR;9957;
+GB;9932;
+GR;9933;
+HR;9934;
+HU;9910;
+IE;9935;
+IT;9906;
+LI;9936;
+LT;9937;
+LU;9938;
+LV;9939;
+MC;9940;
+ME;9941;
+MK;9942;
+MT;9943;
+NL;9944;
+PL;9945;
+PT;9946;
+RO;9947;
+RS;9948;
+SE;9955;
+SI;9949;
+SK;9950;
+SM;9951;
+TR;9952;
+VA;9953;
diff --git a/htdocs/custom/peppol/lib/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.json b/htdocs/custom/peppol/lib/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.json
new file mode 100644 (file)
index 0000000..9f7cb4d
--- /dev/null
@@ -0,0 +1,923 @@
+{
+  "version":"7.5",
+  "entry-count":88,
+  "values":[
+    {
+      "schemeid":"FR:SIRENE",
+      "iso6523":"0002",
+      "country":"FR",
+      "scheme-name":"System Information et Repertoire des Entreprise et des Etablissements: SIRENE",
+      "issuing-agency":"Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.)",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) Number of characters: 9 characters (\"SIREN\") 14 \" 9+5 (\"SIRET\"), The 9 character number designates an organization, The 14 character number designates a specific establishment of the organization designated by the first 9 characters.\n2) Check digits: 9th & 14th character respectively",
+      "display":"The 9 figure code number (SIREN) is written in groups of 3 characters. Example: 784 301 772\nThe 14 figure code number is written in 3 groups of 3 characters and a single group of 5. Example: 784 301 772 00025",
+      "examples":"784301772\n78430177200025",
+      "validation-rules":"RegEx: [0-9]{9}([0-9]{5})?\nCheck digits: Luhn Algorithm",
+      "usage":"1.1.1 - Changed from FR:SIRET to FR:SIRENE (see ISU Jira ISU-231)"
+    },
+    {
+      "schemeid":"SE:ORGNR",
+      "iso6523":"0007",
+      "country":"SE",
+      "scheme-name":"Organisationsnummer",
+      "issuing-agency":"The National Tax Board",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) 10 digits. 1st digit = Group number, 2nd - 9th digit = Ordinalnumber; 1st digit, = Group number, 10th digit = Check digit\n2) Last digit.",
+      "display":"Single group of 10 digits.",
+      "examples":"2120000787",
+      "validation-rules":"RegEx: [0-9]{10}\nCheck digits: Luhn Algorithm"
+    },
+    {
+      "schemeid":"FR:SIRET",
+      "iso6523":"0009",
+      "country":"FR",
+      "scheme-name":"SIRET-CODE",
+      "issuing-agency":"DU PONT DE NEMOURS",
+      "since":"1.1.1",
+      "deprecated":false,
+      "structure":"1) 14 digits\n2) None",
+      "display":"In four groups, Groups 1 - 3 = three digits each, Group 4 = five digits",
+      "examples":"78430177200025",
+      "validation-rules":"RegEx: [0-9]{14}"
+    },
+    {
+      "schemeid":"FI:OVT",
+      "iso6523":"0037",
+      "country":"FI",
+      "scheme-name":"LY-tunnus",
+      "issuing-agency":"National Board of Taxes, (Verohallitus)",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) ICD 4 Digits, Organization code (8 digits, 1st-7th digit = number, 8th digit = check number), optional specifier for organisational unit (5 digits)\n- Example: 00371234567800001\n- 0037 Country code for Finland (ISO 6523  International Code Designator (ICD) value)\n- 12345678 Business ID without hyphen \n- 00001 Optional specifier for organisation unit (assigned by the organisation itself)",
+      "display":"None",
+      "examples":"0037:00371234567800001\n0037:1234567800001",
+      "validation-rules":"RegEx: 0037[0-9]{8}[0-9A-Z]{0,5}\nCheck Digit: mod11 of 8-digit OrgCode (weights 2, 4, 8, 5, 10, 9, 7 [right to left] or 7, 9, 10, 5, 8, 4, 2, 1 [left to right])",
+      "usage":"OVT identifier conforming to standard ISO6523.   \n- Constant 0037 (Finnish tax administration organisation code)\n- Finnish local tax ID, 8 characters with initial zero and no hyphen\n+K4:K5"
+    },
+    {
+      "schemeid":"DUNS",
+      "iso6523":"0060",
+      "country":"international",
+      "scheme-name":"Data Universal Numbering System (D-U-N-S Number)",
+      "issuing-agency":"Dun and Bradstreet Ltd",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) Eight identification digits and a check digit. A two digit prefix will be added in the future but it will not be used to calculate the check digit.\n2) The Organization name is not part of the D-U-N-S number.",
+      "display":"IIIIIIIIC where all characters are the digits 0, to 9, I = an identification digit and C = the check digit. When the prefix (P) is added the display requirement will be eleven digits, PPIIIIIIIIC.",
+      "examples":"812810734",
+      "validation-rules":"RegEx: [0-9]{9}",
+      "usage":"Check digits were removed to get a bigger number area\nUPIK search to validate DUNS numbers\n\"D&B Direct 2.0\" API available"
+    },
+    {
+      "schemeid":"GLN",
+      "iso6523":"0088",
+      "country":"international",
+      "scheme-name":"Global Location Number",
+      "issuing-agency":"GS1 GLN",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) 13 digits including check digits, 2) None",
+      "display":"None",
+      "examples":"1548079098355",
+      "validation-rules":"RegEx: [0-9]{13}\nCheck Digit: mod10 (weights 1, 3)",
+      "usage":"GLN-13 are the only supports supported atm"
+    },
+    {
+      "schemeid":"DK:P",
+      "iso6523":"0096",
+      "country":"DK",
+      "scheme-name":"DANISH CHAMBER OF COMMERCE Scheme",
+      "issuing-agency":"Danish Chamber of Commerce",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"Character repertoire: the EDI identifier consists of digits only.\nThe identifier has a fixed length. No separators are required.\nStructure: [123] [123456] [123456] [12], 17, < >, A B C D\nA: numerical value allocated by the RA to the regional sub-authority, (3 digits)\nB: numerical value allocated by the sub-authority to the registered organization (mandatory part of the identifier; 6 digits)\nC: numerical value used by the registered organization (free part; 6 digits)\nD: numerical check digit calculated by the registered organization; (2 digits)\nCheck digit computation: The check digit is modular 97 computed on ABC as one number.",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9]{17}\nCheck Digits: mod97"
+    },
+    {
+      "schemeid":"IT:FTI",
+      "iso6523":"0097",
+      "country":"IT",
+      "scheme-name":"FTI - Ediforum Italia",
+      "issuing-agency":"FTI - Ediforum Italia",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"Character repertoire: The EDI identifier consists of digits only.\nThe identifier has a fixed length.\nNo separators are required.\nStructure: [1234567] [123] [1] [12345], min 11- max 16, < >, A B C D\nA: numerical value (7 digits) assigned by Uffico Provinciale IVA (local branch of Ministry of Finance)\nB: numerical value a (3 digits) identifying the County\nC: numerical check digit (1 digit);\nD: optional numerical value (up to 5 digits used by the registered organization (free part).\nCheck digit computation: The check digit algorithm is the one published in the Gazzetta Ufficiale no 345 of December 29 1976.",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9]{11,16}\nThe check digit algorithm is the one published in the Gazzetta Ufficiale no 345 of December 29 1976.",
+      "usage":"We couldn't find the checksum algorithm in the scanned PDF of 1976\nProposed to deprecate"
+    },
+    {
+      "schemeid":"NL:KVK",
+      "iso6523":"0106",
+      "country":"NL",
+      "scheme-name":"Vereniging van Kamers van Koophandel en Fabrieken in Nederland (Association of\nChambers of Commerce and Industry in the Netherlands), Scheme",
+      "issuing-agency":"Vereniging van Kamers van Koophandel en Fabrieken in Nederland",
+      "since":"1.1.2",
+      "deprecated":false,
+      "structure":"Character repertoire: The EDI identifier consists of digits only.\nThe identifier has a fixed length.\nNo separators are required.\nStructure: [123] [123456] [123456] [12], 17, < >, A B C D\nA: numerical value allocated by the RA to the regional subauthority, (3 digits)\nB: numerical value allocated by the sub-authority to the registered, organization (mandatory part of the identifier; 6 digits)\nC: numerical value used by the registered organization (free part; 6 digits)\nD: numerical check digit calculated by the registered organization; (2 digits)\nCheck digit computation, The check digit is modular 97 computed on ABC as one number.",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9]{17}\nCheck Digits: mod97",
+      "usage":"Real numbers seem to be 8 characters"
+    },
+    {
+      "schemeid":"EU:NAL",
+      "iso6523":"0130",
+      "country":"international",
+      "scheme-name":"Directorates of the European Commission",
+      "issuing-agency":"European Commission, Information Directorate, Data Transmission Service",
+      "since":"4",
+      "deprecated":false,
+      "structure":"1) ICD 4 digits, 2) None",
+      "display":"None",
+      "usage":"Requested by TICC-10 and TICC-11;\nin SML since 2019-08-23"
+    },
+    {
+      "schemeid":"IT:SIA",
+      "iso6523":"0135",
+      "country":"IT",
+      "scheme-name":"SIA Object Identifiers",
+      "issuing-agency":"SIA-Società Interbancaria per l'Automazione S.p.A.",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"First field: ICD: 4 digits, Second field: sequence of digits",
+      "display":"None",
+      "usage":"Propose to deprecate"
+    },
+    {
+      "schemeid":"IT:SECETI",
+      "iso6523":"0142",
+      "country":"IT",
+      "scheme-name":"SECETI Object Identifiers",
+      "issuing-agency":"Servizi Centralizzati SECETI S.p.A.",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) First field: ICD: 4 digits, Second field: sequence of digits",
+      "display":"None",
+      "usage":"Propose to deprecate"
+    },
+    {
+      "schemeid":"AU:ABN",
+      "iso6523":"0151",
+      "country":"AU",
+      "scheme-name":"Australian Business Number (ABN) Scheme",
+      "issuing-agency":"Australian Taxation Office",
+      "since":"5",
+      "deprecated":false,
+      "structure":"The ABN is an 11 digit numeric identifier.\nThe first two digits are check digits calculated using a modulus 89 of the weighted digits.\nThe first digit of the number is guaranteed to be non-zero by adding 10 to the modulus (so the first two digits range from 10 through to 99).\nFor companies the last 9 digits are identical to their existing Australian Company Number (CAN) which includes a single trailing check digit.\nFor other entities the digits are randomly allocated but are guaranteed to fail the CAN check. This allows the Australian Securities and Investment Commission (ASIC) to continue allocating CAN during a transition period. The valid characters are numeric digits 0-9.",
+      "display":"It is displayed as follows: -, XX XXX XXX XXX",
+      "examples":"51 824 753 556",
+      "validation-rules":"RegEx: [0-9]{11}\nCheck number: mod 89 (weights)\n* Subtract 1 from the first (left-most) digit of the ABN to give a new 11 digit number\n* Multiply each of the digits in this new number by a \"weighting factor\" based on its position as shown in the table below\n*Sum the resulting 11 products\n* Divide the sum total by 89, noting the remainder\n* If the remainder is zero the number is a valid ABN\nWeight: 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19",
+      "usage":"https://abr.business.gov.au/Help/AbnFormat"
+    },
+    {
+      "schemeid":"CH:UIDB",
+      "iso6523":"0183",
+      "country":"CH",
+      "scheme-name":"Swiss Unique Business Identification Number (UIDB)",
+      "issuing-agency":"Swiss Federal Statistical Office (FSO)",
+      "since":"5",
+      "deprecated":false,
+      "structure":"CHEXXXXXXXXP\nUID number, is composed by 9 digits and is random generated and has no internal means.\n1)\n12 characters\nCHE: Swiss Country Code following ISO 3166-1.\nXXXXXXXX: 8 digits for the number itself\nP: check digit\n2)\nCHEXXXXXXXXP, the last digit",
+      "display":"There is no requirements. As suggested in the standards eCH-0097 (http://www.ech.ch) the transmission of the UID is without any separator.\nFor display reason is suggested to use this format CHE-XXX.XXX.XXP minus-character ('-') after 'CHE' and separator dot-character ('.') after 6th and 9th character",
+      "validation-rules":"RegEx: CHE[0-9]{9}\nCheck number: mod11 (weights: 5, 4, 3, 2, 7, 6, 5, 4)",
+      "usage":"Also called \"Numéro d'identification suisse des enterprises (IDE)\""
+    },
+    {
+      "schemeid":"DK:DIGST",
+      "iso6523":"0184",
+      "country":"DK",
+      "scheme-name":"DIGSTORG",
+      "issuing-agency":"DIGSTORG",
+      "since":"1.2.1",
+      "deprecated":false,
+      "structure":"8 or 10 digits",
+      "display":"Group of 10 digits",
+      "validation-rules":"RegEx: [0-9]{8}([0-9]{2})?"
+    },
+    {
+      "schemeid":"NL:OINO",
+      "iso6523":"0190",
+      "country":"NL",
+      "scheme-name":"Organisatie-identificatienummer (OIN)",
+      "issuing-agency":"Logius",
+      "since":"2",
+      "deprecated":false,
+      "structure":"20 digits\n1) Structure: prefix(8)- identification number(8 or 9)- suffix(3 or 4)\n- The first 8 digits prefix designates the origin of the identification number\n- The following 8 or 9 digits designates a unique identification number\n- The last 3 or 4 (depending on the length of the identification number are filled with “0” digit [note: Up until 2017 numbers are issued where this position contains a serial number.]\n2) No check digit",
+      "display":"In one group of 20 digits",
+      "examples":"00000001820029336000",
+      "validation-rules":"RegEx: [0-9]{20}",
+      "usage":"Get all OINs from http://portaal.digikoppeling.nl/registers/"
+    },
+    {
+      "schemeid":"EE:CC",
+      "iso6523":"0191",
+      "country":"EE",
+      "scheme-name":"Company code",
+      "issuing-agency":"Centre of Registers and Information Systems of the Ministry of Justice",
+      "since":"2",
+      "deprecated":false,
+      "structure":"Always 8-digit number\n1) First number in code:\n1 – Commercial organisations\n7 -- State agencies and local government institutions\n8 -- Non-profit associations\n9 -- Foundations\n2)",
+      "display":"None",
+      "examples":"10137025",
+      "validation-rules":"RegEx: [1789][0-9]{7}\nCheckDigit as last char.\nPython code to check:\ndef calc_check_digit(number):\n    \"\"\"Calculate the check digit.\"\"\"\n    check = sum(((i % 9) + 1) * int(n)\n                for i, n in enumerate(number[:-1])) % 11\n    if check == 10:\n        check = sum((((i + 2) % 9) + 1) * int(n)\n                    for i, n in enumerate(number[:-1])) % 11\n    return str(check % 10)",
+      "usage":"See https://ariregister.rik.ee/index?lang=eng"
+    },
+    {
+      "schemeid":"NO:ORG",
+      "iso6523":"0192",
+      "country":"NO",
+      "scheme-name":"Organisasjonsnummer",
+      "issuing-agency":"The Brønnøysund Register Centre",
+      "since":"2",
+      "deprecated":false,
+      "structure":"9 digits\nThe organization number consists of 9 digits where the last digit is a control digit calculated with standard weights, modulus 11. After this, weights 3, 2, 7, 6, 5, 4, 3 and 2 are calculated from the first digit.",
+      "display":"None",
+      "examples":"745707327",
+      "validation-rules":"RegEx: [0-9]{9}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3)"
+    },
+    {
+      "schemeid":"UBLBE",
+      "iso6523":"0193",
+      "country":"BE",
+      "scheme-name":"UBL.BE Party Identifier",
+      "issuing-agency":"UBL.BE",
+      "since":"3",
+      "deprecated":false,
+      "structure":"Maximum 50 characters\n4 Characters fixed length identifying the type \nMaximum 46 characters for the identifier itself",
+      "display":"None",
+      "validation-rules":"RegEx: .{4,50}"
+    },
+    {
+      "schemeid":"SG:UEN",
+      "iso6523":"0195",
+      "country":"SG",
+      "scheme-name":"Singapore Nationwide E-Invoice Framework",
+      "issuing-agency":"lnfocomm Media Development Authority",
+      "since":"4",
+      "deprecated":false,
+      "structure":"The code comprises of 3 fields\n1st field = ICD\n2nd field = Special identifier (e.g. country identifier, test identifier, etc)\n3rd field = Organisation identifrer No check value",
+      "display":"None, except all fields are left justified",
+      "validation-rules":"RegEx: [a-z]{2}[a-z]{3}([0-9]{8}|[0-9]{9}|[RST][0-9]{2}[a-z]{2}[0-9]{4})[0-9a-z]",
+      "usage":"https://www.uen.gov.sg/ueninternet/faces/pages/admin/aboutUEN.jspx?_afrLoop=1018044967911865&_afrWindowMode=0&_adf.ctrl-state=fdr4mq9l0_26"
+    },
+    {
+      "schemeid":"IS:KTNR",
+      "iso6523":"0196",
+      "country":"IS",
+      "scheme-name":"Icelandic identifier",
+      "issuing-agency":"Icelandic National Registry",
+      "since":"4",
+      "deprecated":false,
+      "structure":"10 digit string using numerical characters from 0 to 9\nBased on individuals birthdate or legal entities registration date D1D2M1M2Y1Y2R1R2CM D = day, M = month, Y = year, R = random. C = checksum, M = century.\nNinth character \"C\":\nC = 11 - ((3xD1 + 2xD2 + 7xM1 + 6xM2 + 5xY1 + 4xY2 + 3xR1 + 2xR2) mod 11)",
+      "display":"Whole string: nnnnnnnnnn\nCommonly displayed with hyphen between Y2 and R1, e.g. nnnnnn-nnnn",
+      "validation-rules":"RegEx: [0-9]{10}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3, 2)"
+    },
+    {
+      "schemeid":"DK:ERST",
+      "iso6523":"0198",
+      "country":"DK",
+      "scheme-name":"ERSTORG",
+      "issuing-agency":"The Danish Business Authority",
+      "since":"5",
+      "deprecated":false,
+      "structure":"DKXXXXXXXX\nTwo characters (DK) followed by 8 digits eg. DK12345678",
+      "display":"10 characters, no space or other separator",
+      "validation-rules":"RegEx: DK[0-9]{8}\nCheck digit: mod11 (weights 2, 7, 6, 5, 4, 3, 2, 1)"
+    },
+    {
+      "schemeid":"LEI",
+      "iso6523":"0199",
+      "country":"international",
+      "scheme-name":"Legal Entity Identifier (LEI)",
+      "issuing-agency":"As of December 2018, there are 33 LEI issuing organizations in the world.",
+      "since":"5",
+      "deprecated":false,
+      "structure":"The ISO 17442 standard specifies the minimum reference data, which must the format of the organization identifiers, be Supplied for each LEI:\n* The official name of the legal entity as recorded in the official registers.\n* The registered address of that legal entity.\n* The country of formation.\n* The codes for the representation of names of countries and their subdivisions.\n* The date of the first LEI assignment; the date of last update of the\n* LEI information; and the date of expiry, if applicable.\nAdditional information may be registered as agreed between the legal entity and its LEI issuing organization.\nThe number allocation scheme was further specified in Annex 2 of the Financial Stability Board's third progress note on the Global LEI Initiative on 24 October 2012:\n• Characters 1 -4: A four character prefix allocated uniquely to each LEI issuer.\n• Characters 5-6: Two reserved characters set to zero.\n• Characters 7-18: Entity-specific part of the code generated and assigned by LOUs according to transparent, sound and robust allocation policies.\n• Characters 19-20: Two check digits as described in the ISO 17442 standards. The check digit scheme follows ISO/IEC 7064 (MOD 97-10) and contributes to avoiding typing errors.\nSee http://www.fsb.org/wp-contenVuploads/r_121024.pdf?page_moved=1\n1:)\n1. a) Character representations:\n• n: digits (numeric characters 0 to 9 only);\n• a: uppercase letters (alpha character, A-Z only, without \"special\" characters such as blanks, separators or punctuation).\n2. b) Length indications:\n• nn!: fixed length;\n• nn: maximum length.\nThe format of the LEI shall be\n-18!an2!n.\nThe LEI consists of 20 characters decomposed as follows: characters (18!an) without separators or \"special\" characters; the 19th and 20th characters (2!n) shall be the check digit or digits, as calculated from the scheme defined in this International Standard.\n2:)\nThe check digits shall be calculated based on the scheme defined in ISO/IEC 7064 (MOD 97-10). See Annex A. The check digits are used to verify the LEI.\n1. Convert letters to digits in accordance with the following:\nA=10B=11 C=12D=13E=14\nF=15G=16H=17I=18J=19\nK=20 L = 21 M =22 N =23 0 =24\nP =25Q = 26 R = 27 S = 28 T = 29\nU = 30 V = 31 W = 32 X = 33 Y = 34 Z = 35\n2. Apply the check character system, MOD 97-10, in accordance with ISO/IEC 7064.\n3. If the remainder is 1 (one), the number is valid.\n\nGenerating the check digits\n\n4. Add \"00\" to the right-hand end of the LEI.\n5. Convert alpha characters into numeric characters in accordance with letters in #1.\n6. Apply the check character system, MOD 97-10, in accordance with ISO/IEC 7064.",
+      "display":"The entire 20 character code (including the check digits)",
+      "validation-rules":"RegEx: [A-Z0-9]{18}[0-9]{2}\nCheck digit: mod97-10"
+    },
+    {
+      "schemeid":"LT:LEC",
+      "iso6523":"0200",
+      "country":"LT",
+      "scheme-name":"Legal entity code",
+      "issuing-agency":"State Enterprise Centre of Registers",
+      "since":"5",
+      "deprecated":false,
+      "structure":"9 (nine) digits\nEach legal entity's code number is multiplied by 1, 2, 3, 4, 5, 6, 7, 8\n(weighting) starting from the left-hand side of the code. Calculates the sum of the product, divided by 11. The remainder of the division, which must be less than 10, is the 9th, control, number of the legal entity's code.",
+      "display":"None",
+      "examples":"111963319",
+      "validation-rules":"RegEx: [0-9]{9}\nCheck number: see text"
+    },
+    {
+      "schemeid":"IT:CUUO",
+      "iso6523":"0201",
+      "country":"IT",
+      "scheme-name":"Codice Univoco Unità Organizzativa iPA",
+      "issuing-agency":"Agenzia per l’Italia digitale",
+      "since":"6",
+      "deprecated":false,
+      "structure":"String of 6 alphanumeric characters",
+      "display":"None",
+      "validation-rules":"RegEx: [0-9a-zA-Z]{6}\nNo checkdigit",
+      "usage":"\"Alphanumeric characters\""
+    },
+    {
+      "schemeid":"DE:LWID",
+      "iso6523":"0204",
+      "country":"DE",
+      "scheme-name":"Leitweg-ID",
+      "issuing-agency":"Koordinierungsstelle für IT-Standards (KoSIT)",
+      "since":"6",
+      "deprecated":false,
+      "structure":"Up to 44 alphanumeric characters\nFormat: “Up to 12 numeric characters – up to 30 alphanumeric characters – 2 numeric characters”",
+      "display":"Whole string",
+      "validation-rules":"RegEx: [0-9]{0,12}(\\-[0-9a-zA-Z]{0,30}(\\-[0-9]{2}))",
+      "usage":"Each part is somehow optional"
+    },
+    {
+      "schemeid":"BE:EN",
+      "iso6523":"0208",
+      "country":"BE",
+      "scheme-name":"Numero d'entreprise / ondernemingsnummer / Unternehmensnummer",
+      "issuing-agency":"Banque-Carrefour des Entreprises (BCE) / Kruispuntbank van Ondernemingen (KBO) / Zentrale Datenbank der Unternehmen (ZOU)\nService public fédéral Economie, P.M.E. Classes moyennes et Energie",
+      "since":"7",
+      "deprecated":false,
+      "structure":"10 numeric characters.\n1. Enterprise identification number: the first digit has to be \"0\" or \"1\"",
+      "display":"The identification number can be displayed in the following ways:\nFor enterprise numbers:\n- a group of four digits, then two groups of three digits, each group separated by a dot. Example: 1234.456.789\n- one digit, then three groups of three digits, each separated by a dot. Example: 1.234.456.789\nFor establishment unit numbers:\n- one digit, then three groups of three digits, each separated by a dot. Example: 2.123.456.789",
+      "validation-rules":"RegEx: 0[0-9]{9}\nCheck digit: mod97\nSee https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/be/vat.py"
+    },
+    {
+      "schemeid":"GS1",
+      "iso6523":"0209",
+      "country":"international",
+      "scheme-name":"GS1 identification keys",
+      "issuing-agency":"GS1",
+      "since":"7.5",
+      "deprecated":false,
+      "structure":"The code will include an application identifier indicating the type of GS1 identification key used for an object, followed by the value of the key. The string can be completed by other application identifiers indicating attributes related to the GS1 ID key and the value of these attributes related to the identified object.",
+      "display":"None",
+      "examples":"414541000099999325412345678901234567890",
+      "validation-rules":"See document \"GS1 Application Standard for usage of ISO/IEC 6523 International Code Designator (ICD) 0209\""
+    },
+    {
+      "schemeid":"IT:CFI",
+      "iso6523":"0210",
+      "country":"IT",
+      "scheme-name":"CODICE FISCALE",
+      "issuing-agency":"Agenzia delle Entrate",
+      "since":"7.5",
+      "deprecated":false,
+      "structure":"The code is 16 alphanumeric digits for natural persons or 11 numeric digits for legal persons.\nThe code is 16 alphanumeric digits for natural persons, with this structure:\n3 digits - Surname according to specific rules\n3 digits - Name according to specific rules\n2 digits - Last two digits of year of birth\n1 digit - Month of birth according to a specific conversion table\n2 digits - Day of birth and gender\n4 digits - Place of birth in a “Belfiore” code\n1 digit - CIN – Control Internal Number\nThe code is 11 numeric digits for legal persons, with this structure:\n7 digits - Progressive number\n3 digits - Revenue Office ID\n1 digit - check\nLast digit for natural persons - CIN - Control Internal Number\nLast digit for legal persons - Check",
+      "validation-rules":"Character Repertoire : A to Z (upper case) and 0 to 9"
+    },
+    {
+      "schemeid":"IT:IVA",
+      "iso6523":"0211",
+      "country":"IT",
+      "scheme-name":"PARTITA IVA",
+      "issuing-agency":"Agenzia delle Entrate",
+      "since":"7.5",
+      "deprecated":false,
+      "structure":"The code is 11 numeric digits\nFirst 7 digits is a progressive number\nThe following 3 digits means the province of residence\nThe last digit is a check number, calculated using Luhn's Algorithm",
+      "validation-rules":"Character Repertoire: 0 to 9"
+    },
+    {
+      "schemeid":"FI:ORG",
+      "iso6523":"0212",
+      "country":"FI",
+      "scheme-name":"Finnish Organization Identifier",
+      "issuing-agency":"State Treasury of Finland / Valtiokonttori",
+      "since":"7.5",
+      "deprecated":false,
+      "structure":"9999999-9\nnine characters\nlast digit after the hyphen is check character",
+      "display":"Shall be presented as string so that leading zeros have to be present.\nHyphen shall be present between last two digits.",
+      "validation-rules":"Character Repertoire: digits 0-9 and hyphen \"-\""
+    },
+    {
+      "schemeid":"FI:VAT",
+      "iso6523":"0213",
+      "country":"FI",
+      "scheme-name":"Finnish Organization Value Add Tax Identifier",
+      "issuing-agency":"State Treasury of Finland / Valtiokonttori",
+      "since":"7.5",
+      "deprecated":false,
+      "structure":"FI99999999\nten characters",
+      "display":"Shall be presented as string so that leading zeros have to be present. Two first characters have always fixed value FI.",
+      "validation-rules":"Character Repertoire: digits 0-9 and FI"
+    },
+    {
+      "schemeid":"DK:CPR",
+      "iso6523":"9901",
+      "country":"DK",
+      "scheme-name":"Danish Ministry of the Interior and Health",
+      "issuing-agency":"Danish Ministry of the Interior and Health",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"1) First field: ICD: 4 digits, Second field: sequence of digits",
+      "display":"None",
+      "usage":"Personal identifier"
+    },
+    {
+      "schemeid":"DK:CVR",
+      "iso6523":"9902",
+      "country":"DK",
+      "scheme-name":"The Danish Commerce and Companies Agency",
+      "issuing-agency":"The Danish Commerce and Companies Agency",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"13585628",
+      "validation-rules":"RegEx: [1-9][0-9]{7}\nCheck digit: mod11 (weights, 2, 7, 6, 5, 4, 3, 2, 1)"
+    },
+    {
+      "schemeid":"DK:SE",
+      "iso6523":"9904",
+      "country":"DK",
+      "scheme-name":"Danish Ministry of Taxation, Central Customs and Tax Administration",
+      "issuing-agency":"Danish Ministry of Taxation, Central Customs and Tax Administration",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"DK26769388",
+      "validation-rules":"RegEx: DK[0-9]{8}\nTaks: validate Check digit: mod11 (weights 2, 7, 6, 5, 4, 3, 2, 1)"
+    },
+    {
+      "schemeid":"DK:VANS",
+      "iso6523":"9905",
+      "country":"DK",
+      "scheme-name":"Danish VANS providers",
+      "issuing-agency":"Danish VANS providers",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"DK26769388",
+      "usage":"Propose to deprecate (only 7 identifiers, only IBM - all look like test)"
+    },
+    {
+      "schemeid":"IT:VAT",
+      "iso6523":"9906",
+      "country":"IT",
+      "scheme-name":"Ufficio responsabile gestione partite IVA",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"IT06363391001",
+      "validation-rules":"RegEx: IT[0-9]{11}\nfirst 7: company identifiers\nnext 3: province of residence (between \"001\" and \"100\"; or \"120\", \"121\", \"888\" \"999\")\nLast: check digit\nCheck digit: Luhn"
+    },
+    {
+      "schemeid":"IT:CF",
+      "iso6523":"9907",
+      "country":"IT",
+      "scheme-name":"TAX Authority",
+      "issuing-agency":"TAX Authority",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"RSSBBR69C48F839A",
+      "validation-rules":"RegEx: [0-9]{11} (company identification)\nfirst 7: company identifiers\nnext 3: province of residence (between \"001\" and \"100\"; or \"120\", \"121\", \"888\" \"999\")\nLast: check digit\nCheck digit: Luhn\n\nRegEx: [A-Z]{6}[0-9LMNPQRSTUV]{2}[ABCDEHLMPRST][0-9LMNPQRSTUV]{2}[A-Z][0-9LMNPQRSTUV]{3}[A-Z] (personal identification)\nCheck digit: https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/it/codicefiscale.py",
+      "usage":"NOTE: The \"CF\" is a Fiscal Code that can be \"personal\" or for a \"legal entity\".\nThe CF for legal entities is like the Italian VAT code (IT:VAT)"
+    },
+    {
+      "schemeid":"NO:ORGNR",
+      "iso6523":"9908",
+      "country":"NO",
+      "scheme-name":"Enhetsregisteret ved Bronnoysundregisterne",
+      "issuing-agency":"The Brønnøysund Register Centre",
+      "since":"1.0.0",
+      "deprecated":false,
+      "structure":"9 digits\nThe organization number consists of 9 digits where the last digit is a control digit calculated with standard weights, modulus 11. After this, weights 3, 2, 7, 6, 5, 4, 3 and 2 are calculated from the first digit.",
+      "validation-rules":"RegEx: [0-9]{9}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3)",
+      "usage":"Same as 0192"
+    },
+    {
+      "schemeid":"NO:VAT",
+      "iso6523":"9909",
+      "country":"NO",
+      "scheme-name":"Norwegian VAT number",
+      "issuing-agency":"Enhetsregisteret ved Bronnoysundregisterne",
+      "since":"1.0.0",
+      "deprecated":true,
+      "deprecated-since":"1.1.0",
+      "examples":"990399123MVA",
+      "validation-rules":"RegEx: NO[0-9]{9}MVA\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3)",
+      "usage":"Numerical part is the OrgNumber"
+    },
+    {
+      "schemeid":"HU:VAT",
+      "iso6523":"9910",
+      "country":"HU",
+      "scheme-name":"Hungary VAT number",
+      "since":"1.0.0",
+      "deprecated":false,
+      "validation-rules":"RegEx: HU[0-9]{8}\nCheck digit: https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/hu/anum.py"
+    },
+    {
+      "schemeid":"EU:VAT",
+      "iso6523":"9912",
+      "country":"international",
+      "scheme-name":"National ministries of Economy",
+      "since":"1.0.0",
+      "deprecated":true,
+      "deprecated-since":"1.1.0",
+      "structure":"Must start with the country code",
+      "validation-rules":"RegEx: [A-Z]{2}[A-Z0-9]{,20}",
+      "usage":"Proposed to undeprecate; longest known is 18 chars (incl. country code)\nDeprecated in 1.1.0"
+    },
+    {
+      "schemeid":"EU:REID",
+      "iso6523":"9913",
+      "country":"international",
+      "scheme-name":"Business Registers Network",
+      "issuing-agency":"Business Registers Network",
+      "since":"1.0.0",
+      "deprecated":false,
+      "usage":"Proposed to deprecate"
+    },
+    {
+      "schemeid":"AT:VAT",
+      "iso6523":"9914",
+      "country":"AT",
+      "scheme-name":"Österreichische Umsatzsteuer-Identifikationsnummer",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"ATU12345678"
+    },
+    {
+      "schemeid":"AT:GOV",
+      "iso6523":"9915",
+      "country":"AT",
+      "scheme-name":"Österreichisches Verwaltungs bzw. Organisationskennzeichen",
+      "since":"1.0.0",
+      "deprecated":false,
+      "examples":"b",
+      "validation-rules":"RegEx: [A-Z][A-Z0-9]*",
+      "usage":"No entity behind id"
+    },
+    {
+      "schemeid":"AT:CID",
+      "iso6523":"9916",
+      "country":"AT",
+      "scheme-name":"Firmenidentifikationsnummer der Statistik Austria",
+      "since":"1.0.0",
+      "deprecated":true,
+      "deprecated-since":"1.0.2"
+    },
+    {
+      "schemeid":"IS:KT",
+      "iso6523":"9917",
+      "country":"IS",
+      "scheme-name":"Icelandic National Registry",
+      "since":"1.0.0",
+      "deprecated":true,
+      "deprecated-since":"4",
+      "structure":"10 digit string using numerical characters from 0 to 9\nBased on individuals birthdate or legal entities registration date D1D2M1M2Y1Y2R1R2CM D = day, M = month, Y = year, R = random. C = checksum, M = century.\nNinth character \"C\":\nC = 11 - ((3xD1 + 2xD2 + 7xM1 + 6xM2 + 5xY1 + 4xY2 + 3xR1 + 2xR2) mod 11)",
+      "display":"Whole string: nnnnnnnnnn\nCommonly displayed with hyphen between Y2 and R1, e.g. nnnnnn-nnnn",
+      "validation-rules":"RegEx: [0-9]{10}\nCheck digit: mod11 (weights 3, 2, 7, 6, 5, 4, 3, 2)",
+      "usage":"In favour of 0196"
+    },
+    {
+      "schemeid":"IBAN",
+      "iso6523":"9918",
+      "country":"international",
+      "scheme-name":"SOCIETY FOR WORLDWIDE INTERBANK FINANCIAL, TELECOMMUNICATION S.W.I.F.T",
+      "issuing-agency":"SOCIETY FOR WORLDWIDE INTERBANK FINANCIAL, TELECOMMUNICATION S.W.I.F.T",
+      "since":"1.0.1",
+      "deprecated":false,
+      "structure":"RegEx: [A-Z]{2}[0-9]{2}[A-Z-0-9]{11,30}\nChecking: https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/iban.py\nhttps://github.com/arthurdejong/python-stdnum/blob/master/stdnum/iban.dat"
+    },
+    {
+      "schemeid":"AT:KUR",
+      "iso6523":"9919",
+      "country":"AT",
+      "scheme-name":"Kennziffer des Unternehmensregisters",
+      "since":"1.0.2",
+      "deprecated":false,
+      "structure":"9 characters in total; letter, number x3, letter, number x3, letter",
+      "usage":"Propose to deprecated"
+    },
+    {
+      "schemeid":"ES:VAT",
+      "iso6523":"9920",
+      "country":"ES",
+      "scheme-name":"Agencia Española de Administración Tributaria",
+      "issuing-agency":"Agencia Española de Administración Tributaria",
+      "since":"1.0.2",
+      "deprecated":false
+    },
+    {
+      "schemeid":"IT:IPA",
+      "iso6523":"9921",
+      "country":"IT",
+      "scheme-name":"Indice delle Pubbliche Amministrazioni",
+      "issuing-agency":"Indice delle Pubbliche Amministrazioni",
+      "since":"1.1.0",
+      "deprecated":true,
+      "deprecated-since":"6",
+      "usage":"Propose to deprecate; not used in BIS 3"
+    },
+    {
+      "schemeid":"AD:VAT",
+      "iso6523":"9922",
+      "country":"AD",
+      "scheme-name":"Andorra VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"AL:VAT",
+      "iso6523":"9923",
+      "country":"AL",
+      "scheme-name":"Albania VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"BA:VAT",
+      "iso6523":"9924",
+      "country":"BA",
+      "scheme-name":"Bosnia and Herzegovina VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"BE:VAT",
+      "iso6523":"9925",
+      "country":"BE",
+      "scheme-name":"Belgium VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"BG:VAT",
+      "iso6523":"9926",
+      "country":"BG",
+      "scheme-name":"Bulgaria VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"CH:VAT",
+      "iso6523":"9927",
+      "country":"CH",
+      "scheme-name":"Switzerland VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"CY:VAT",
+      "iso6523":"9928",
+      "country":"CY",
+      "scheme-name":"Cyprus VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"CZ:VAT",
+      "iso6523":"9929",
+      "country":"CZ",
+      "scheme-name":"Czech Republic VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"DE:VAT",
+      "iso6523":"9930",
+      "country":"DE",
+      "scheme-name":"Germany VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"EE:VAT",
+      "iso6523":"9931",
+      "country":"EE",
+      "scheme-name":"Estonia VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"GB:VAT",
+      "iso6523":"9932",
+      "country":"GB",
+      "scheme-name":"United Kingdom VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"GR:VAT",
+      "iso6523":"9933",
+      "country":"GR",
+      "scheme-name":"Greece VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"HR:VAT",
+      "iso6523":"9934",
+      "country":"HR",
+      "scheme-name":"Croatia VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"IE:VAT",
+      "iso6523":"9935",
+      "country":"IE",
+      "scheme-name":"Ireland VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"LI:VAT",
+      "iso6523":"9936",
+      "country":"LI",
+      "scheme-name":"Liechtenstein VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"LT:VAT",
+      "iso6523":"9937",
+      "country":"LT",
+      "scheme-name":"Lithuania VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"LU:VAT",
+      "iso6523":"9938",
+      "country":"LU",
+      "scheme-name":"Luxemburg VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"LV:VAT",
+      "iso6523":"9939",
+      "country":"LV",
+      "scheme-name":"Latvia VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"MC:VAT",
+      "iso6523":"9940",
+      "country":"MC",
+      "scheme-name":"Monaco VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"ME:VAT",
+      "iso6523":"9941",
+      "country":"ME",
+      "scheme-name":"Montenegro VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"MK:VAT",
+      "iso6523":"9942",
+      "country":"MK",
+      "scheme-name":"Macedonia, the former Yugoslav Republic of VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"MT:VAT",
+      "iso6523":"9943",
+      "country":"MT",
+      "scheme-name":"Malta VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"NL:VAT",
+      "iso6523":"9944",
+      "country":"NL",
+      "scheme-name":"Netherlands VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"PL:VAT",
+      "iso6523":"9945",
+      "country":"PL",
+      "scheme-name":"Poland VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"PT:VAT",
+      "iso6523":"9946",
+      "country":"PT",
+      "scheme-name":"Portugal VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"RO:VAT",
+      "iso6523":"9947",
+      "country":"RO",
+      "scheme-name":"Romania VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"RS:VAT",
+      "iso6523":"9948",
+      "country":"RS",
+      "scheme-name":"Serbia VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"SI:VAT",
+      "iso6523":"9949",
+      "country":"SI",
+      "scheme-name":"Slovenia VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"SK:VAT",
+      "iso6523":"9950",
+      "country":"SK",
+      "scheme-name":"Slovakia VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"SM:VAT",
+      "iso6523":"9951",
+      "country":"SM",
+      "scheme-name":"San Marino VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"TR:VAT",
+      "iso6523":"9952",
+      "country":"TR",
+      "scheme-name":"Turkey VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"VA:VAT",
+      "iso6523":"9953",
+      "country":"VA",
+      "scheme-name":"Holy See (Vatican City State) VAT number",
+      "since":"1.1.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"NL:OIN",
+      "iso6523":"9954",
+      "country":"NL",
+      "scheme-name":"Dutch Originator's Identification Number",
+      "since":"1.1.3",
+      "deprecated":true,
+      "deprecated-since":"2",
+      "usage":"Deprecated by 0190"
+    },
+    {
+      "schemeid":"SE:VAT",
+      "iso6523":"9955",
+      "country":"SE",
+      "scheme-name":"Swedish VAT number",
+      "since":"1.2.0",
+      "deprecated":false
+    },
+    {
+      "schemeid":"BE:CBE",
+      "iso6523":"9956",
+      "country":"BE",
+      "scheme-name":"Belgian Crossroad Bank of Enterprise number",
+      "issuing-agency":"Belgian Crossroad Bank of Enterprises",
+      "since":"1.2.1",
+      "deprecated":true,
+      "deprecated-since":"7.4",
+      "structure":"Format: 9.999.999.999 - Check: 99 = 97 - (9.999.999.9 modulo 97)",
+      "examples":"0899965307",
+      "validation-rules":"RegEx: 0[0-9]{9}\nCheck digit: mod97\nSee https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/be/vat.py"
+    },
+    {
+      "schemeid":"FR:VAT",
+      "iso6523":"9957",
+      "country":"FR",
+      "scheme-name":"French VAT number",
+      "since":"1.2.1",
+      "deprecated":false
+    },
+    {
+      "schemeid":"DE:LID",
+      "iso6523":"9958",
+      "country":"DE",
+      "scheme-name":"German Leitweg ID",
+      "since":"3",
+      "deprecated":true,
+      "deprecated-since":"6",
+      "usage":"Replaced by 0204"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/htdocs/custom/peppol/lib/PeppolCodeLists.csv b/htdocs/custom/peppol/lib/PeppolCodeLists.csv
new file mode 100644 (file)
index 0000000..e22477f
--- /dev/null
@@ -0,0 +1,88 @@
+FR:SIRENE;0002;FR
+SE:ORGNR;0007;SE
+FR:SIRET;0009;FR
+FI:OVT;0037;FI
+DUNS;0060;international
+GLN;0088;international
+DK:P;0096;DK
+IT:FTI;0097;IT
+NL:KVK;0106;NL
+EU:NAL;0130;international
+IT:SIA;0135;IT
+IT:SECETI;0142;IT
+AU:ABN;0151;AU
+CH:UIDB;0183;CH
+DK:DIGST;0184;DK
+NL:OINO;0190;NL
+EE:CC;0191;EE
+NO:ORG;0192;NO
+UBLBE;0193;BE
+SG:UEN;0195;SG
+IS:KTNR;0196;IS
+DK:ERST;0198;DK
+LEI;0199;international
+LT:LEC;0200;LT
+IT:CUUO;0201;IT
+DE:LWID;0204;DE
+BE:EN;0208;BE
+GS1;0209;international
+IT:CFI;0210;IT
+IT:IVA;0211;IT
+FI:ORG;0212;FI
+FI:VAT;0213;FI
+DK:CPR;9901;DK
+DK:CVR;9902;DK
+DK:SE;9904;DK
+DK:VANS;9905;DK
+IT:VAT;9906;IT
+IT:CF;9907;IT
+NO:ORGNR;9908;NO
+NO:VAT;9909;NO
+HU:VAT;9910;HU
+EU:VAT;9912;international
+EU:REID;9913;international
+AT:VAT;9914;AT
+AT:GOV;9915;AT
+AT:CID;9916;AT
+IS:KT;9917;IS
+IBAN;9918;international
+AT:KUR;9919;AT
+ES:VAT;9920;ES
+IT:IPA;9921;IT
+AD:VAT;9922;AD
+AL:VAT;9923;AL
+BA:VAT;9924;BA
+BE:VAT;9925;BE
+BG:VAT;9926;BG
+CH:VAT;9927;CH
+CY:VAT;9928;CY
+CZ:VAT;9929;CZ
+DE:VAT;9930;DE
+EE:VAT;9931;EE
+GB:VAT;9932;GB
+GR:VAT;9933;GR
+HR:VAT;9934;HR
+IE:VAT;9935;IE
+LI:VAT;9936;LI
+LT:VAT;9937;LT
+LU:VAT;9938;LU
+LV:VAT;9939;LV
+MC:VAT;9940;MC
+ME:VAT;9941;ME
+MK:VAT;9942;MK
+MT:VAT;9943;MT
+NL:VAT;9944;NL
+PL:VAT;9945;PL
+PT:VAT;9946;PT
+RO:VAT;9947;RO
+RS:VAT;9948;RS
+SI:VAT;9949;SI
+SK:VAT;9950;SK
+SM:VAT;9951;SM
+TR:VAT;9952;TR
+VA:VAT;9953;VA
+NL:OIN;9954;NL
+SE:VAT;9955;SE
+BE:CBE;9956;BE
+FR:VAT;9957;FR
+DE:LID;9958;DE
diff --git a/htdocs/custom/peppol/lib/peppol.lib.php b/htdocs/custom/peppol/lib/peppol.lib.php
new file mode 100644 (file)
index 0000000..899ba01
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+/* Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file    peppol/lib/peppol.lib.php
+ * \ingroup peppol
+ * \brief   Library files with common functions for Peppol
+ */
+
+/**
+ * Prepare admin pages header
+ *
+ * @return array
+ */
+function peppolAdminPrepareHead()
+{
+    global $langs, $conf;
+
+    $langs->load("peppol@peppol");
+
+    $h = 0;
+    $head = array();
+
+    $head[$h][0] = dol_buildpath("/peppol/admin/setup.php", 1);
+    $head[$h][1] = $langs->trans("Settings");
+    $head[$h][2] = 'settings';
+    $h++;
+
+    /*
+    $head[$h][0] = dol_buildpath("/peppol/admin/myobject_extrafields.php", 1);
+    $head[$h][1] = $langs->trans("ExtraFields");
+    $head[$h][2] = 'myobject_extrafields';
+    $h++;
+    */
+
+    $head[$h][0] = dol_buildpath("/peppol/admin/about.php", 1);
+    $head[$h][1] = $langs->trans("About");
+    $head[$h][2] = 'about';
+    $h++;
+
+    // Show more tabs from modules
+    // Entries must be declared in modules descriptor with line
+    //$this->tabs = array(
+    // 'entity:+tabname:Title:@peppol:/peppol/mypage.php?id=__ID__'
+    //); // to add new tab
+    //$this->tabs = array(
+    // 'entity:-tabname:Title:@peppol:/peppol/mypage.php?id=__ID__'
+    //); // to remove a tab
+    complete_head_from_modules($conf, $langs, null, $head, $h, 'peppol');
+
+    return $head;
+}
+
+/**
+ * return schema identifyer from vat number
+ *
+ * @param   [type]  $vatNumber  [$vatNumber description]
+ *
+ * @return  [type]              [return description]
+ */
+function peppolGetIdentifierSchemeFromVatNumber($vatNumber)
+{
+       $res = null;
+       $search = substr($vatNumber,0,2);
+       dol_syslog('peppolGetIdentifierSchemeFromVatNumber=' . $vatNumber . ", search=" . $search);
+    $csvFile = __DIR__ . "/PeppolCodeLists-ParticipantIdentifierSchemesv7.5.csv";
+
+    if (($handle = fopen($csvFile, "r")) !== FALSE) {
+        while (($data = fgetcsv($handle, 1024, ";")) !== FALSE) {
+            if($data[0] == $search) {
+                $res = $data[1];
+                break;
+            }
+        }
+        fclose($handle);
+    }
+
+       dol_syslog('peppolGetIdentifierSchemeFromVatNumber=' . $res);
+       return $res;
+}
+
+//Netttoyage d'un nombre éventuellement accompagné d'un signe euro par exemple
+function clean_amount($str)
+{
+    $number = preg_replace('/[^\d.,]+/', '', $str);
+    $ret = number_format($number, 2, ',', '');
+    dol_syslog(" peppol clean amount $str -> $ret");
+    return $ret;
+}
+
+//Netttoyage d'un nombre éventuellement accompagné d'un signe euro par exemple
+function amount_to_float($str)
+{
+    $number = preg_replace('/[^\d.,]+/', '', $str);
+    $ret = number_format($number, 2);
+    dol_syslog(" peppol clean amount as float $str -> $ret");
+    return $ret;
+}
diff --git a/htdocs/custom/peppol/modulebuilder.txt b/htdocs/custom/peppol/modulebuilder.txt
new file mode 100644 (file)
index 0000000..670a177
--- /dev/null
@@ -0,0 +1,3 @@
+# DO NOT DELETE THIS FILE MANUALLY
+# File to flag module built using official module template.
+# When this file is present into a module directory, you can edit it with the module builder tool. 
\ No newline at end of file
diff --git a/htdocs/custom/peppol/myobject_contact.php b/htdocs/custom/peppol/myobject_contact.php
new file mode 100644 (file)
index 0000000..fced3e9
--- /dev/null
@@ -0,0 +1,203 @@
+<?php
+/* Copyright (C) 2007-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2021 Éric Seigne <eric.seigne@cap-rel.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  \file       peppol/myobject_contact.php
+ *  \ingroup    peppol
+ *  \brief      Tab for contacts linked to MyObject
+ */
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+dol_include_once('/peppol/class/myobject.class.php');
+dol_include_once('/peppol/lib/peppol_myobject.lib.php');
+
+// Load translation files required by the page
+$langs->loadLangs(array("peppol@peppol", "companies", "other", "mails"));
+
+$id     = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
+$ref    = GETPOST('ref', 'alpha');
+$lineid = GETPOST('lineid', 'int');
+$socid  = GETPOST('socid', 'int');
+$action = GETPOST('action', 'aZ09');
+
+// Initialize technical objects
+$object = new MyObject($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->peppol->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('myobjectcontact', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+// Security check - Protection if external user
+//if ($user->socid > 0) accessforbidden();
+//if ($user->socid > 0) $socid = $user->socid;
+//$result = restrictedArea($user, 'peppol', $object->id);
+
+$permission = $user->rights->peppol->myobject->write;
+
+/*
+ * Add a new contact
+ */
+
+if ($action == 'addcontact' && $permission)
+{
+       $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
+       $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
+       $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
+
+       if ($result >= 0)
+       {
+               header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+               exit;
+       } else {
+               if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+               {
+                       $langs->load("errors");
+                       setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
+               } else {
+                       setEventMessages($object->error, $object->errors, 'errors');
+               }
+       }
+} // Toggle the status of a contact
+elseif ($action == 'swapstatut' && $permission)
+{
+       $result = $object->swapContactStatus(GETPOST('ligne'));
+} // Deletes a contact
+elseif ($action == 'deletecontact' && $permission)
+{
+       $result = $object->delete_contact($lineid);
+
+       if ($result >= 0)
+       {
+               header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+               exit;
+       } else {
+               dol_print_error($db);
+       }
+}
+
+
+/*
+ * View
+ */
+
+$title = $langs->trans('MyObject')." - ".$langs->trans('ContactsAddresses');
+$help_url = '';
+//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+llxHeader('', $title, $help_url);
+
+$form = new Form($db);
+$formcompany = new FormCompany($db);
+$contactstatic = new Contact($db);
+$userstatic = new User($db);
+
+
+/* *************************************************************************** */
+/*                                                                             */
+/* View and edit mode                                                         */
+/*                                                                             */
+/* *************************************************************************** */
+
+if ($object->id)
+{
+       /*
+        * Show tabs
+        */
+       $head = myobjectPrepareHead($object);
+
+       print dol_get_fiche_head($head, 'contact', $langs->trans("MyObject"), -1, $object->picto);
+
+       $linkback = '<a href="'.dol_buildpath('/peppol/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
+
+       $morehtmlref = '<div class="refidno">';
+       /*
+        // Ref customer
+        $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+        $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+        // Thirdparty
+        $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
+        // Project
+        if (! empty($conf->projet->enabled))
+        {
+        $langs->load("projects");
+        $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+        if ($permissiontoadd)
+        {
+        if ($action != 'classify')
+        //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
+        $morehtmlref.=' : ';
+        if ($action == 'classify') {
+        //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+        $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+        $morehtmlref.='<input type="hidden" name="action" value="classin">';
+        $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
+        $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+        $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+        $morehtmlref.='</form>';
+        } else {
+        $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+        }
+        } else {
+        if (! empty($object->fk_project)) {
+        $proj = new Project($db);
+        $proj->fetch($object->fk_project);
+        $morehtmlref .= ': '.$proj->getNomUrl();
+        } else {
+        $morehtmlref .= '';
+        }
+        }
+        }*/
+       $morehtmlref .= '</div>';
+
+       dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
+
+       print dol_get_fiche_end();
+
+       print '<br>';
+
+       // Contacts lines (modules that overwrite templates must declare this into descriptor)
+       $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
+       foreach ($dirtpls as $reldir)
+       {
+               $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
+               if ($res) break;
+       }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/custom/peppol/peppolindex.php b/htdocs/custom/peppol/peppolindex.php
new file mode 100644 (file)
index 0000000..baec847
--- /dev/null
@@ -0,0 +1,224 @@
+<?php
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@inodbox.com>
+ * Copyright (C) 2015      Jean-François Ferry        <jfefe@aternatik.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ *     \file       peppol/peppolindex.php
+ *     \ingroup    peppol
+ *     \brief      Home page of peppol top menu
+ */
+
+// Load Dolibarr environment
+$res = 0;
+// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
+// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
+// Try main.inc.php using relative path
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("peppol@peppol"));
+
+$action = GETPOST('action', 'aZ09');
+
+
+// Security check
+//if (! $user->rights->peppol->myobject->read) accessforbidden();
+$socid = GETPOST('socid', 'int');
+if (isset($user->socid) && $user->socid > 0)
+{
+       $action = '';
+       $socid = $user->socid;
+}
+
+$max = 5;
+$now = dol_now();
+
+
+/*
+ * Actions
+ */
+
+// None
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formfile = new FormFile($db);
+
+llxHeader("", $langs->trans("PeppolArea"));
+
+print load_fiche_titre($langs->trans("PeppolArea"), '', 'peppol.png@peppol');
+
+print '<div class="fichecenter"><div class="fichethirdleft">';
+
+
+/* BEGIN MODULEBUILDER DRAFT MYOBJECT
+// Draft MyObject
+if (! empty($conf->peppol->enabled) && $user->rights->peppol->read)
+{
+       $langs->load("orders");
+
+       $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
+       $sql.= ", s.code_client";
+       $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
+       $sql.= ", ".MAIN_DB_PREFIX."societe as s";
+       if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+       $sql.= " WHERE c.fk_soc = s.rowid";
+       $sql.= " AND c.fk_statut = 0";
+       $sql.= " AND c.entity IN (".getEntity('commande').")";
+       if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+       if ($socid)     $sql.= " AND c.fk_soc = ".$socid;
+
+       $resql = $db->query($sql);
+       if ($resql)
+       {
+               $total = 0;
+               $num = $db->num_rows($resql);
+
+               print '<table class="noborder centpercent">';
+               print '<tr class="liste_titre">';
+               print '<th colspan="3">'.$langs->trans("DraftMyObjects").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
+
+               $var = true;
+               if ($num > 0)
+               {
+                       $i = 0;
+                       while ($i < $num)
+                       {
+
+                               $obj = $db->fetch_object($resql);
+                               print '<tr class="oddeven"><td class="nowrap">';
+
+                               $myobjectstatic->id=$obj->rowid;
+                               $myobjectstatic->ref=$obj->ref;
+                               $myobjectstatic->ref_client=$obj->ref_client;
+                               $myobjectstatic->total_ht = $obj->total_ht;
+                               $myobjectstatic->total_tva = $obj->total_tva;
+                               $myobjectstatic->total_ttc = $obj->total_ttc;
+
+                               print $myobjectstatic->getNomUrl(1);
+                               print '</td>';
+                               print '<td class="nowrap">';
+                               print '</td>';
+                               print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
+                               $i++;
+                               $total += $obj->total_ttc;
+                       }
+                       if ($total>0)
+                       {
+
+                               print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
+                       }
+               }
+               else
+               {
+
+                       print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
+               }
+               print "</table><br>";
+
+               $db->free($resql);
+       }
+       else
+       {
+               dol_print_error($db);
+       }
+}
+END MODULEBUILDER DRAFT MYOBJECT */
+
+
+print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
+
+
+$NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
+$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
+
+/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
+// Last modified myobject
+if (! empty($conf->peppol->enabled) && $user->rights->peppol->read)
+{
+       $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
+       $sql.= " FROM ".MAIN_DB_PREFIX."peppol_myobject as s";
+       //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+       $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
+       //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+       //if ($socid)   $sql.= " AND s.rowid = $socid";
+       $sql .= " ORDER BY s.tms DESC";
+       $sql .= $db->plimit($max, 0);
+
+       $resql = $db->query($sql);
+       if ($resql)
+       {
+               $num = $db->num_rows($resql);
+               $i = 0;
+
+               print '<table class="noborder centpercent">';
+               print '<tr class="liste_titre">';
+               print '<th colspan="2">';
+               print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
+               print '</th>';
+               print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
+               print '</tr>';
+               if ($num)
+               {
+                       while ($i < $num)
+                       {
+                               $objp = $db->fetch_object($resql);
+
+                               $myobjectstatic->id=$objp->rowid;
+                               $myobjectstatic->ref=$objp->ref;
+                               $myobjectstatic->label=$objp->label;
+                               $myobjectstatic->status = $objp->status;
+
+                               print '<tr class="oddeven">';
+                               print '<td class="nowrap">'.$myobjectstatic->getNomUrl(1).'</td>';
+                               print '<td class="right nowrap">';
+                               print "</td>";
+                               print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
+                               print '</tr>';
+                               $i++;
+                       }
+
+                       $db->free($resql);
+               } else {
+                       print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+               }
+               print "</table><br>";
+       }
+}
+*/
+
+print '</div></div></div>';
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/custom/peppol/vendor/autoload.php b/htdocs/custom/peppol/vendor/autoload.php
new file mode 100644 (file)
index 0000000..921e415
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+// autoload.php @generated by Composer
+
+require_once __DIR__ . '/composer/autoload_real.php';
+
+return ComposerAutoloaderInit7e7c9cec0f2a4994c99e01fba9e484fe::getLoader();
diff --git a/htdocs/custom/peppol/vendor/composer/ClassLoader.php b/htdocs/custom/peppol/vendor/composer/ClassLoader.php
new file mode 100644 (file)
index 0000000..0cd6055
--- /dev/null
@@ -0,0 +1,572 @@
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ *     Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ *     $loader = new \Composer\Autoload\ClassLoader();
+ *
+ *     // register classes with namespaces
+ *     $loader->add('Symfony\Component', __DIR__.'/component');
+ *     $loader->add('Symfony',           __DIR__.'/framework');
+ *
+ *     // activate the autoloader
+ *     $loader->register();
+ *
+ *     // to enable searching the include path (eg. for PEAR packages)
+ *     $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Jordi Boggiano <j.boggiano@seld.be>
+ * @see    https://www.php-fig.org/psr/psr-0/
+ * @see    https://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+    /** @var ?string */
+    private $vendorDir;
+
+    // PSR-4
+    /**
+     * @var array[]
+     * @psalm-var array<string, array<string, int>>
+     */
+    private $prefixLengthsPsr4 = array();
+    /**
+     * @var array[]
+     * @psalm-var array<string, array<int, string>>
+     */
+    private $prefixDirsPsr4 = array();
+    /**
+     * @var array[]
+     * @psalm-var array<string, string>
+     */
+    private $fallbackDirsPsr4 = array();
+
+    // PSR-0
+    /**
+     * @var array[]
+     * @psalm-var array<string, array<string, string[]>>
+     */
+    private $prefixesPsr0 = array();
+    /**
+     * @var array[]
+     * @psalm-var array<string, string>
+     */
+    private $fallbackDirsPsr0 = array();
+
+    /** @var bool */
+    private $useIncludePath = false;
+
+    /**
+     * @var string[]
+     * @psalm-var array<string, string>
+     */
+    private $classMap = array();
+
+    /** @var bool */
+    private $classMapAuthoritative = false;
+
+    /**
+     * @var bool[]
+     * @psalm-var array<string, bool>
+     */
+    private $missingClasses = array();
+
+    /** @var ?string */
+    private $apcuPrefix;
+
+    /**
+     * @var self[]
+     */
+    private static $registeredLoaders = array();
+
+    /**
+     * @param ?string $vendorDir
+     */
+    public function __construct($vendorDir = null)
+    {
+        $this->vendorDir = $vendorDir;
+    }
+
+    /**
+     * @return string[]
+     */
+    public function getPrefixes()
+    {
+        if (!empty($this->prefixesPsr0)) {
+            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
+        }
+
+        return array();
+    }
+
+    /**
+     * @return array[]
+     * @psalm-return array<string, array<int, string>>
+     */
+    public function getPrefixesPsr4()
+    {
+        return $this->prefixDirsPsr4;
+    }
+
+    /**
+     * @return array[]
+     * @psalm-return array<string, string>
+     */
+    public function getFallbackDirs()
+    {
+        return $this->fallbackDirsPsr0;
+    }
+
+    /**
+     * @return array[]
+     * @psalm-return array<string, string>
+     */
+    public function getFallbackDirsPsr4()
+    {
+        return $this->fallbackDirsPsr4;
+    }
+
+    /**
+     * @return string[] Array of classname => path
+     * @psalm-var array<string, string>
+     */
+    public function getClassMap()
+    {
+        return $this->classMap;
+    }
+
+    /**
+     * @param string[] $classMap Class to filename map
+     * @psalm-param array<string, string> $classMap
+     *
+     * @return void
+     */
+    public function addClassMap(array $classMap)
+    {
+        if ($this->classMap) {
+            $this->classMap = array_merge($this->classMap, $classMap);
+        } else {
+            $this->classMap = $classMap;
+        }
+    }
+
+    /**
+     * Registers a set of PSR-0 directories for a given prefix, either
+     * appending or prepending to the ones previously set for this prefix.
+     *
+     * @param string          $prefix  The prefix
+     * @param string[]|string $paths   The PSR-0 root directories
+     * @param bool            $prepend Whether to prepend the directories
+     *
+     * @return void
+     */
+    public function add($prefix, $paths, $prepend = false)
+    {
+        if (!$prefix) {
+            if ($prepend) {
+                $this->fallbackDirsPsr0 = array_merge(
+                    (array) $paths,
+                    $this->fallbackDirsPsr0
+                );
+            } else {
+                $this->fallbackDirsPsr0 = array_merge(
+                    $this->fallbackDirsPsr0,
+                    (array) $paths
+                );
+            }
+
+            return;
+        }
+
+        $first = $prefix[0];
+        if (!isset($this->prefixesPsr0[$first][$prefix])) {
+            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+
+            return;
+        }
+        if ($prepend) {
+            $this->prefixesPsr0[$first][$prefix] = array_merge(
+                (array) $paths,
+                $this->prefixesPsr0[$first][$prefix]
+            );
+        } else {
+            $this->prefixesPsr0[$first][$prefix] = array_merge(
+                $this->prefixesPsr0[$first][$prefix],
+                (array) $paths
+            );
+        }
+    }
+
+    /**
+     * Registers a set of PSR-4 directories for a given namespace, either
+     * appending or prepending to the ones previously set for this namespace.
+     *
+     * @param string          $prefix  The prefix/namespace, with trailing '\\'
+     * @param string[]|string $paths   The PSR-4 base directories
+     * @param bool            $prepend Whether to prepend the directories
+     *
+     * @throws \InvalidArgumentException
+     *
+     * @return void
+     */
+    public function addPsr4($prefix, $paths, $prepend = false)
+    {
+        if (!$prefix) {
+            // Register directories for the root namespace.
+            if ($prepend) {
+                $this->fallbackDirsPsr4 = array_merge(
+                    (array) $paths,
+                    $this->fallbackDirsPsr4
+                );
+            } else {
+                $this->fallbackDirsPsr4 = array_merge(
+                    $this->fallbackDirsPsr4,
+                    (array) $paths
+                );
+            }
+        } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+            // Register directories for a new namespace.
+            $length = strlen($prefix);
+            if ('\\' !== $prefix[$length - 1]) {
+                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+            }
+            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+            $this->prefixDirsPsr4[$prefix] = (array) $paths;
+        } elseif ($prepend) {
+            // Prepend directories for an already registered namespace.
+            $this->prefixDirsPsr4[$prefix] = array_merge(
+                (array) $paths,
+                $this->prefixDirsPsr4[$prefix]
+            );
+        } else {
+            // Append directories for an already registered namespace.
+            $this->prefixDirsPsr4[$prefix] = array_merge(
+                $this->prefixDirsPsr4[$prefix],
+                (array) $paths
+            );
+        }
+    }
+
+    /**
+     * Registers a set of PSR-0 directories for a given prefix,
+     * replacing any others previously set for this prefix.
+     *
+     * @param string          $prefix The prefix
+     * @param string[]|string $paths  The PSR-0 base directories
+     *
+     * @return void
+     */
+    public function set($prefix, $paths)
+    {
+        if (!$prefix) {
+            $this->fallbackDirsPsr0 = (array) $paths;
+        } else {
+            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+        }
+    }
+
+    /**
+     * Registers a set of PSR-4 directories for a given namespace,
+     * replacing any others previously set for this namespace.
+     *
+     * @param string          $prefix The prefix/namespace, with trailing '\\'
+     * @param string[]|string $paths  The PSR-4 base directories
+     *
+     * @throws \InvalidArgumentException
+     *
+     * @return void
+     */
+    public function setPsr4($prefix, $paths)
+    {
+        if (!$prefix) {
+            $this->fallbackDirsPsr4 = (array) $paths;
+        } else {
+            $length = strlen($prefix);
+            if ('\\' !== $prefix[$length - 1]) {
+                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+            }
+            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+            $this->prefixDirsPsr4[$prefix] = (array) $paths;
+        }
+    }
+
+    /**
+     * Turns on searching the include path for class files.
+     *
+     * @param bool $useIncludePath
+     *
+     * @return void
+     */
+    public function setUseIncludePath($useIncludePath)
+    {
+        $this->useIncludePath = $useIncludePath;
+    }
+
+    /**
+     * Can be used to check if the autoloader uses the include path to check
+     * for classes.
+     *
+     * @return bool
+     */
+    public function getUseIncludePath()
+    {
+        return $this->useIncludePath;
+    }
+
+    /**
+     * Turns off searching the prefix and fallback directories for classes
+     * that have not been registered with the class map.
+     *
+     * @param bool $classMapAuthoritative
+     *
+     * @return void
+     */
+    public function setClassMapAuthoritative($classMapAuthoritative)
+    {
+        $this->classMapAuthoritative = $classMapAuthoritative;
+    }
+
+    /**
+     * Should class lookup fail if not found in the current class map?
+     *
+     * @return bool
+     */
+    public function isClassMapAuthoritative()
+    {
+        return $this->classMapAuthoritative;
+    }
+
+    /**
+     * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
+     *
+     * @param string|null $apcuPrefix
+     *
+     * @return void
+     */
+    public function setApcuPrefix($apcuPrefix)
+    {
+        $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
+    }
+
+    /**
+     * The APCu prefix in use, or null if APCu caching is not enabled.
+     *
+     * @return string|null
+     */
+    public function getApcuPrefix()
+    {
+        return $this->apcuPrefix;
+    }
+
+    /**
+     * Registers this instance as an autoloader.
+     *
+     * @param bool $prepend Whether to prepend the autoloader or not
+     *
+     * @return void
+     */
+    public function register($prepend = false)
+    {
+        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+
+        if (null === $this->vendorDir) {
+            return;
+        }
+
+        if ($prepend) {
+            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
+        } else {
+            unset(self::$registeredLoaders[$this->vendorDir]);
+            self::$registeredLoaders[$this->vendorDir] = $this;
+        }
+    }
+
+    /**
+     * Unregisters this instance as an autoloader.
+     *
+     * @return void
+     */
+    public function unregister()
+    {
+        spl_autoload_unregister(array($this, 'loadClass'));
+
+        if (null !== $this->vendorDir) {
+            unset(self::$registeredLoaders[$this->vendorDir]);
+        }
+    }
+
+    /**
+     * Loads the given class or interface.
+     *
+     * @param  string    $class The name of the class
+     * @return true|null True if loaded, null otherwise
+     */
+    public function loadClass($class)
+    {
+        if ($file = $this->findFile($class)) {
+            includeFile($file);
+
+            return true;
+        }
+
+        return null;
+    }
+
+    /**
+     * Finds the path to the file where the class is defined.
+     *
+     * @param string $class The name of the class
+     *
+     * @return string|false The path if found, false otherwise
+     */
+    public function findFile($class)
+    {
+        // class map lookup
+        if (isset($this->classMap[$class])) {
+            return $this->classMap[$class];
+        }
+        if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
+            return false;
+        }
+        if (null !== $this->apcuPrefix) {
+            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
+            if ($hit) {
+                return $file;
+            }
+        }
+
+        $file = $this->findFileWithExtension($class, '.php');
+
+        // Search for Hack files if we are running on HHVM
+        if (false === $file && defined('HHVM_VERSION')) {
+            $file = $this->findFileWithExtension($class, '.hh');
+        }
+
+        if (null !== $this->apcuPrefix) {
+            apcu_add($this->apcuPrefix.$class, $file);
+        }
+
+        if (false === $file) {
+            // Remember that this class does not exist.
+            $this->missingClasses[$class] = true;
+        }
+
+        return $file;
+    }
+
+    /**
+     * Returns the currently registered loaders indexed by their corresponding vendor directories.
+     *
+     * @return self[]
+     */
+    public static function getRegisteredLoaders()
+    {
+        return self::$registeredLoaders;
+    }
+
+    /**
+     * @param  string       $class
+     * @param  string       $ext
+     * @return string|false
+     */
+    private function findFileWithExtension($class, $ext)
+    {
+        // PSR-4 lookup
+        $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+        $first = $class[0];
+        if (isset($this->prefixLengthsPsr4[$first])) {
+            $subPath = $class;
+            while (false !== $lastPos = strrpos($subPath, '\\')) {
+                $subPath = substr($subPath, 0, $lastPos);
+                $search = $subPath . '\\';
+                if (isset($this->prefixDirsPsr4[$search])) {
+                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+                    foreach ($this->prefixDirsPsr4[$search] as $dir) {
+                        if (file_exists($file = $dir . $pathEnd)) {
+                            return $file;
+                        }
+                    }
+                }
+            }
+        }
+
+        // PSR-4 fallback dirs
+        foreach ($this->fallbackDirsPsr4 as $dir) {
+            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+                return $file;
+            }
+        }
+
+        // PSR-0 lookup
+        if (false !== $pos = strrpos($class, '\\')) {
+            // namespaced class name
+            $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+                . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+        } else {
+            // PEAR-like class name
+            $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+        }
+
+        if (isset($this->prefixesPsr0[$first])) {
+            foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+                if (0 === strpos($class, $prefix)) {
+                    foreach ($dirs as $dir) {
+                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+                            return $file;
+                        }
+                    }
+                }
+            }
+        }
+
+        // PSR-0 fallback dirs
+        foreach ($this->fallbackDirsPsr0 as $dir) {
+            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+                return $file;
+            }
+        }
+
+        // PSR-0 include paths.
+        if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+            return $file;
+        }
+
+        return false;
+    }
+}
+
+/**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ *
+ * @param  string $file
+ * @return void
+ * @private
+ */
+function includeFile($file)
+{
+    include $file;
+}
diff --git a/htdocs/custom/peppol/vendor/composer/InstalledVersions.php b/htdocs/custom/peppol/vendor/composer/InstalledVersions.php
new file mode 100644 (file)
index 0000000..d50e0c9
--- /dev/null
@@ -0,0 +1,350 @@
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ *     Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer;
+
+use Composer\Autoload\ClassLoader;
+use Composer\Semver\VersionParser;
+
+/**
+ * This class is copied in every Composer installed project and available to all
+ *
+ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
+ *
+ * To require its presence, you can require `composer-runtime-api ^2.0`
+ */
+class InstalledVersions
+{
+    /**
+     * @var mixed[]|null
+     * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
+     */
+    private static $installed;
+
+    /**
+     * @var bool|null
+     */
+    private static $canGetVendors;
+
+    /**
+     * @var array[]
+     * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
+     */
+    private static $installedByVendor = array();
+
+    /**
+     * Returns a list of all package names which are present, either by being installed, replaced or provided
+     *
+     * @return string[]
+     * @psalm-return list<string>
+     */
+    public static function getInstalledPackages()
+    {
+        $packages = array();
+        foreach (self::getInstalled() as $installed) {
+            $packages[] = array_keys($installed['versions']);
+        }
+
+        if (1 === \count($packages)) {
+            return $packages[0];
+        }
+
+        return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
+    }
+
+    /**
+     * Returns a list of all package names with a specific type e.g. 'library'
+     *
+     * @param  string   $type
+     * @return string[]
+     * @psalm-return list<string>
+     */
+    public static function getInstalledPackagesByType($type)
+    {
+        $packagesByType = array();
+
+        foreach (self::getInstalled() as $installed) {
+            foreach ($installed['versions'] as $name => $package) {
+                if (isset($package['type']) && $package['type'] === $type) {
+                    $packagesByType[] = $name;
+                }
+            }
+        }
+
+        return $packagesByType;
+    }
+
+    /**
+     * Checks whether the given package is installed
+     *
+     * This also returns true if the package name is provided or replaced by another package
+     *
+     * @param  string $packageName
+     * @param  bool   $includeDevRequirements
+     * @return bool
+     */
+    public static function isInstalled($packageName, $includeDevRequirements = true)
+    {
+        foreach (self::getInstalled() as $installed) {
+            if (isset($installed['versions'][$packageName])) {
+                return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Checks whether the given package satisfies a version constraint
+     *
+     * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
+     *
+     *   Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
+     *
+     * @param  VersionParser $parser      Install composer/semver to have access to this class and functionality
+     * @param  string        $packageName
+     * @param  string|null   $constraint  A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
+     * @return bool
+     */
+    public static function satisfies(VersionParser $parser, $packageName, $constraint)
+    {
+        $constraint = $parser->parseConstraints($constraint);
+        $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
+
+        return $provided->matches($constraint);
+    }
+
+    /**
+     * Returns a version constraint representing all the range(s) which are installed for a given package
+     *
+     * It is easier to use this via isInstalled() with the $constraint argument if you need to check
+     * whether a given version of a package is installed, and not just whether it exists
+     *
+     * @param  string $packageName
+     * @return string Version constraint usable with composer/semver
+     */
+    public static function getVersionRanges($packageName)
+    {
+        foreach (self::getInstalled() as $installed) {
+            if (!isset($installed['versions'][$packageName])) {
+                continue;
+            }
+
+            $ranges = array();
+            if (isset($installed['versions'][$packageName]['pretty_version'])) {
+                $ranges[] = $installed['versions'][$packageName]['pretty_version'];
+            }
+            if (array_key_exists('aliases', $installed['versions'][$packageName])) {
+                $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
+            }
+            if (array_key_exists('replaced', $installed['versions'][$packageName])) {
+                $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
+            }
+            if (array_key_exists('provided', $installed['versions'][$packageName])) {
+                $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
+            }
+
+            return implode(' || ', $ranges);
+        }
+
+        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+    }
+
+    /**
+     * @param  string      $packageName
+     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+     */
+    public static function getVersion($packageName)
+    {
+        foreach (self::getInstalled() as $installed) {
+            if (!isset($installed['versions'][$packageName])) {
+                continue;
+            }
+
+            if (!isset($installed['versions'][$packageName]['version'])) {
+                return null;
+            }
+
+            return $installed['versions'][$packageName]['version'];
+        }
+
+        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+    }
+
+    /**
+     * @param  string      $packageName
+     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+     */
+    public static function getPrettyVersion($packageName)
+    {
+        foreach (self::getInstalled() as $installed) {
+            if (!isset($installed['versions'][$packageName])) {
+                continue;
+            }
+
+            if (!isset($installed['versions'][$packageName]['pretty_version'])) {
+                return null;
+            }
+
+            return $installed['versions'][$packageName]['pretty_version'];
+        }
+
+        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+    }
+
+    /**
+     * @param  string      $packageName
+     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
+     */
+    public static function getReference($packageName)
+    {
+        foreach (self::getInstalled() as $installed) {
+            if (!isset($installed['versions'][$packageName])) {
+                continue;
+            }
+
+            if (!isset($installed['versions'][$packageName]['reference'])) {
+                return null;
+            }
+
+            return $installed['versions'][$packageName]['reference'];
+        }
+
+        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+    }
+
+    /**
+     * @param  string      $packageName
+     * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
+     */
+    public static function getInstallPath($packageName)
+    {
+        foreach (self::getInstalled() as $installed) {
+            if (!isset($installed['versions'][$packageName])) {
+                continue;
+            }
+
+            return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
+        }
+
+        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+    }
+
+    /**
+     * @return array
+     * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
+     */
+    public static function getRootPackage()
+    {
+        $installed = self::getInstalled();
+
+        return $installed[0]['root'];
+    }
+
+    /**
+     * Returns the raw installed.php data for custom implementations
+     *
+     * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
+     * @return array[]
+     * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
+     */
+    public static function getRawData()
+    {
+        @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
+
+        if (null === self::$installed) {
+            // only require the installed.php file if this file is loaded from its dumped location,
+            // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+            if (substr(__DIR__, -8, 1) !== 'C') {
+                self::$installed = include __DIR__ . '/installed.php';
+            } else {
+                self::$installed = array();
+            }
+        }
+
+        return self::$installed;
+    }
+
+    /**
+     * Returns the raw data of all installed.php which are currently loaded for custom implementations
+     *
+     * @return array[]
+     * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
+     */
+    public static function getAllRawData()
+    {
+        return self::getInstalled();
+    }
+
+    /**
+     * Lets you reload the static array from another file
+     *
+     * This is only useful for complex integrations in which a project needs to use
+     * this class but then also needs to execute another project's autoloader in process,
+     * and wants to ensure both projects have access to their version of installed.php.
+     *
+     * A typical case would be PHPUnit, where it would need to make sure it reads all
+     * the data it needs from this class, then call reload() with
+     * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
+     * the project in which it runs can then also use this class safely, without
+     * interference between PHPUnit's dependencies and the project's dependencies.
+     *
+     * @param  array[] $data A vendor/composer/installed.php data set
+     * @return void
+     *
+     * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
+     */
+    public static function reload($data)
+    {
+        self::$installed = $data;
+        self::$installedByVendor = array();
+    }
+
+    /**
+     * @return array[]
+     * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
+     */
+    private static function getInstalled()
+    {
+        if (null === self::$canGetVendors) {
+            self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
+        }
+
+        $installed = array();
+
+        if (self::$canGetVendors) {
+            foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
+                if (isset(self::$installedByVendor[$vendorDir])) {
+                    $installed[] = self::$installedByVendor[$vendorDir];
+                } elseif (is_file($vendorDir.'/composer/installed.php')) {
+                    $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
+                    if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
+                        self::$installed = $installed[count($installed) - 1];
+                    }
+                }
+            }
+        }
+
+        if (null === self::$installed) {
+            // only require the installed.php file if this file is loaded from its dumped location,
+            // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+            if (substr(__DIR__, -8, 1) !== 'C') {
+                self::$installed = require __DIR__ . '/installed.php';
+            } else {
+                self::$installed = array();
+            }
+        }
+        $installed[] = self::$installed;
+
+        return $installed;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/composer/LICENSE b/htdocs/custom/peppol/vendor/composer/LICENSE
new file mode 100644 (file)
index 0000000..f27399a
--- /dev/null
@@ -0,0 +1,21 @@
+
+Copyright (c) Nils Adermann, Jordi Boggiano
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/htdocs/custom/peppol/vendor/composer/autoload_classmap.php b/htdocs/custom/peppol/vendor/composer/autoload_classmap.php
new file mode 100644 (file)
index 0000000..b26f1b1
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+// autoload_classmap.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
+);
diff --git a/htdocs/custom/peppol/vendor/composer/autoload_namespaces.php b/htdocs/custom/peppol/vendor/composer/autoload_namespaces.php
new file mode 100644 (file)
index 0000000..b7fc012
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+// autoload_namespaces.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+);
diff --git a/htdocs/custom/peppol/vendor/composer/autoload_psr4.php b/htdocs/custom/peppol/vendor/composer/autoload_psr4.php
new file mode 100644 (file)
index 0000000..83bc3a9
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+// autoload_psr4.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+    'UXML\\' => array($vendorDir . '/josemmo/uxml/src'),
+    'Einvoicing\\' => array($vendorDir . '/josemmo/einvoicing/src'),
+);
diff --git a/htdocs/custom/peppol/vendor/composer/autoload_real.php b/htdocs/custom/peppol/vendor/composer/autoload_real.php
new file mode 100644 (file)
index 0000000..01a0581
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+// autoload_real.php @generated by Composer
+
+class ComposerAutoloaderInit7e7c9cec0f2a4994c99e01fba9e484fe
+{
+    private static $loader;
+
+    public static function loadClassLoader($class)
+    {
+        if ('Composer\Autoload\ClassLoader' === $class) {
+            require __DIR__ . '/ClassLoader.php';
+        }
+    }
+
+    /**
+     * @return \Composer\Autoload\ClassLoader
+     */
+    public static function getLoader()
+    {
+        if (null !== self::$loader) {
+            return self::$loader;
+        }
+
+        require __DIR__ . '/platform_check.php';
+
+        spl_autoload_register(array('ComposerAutoloaderInit7e7c9cec0f2a4994c99e01fba9e484fe', 'loadClassLoader'), true, true);
+        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
+        spl_autoload_unregister(array('ComposerAutoloaderInit7e7c9cec0f2a4994c99e01fba9e484fe', 'loadClassLoader'));
+
+        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
+        if ($useStaticLoader) {
+            require __DIR__ . '/autoload_static.php';
+
+            call_user_func(\Composer\Autoload\ComposerStaticInit7e7c9cec0f2a4994c99e01fba9e484fe::getInitializer($loader));
+        } else {
+            $map = require __DIR__ . '/autoload_namespaces.php';
+            foreach ($map as $namespace => $path) {
+                $loader->set($namespace, $path);
+            }
+
+            $map = require __DIR__ . '/autoload_psr4.php';
+            foreach ($map as $namespace => $path) {
+                $loader->setPsr4($namespace, $path);
+            }
+
+            $classMap = require __DIR__ . '/autoload_classmap.php';
+            if ($classMap) {
+                $loader->addClassMap($classMap);
+            }
+        }
+
+        $loader->register(true);
+
+        return $loader;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/composer/autoload_static.php b/htdocs/custom/peppol/vendor/composer/autoload_static.php
new file mode 100644 (file)
index 0000000..cee1ca0
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+// autoload_static.php @generated by Composer
+
+namespace Composer\Autoload;
+
+class ComposerStaticInit7e7c9cec0f2a4994c99e01fba9e484fe
+{
+    public static $prefixLengthsPsr4 = array (
+        'U' => 
+        array (
+            'UXML\\' => 5,
+        ),
+        'E' => 
+        array (
+            'Einvoicing\\' => 11,
+        ),
+    );
+
+    public static $prefixDirsPsr4 = array (
+        'UXML\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/josemmo/uxml/src',
+        ),
+        'Einvoicing\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/josemmo/einvoicing/src',
+        ),
+    );
+
+    public static $classMap = array (
+        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
+    );
+
+    public static function getInitializer(ClassLoader $loader)
+    {
+        return \Closure::bind(function () use ($loader) {
+            $loader->prefixLengthsPsr4 = ComposerStaticInit7e7c9cec0f2a4994c99e01fba9e484fe::$prefixLengthsPsr4;
+            $loader->prefixDirsPsr4 = ComposerStaticInit7e7c9cec0f2a4994c99e01fba9e484fe::$prefixDirsPsr4;
+            $loader->classMap = ComposerStaticInit7e7c9cec0f2a4994c99e01fba9e484fe::$classMap;
+
+        }, null, ClassLoader::class);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/composer/installed.json b/htdocs/custom/peppol/vendor/composer/installed.json
new file mode 100644 (file)
index 0000000..33f82ba
--- /dev/null
@@ -0,0 +1,118 @@
+{
+    "packages": [
+        {
+            "name": "josemmo/einvoicing",
+            "version": "v0.1.6",
+            "version_normalized": "0.1.6.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/josemmo/einvoicing.git",
+                "reference": "9704bb184b0cbbc1b0872a1589cae8b6954e54cd"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/josemmo/einvoicing/zipball/9704bb184b0cbbc1b0872a1589cae8b6954e54cd",
+                "reference": "9704bb184b0cbbc1b0872a1589cae8b6954e54cd",
+                "shasum": ""
+            },
+            "require": {
+                "josemmo/uxml": "^0.1.2",
+                "php": ">=7.0"
+            },
+            "require-dev": {
+                "ext-openssl": "*",
+                "phan/phan": "^5.0",
+                "phpdocumentor/reflection": "^4.0",
+                "symfony/phpunit-bridge": "^5.3"
+            },
+            "time": "2021-11-22T20:09:03+00:00",
+            "type": "library",
+            "installation-source": "dist",
+            "autoload": {
+                "psr-4": {
+                    "Einvoicing\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "José Miguel Moreno",
+                    "email": "josemmo@pm.me",
+                    "homepage": "https://github.com/josemmo"
+                }
+            ],
+            "description": "Library for reading and creating European-compliant electronic invoices (EN 16931)",
+            "homepage": "https://github.com/josemmo/einvoicing",
+            "keywords": [
+                "cii",
+                "invoice",
+                "invoicing",
+                "peppol",
+                "ubl"
+            ],
+            "support": {
+                "issues": "https://github.com/josemmo/einvoicing/issues",
+                "source": "https://github.com/josemmo/einvoicing/tree/v0.1.6"
+            },
+            "install-path": "../josemmo/einvoicing"
+        },
+        {
+            "name": "josemmo/uxml",
+            "version": "v0.1.2",
+            "version_normalized": "0.1.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/josemmo/uxml.git",
+                "reference": "be11039e103ad1a3d801ea67c03fdc30756f7992"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/josemmo/uxml/zipball/be11039e103ad1a3d801ea67c03fdc30756f7992",
+                "reference": "be11039e103ad1a3d801ea67c03fdc30756f7992",
+                "shasum": ""
+            },
+            "require": {
+                "lib-libxml": "*",
+                "php": ">=7.0"
+            },
+            "require-dev": {
+                "phan/phan": "^5.0",
+                "symfony/phpunit-bridge": "^5.3"
+            },
+            "time": "2021-08-07T09:49:41+00:00",
+            "type": "library",
+            "installation-source": "dist",
+            "autoload": {
+                "psr-4": {
+                    "UXML\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "José Miguel Moreno",
+                    "email": "josemmo@pm.me",
+                    "homepage": "https://github.com/josemmo"
+                }
+            ],
+            "description": "Uncomplicated XML manipulation library with a clean and concise syntax",
+            "homepage": "https://github.com/josemmo/uxml",
+            "keywords": [
+                "xml"
+            ],
+            "support": {
+                "issues": "https://github.com/josemmo/uxml/issues",
+                "source": "https://github.com/josemmo/uxml/tree/v0.1.2"
+            },
+            "install-path": "../josemmo/uxml"
+        }
+    ],
+    "dev": true,
+    "dev-package-names": []
+}
diff --git a/htdocs/custom/peppol/vendor/composer/installed.php b/htdocs/custom/peppol/vendor/composer/installed.php
new file mode 100644 (file)
index 0000000..87f9a35
--- /dev/null
@@ -0,0 +1,41 @@
+<?php return array(
+    'root' => array(
+        'pretty_version' => 'dev-master',
+        'version' => 'dev-master',
+        'type' => 'library',
+        'install_path' => __DIR__ . '/../../',
+        'aliases' => array(),
+        'reference' => '06210a2c32296646e6c84f513fe5481b7b29d375',
+        'name' => '__root__',
+        'dev' => true,
+    ),
+    'versions' => array(
+        '__root__' => array(
+            'pretty_version' => 'dev-master',
+            'version' => 'dev-master',
+            'type' => 'library',
+            'install_path' => __DIR__ . '/../../',
+            'aliases' => array(),
+            'reference' => '06210a2c32296646e6c84f513fe5481b7b29d375',
+            'dev_requirement' => false,
+        ),
+        'josemmo/einvoicing' => array(
+            'pretty_version' => 'v0.1.6',
+            'version' => '0.1.6.0',
+            'type' => 'library',
+            'install_path' => __DIR__ . '/../josemmo/einvoicing',
+            'aliases' => array(),
+            'reference' => '9704bb184b0cbbc1b0872a1589cae8b6954e54cd',
+            'dev_requirement' => false,
+        ),
+        'josemmo/uxml' => array(
+            'pretty_version' => 'v0.1.2',
+            'version' => '0.1.2.0',
+            'type' => 'library',
+            'install_path' => __DIR__ . '/../josemmo/uxml',
+            'aliases' => array(),
+            'reference' => 'be11039e103ad1a3d801ea67c03fdc30756f7992',
+            'dev_requirement' => false,
+        ),
+    ),
+);
diff --git a/htdocs/custom/peppol/vendor/composer/platform_check.php b/htdocs/custom/peppol/vendor/composer/platform_check.php
new file mode 100644 (file)
index 0000000..f79e574
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+// platform_check.php @generated by Composer
+
+$issues = array();
+
+if (!(PHP_VERSION_ID >= 70000)) {
+    $issues[] = 'Your Composer dependencies require a PHP version ">= 7.0.0". You are running ' . PHP_VERSION . '.';
+}
+
+if ($issues) {
+    if (!headers_sent()) {
+        header('HTTP/1.1 500 Internal Server Error');
+    }
+    if (!ini_get('display_errors')) {
+        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
+            fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
+        } elseif (!headers_sent()) {
+            echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
+        }
+    }
+    trigger_error(
+        'Composer detected issues in your platform: ' . implode(' ', $issues),
+        E_USER_ERROR
+    );
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/.editorconfig b/htdocs/custom/peppol/vendor/josemmo/einvoicing/.editorconfig
new file mode 100644 (file)
index 0000000..f1c0537
--- /dev/null
@@ -0,0 +1,18 @@
+# This file is for unifying the coding style for different editors and IDEs
+# editorconfig.org
+
+root = true
+charset = utf-8
+trim_trailing_whitespace = true
+
+[*]
+end_of_line = lf
+indent_style = space
+indent_size = 4
+insert_final_newline = false
+
+[*.yml]
+indent_size = 2
+
+[*.{php,json,yml,xml,md}]
+insert_final_newline = true
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/.gitattributes b/htdocs/custom/peppol/vendor/josemmo/einvoicing/.gitattributes
new file mode 100644 (file)
index 0000000..94f480d
--- /dev/null
@@ -0,0 +1 @@
+* text=auto eol=lf
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/.github/workflows/ci.yml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/.github/workflows/ci.yml
new file mode 100644 (file)
index 0000000..5b5ce45
--- /dev/null
@@ -0,0 +1,59 @@
+name: CI
+
+on: [push, pull_request]
+
+jobs:
+  ci:
+    name: Run tests and deploy
+    runs-on: ubuntu-latest
+    continue-on-error: ${{ matrix.experimental || false }}
+    strategy:
+      fail-fast: false
+      matrix:
+        php-version: ['7.1', '7.2', '7.3', '7.4']
+        include:
+          - php-version: '8.0'
+            deploy: ${{ github.ref == 'refs/heads/master' }}
+          - php-version: '8.1'
+            experimental: true
+    steps:
+      # Download code from repository
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+      # Setup PHP
+      - name: Setup PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php-version }}
+          coverage: none
+          extensions: ast-stable
+
+      # Setup Composer
+      - name: Setup Composer
+        run: composer validate --strict && composer install --ignore-platform-reqs
+
+      # Run static analyzer
+      - name: Run static analyzer
+        if: ${{ success() && matrix.php-version != '7.1' }}
+        run: vendor/bin/phan --color --no-progress-bar
+
+      # Run tests
+      - name: Run tests
+        run: vendor/bin/simple-phpunit --testdox
+
+      # Build documentation
+      - name: Build documentation
+        if: ${{ success() && matrix.deploy || false }}
+        run: |
+          php ./scripts/build-docs.php
+          docker run --rm -v ${PWD}:/docs squidfunk/mkdocs-material build
+
+       # Deploy documentation
+      - name: Deploy documentation
+        if: ${{ success() && matrix.deploy || false }}
+        uses: JamesIves/github-pages-deploy-action@4.1.4
+        with:
+          branch: gh-pages
+          folder: site
+          clean: true # Automatically remove deleted files from the deploy branch
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/.gitignore b/htdocs/custom/peppol/vendor/josemmo/einvoicing/.gitignore
new file mode 100644 (file)
index 0000000..49ce3c1
--- /dev/null
@@ -0,0 +1 @@
+/vendor
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/.phan/config.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/.phan/config.php
new file mode 100644 (file)
index 0000000..4be53c2
--- /dev/null
@@ -0,0 +1,190 @@
+<?php
+use Phan\Issue;
+
+/**
+ * This configuration will be read and overlaid on top of the
+ * default configuration. Command line arguments will be applied
+ * after this file is read.
+ *
+ * @see https://github.com/phan/phan/wiki/Phan-Config-Settings for all configurable options
+ * @see src/Phan/Config.php for the configurable options in this version of Phan
+ *
+ * A Note About Paths
+ * ==================
+ *
+ * Files referenced from this file should be defined as
+ *
+ * ```
+ *   Config::projectPath('relative_path/to/file')
+ * ```
+ *
+ * where the relative path is relative to the root of the
+ * project which is defined as either the working directory
+ * of the phan executable or a path passed in via the CLI
+ * '-d' flag.
+ */
+return [
+    // The PHP version that the codebase will be checked for compatibility against.
+    // For best results, the PHP binary used to run Phan should have the same PHP version.
+    // (Phan relies on Reflection for some types, param counts,
+    // and checks for undefined classes/methods/functions)
+    //
+    // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`,
+    // `'8.0'`, `'8.1'`, `null`.
+    // If this is set to `null`,
+    // then Phan assumes the PHP version which is closest to the minor version
+    // of the php executable used to execute Phan.
+    //
+    // Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
+    // (See `backward_compatibility_checks` for additional options)
+    'target_php_version' => null,
+
+    // A list of directories that should be parsed for class and
+    // method information. After excluding the directories
+    // defined in exclude_analysis_directory_list, the remaining
+    // files will be statically analyzed for errors.
+    //
+    // Thus, both first-party and third-party code being used by
+    // your application should be included in this list.
+    'directory_list' => [
+        'src',
+        'vendor',
+    ],
+
+    // A directory list that defines files that will be excluded
+    // from static analysis, but whose class and method
+    // information should be included.
+    //
+    // Generally, you'll want to include the directories for
+    // third-party code (such as "vendor/") in this list.
+    //
+    // n.b.: If you'd like to parse but not analyze 3rd
+    //       party code, directories containing that code
+    //       should be added to both the `directory_list`
+    //       and `exclude_analysis_directory_list` arrays.
+    'exclude_analysis_directory_list' => [
+        'vendor',
+    ],
+
+    // If enabled, Phan will warn if **any** type in a method invocation's object
+    // is definitely not an object,
+    // or if **any** type in an invoked expression is not a callable.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    'strict_method_checking' => true,
+
+    // If enabled, Phan will warn if **any** type in the argument's union type
+    // cannot be cast to a type in the parameter's expected union type.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    'strict_param_checking' => true,
+
+    // If enabled, Phan will warn if **any** type in a property assignment's union type
+    // cannot be cast to a type in the property's declared union type.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions, due to \ast\Node being difficult to type check)
+    'strict_property_checking' => true,
+
+    // If enabled, Phan will warn if **any** type in a returned value's union type
+    // cannot be cast to the declared return type.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions, due to \ast\Node being difficult to type check)
+    'strict_return_checking' => true,
+
+    // If enabled, Phan will warn if **any** type of the object expression for a property access
+    // does not contain that property.
+    'strict_object_checking' => true,
+
+    // If enabled, check all methods that override a
+    // parent method to make sure its signature is
+    // compatible with the parent's. This check
+    // can add quite a bit of time to the analysis.
+    // This will also check if final methods are overridden, etc.
+    'analyze_signature_compatibility' => true,
+
+    // If true, check to make sure the return type declared
+    // in the doc-block (if any) matches the return type
+    // declared in the method signature.
+    'check_docblock_signature_return_type_match' => true,
+
+    // If true, check to make sure the param types declared
+    // in the doc-block (if any) matches the param types
+    // declared in the method signature.
+    'check_docblock_signature_param_type_match' => true,
+
+    // Set to true in order to attempt to detect dead
+    // (unreferenced) code. Keep in mind that the
+    // results will only be a guess given that classes,
+    // properties, constants and methods can be referenced
+    // as variables (like `$class->$property` or
+    // `$class->$method()`) in ways that we're unable
+    // to make sense of.
+    //
+    // To more aggressively detect dead code,
+    // you may want to set `dead_code_detection_prefer_false_negative` to `false`.
+    'dead_code_detection' => true,
+
+    // Set to true in order to attempt to detect redundant and impossible conditions.
+    //
+    // This has some false positives involving loops,
+    // variables set in branches of loops, and global variables.
+    'redundant_condition_detection' => true,
+
+    // Set to true in order to attempt to detect error-prone truthiness/falsiness checks.
+    //
+    // This is not suitable for all codebases.
+    'error_prone_truthy_condition_detection' => true,
+
+    // Enable or disable support for generic templated
+    // class types.
+    'generic_types_enabled' => true,
+
+    // If enabled, warn about throw statement where the exception types
+    // are not documented in the PHPDoc of functions, methods, and closures.
+    'warn_about_undocumented_throw_statements' => true,
+
+    // If enabled (and `warn_about_undocumented_throw_statements` is enabled),
+    // Phan will warn about function/closure/method invocations that have `@throws`
+    // that aren't caught or documented in the invoking method.
+    'warn_about_undocumented_exceptions_thrown_by_invoked_functions' => true,
+
+    // The minimum severity level to report on. This can be
+    // set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
+    // Issue::SEVERITY_CRITICAL.
+    'minimum_severity' => Issue::SEVERITY_NORMAL,
+
+    // Add any issue types (such as `'PhanUndeclaredMethod'`)
+    // to this list to inhibit them from being reported.
+    'suppress_issue_types' => [
+        'PhanUnreferencedClass',
+        'PhanUnreferencedPublicMethod',
+    ],
+
+    // A list of plugin files to execute.
+    // Plugins which are bundled with Phan can be added here by providing their name
+    // (e.g. 'AlwaysReturnPlugin')
+    //
+    // Documentation about available bundled plugins can be found
+    // at https://github.com/phan/phan/tree/v4/.phan/plugins
+    //
+    // Alternately, you can pass in the full path to a PHP file
+    // with the plugin's implementation.
+    // (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php')
+    'plugins' => [
+        'AlwaysReturnPlugin', // Checks if a function, closure or method unconditionally returns.
+        'DollarDollarPlugin',
+        'DuplicateArrayKeyPlugin',
+        'DuplicateExpressionPlugin',
+        'EmptyStatementListPlugin',
+        'InlineHTMLPlugin',
+        'LoopVariableReusePlugin',
+        'PreferNamespaceUsePlugin',
+        'PregRegexCheckerPlugin',
+        'PrintfCheckerPlugin',
+        'SleepCheckerPlugin',
+        'UnreachableCodePlugin', // Checks for syntactically unreachable statements in the global scope or function bodies.
+        'UseReturnValuePlugin',
+    ],
+];
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/CONTRIBUTING.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..05214d8
--- /dev/null
@@ -0,0 +1,38 @@
+# Contributing
+Thanks for taking your time to contribute to this project!
+This document will get you on the right track to help improve eInvoicing.
+
+## How to Get Started
+Use the following sites to get more information about the European electronic invocing specification:
+
+- [EU e-Invoicing core concepts](https://josemmo.github.io/einvoicing/getting-started/eu-einvoicing-concepts/)
+- [Compliance with the European standard on eInvoicing](https://ec.europa.eu/cefdigital/wiki/x/ggTvB)
+- [Obtaining a copy of the European standard on eInvoicing](https://ec.europa.eu/cefdigital/wiki/x/kgLvB)
+- [UBL Invoice fields](https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/tree/)
+- [CEF eInvoicing Validator](https://www.itb.ec.europa.eu/invoice/upload)
+
+## PR Requirements
+Before opening a Pull Request, please make sure your code meets the following requirements:
+
+### 1. Uses `develop` as the base branch
+The main repository branch is only for stable releases.
+
+### 2. Passes static analysis inspection
+```
+vendor/bin/phan --testdox
+```
+
+### 3. Passes all tests
+```
+vendor/bin/simple-phpunit
+```
+
+### 4. Complies with EN 16931
+Although the most popular European Invoicing CIUS is [PEPPOL BIS Billing 3.0](https://docs.peppol.eu/poacc/billing/3.0/),
+the real deal is the "European Standard for Electronic invocing" or EN 16931.
+
+This means that, while most users will use the [Peppol](src/Presets/Peppol.php) preset for reading and writing invoices,
+there are other CIUS/extensions from various member states and business sectors which might not be an exact match to PEPPOL.
+
+Because the one thing all these specifications have in common is EN 16931, fields and methods you add to the library
+must have the same names as they do in the European Standard.
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/LICENSE b/htdocs/custom/peppol/vendor/josemmo/einvoicing/LICENSE
new file mode 100644 (file)
index 0000000..4e7d522
--- /dev/null
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020-present José M. Moreno <josemmo@pm.me> (https://github.com/josemmo)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/README.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/README.md
new file mode 100644 (file)
index 0000000..e51662f
--- /dev/null
@@ -0,0 +1,106 @@
+<h1 align="center">
+    <a href="https://josemmo.github.io/einvoicing/"><img src="docs/logo.svg" width="100" alt=""><br>European Invoicing (eInvoicing)</a>
+</h1>
+
+<p align="center">
+    <a href="https://github.com/josemmo/einvoicing/actions"><img src="https://github.com/josemmo/einvoicing/workflows/CI/badge.svg" alt="Build Status"></a>
+    <a href="https://packagist.org/packages/josemmo/einvoicing"><img src="https://img.shields.io/packagist/v/josemmo/einvoicing" alt="Latest Version"></a>
+    <a href="#installation"><img src="https://img.shields.io/packagist/php-v/josemmo/einvoicing" alt="Supported PHP Versions"></a>
+    <a href="LICENSE"><img src="https://img.shields.io/github/license/josemmo/einvoicing" alt="License"></a>
+    <a href="https://josemmo.github.io/einvoicing/"><img src="https://img.shields.io/badge/online-docs-blueviolet" alt="Documentation"></a>
+</p>
+
+## About
+eInvoicing is a PHP library for creating and reading electronic invoices according to the [eInvoicing Directive and European standard](https://ec.europa.eu/cefdigital/wiki/display/CEFDIGITAL/eInvoicing).
+
+It aims to be 100% compliant with [EN 16931](https://ec.europa.eu/cefdigital/wiki/x/kwFVBg) as well as with the most popular CIUS and extensions, such as [PEPPOL BIS](https://docs.peppol.eu/poacc/billing/3.0/bis/).
+
+## Installation
+First of all, make sure your environment meets the following requirements:
+
+- PHP 7.1 or higher
+- [SimpleXML extension](https://www.php.net/book.simplexml) for reading and exporting UBL/CII invoices
+
+Then, you should be able to install this library using Composer:
+
+```
+composer require josemmo/einvoicing
+```
+
+## Usage
+For a proper quick start guide, visit the documentation website at
+[https://josemmo.github.io/einvoicing/](https://josemmo.github.io/einvoicing/).
+
+### Importing invoice documents
+```php
+use Einvoicing\Exceptions\ValidationException;
+use Einvoicing\Readers\UblReader;
+
+$reader = new UblReader();
+$document = file_get_contents(__DIR__ . "/example.xml");
+$inv = $reader->import($document);
+try {
+    $inv->validate();
+} catch (ValidationException $e) {
+    // Invoice is not EN 16931 complaint 
+}
+```
+
+### Exporting invoice documents
+```php
+use Einvoicing\Identifier;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\Party;
+use Einvoicing\Presets;
+use Einvoicing\Writers\UblWriter;
+
+// Create PEPPOL invoice instance
+$inv = new Invoice(Presets\Peppol::class);
+$inv->setNumber('F-202000012')
+    ->setIssueDate(new DateTime('2020-11-01'))
+    ->setDueDate(new DateTime('2020-11-30'));
+
+// Set seller
+$seller = new Party();
+$seller->setElectronicAddress(new Identifier('9482348239847239874', '0088'))
+    ->setCompanyId(new Identifier('AH88726', '0183'))
+    ->setName('Seller Name Ltd.')
+    ->setTradingName('Seller Name')
+    ->setVatNumber('ESA00000000')
+    ->setAddress(['Fake Street 123', 'Apartment Block 2B'])
+    ->setCity('Springfield')
+    ->setCountry('DE');
+$inv->setSeller($seller);
+
+// Set buyer
+$buyer = new Party();
+$buyer->setElectronicAddress(new Identifier('ES12345', '0002'))
+    ->setName('Buyer Name Ltd.')
+    ->setCountry('FR');
+$inv->setBuyer($buyer);
+
+// Add a product line
+$line = new InvoiceLine();
+$line->setName('Product Name')
+    ->setPrice(100)
+    ->setVatRate(16)
+    ->setQuantity(1);
+$inv->addLine($line);
+
+// Export invoice to a UBL document
+header('Content-Type: text/xml');
+$writer = new UblWriter();
+echo $writer->export($inv);
+```
+
+## Roadmap
+These are the expected features for the library and how's it going so far:
+
+- [x] Representation of invoices, parties and invoice lines as objects
+- [x] Compatibility with the most used [CIUS and extensions](https://ec.europa.eu/cefdigital/wiki/x/5xLoAg)
+- [x] Export invoices to UBL documents
+- [x] Import invoices from UBL documents
+- [ ] Export invoices to CII documents
+- [ ] Import invoices from CII documents
+- [x] Proper documentation
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/composer.json b/htdocs/custom/peppol/vendor/josemmo/einvoicing/composer.json
new file mode 100644 (file)
index 0000000..d698634
--- /dev/null
@@ -0,0 +1,40 @@
+{
+    "name": "josemmo/einvoicing",
+    "description": "Library for reading and creating European-compliant electronic invoices (EN 16931)",
+    "keywords": [
+        "invoicing",
+        "invoice",
+        "peppol",
+        "ubl",
+        "cii"
+    ],
+    "license": "MIT",
+    "homepage": "https://github.com/josemmo/einvoicing",
+    "authors": [
+        {
+            "name": "José Miguel Moreno",
+            "email": "josemmo@pm.me",
+            "homepage": "https://github.com/josemmo"
+        }
+    ],
+    "autoload": {
+        "psr-4": {
+            "Einvoicing\\": "src/"
+        }
+    },
+    "autoload-dev": {
+        "psr-4": {
+            "Tests\\": "tests/"
+        }
+    },
+    "require": {
+        "php": ">=7.1",
+        "josemmo/uxml": "^0.1.2"
+    },
+    "require-dev": {
+        "ext-openssl": "*",
+        "phan/phan": "^5.0",
+        "phpdocumentor/reflection": "^4.0",
+        "symfony/phpunit-bridge": "^5.3"
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/composer.lock b/htdocs/custom/peppol/vendor/josemmo/einvoicing/composer.lock
new file mode 100644 (file)
index 0000000..157d797
--- /dev/null
@@ -0,0 +1,1887 @@
+{
+    "_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": "1cc14bd61534b65cbd3dd84fdc0c7465",
+    "packages": [
+        {
+            "name": "josemmo/uxml",
+            "version": "v0.1.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/josemmo/uxml.git",
+                "reference": "be11039e103ad1a3d801ea67c03fdc30756f7992"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/josemmo/uxml/zipball/be11039e103ad1a3d801ea67c03fdc30756f7992",
+                "reference": "be11039e103ad1a3d801ea67c03fdc30756f7992",
+                "shasum": ""
+            },
+            "require": {
+                "lib-libxml": "*",
+                "php": ">=7.1"
+            },
+            "require-dev": {
+                "phan/phan": "^5.0",
+                "symfony/phpunit-bridge": "^5.3"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "UXML\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "José Miguel Moreno",
+                    "email": "josemmo@pm.me",
+                    "homepage": "https://github.com/josemmo"
+                }
+            ],
+            "description": "Uncomplicated XML manipulation library with a clean and concise syntax",
+            "homepage": "https://github.com/josemmo/uxml",
+            "keywords": [
+                "xml"
+            ],
+            "support": {
+                "issues": "https://github.com/josemmo/uxml/issues",
+                "source": "https://github.com/josemmo/uxml/tree/v0.1.2"
+            },
+            "time": "2021-08-07T09:49:41+00:00"
+        }
+    ],
+    "packages-dev": [
+        {
+            "name": "composer/semver",
+            "version": "3.2.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/composer/semver.git",
+                "reference": "83e511e247de329283478496f7a1e114c9517506"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/composer/semver/zipball/83e511e247de329283478496f7a1e114c9517506",
+                "reference": "83e511e247de329283478496f7a1e114c9517506",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^5.3.2 || ^7.0 || ^8.0"
+            },
+            "require-dev": {
+                "phpstan/phpstan": "^0.12.54",
+                "symfony/phpunit-bridge": "^4.2 || ^5"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "3.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Composer\\Semver\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nils Adermann",
+                    "email": "naderman@naderman.de",
+                    "homepage": "http://www.naderman.de"
+                },
+                {
+                    "name": "Jordi Boggiano",
+                    "email": "j.boggiano@seld.be",
+                    "homepage": "http://seld.be"
+                },
+                {
+                    "name": "Rob Bast",
+                    "email": "rob.bast@gmail.com",
+                    "homepage": "http://robbast.nl"
+                }
+            ],
+            "description": "Semver library that offers utilities, version constraint parsing and validation.",
+            "keywords": [
+                "semantic",
+                "semver",
+                "validation",
+                "versioning"
+            ],
+            "support": {
+                "irc": "irc://irc.freenode.org/composer",
+                "issues": "https://github.com/composer/semver/issues",
+                "source": "https://github.com/composer/semver/tree/3.2.6"
+            },
+            "funding": [
+                {
+                    "url": "https://packagist.com",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/composer",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-10-25T11:34:17+00:00"
+        },
+        {
+            "name": "composer/xdebug-handler",
+            "version": "2.0.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/composer/xdebug-handler.git",
+                "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339",
+                "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^5.3.2 || ^7.0 || ^8.0",
+                "psr/log": "^1 || ^2 || ^3"
+            },
+            "require-dev": {
+                "phpstan/phpstan": "^0.12.55",
+                "symfony/phpunit-bridge": "^4.2 || ^5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Composer\\XdebugHandler\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "John Stevenson",
+                    "email": "john-stevenson@blueyonder.co.uk"
+                }
+            ],
+            "description": "Restarts a process without Xdebug.",
+            "keywords": [
+                "Xdebug",
+                "performance"
+            ],
+            "support": {
+                "irc": "irc://irc.freenode.org/composer",
+                "issues": "https://github.com/composer/xdebug-handler/issues",
+                "source": "https://github.com/composer/xdebug-handler/tree/2.0.2"
+            },
+            "funding": [
+                {
+                    "url": "https://packagist.com",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/composer",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-07-31T17:03:58+00:00"
+        },
+        {
+            "name": "felixfbecker/advanced-json-rpc",
+            "version": "v3.2.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git",
+                "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447",
+                "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447",
+                "shasum": ""
+            },
+            "require": {
+                "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
+                "php": "^7.1 || ^8.0",
+                "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^7.0 || ^8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "AdvancedJsonRpc\\": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "ISC"
+            ],
+            "authors": [
+                {
+                    "name": "Felix Becker",
+                    "email": "felix.b@outlook.com"
+                }
+            ],
+            "description": "A more advanced JSONRPC implementation",
+            "support": {
+                "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues",
+                "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1"
+            },
+            "time": "2021-06-11T22:34:44+00:00"
+        },
+        {
+            "name": "microsoft/tolerant-php-parser",
+            "version": "v0.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/microsoft/tolerant-php-parser.git",
+                "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/6a965617cf484355048ac6d2d3de7b6ec93abb16",
+                "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.2"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^8.5.15"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Microsoft\\PhpParser\\": [
+                        "src/"
+                    ]
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Rob Lourens",
+                    "email": "roblou@microsoft.com"
+                }
+            ],
+            "description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios",
+            "support": {
+                "issues": "https://github.com/microsoft/tolerant-php-parser/issues",
+                "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.1"
+            },
+            "time": "2021-07-16T21:28:12+00:00"
+        },
+        {
+            "name": "netresearch/jsonmapper",
+            "version": "v4.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/cweiske/jsonmapper.git",
+                "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d",
+                "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d",
+                "shasum": ""
+            },
+            "require": {
+                "ext-json": "*",
+                "ext-pcre": "*",
+                "ext-reflection": "*",
+                "ext-spl": "*",
+                "php": ">=7.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0",
+                "squizlabs/php_codesniffer": "~3.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "JsonMapper": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "OSL-3.0"
+            ],
+            "authors": [
+                {
+                    "name": "Christian Weiske",
+                    "email": "cweiske@cweiske.de",
+                    "homepage": "http://github.com/cweiske/jsonmapper/",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Map nested JSON structures onto PHP classes",
+            "support": {
+                "email": "cweiske@cweiske.de",
+                "issues": "https://github.com/cweiske/jsonmapper/issues",
+                "source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0"
+            },
+            "time": "2020-12-01T19:48:11+00:00"
+        },
+        {
+            "name": "nikic/php-parser",
+            "version": "v4.13.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/nikic/PHP-Parser.git",
+                "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd",
+                "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd",
+                "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.13.1"
+            },
+            "time": "2021-11-03T20:52:16+00:00"
+        },
+        {
+            "name": "phan/phan",
+            "version": "5.3.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phan/phan.git",
+                "reference": "42ee10d1d456d4c26b72035a8051487c864d712b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phan/phan/zipball/42ee10d1d456d4c26b72035a8051487c864d712b",
+                "reference": "42ee10d1d456d4c26b72035a8051487c864d712b",
+                "shasum": ""
+            },
+            "require": {
+                "composer/semver": "^1.4|^2.0|^3.0",
+                "composer/xdebug-handler": "^1.3.2|^2.0.0",
+                "ext-filter": "*",
+                "ext-json": "*",
+                "ext-tokenizer": "*",
+                "felixfbecker/advanced-json-rpc": "^3.0.4",
+                "microsoft/tolerant-php-parser": "^0.1.0",
+                "netresearch/jsonmapper": "^1.6.0|^2.0|^3.0|^4.0",
+                "php": "^7.2.0|^8.0.0",
+                "sabre/event": "^5.0.3",
+                "symfony/console": "^3.2|^4.0|^5.0",
+                "symfony/polyfill-mbstring": "^1.11.0",
+                "symfony/polyfill-php80": "^1.20.0",
+                "tysonandre/var_representation_polyfill": "^0.0.2|^0.1.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^8.5.0"
+            },
+            "suggest": {
+                "ext-ast": "Needed for parsing ASTs (unless --use-fallback-parser is used). 1.0.1+ is needed, 1.0.14+ is recommended.",
+                "ext-iconv": "Either iconv or mbstring is needed to ensure issue messages are valid utf-8",
+                "ext-igbinary": "Improves performance of polyfill when ext-ast is unavailable",
+                "ext-mbstring": "Either iconv or mbstring is needed to ensure issue messages are valid utf-8",
+                "ext-tokenizer": "Needed for fallback/polyfill parser support and file/line-based suppressions.",
+                "ext-var_representation": "Suggested for converting values to strings in issue messages"
+            },
+            "bin": [
+                "phan",
+                "phan_client",
+                "tocheckstyle"
+            ],
+            "type": "project",
+            "autoload": {
+                "psr-4": {
+                    "Phan\\": "src/Phan"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Tyson Andre"
+                },
+                {
+                    "name": "Rasmus Lerdorf"
+                },
+                {
+                    "name": "Andrew S. Morrison"
+                }
+            ],
+            "description": "A static analyzer for PHP",
+            "keywords": [
+                "analyzer",
+                "php",
+                "static"
+            ],
+            "support": {
+                "issues": "https://github.com/phan/phan/issues",
+                "source": "https://github.com/phan/phan/tree/5.3.0"
+            },
+            "time": "2021-11-13T16:53:42+00:00"
+        },
+        {
+            "name": "phpdocumentor/reflection",
+            "version": "4.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpDocumentor/Reflection.git",
+                "reference": "447928a45710d6313e68774cf12b5f730b909baa"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/447928a45710d6313e68774cf12b5f730b909baa",
+                "reference": "447928a45710d6313e68774cf12b5f730b909baa",
+                "shasum": ""
+            },
+            "require": {
+                "nikic/php-parser": "^4.0",
+                "php": ">=7.2",
+                "phpdocumentor/reflection-common": "^2.0",
+                "phpdocumentor/reflection-docblock": "^5",
+                "phpdocumentor/type-resolver": "^1.0",
+                "psr/log": "~1.0",
+                "webmozart/assert": "^1.0"
+            },
+            "require-dev": {
+                "mikey179/vfsstream": "~1.2",
+                "mockery/mockery": "~1.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-4.x": "4.1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "phpDocumentor\\": "src/phpDocumentor"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "Reflection library to do Static Analysis for PHP Projects",
+            "homepage": "http://www.phpdoc.org",
+            "keywords": [
+                "phpDocumentor",
+                "phpdoc",
+                "reflection",
+                "static analysis"
+            ],
+            "support": {
+                "issues": "https://github.com/phpDocumentor/Reflection/issues",
+                "source": "https://github.com/phpDocumentor/Reflection/tree/4.x"
+            },
+            "time": "2020-06-19T18:26:14+00:00"
+        },
+        {
+            "name": "phpdocumentor/reflection-common",
+            "version": "2.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
+                "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
+                "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-2.x": "2.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "phpDocumentor\\Reflection\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jaap van Otterdijk",
+                    "email": "opensource@ijaap.nl"
+                }
+            ],
+            "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
+            "homepage": "http://www.phpdoc.org",
+            "keywords": [
+                "FQSEN",
+                "phpDocumentor",
+                "phpdoc",
+                "reflection",
+                "static analysis"
+            ],
+            "support": {
+                "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
+                "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
+            },
+            "time": "2020-06-27T09:03:43+00:00"
+        },
+        {
+            "name": "phpdocumentor/reflection-docblock",
+            "version": "5.3.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
+                "reference": "622548b623e81ca6d78b721c5e029f4ce664f170"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170",
+                "reference": "622548b623e81ca6d78b721c5e029f4ce664f170",
+                "shasum": ""
+            },
+            "require": {
+                "ext-filter": "*",
+                "php": "^7.2 || ^8.0",
+                "phpdocumentor/reflection-common": "^2.2",
+                "phpdocumentor/type-resolver": "^1.3",
+                "webmozart/assert": "^1.9.1"
+            },
+            "require-dev": {
+                "mockery/mockery": "~1.3.2",
+                "psalm/phar": "^4.8"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "5.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "phpDocumentor\\Reflection\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mike van Riel",
+                    "email": "me@mikevanriel.com"
+                },
+                {
+                    "name": "Jaap van Otterdijk",
+                    "email": "account@ijaap.nl"
+                }
+            ],
+            "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
+            "support": {
+                "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
+                "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
+            },
+            "time": "2021-10-19T17:43:47+00:00"
+        },
+        {
+            "name": "phpdocumentor/type-resolver",
+            "version": "1.5.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpDocumentor/TypeResolver.git",
+                "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae",
+                "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0",
+                "phpdocumentor/reflection-common": "^2.0"
+            },
+            "require-dev": {
+                "ext-tokenizer": "*",
+                "psalm/phar": "^4.8"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-1.x": "1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "phpDocumentor\\Reflection\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mike van Riel",
+                    "email": "me@mikevanriel.com"
+                }
+            ],
+            "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
+            "support": {
+                "issues": "https://github.com/phpDocumentor/TypeResolver/issues",
+                "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1"
+            },
+            "time": "2021-10-02T14:08:47+00:00"
+        },
+        {
+            "name": "psr/container",
+            "version": "1.1.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/container.git",
+                "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
+                "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.4.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Container\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "https://www.php-fig.org/"
+                }
+            ],
+            "description": "Common Container Interface (PHP FIG PSR-11)",
+            "homepage": "https://github.com/php-fig/container",
+            "keywords": [
+                "PSR-11",
+                "container",
+                "container-interface",
+                "container-interop",
+                "psr"
+            ],
+            "support": {
+                "issues": "https://github.com/php-fig/container/issues",
+                "source": "https://github.com/php-fig/container/tree/1.1.2"
+            },
+            "time": "2021-11-05T16:50:12+00:00"
+        },
+        {
+            "name": "psr/log",
+            "version": "1.1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/log.git",
+                "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
+                "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Log\\": "Psr/Log/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "https://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interface for logging libraries",
+            "homepage": "https://github.com/php-fig/log",
+            "keywords": [
+                "log",
+                "psr",
+                "psr-3"
+            ],
+            "support": {
+                "source": "https://github.com/php-fig/log/tree/1.1.4"
+            },
+            "time": "2021-05-03T11:20:27+00:00"
+        },
+        {
+            "name": "sabre/event",
+            "version": "5.1.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sabre-io/event.git",
+                "reference": "d7da22897125d34d7eddf7977758191c06a74497"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sabre-io/event/zipball/d7da22897125d34d7eddf7977758191c06a74497",
+                "reference": "d7da22897125d34d7eddf7977758191c06a74497",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.1 || ^8.0"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "~2.17.1",
+                "phpstan/phpstan": "^0.12",
+                "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Sabre\\Event\\": "lib/"
+                },
+                "files": [
+                    "lib/coroutine.php",
+                    "lib/Loop/functions.php",
+                    "lib/Promise/functions.php"
+                ]
+            },
+            "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": "sabre/event is a library for lightweight event-based programming",
+            "homepage": "http://sabre.io/event/",
+            "keywords": [
+                "EventEmitter",
+                "async",
+                "coroutine",
+                "eventloop",
+                "events",
+                "hooks",
+                "plugin",
+                "promise",
+                "reactor",
+                "signal"
+            ],
+            "support": {
+                "forum": "https://groups.google.com/group/sabredav-discuss",
+                "issues": "https://github.com/sabre-io/event/issues",
+                "source": "https://github.com/fruux/sabre-event"
+            },
+            "time": "2021-11-04T06:51:17+00:00"
+        },
+        {
+            "name": "symfony/console",
+            "version": "v5.3.11",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/console.git",
+                "reference": "3e7ab8f5905058984899b05a4648096f558bfeba"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/console/zipball/3e7ab8f5905058984899b05a4648096f558bfeba",
+                "reference": "3e7ab8f5905058984899b05a4648096f558bfeba",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.2.5",
+                "symfony/deprecation-contracts": "^2.1",
+                "symfony/polyfill-mbstring": "~1.0",
+                "symfony/polyfill-php73": "^1.8",
+                "symfony/polyfill-php80": "^1.16",
+                "symfony/service-contracts": "^1.1|^2",
+                "symfony/string": "^5.1"
+            },
+            "conflict": {
+                "symfony/dependency-injection": "<4.4",
+                "symfony/dotenv": "<5.1",
+                "symfony/event-dispatcher": "<4.4",
+                "symfony/lock": "<4.4",
+                "symfony/process": "<4.4"
+            },
+            "provide": {
+                "psr/log-implementation": "1.0|2.0"
+            },
+            "require-dev": {
+                "psr/log": "^1|^2",
+                "symfony/config": "^4.4|^5.0",
+                "symfony/dependency-injection": "^4.4|^5.0",
+                "symfony/event-dispatcher": "^4.4|^5.0",
+                "symfony/lock": "^4.4|^5.0",
+                "symfony/process": "^4.4|^5.0",
+                "symfony/var-dumper": "^4.4|^5.0"
+            },
+            "suggest": {
+                "psr/log": "For using the console logger",
+                "symfony/event-dispatcher": "",
+                "symfony/lock": "",
+                "symfony/process": ""
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Component\\Console\\": ""
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Eases the creation of beautiful and testable command line interfaces",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "cli",
+                "command line",
+                "console",
+                "terminal"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/console/tree/v5.3.11"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-11-21T19:41:05+00:00"
+        },
+        {
+            "name": "symfony/deprecation-contracts",
+            "version": "v2.5.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/deprecation-contracts.git",
+                "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
+                "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "2.5-dev"
+                },
+                "thanks": {
+                    "name": "symfony/contracts",
+                    "url": "https://github.com/symfony/contracts"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "function.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "A generic function and convention to trigger deprecation notices",
+            "homepage": "https://symfony.com",
+            "support": {
+                "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-07-12T14:48:14+00:00"
+        },
+        {
+            "name": "symfony/phpunit-bridge",
+            "version": "v5.3.11",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/phpunit-bridge.git",
+                "reference": "7b3637f0ce55c510a0fbe6e4d49b223103b7bf7b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/7b3637f0ce55c510a0fbe6e4d49b223103b7bf7b",
+                "reference": "7b3637f0ce55c510a0fbe6e4d49b223103b7bf7b",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1.3",
+                "symfony/deprecation-contracts": "^2.1"
+            },
+            "conflict": {
+                "phpunit/phpunit": "<7.5|9.1.2"
+            },
+            "require-dev": {
+                "symfony/error-handler": "^4.4|^5.0"
+            },
+            "suggest": {
+                "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
+            },
+            "bin": [
+                "bin/simple-phpunit"
+            ],
+            "type": "symfony-bridge",
+            "extra": {
+                "thanks": {
+                    "name": "phpunit/phpunit",
+                    "url": "https://github.com/sebastianbergmann/phpunit"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "bootstrap.php"
+                ],
+                "psr-4": {
+                    "Symfony\\Bridge\\PhpUnit\\": ""
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Provides utilities for PHPUnit, especially user deprecation notices management",
+            "homepage": "https://symfony.com",
+            "support": {
+                "source": "https://github.com/symfony/phpunit-bridge/tree/v5.3.11"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-11-12T11:38:27+00:00"
+        },
+        {
+            "name": "symfony/polyfill-ctype",
+            "version": "v1.23.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-ctype.git",
+                "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
+                "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "suggest": {
+                "ext-ctype": "For best performance"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Ctype\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Gert de Pagter",
+                    "email": "BackEndTea@gmail.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for ctype functions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "ctype",
+                "polyfill",
+                "portable"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-02-19T12:13:01+00:00"
+        },
+        {
+            "name": "symfony/polyfill-intl-grapheme",
+            "version": "v1.23.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-intl-grapheme.git",
+                "reference": "16880ba9c5ebe3642d1995ab866db29270b36535"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535",
+                "reference": "16880ba9c5ebe3642d1995ab866db29270b36535",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "suggest": {
+                "ext-intl": "For best performance"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for intl's grapheme_* functions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "grapheme",
+                "intl",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-05-27T12:26:48+00:00"
+        },
+        {
+            "name": "symfony/polyfill-intl-normalizer",
+            "version": "v1.23.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
+                "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8",
+                "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "suggest": {
+                "ext-intl": "For best performance"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ],
+                "classmap": [
+                    "Resources/stubs"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for intl's Normalizer class and related functions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "intl",
+                "normalizer",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-02-19T12:13:01+00:00"
+        },
+        {
+            "name": "symfony/polyfill-mbstring",
+            "version": "v1.23.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-mbstring.git",
+                "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6",
+                "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "suggest": {
+                "ext-mbstring": "For best performance"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Mbstring\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for the Mbstring extension",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "mbstring",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-05-27T12:26:48+00:00"
+        },
+        {
+            "name": "symfony/polyfill-php73",
+            "version": "v1.23.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-php73.git",
+                "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010",
+                "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Php73\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ],
+                "classmap": [
+                    "Resources/stubs"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-02-19T12:13:01+00:00"
+        },
+        {
+            "name": "symfony/polyfill-php80",
+            "version": "v1.23.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-php80.git",
+                "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
+                "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.23-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Php80\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ],
+                "classmap": [
+                    "Resources/stubs"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Ion Bazan",
+                    "email": "ion.bazan@gmail.com"
+                },
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-07-28T13:41:28+00:00"
+        },
+        {
+            "name": "symfony/service-contracts",
+            "version": "v2.5.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/service-contracts.git",
+                "reference": "1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/service-contracts/zipball/1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc",
+                "reference": "1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.2.5",
+                "psr/container": "^1.1",
+                "symfony/deprecation-contracts": "^2.1"
+            },
+            "conflict": {
+                "ext-psr": "<1.1|>=2"
+            },
+            "suggest": {
+                "symfony/service-implementation": ""
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "2.5-dev"
+                },
+                "thanks": {
+                    "name": "symfony/contracts",
+                    "url": "https://github.com/symfony/contracts"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Contracts\\Service\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Generic abstractions related to writing services",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "abstractions",
+                "contracts",
+                "decoupling",
+                "interfaces",
+                "interoperability",
+                "standards"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/service-contracts/tree/v2.5.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-11-04T16:48:04+00:00"
+        },
+        {
+            "name": "symfony/string",
+            "version": "v5.3.10",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/string.git",
+                "reference": "d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/string/zipball/d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c",
+                "reference": "d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.2.5",
+                "symfony/polyfill-ctype": "~1.8",
+                "symfony/polyfill-intl-grapheme": "~1.0",
+                "symfony/polyfill-intl-normalizer": "~1.0",
+                "symfony/polyfill-mbstring": "~1.0",
+                "symfony/polyfill-php80": "~1.15"
+            },
+            "require-dev": {
+                "symfony/error-handler": "^4.4|^5.0",
+                "symfony/http-client": "^4.4|^5.0",
+                "symfony/translation-contracts": "^1.1|^2",
+                "symfony/var-exporter": "^4.4|^5.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Component\\String\\": ""
+                },
+                "files": [
+                    "Resources/functions.php"
+                ],
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "grapheme",
+                "i18n",
+                "string",
+                "unicode",
+                "utf-8",
+                "utf8"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/string/tree/v5.3.10"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-10-27T18:21:46+00:00"
+        },
+        {
+            "name": "tysonandre/var_representation_polyfill",
+            "version": "0.1.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/TysonAndre/var_representation_polyfill.git",
+                "reference": "0a942e74e18af5514749895507bc6ca7ab96399a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/TysonAndre/var_representation_polyfill/zipball/0a942e74e18af5514749895507bc6ca7ab96399a",
+                "reference": "0a942e74e18af5514749895507bc6ca7ab96399a",
+                "shasum": ""
+            },
+            "require": {
+                "ext-tokenizer": "*",
+                "php": "^7.2.0|^8.0.0"
+            },
+            "require-dev": {
+                "phan/phan": "^4.0",
+                "phpunit/phpunit": "^8.5.0"
+            },
+            "suggest": {
+                "ext-var_representation": "*"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "VarRepresentation\\": "src/VarRepresentation"
+                },
+                "files": [
+                    "src/var_representation.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Tyson Andre"
+                }
+            ],
+            "description": "Polyfill for var_representation: convert a variable to a string in a way that fixes the shortcomings of var_export",
+            "keywords": [
+                "var_export",
+                "var_representation"
+            ],
+            "support": {
+                "issues": "https://github.com/TysonAndre/var_representation_polyfill/issues",
+                "source": "https://github.com/TysonAndre/var_representation_polyfill/tree/0.1.1"
+            },
+            "time": "2021-08-16T00:12:50+00:00"
+        },
+        {
+            "name": "webmozart/assert",
+            "version": "1.10.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/webmozarts/assert.git",
+                "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25",
+                "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0",
+                "symfony/polyfill-ctype": "^1.8"
+            },
+            "conflict": {
+                "phpstan/phpstan": "<0.12.20",
+                "vimeo/psalm": "<4.6.1 || 4.6.2"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^8.5.13"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.10-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Webmozart\\Assert\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Bernhard Schussek",
+                    "email": "bschussek@gmail.com"
+                }
+            ],
+            "description": "Assertions to validate method input/output with nice error messages.",
+            "keywords": [
+                "assert",
+                "check",
+                "validate"
+            ],
+            "support": {
+                "issues": "https://github.com/webmozarts/assert/issues",
+                "source": "https://github.com/webmozarts/assert/tree/1.10.0"
+            },
+            "time": "2021-03-09T10:59:23+00:00"
+        }
+    ],
+    "aliases": [],
+    "minimum-stability": "stable",
+    "stability-flags": [],
+    "prefer-stable": false,
+    "prefer-lowest": false,
+    "platform": {
+        "php": ">=7.1"
+    },
+    "platform-dev": {
+        "ext-openssl": "*"
+    },
+    "plugin-api-version": "2.1.0"
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/favicon.png b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/favicon.png
new file mode 100644 (file)
index 0000000..6028c76
Binary files /dev/null and b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/favicon.png differ
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/creating-custom-presets.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/creating-custom-presets.md
new file mode 100644 (file)
index 0000000..1cfc622
--- /dev/null
@@ -0,0 +1,98 @@
+# Creating custom presets
+Presets are the way in which this library implements CIUS and extensions. You can find built-in presets in the
+`\Einvoicing\Presets` namespace.
+
+Defining a custom preset is, in most cases, a simple and quick process.
+You should start by creating a new class that extends `\Einvoicing\Presets\AbstractPreset`:
+```php
+namespace Acme\Invoicing\Presets;
+
+use Einvoicing\Presets\AbstractPreset;
+
+class CustomPreset extends AbstractPreset {
+    public function getSpecification(): string {
+        return "urn:cen.eu:en16931:2017#compliant#urn:acme.com:MY-PRESET:1.0.0";
+    }
+}
+```
+
+The only method you are required to define is `getSpecification()` as it returns the specification identifier of the
+CIUS/extension you're implementing.
+
+With that, you have created a working custom preset. Next time you instantiate an invoice from it, the latter will be
+set to the defined specification identifier:
+```php
+use Acme\Invoicing\Presets\CustomPreset;
+use Einvoicing\Invoice;
+
+$inv = new Invoice(CustomPreset::class);
+echo $inv->getSpecification(); // urn:cen.eu:en16931:2017#compliant#urn:acme.com:MY-PRESET:1.0.0
+```
+
+## Adding and removing business rules
+Some presets may require additional business rules for an invoice to be considered valid apart from the ones defined
+in the EN 16931, which will be enforced when calling [`Invoice::validate()`](../reference/invoice.md#validate).
+
+Given that rules are internally stored as PHP functions or callables, they can essentially be as complex as you need
+them to be.
+
+To add new rules to your preset, create a new method called `getRules()` in your preset class:
+```php
+use Einvoicing\Invoice;
+use Einvoicing\Presets\AbstractPreset;
+use function mb_strpos;
+
+class CustomPreset extends AbstractPreset {
+    // [...]
+
+    public function getRules(): array {
+        $res = [];
+
+        $res['BR-ACME-01'] = static function(Invoice $inv) {
+            if (!empty($inv->getAllowances())) return "No allowances at the invoice level are allowed";
+        };
+
+        $res['BR-ACME-02'] = static function(Invoice $inv) {
+            if (mb_strpos($inv->getNumber(), 'ACME-') !== 0) return "Invoice number must start with 'ACME-'";
+        };
+
+        return $res;
+    }
+}
+```
+
+As you can see in the above example, a rule returns `void` or **an empty value** when the invoice passes that particular
+validation, and a `string` detailing the non-compliance reason otherwise.
+
+!!! note
+    The order in which rules are defined matters, as they will be evaluated in the same fashion.
+    EN 16931 business rules are **always validated before** custom presets rules.
+
+Removing or modifying rules from the European standard is also possible by overriding them:
+```php
+$res['BR-03'] = static function(Invoice $inv) {
+    // Now this test (rule) will always pass
+};
+```
+
+## Custom invoice modifications
+There may be some occasions when presets will require to initialise the invoice instance with some default values.
+For example, setting a rounding matrix to define the number of decimal places allowed in certain fields.
+
+To achieve that, you can make use of the `setupInvoice()` method of a preset class, which will be called just before
+finishing creating a new invoice instance:
+```php
+use Einvoicing\Invoice;
+use Einvoicing\Presets\AbstractPreset;
+
+class CustomPreset extends AbstractPreset {
+    // [...]
+
+    public function setupInvoice(Invoice $invoice) {
+        $invoice->setRoundingMatrix([
+            "line/netAmount" => 4,
+            "" => 2
+        ]);
+    }
+}
+```
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/eu-einvoicing-concepts.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/eu-einvoicing-concepts.md
new file mode 100644 (file)
index 0000000..e307fec
--- /dev/null
@@ -0,0 +1,45 @@
+# EU e-Invoicing core concepts
+Prior to using this library, there are some key concepts about European e-Invoicing you should be aware of.
+
+## EN 16931
+The European e-Invoicing standard (EN 16931) describes the **semantic data model** and business rules of an electronic
+invoice. In other words, this document (specifically [part 1][1]) specificies **what an invoice is** (fields it must/can
+have) and the possible values those fields can contain.
+
+But that's it: it just gives an abstract definition of an invoice without getting into the technical structure (syntax).
+We need a format (or *formats*) for representing electronic invoices as documents (files), and the two specifications
+allowed by the standard are UBL and CII.
+
+The main purpose of this library is to represent invoices as defined by the European standard and convert them from/to
+its document representations in UBL or CII.
+
+## UBL and CII
+UBL (Universal Business Language) and CII (UN/CEFACT Cross Industry Invoice) are two XML-based specifications for
+exchanging business information. They both already existed prior to the European standard and were then chosen as the
+only supported syntaxes for representing invoice documents that comply with EN 16931.
+
+In theory, they can be used interchangeable with respect to EU e-invoices, although some exceptions may apply depending
+on additional business rules enforced by a CIUS or an extension.
+
+To determine which field from an European invoice goes to which UBL/CII XML node, there are [mappings][2] defined for
+both formats in parts 2 and 3 of the European standard.
+
+## CIUS and extensions
+Not all European member states have the same legislation (e.g. tax rates may not be the same across borders) nor all
+business sectors require the same set of fields to be present in an invoice (e.g. the energy sector may need a document
+to contain the meter info and meter readings of a client while others don't).
+
+To solve this problem, the European e-Invoicing standard proposes the use of CIUS ([Core Invoice Usage Specifications][3])
+and Extensions, which are **additional specifications** made by EU state governments or other stakeholders that add or
+remove business rules from the EN 16931.
+
+This way, the standard can stay uniform across all European members whilst providing enough flexibility for handling
+more particular cases, such us the ones mentioned before.
+
+The most popular CIUS is [PEPPOL BIS Billing 3.0][4], a cross-border specification used by multiple countries and
+international companies from both public and private sectors.
+
+[1]: https://ec.europa.eu/cefdigital/wiki/display/CEFDIGITAL/Navigating+the+eInvoicing+standard+documentation
+[2]: https://ec.europa.eu/cefdigital/wiki/display/CEFDIGITAL/Required+syntaxes
+[3]: https://ec.europa.eu/cefdigital/wiki/x/5xLoAg
+[4]: http://docs.peppol.eu/poacc/billing/3.0/
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/importing-exporting-and-validating.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/importing-exporting-and-validating.md
new file mode 100644 (file)
index 0000000..5bba43b
--- /dev/null
@@ -0,0 +1,66 @@
+# Importing, exporting and validating documents
+To switch between [`Invoice`](../reference/invoice.md) instances and UBL/CII documents, this library provides a set of
+readers and writers for importing and exporting invoices, respectively.
+For example, if you want to export an invoice to UBL, you'll have to use the [`UblWriter`](../reference/ubl-writer.md).
+
+## Exporting invoices
+Once you have a working invoice instance, create a writer to export it to a document. For example:
+```php
+use Einvoicing\Writers\UblWriter;
+
+$writer = new UblWriter();
+$document = $writer->export($inv);
+file_put_contents(__DIR__ . "/example.xml", $document);
+```
+
+## Importing documents
+Similar to exporting invoices, you need a reader to import a document into an invoice instance:
+```php
+use Einvoicing\Readers\UblReader;
+
+$reader = new UblReader();
+$document = file_get_contents(__DIR__ . "/example.xml");
+try {
+    $inv = $reader->import($document);
+} catch (\InvalidArgumentException $e) {
+    // Failed to parse XML document
+}
+```
+
+If the document you're importing has a custom CIUS/extension not supported by this library, you need to register the
+preset implementing that specification when instantiating the reader:
+```php
+use Einvoicing\Readers\UblReader;
+use Acme\Invoicing\Presets\CustomPreset;
+
+$reader = new UblReader();
+$reader->registerPreset(CustomPreset::class);
+$inv = $reader->import($document);
+```
+
+Check the [Creating custom presets](creating-custom-presets.md) page for more information.
+
+## Validating invoices
+It is good practice to validate an invoice against the business rules defined in the European standard and its preset
+(if using one) before exporting to and after importing from a document.
+
+This step is extremely simple as it only requires calling one method from the invoice instance:
+```php
+use Einvoicing\Exceptions\ValidationException;
+
+try {
+    $inv->validate();
+} catch (ValidationException $e) {
+    // The invoice is not valid (see exception for more details)
+}
+```
+
+The [`Invoice::validate()`](../reference/invoice.md#validate) method does not return any value and instead will throw an
+exception when the invoice is not valid.
+
+!!! warning
+    All readers and writers in this library are silent: they will read and export documents without throwing a
+    validation exception **even if the invoice is not valid**.
+
+    Unless you explicitly ask the invoice to be validated, you cannot be sure if it complies with the relevant
+    specifications.
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/installation.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/installation.md
new file mode 100644 (file)
index 0000000..9aacb43
--- /dev/null
@@ -0,0 +1,17 @@
+# Getting Started
+eInvoicing (short for "European Invoicing") is a free and open-source library written in PHP for creating and reading
+electronic invoices compliant with [EN 16931](https://ec.europa.eu/cefdigital/wiki/x/kwFVBg).
+
+## Requirements
+In order to install this library, your environment has to meet the following requirements:
+
+- PHP 7.1 or higher
+- [SimpleXML extension](https://www.php.net/book.simplexml) for reading and exporting UBL/CII invoices
+
+## Installation
+eInvoicing is distributed as a Composer package publicly available through Packagist, so installing it is as simple
+as adding it as a dependency to your project:
+
+```bash
+composer require josemmo/einvoicing
+```
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/your-first-invoice.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/getting-started/your-first-invoice.md
new file mode 100644 (file)
index 0000000..6129d36
--- /dev/null
@@ -0,0 +1,88 @@
+# Creating your first invoice
+There are two ways of creating an invoice from scratch: either instantiating a new blank
+[`Invoice`](../reference/invoice.md) or by using a preset (recommended).
+
+In this library, **presets** are the implementation of CIUS and extensions as defined in the European standard.
+Most probably, the CIUS you'll be using when creating invoices will be **PEPPOL BIS** as it is widely used in multiple
+countries and business sectors, but you can use any preset defined in the `\Einvoicing\Presets` namespace or even
+create a custom one yourself.
+
+To create a minimal valid invoice, you'll need four elements:
+
+- The invoice instance ([`Invoice`](../reference/invoice.md))
+- A seller party ([`Party`](../reference/party.md))
+- A buyer party ([`Party`](../reference/party.md))
+- Some invoice lines ([`InvoiceLine`](../reference/invoice-line.md))
+
+Start by creating the invoice instance:
+```php
+use DateTime;
+use Einvoicing\Invoice;
+use Einvoicing\Presets;
+
+$inv = new Invoice(Presets\Peppol::class);
+$inv->setNumber('F-202000012')
+    ->setIssueDate(new DateTime('2020-11-01'))
+    ->setDueDate(new DateTime('2020-11-30'));
+```
+
+!!! note
+    You can instantiate an invoice without passing a preset argument, although this is highly discouraged.
+    Setting a preset enhances the invoice in multiple aspects as it:
+
+    - Sets the correct specification identifier
+    - Overrides the number of decimal places of multiple fields
+    - Adds/removes custom validation rules defined by the CIUS or extension implemented by the preset
+
+    In short, it makes creating invoices easier.
+
+
+Then, declare both parties involved in the transaction (seller and buyer):
+```php
+use Einvoicing\Identifier;
+use Einvoicing\Party;
+
+$seller = new Party();
+$seller->setElectronicAddress(new Identifier('9482348239847239874', '0088'))
+    ->setCompanyId(new Identifier('AH88726', '0183'))
+    ->setName('Seller Name Ltd.')
+    ->setTradingName('Seller Name')
+    ->setVatNumber('ESA00000000')
+    ->setAddress(['Fake Street 123', 'Apartment Block 2B'])
+    ->setCity('Springfield')
+    ->setCountry('DE');
+$inv->setSeller($seller);
+
+$buyer = new Party();
+$buyer->setElectronicAddress(new Identifier('ES12345', '0002'))
+    ->setName('Buyer Name Ltd.')
+    ->setCountry('FR');
+$inv->setBuyer($buyer);
+```
+
+Lastly, add the invoice lines:
+```php
+use Einvoicing\InvoiceLine;
+
+// 4 items priced at €40/unit + 16% VAT
+$firstLine = new InvoiceLine();
+$firstLine->setName('Product Name')
+    ->setPrice(40)
+    ->setVatRate(16)
+    ->setQuantity(4);
+$inv->addLine($firstLine);
+
+// 27 items price at €10 per 5 units + 4% VAT
+$secondLine = new InvoiceLine();
+$secondLine->setName('Line #2')
+    ->setDescription('The description for the second line')
+    ->setPrice(10, 5)
+    ->setQuantity(27)
+    ->setVatRate(4);
+$inv->addLine($secondLine);
+```
+
+Congrats! You have successfully created your first EN 16931 compliant invoice.
+
+Now what's left is to export the invoice to a UBL/CII document that can be easily exchanged with third-parties.
+See the next chapter for more information.
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/index.md b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/index.md
new file mode 100644 (file)
index 0000000..341f878
--- /dev/null
@@ -0,0 +1,9 @@
+# European Invoicing (eInvoicing)
+
+eInvoicing is a PHP library for creating and reading electronic invoices according to the [eInvoicing Directive and European standard](https://ec.europa.eu/cefdigital/wiki/display/CEFDIGITAL/eInvoicing).
+
+It aims to be 100% compliant with [EN 16931](https://ec.europa.eu/cefdigital/wiki/x/kwFVBg) as well as with the most popular CIUS and extensions, such as [PEPPOL BIS](https://docs.peppol.eu/poacc/billing/3.0/bis/).
+
+[Get Started](getting-started/installation.md){: .md-button .md-button--primary }
+&nbsp;
+[Go to GitHub](https://github.com/josemmo/einvoicing){: .md-button }
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/logo-white.svg b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/logo-white.svg
new file mode 100644 (file)
index 0000000..2f504a7
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><g fill="#fff"><path d="M182 102c0-5-4-10-9-10H76a9 9 0 000 19h97c5 0 9-4 9-9zM76 130a9 9 0 000 18h59a9 9 0 000-18H76z"/><path d="M98 229H67c-10 0-19-8-19-19V46c0-11 9-19 19-19h115c10 0 19 8 19 19v57a9 9 0 0018 0V46c0-21-16-38-37-38H67C46 8 30 25 30 46v164c0 21 16 38 37 38h31a9 9 0 000-19z"/><path d="M173 55H76a9 9 0 000 19h97a9 9 0 000-19z"/></g><path fill="#fc0" d="M186 139l11 32 33 1c4 0 6 5 3 8l-27 20 10 32c1 4-3 8-7 5l-27-20-27 20c-3 3-8-1-7-5l10-32-27-20c-3-3-1-8 3-8l33-1 11-32c1-4 7-4 8 0z"/></svg>
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/logo.svg b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/logo.svg
new file mode 100644 (file)
index 0000000..cb20b35
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><g fill="#046cbb"><path d="M182 102c0-5-4-10-9-10H76a9 9 0 000 19h97c5 0 9-4 9-9zM76 130a9 9 0 000 18h59a9 9 0 000-18H76z"/><path d="M98 229H67c-10 0-19-8-19-19V46c0-11 9-19 19-19h115c10 0 19 8 19 19v57a9 9 0 0018 0V46c0-21-16-38-37-38H67C46 8 30 25 30 46v164c0 21 16 38 37 38h31a9 9 0 000-19z"/><path d="M173 55H76a9 9 0 000 19h97a9 9 0 000-19z"/></g><path fill="#fc0" d="M186 139l11 32 33 1c4 0 6 5 3 8l-27 20 10 32c1 4-3 8-7 5l-27-20-27 20c-3 3-8-1-7-5l10-32-27-20c-3-3-1-8 3-8l33-1 11-32c1-4 7-4 8 0z"/></svg>
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/reference/.gitignore b/htdocs/custom/peppol/vendor/josemmo/einvoicing/docs/reference/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/mkdocs.yml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/mkdocs.yml
new file mode 100644 (file)
index 0000000..6e0835e
--- /dev/null
@@ -0,0 +1,48 @@
+# Project configuration
+site_name: European Invoicing (eInvoicing)
+site_url: https://josemmo.github.io/einvoicing/
+repo_name: josemmo/einvoicing
+repo_url: https://github.com/josemmo/einvoicing
+edit_uri: ""
+
+# Theme customization
+theme:
+  name: material
+  logo: logo-white.svg
+  favicon: favicon.png
+  palette:
+    scheme: slate
+    primary: blue
+    accent: yellow
+  features:
+    - navigation.tabs
+
+# Plugins
+plugins:
+  - search
+  - minify:
+      minify_html: true
+
+# Extensions
+markdown_extensions:
+  - admonition
+  - attr_list
+  - toc:
+      permalink: true
+  - pymdownx.highlight:
+      extend_pygments_lang:
+        - name: php
+          lang: php
+          options:
+            startinline: true
+  - pymdownx.superfences
+
+# Table of Contents
+nav:
+  - Home: index.md
+  - Getting Started:
+    - Installation: getting-started/installation.md
+    - EU e-Invoicing core concepts: getting-started/eu-einvoicing-concepts.md
+    - Creating your first invoice: getting-started/your-first-invoice.md
+    - Importing, exporting and validating documents: getting-started/importing-exporting-and-validating.md
+    - Creating custom presets: getting-started/creating-custom-presets.md
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/phpunit.xml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/phpunit.xml
new file mode 100644 (file)
index 0000000..b53a53e
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<phpunit cacheResult="false" colors="true" bootstrap="vendor/autoload.php" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
+    <coverage processUncoveredFiles="true">
+        <include>
+            <directory suffix=".php">src</directory>
+        </include>
+    </coverage>
+    <testsuites>
+        <testsuite name="Tests">
+            <directory>tests</directory>
+        </testsuite>
+    </testsuites>
+</phpunit>
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/scripts/build-docs.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/scripts/build-docs.php
new file mode 100644 (file)
index 0000000..fd4f9a6
--- /dev/null
@@ -0,0 +1,289 @@
+<?php
+use phpDocumentor\Reflection\DocBlock;
+use phpDocumentor\Reflection\DocBlock\Tags\Param;
+use phpDocumentor\Reflection\DocBlock\Tags\Return_;
+use phpDocumentor\Reflection\DocBlock\Tags\Throws;
+use phpDocumentor\Reflection\DocBlock\Tags\Var_;
+use phpDocumentor\Reflection\File\LocalFile;
+use phpDocumentor\Reflection\Php\Class_;
+use phpDocumentor\Reflection\Php\Constant;
+use phpDocumentor\Reflection\Php\Method;
+use phpDocumentor\Reflection\Php\Property;
+use phpDocumentor\Reflection\Php\Trait_;
+use phpDocumentor\Reflection\Php\ProjectFactory;
+use phpDocumentor\Reflection\Php\Project;
+use phpDocumentor\Reflection\Php\Visibility;
+use phpDocumentor\Reflection\Type;
+use phpDocumentor\Reflection\Types\Compound;
+use phpDocumentor\Reflection\Types\Self_;
+use phpDocumentor\Reflection\Types\Array_;
+
+require __DIR__ . "/../vendor/autoload.php";
+
+const BASE_NAMESPACE = "\\Einvoicing\\";
+const SRC_DIR = __DIR__ . "/../src";
+const DOCS_DIR = __DIR__ . "/../docs";
+const MKDOCS_CONFIG = __DIR__ . "/../mkdocs.yml";
+
+/**
+ * Get project files
+ * @return Element[string] Array of documentable classes
+ */
+function getProjectFiles(): array {
+    $files = [];
+    foreach (glob(SRC_DIR . '/{,**/}*.php', GLOB_BRACE) as $path) {
+        $files[] = new LocalFile($path);
+    }
+
+    /** @var Project */
+    $project = ProjectFactory::createInstance()->create('Project', $files);
+
+    $res = [];
+    foreach ($project->getFiles() as $file) {
+        foreach ($file->getClasses() as $class) {
+            $res[(string) $class->getFqsen()] = $class;
+        }
+        foreach ($file->getTraits() as $trait) {
+            $res[(string) $trait->getFqsen()] = $trait;
+        }
+    }
+    return $res;
+}
+
+
+/**
+ * Get class public elements
+ * @param  Class_                         $class    Class instance
+ * @param  string                         $type     Element type ("constants", "properties" or "methods")
+ * @param  Element[string]                &$project Project files
+ * @return Constant[]|Property[]|Method[]           Public elements
+ */
+function getPublicElements(Class_ $class, string $type, array &$project): array {
+    $fn = "get" . ucfirst($type);
+    $res = $class->{$fn}();
+
+    // Elements from traits
+    foreach ($class->getUsedTraits() as $traitFqsen) {
+        /** @var Trait_ */
+        $trait = $project[(string) $traitFqsen];
+        $res = array_merge($res, $trait->{$fn}());
+    }
+
+    // Elements from parent class
+    /** @var Class_|null */
+    $parentClass = $project[(string) $class->getParent()] ?? null;
+    if ($parentClass !== null) {
+        $res = array_merge($res, getPublicElements($parentClass, $type, $project));
+    }
+
+    // Filter non-public elements
+    $res = array_filter($res, function($item) {
+        return ($item->getVisibility() == Visibility::PUBLIC_);
+    });
+
+    return $res;
+}
+
+
+/**
+ * Get class URL
+ * @param  string $fqsen Class FQSEN
+ * @return string        Documentation page URL
+ */
+function getClassUrl(string $fqsen): string {
+    $parts = explode('\\', $fqsen);
+    if (strpos($fqsen, BASE_NAMESPACE) === 0) {
+        $slug = strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', end($parts)));
+        return "$slug.md";
+    }
+    return "https://www.php.net/manual/class." . strtolower(end($parts)) . ".php";
+}
+
+
+/**
+ * Render class
+ * @param  Class_          $class    Class instance
+ * @param  Element[string] &$project Project files
+ * @return string                    Markdown documentation
+ */
+function renderClass(Class_ $class, array &$project): string {
+    $doc = "# {$class->getFqsen()}\n\n";
+    $docItems = [];
+
+    // Public properties
+    foreach (getPublicElements($class, 'properties', $project) as $property) {
+        $docItems[] = renderProperty($property, $class);
+    }
+
+    // Public methods
+    $methodsMap = [];
+    foreach (getPublicElements($class, 'methods', $project) as $method) {
+        $name = $method->getFqsen()->getName();
+        if ($method->getDocBlock()->hasTag('inheritdoc')) {
+            $methodsMap[$name]['additional'][] = $method->getDocBlock();
+        } else {
+            $methodsMap[$name]['main'] = $method;
+        }
+    }
+    foreach ($methodsMap as &$item) {
+        $docItems[] = renderMethod($item['main'], $item['additional'] ?? [], $class);
+    }
+
+    $doc .= implode("\n---\n\n", $docItems);
+    return $doc;
+}
+
+
+/**
+ * Render property
+ * @param  Property $property Property instance
+ * @param  Class_   $class    Class instance
+ * @return string             Rendered method in markdown
+ */
+function renderProperty(Property $property, Class_ $class): string {
+    $docblock = $property->getDocBlock();
+    /** @var Var_ */
+    $varTag = $docblock->getTagsByName('var')[0];
+    $defaultValue = $property->getDefault();
+
+    // Property summary
+    $doc = "## \${$property->getName()}\n";
+    $doc .= $docblock->getSummary() . "\n";
+
+    // Signature
+    $doc .= "\n```php\n";
+    $doc .= "public " . ($property->isStatic() ? "static " : "");
+    $doc .= renderType($varTag->getType(), $class, false) . " ";
+    $doc .= "$" . $property->getName();
+    if ($defaultValue !== null) {
+        $doc .= " = $defaultValue";
+    }
+    $doc .= "\n```\n";
+
+    return $doc;
+}
+
+
+/**
+ * Render method
+ * @param  Method     $method       Method instance
+ * @param  DocBlock[] $addDocblocks Additional DocBlocks (for inheritance)
+ * @param  Class_     $class        Class instance
+ * @return string                   Rendered method in markdown
+ */
+function renderMethod(Method $method, array $addDocblocks, Class_ $class): string {
+    $docblock = $method->getDocBlock();
+    /** @var Param[] */
+    $params = $docblock->getTagsByName('param');
+    $arguments = $method->getArguments();
+    /** @var Return_|null */
+    $return = $docblock->getTagsByName('return')[0] ?? null;
+
+    // Method summary
+    $doc = "## `{$method->getName()}()`\n";
+    $doc .= $docblock->getSummary() . "\n";
+
+    // Signature
+    $doc .= "\n```php\n";
+    $doc .= "public " . ($method->isStatic() ? "static " : "") . $method->getName() . "(";
+    $doc .= implode(', ', array_map(function($param, $i) use ($class, $arguments) {
+        $defaultValue = $arguments[$i]->getDefault();
+        return "\${$param->getVariableName()}: " . renderType($param->getType(), $class, false) .
+            ($defaultValue === null ? "" : " = $defaultValue");
+    }, $params, array_keys($params)));
+    $doc .= ")";
+    if ($return !== null) {
+        $doc .= ": " . renderType($return->getType(), $class, false);
+    }
+    $doc .= "\n```\n";
+
+    // Parameters
+    if (!empty($params)) {
+        $doc .= "\n";
+        $doc .= "<h3>Parameters</h3>\n\n";
+        foreach ($params as $param) {
+            $doc .= "- `\${$param->getVariableName()}`: " . renderType($param->getType(), $class);
+            $doc .= " — {$param->getDescription()}\n";
+        }
+    }
+
+    // Return type
+    if ($return !== null) {
+        $doc .= "\n";
+        $doc .= "<h3>Returns</h3>\n\n";
+        $doc .= "- " . renderType($return->getType(), $class) . " — {$return->getDescription()}\n";
+    }
+
+    // Throws
+    /** @var Throws[] */
+    $throws = $docblock->getTagsByName('throws');
+    foreach ($addDocblocks as $elem) {
+        $throws = array_merge($throws, $elem->getTagsByName('throws'));
+    }
+    if (!empty($throws)) {
+        $doc .= "\n";
+        $doc .= "<h3>Throws</h3>\n\n";
+        foreach ($throws as $item) {
+            $doc .= "- " . renderType($item->getType(), $class) . " {$item->getDescription()}\n";
+        }
+    }
+
+    return $doc;
+}
+
+
+/**
+ * Render type
+ * @param  Type    $type phpDoc type instance
+ * @param  Class_  $ctx  Context class
+ * @param  boolean $md   Return markdown
+ * @return string        Rendered type
+ */
+function renderType(Type $type, Class_ $ctx, bool $md=true): string {
+    if ($type instanceof Compound) {
+        $res = [];
+        foreach ($type as $elem) {
+            $res[] = renderType($elem, $ctx, $md);
+        }
+        return implode('|', $res);
+    }
+
+    if ($type instanceof Array_) {
+        return renderType($type->getValueType(), $ctx, $md) . "[]";
+    }
+
+    if ($type instanceof Self_) {
+        $fqsen = (string) $ctx->getFqsen();
+        return $md ? "[`$fqsen`](" . getClassUrl($fqsen) . ")" : $fqsen;
+    }
+
+    $type = (string) $type;
+    if (!$md) return $type;
+    if (strpos($type, '\\') === 0) {
+        return "[`$type`](" . getClassUrl($type) . ")";
+    }
+    return "`$type`";
+}
+
+
+// Generate classes documentation
+$project = getProjectFiles();
+$toc = [];
+foreach ($project as $fqsen=>$file) {
+    if (!$file instanceof Class_) continue;
+    if ($file->isAbstract()) continue;
+    $destPath = DOCS_DIR . "/reference/" . getClassUrl($fqsen);
+    $doc = renderClass($file, $project);
+    file_put_contents($destPath, $doc);
+    $toc[] = substr($fqsen, strlen(BASE_NAMESPACE)) . ": reference/" . getClassUrl($fqsen);
+    echo "[i] Generated documentation for $fqsen\n";
+}
+
+// Update Table of Contents
+$mkdocs = file_get_contents(MKDOCS_CONFIG);
+$mkdocs = rtrim($mkdocs);
+$mkdocs .= "\n";
+$mkdocs .= "  - Reference:\n";
+$mkdocs .= "    - " . implode("\n    - ", $toc) . "\n";
+file_put_contents(MKDOCS_CONFIG, $mkdocs);
+echo "[i] Updated Table of Contents\n";
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/AllowanceOrCharge.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/AllowanceOrCharge.php
new file mode 100644 (file)
index 0000000..a6ba33b
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+namespace Einvoicing;
+
+use Einvoicing\Traits\VatTrait;
+use function round;
+
+class AllowanceOrCharge {
+    protected $reasonCode = null;
+    protected $reason = null;
+    protected $amount = null;
+    protected $isPercentage = false;
+
+    use VatTrait;
+
+    /**
+     * Get reason code
+     * @return string|null Reason code
+     */
+    public function getReasonCode() {
+        return $this->reasonCode;
+    }
+
+
+    /**
+     * Set reason code
+     * @param  string|null $reasonCode Reason code
+     * @return self                    This instance
+     */
+    public function setReasonCode($reasonCode): self {
+        $this->reasonCode = $reasonCode;
+        return $this;
+    }
+
+
+    /**
+     * Get reason
+     * @return string|null Reason expressed as text
+     */
+    public function getReason() {
+        return $this->reason;
+    }
+
+
+    /**
+     * Set reason
+     * @param  string|null $reason Reason expressed as text
+     * @return self                This instance
+     */
+    public function setReason($reason): self {
+        $this->reason = $reason;
+        return $this;
+    }
+
+
+    /**
+     * Get amount
+     * @return float Allowance/charge amount
+     */
+    public function getAmount(): float {
+        return $this->amount;
+    }
+
+
+    /**
+     * Set amount
+     * @param  float $amount Allowance/charge amount
+     * @return self          This instance
+     */
+    public function setAmount(float $amount): self {
+        $this->amount = $amount;
+        return $this;
+    }
+
+
+    /**
+     * Is percentage
+     * @return boolean Whether amount is a percentage or not
+     */
+    public function isPercentage(): bool {
+        return $this->isPercentage;
+    }
+
+
+    /**
+     * Mark as percentage
+     * @return self This instance
+     */
+    public function markAsPercentage(): self {
+        $this->isPercentage = true;
+        return $this;
+    }
+
+    
+    /**
+     * Mark as fixed amount (not a percentage)
+     * @return self This instance
+     */
+    public function markAsFixedAmount(): self {
+        $this->isPercentage = false;
+        return $this;
+    }
+
+
+    /**
+     * Get effective amount relative to base amount
+     * @param  float $baseAmount Base amount
+     * @param  int   $decimals   Number of decimal places
+     * @return float             Effective amount
+     */
+    public function getEffectiveAmount(float $baseAmount, int $decimals): float {
+        $amount = $this->getAmount();
+        if ($this->isPercentage()) {
+            $amount = $baseAmount * ($amount / 100);
+        }
+        $amount = round($amount, $decimals);
+        return $amount;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Attachment.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Attachment.php
new file mode 100644 (file)
index 0000000..aee17fa
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+namespace Einvoicing;
+
+class Attachment {
+    protected $id = null;
+    protected $description = null;
+    protected $externalUrl = null;
+    protected $filename = null;
+    protected $mimeCode = null;
+    protected $contents = null;
+
+    /**
+     * Get attachment ID
+     * @return Identifier|null Attachment ID
+     */
+    public function getId() {
+        return $this->id;
+    }
+
+
+    /**
+     * Set attachment ID
+     * @param  Identifier|null $id Attachment ID
+     * @return self                Attachment instance
+     */
+    public function setId($id): self {
+        $this->id = $id;
+        return $this;
+    }
+
+
+    /**
+     * Get description
+     * @return string|null Attachment description
+     */
+    public function getDescription() {
+        return $this->description;
+    }
+
+
+    /**
+     * Set description
+     * @param  string|null $description Attachment description
+     * @return self                     Attachment instance
+     */
+    public function setDescription($description): self {
+        $this->description = $description;
+        return $this;
+    }
+
+
+    /**
+     * Has external URL
+     * @return boolean Whether this attachment has an external URL or not
+     */
+    public function hasExternalUrl(): bool {
+        return ($this->externalUrl !== null);
+    }
+
+
+    /**
+     * Get external URL
+     * @return string|null Attachment external URL
+     */
+    public function getExternalUrl() {
+        return $this->externalUrl;
+    }
+
+
+    /**
+     * Set external URL
+     * @param  string|null $externalUrl Attachment external URL
+     * @return self                     Attachment instance
+     */
+    public function setExternalUrl($externalUrl): self {
+        $this->externalUrl = $externalUrl;
+        return $this;
+    }
+
+
+    /**
+     * Get filename
+     * @return string|null Attachment filename
+     */
+    public function getFilename() {
+        return $this->filename;
+    }
+
+
+    /**
+     * Set filename
+     * @param  string|null $filename Attachment filename
+     * @return self                  Attachment instance
+     */
+    public function setFilename($filename): self {
+        $this->filename = $filename;
+        return $this;
+    }
+
+
+    /**
+     * Get mime code
+     * @return string|null Attachment mime code
+     */
+    public function getMimeCode() {
+        return $this->mimeCode;
+    }
+
+
+    /**
+     * Set mime code
+     * @param  string|null $mimeCode Attachment mime code
+     * @return self                  Attachment instance
+     */
+    public function setMimeCode($mimeCode): self {
+        $this->mimeCode = $mimeCode;
+        return $this;
+    }
+
+
+    /**
+     * Has embedded contents
+     * @return boolean Whether this attachment has embedded contents or not
+     */
+    public function hasContents(): bool {
+        return ($this->contents !== null);
+    }
+
+
+    /**
+     * Get embedded contents
+     * @return string|null Attachment contents
+     */
+    public function getContents() {
+        return $this->contents;
+    }
+
+
+    /**
+     * Set embedded contents
+     * @param  string|null $content Attachment contents
+     * @return self                 Attachment instance
+     * @param string|null $contents
+     */
+    public function setContents($contents): self {
+        $this->contents = $contents;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Attribute.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Attribute.php
new file mode 100644 (file)
index 0000000..63c2988
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+namespace Einvoicing;
+
+class Attribute {
+    protected $name;
+    protected $value;
+
+    /**
+     * Class constructor
+     * @param string $name  Attribute name
+     * @param string $value Attribute value
+     */
+    public function __construct(string $name, string $value) {
+        $this->setName($name);
+        $this->setValue($value);
+    }
+
+
+    /**
+     * Get attribute name
+     * @return string Attribute name
+     */
+    public function getName(): string {
+        return $this->name;
+    }
+
+
+    /**
+     * Set attribute name
+     * @param  string $name Attribute name
+     * @return self         Attribute instance
+     */
+    public function setName(string $name): self {
+        $this->name = $name;
+        return $this;
+    }
+
+
+    /**
+     * Get attribute value
+     * @return string Attribute value
+     */
+    public function getValue(): string {
+        return $this->value;
+    }
+
+
+    /**
+     * Set attribute value
+     * @param  string $value Attribute value
+     * @return self          Attribute instance
+     */
+    public function setValue(string $value): self {
+        $this->value = $value;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Delivery.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Delivery.php
new file mode 100644 (file)
index 0000000..53c8e12
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+namespace Einvoicing;
+
+use DateTime;
+use Einvoicing\Traits\PostalAddressTrait;
+
+class Delivery {
+    protected $name = null;
+    protected $date = null;
+    protected $locationIdentifier = null;
+
+    use PostalAddressTrait;
+
+    /**
+     * Get party name
+     * @return string|null Party name
+     */
+    public function getName() {
+        return $this->name;
+    }
+
+
+    /**
+     * Set party name
+     * @param  string|null $name Party name
+     * @return self              Delivery instance
+     */
+    public function setName($name): self {
+        $this->name = $name;
+        return $this;
+    }
+
+
+    /**
+     * Get actual delivery date
+     * @return DateTime|null Actual delivery date
+     */
+    public function getDate() {
+        return $this->date;
+    }
+
+
+    /**
+     * Set actual delivery date
+     * @param  DateTime|null $date Actual delivery date
+     * @return self                Delivery instance
+     */
+    public function setDate($date): self {
+        $this->date = $date;
+        return $this;
+    }
+
+
+    /**
+     * Get delivery location identifier
+     * @return Identifier|null Delivery location identifier
+     */
+    public function getLocationIdentifier() {
+        return $this->locationIdentifier;
+    }
+
+
+    /**
+     * Set delivery location identifier
+     * @param  Identifier|null $identifier Delivery location identifier
+     * @return self                        Delivery instance
+     */
+    public function setLocationIdentifier($identifier): self {
+        $this->locationIdentifier = $identifier;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Exceptions/ValidationException.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Exceptions/ValidationException.php
new file mode 100644 (file)
index 0000000..4d3e1ce
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+namespace Einvoicing\Exceptions;
+
+use Exception;
+
+class ValidationException extends Exception {
+    protected $businessRuleId;
+
+    /**
+     * Class constructor
+     * @param string      $message Exception message
+     * @param string|null $brId    Business rule ID
+     */
+    public function __construct(string $message, $brId=null) {
+        $this->businessRuleId = $brId;
+        parent::__construct($message);
+    }
+
+
+    /**
+     * Get business rule ID
+     * @return string|null Business rule ID
+     */
+    public function getBusinessRuleId() {
+        return $this->businessRuleId;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Identifier.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Identifier.php
new file mode 100644 (file)
index 0000000..415a9ec
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+namespace Einvoicing;
+
+class Identifier {
+    protected $value;
+    protected $scheme;
+
+    /**
+     * Class constructor
+     * @param string      $value  Value
+     * @param string|null $scheme Scheme ID
+     */
+    public function __construct(string $value, $scheme=null) {
+        $this->setValue($value);
+        $this->setScheme($scheme);
+    }
+
+
+    /**
+     * Get value
+     * @return string Value
+     */
+    public function getValue(): string {
+        return $this->value;
+    }
+
+
+    /**
+     * Set value
+     * @param  string $value Value
+     * @return self          Identifier instance
+     */
+    public function setValue(string $value): self {
+        $this->value = $value;
+        return $this;
+    }
+
+
+    /**
+     * Get scheme ID
+     * @return string|null Scheme ID
+     */
+    public function getScheme() {
+        return $this->scheme;
+    }
+
+
+    /**
+     * Set scheme ID
+     * @param  string|null $scheme Scheme ID
+     * @return self                Identifier instance
+     */
+    public function setScheme($scheme): self {
+        $this->scheme = $scheme;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Invoice.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Invoice.php
new file mode 100644 (file)
index 0000000..720f966
--- /dev/null
@@ -0,0 +1,572 @@
+<?php
+namespace Einvoicing;
+
+use DateTime;
+use Einvoicing\Models\InvoiceTotals;
+use Einvoicing\Payments\Payment;
+use Einvoicing\Presets\AbstractPreset;
+use Einvoicing\Traits\AllowanceOrChargeTrait;
+use Einvoicing\Traits\AttachmentsTrait;
+use Einvoicing\Traits\BuyerAccountingReferenceTrait;
+use Einvoicing\Traits\InvoiceValidationTrait;
+use Einvoicing\Traits\PeriodTrait;
+use Einvoicing\Traits\PrecedingInvoiceReferencesTrait;
+use InvalidArgumentException;
+use OutOfBoundsException;
+use function array_splice;
+use function count;
+use function is_subclass_of;
+use function round;
+
+class Invoice {
+    const DEFAULT_DECIMALS = 8;
+
+    protected $preset = null;
+    protected $roundingMatrix = null;
+    protected $specification = null;
+    protected $businessProcess = null;
+    protected $number = null;
+    protected $type = 380; // TODO: add constants
+    protected $currency = "EUR"; // TODO: add constants
+    protected $issueDate = null;
+    protected $dueDate = null;
+    protected $taxPointDate = null;
+    protected $note = null;
+    protected $buyerReference = null;
+    protected $purchaseOrderReference = null;
+    protected $salesOrderReference = null;
+    protected $tenderOrLotReference = null;
+    protected $contractReference = null;
+    protected $paidAmount = 0;
+    protected $roundingAmount = 0;
+    protected $seller = null;
+    protected $buyer = null;
+    protected $payee = null;
+    protected $delivery = null;
+    protected $payment = null;
+    protected $lines = [];
+
+    use AllowanceOrChargeTrait;
+    use AttachmentsTrait;
+    use BuyerAccountingReferenceTrait;
+    use PeriodTrait;
+    use InvoiceValidationTrait;
+    use PrecedingInvoiceReferencesTrait;
+
+    /**
+     * Invoice constructor
+     * @param string|null $preset Preset classname or NULL for blank invoice
+     * @throws InvalidArgumentException if not a valid preset
+     */
+    public function __construct($preset=null) {
+        if ($preset === null) return;
+
+        // Validate preset classname
+        if (!is_subclass_of($preset, AbstractPreset::class)) {
+            throw new InvalidArgumentException("$preset is not a valid invoice preset");
+        }
+        /** @var AbstractPreset */
+        $this->preset = new $preset();
+
+        // Initialize instance from preset
+        $this->setSpecification($this->preset->getSpecification());
+        $this->preset->setupInvoice($this);
+    }
+
+
+    /**
+     * Get number of decimal places for a given field
+     * @param  string $field Field name
+     * @return int           Number of decimal places
+     */
+    public function getDecimals(string $field): int {
+        return $this->roundingMatrix[$field] ?? $this->roundingMatrix[''] ?? self::DEFAULT_DECIMALS;
+    }
+
+
+    /**
+     * Set rounding matrix
+     * @param  array $matrix Rounding matrix
+     * @return self          Invoice instance
+     */
+    public function setRoundingMatrix(array $matrix): self {
+        $this->roundingMatrix = $matrix;
+        return $this;
+    }
+
+
+    /**
+     * Get specification identifier
+     * @return string|null Specification identifier
+     */
+    public function getSpecification() {
+        return $this->specification;
+    }
+
+
+    /**
+     * Set specification identifier
+     * @param  string $specification Specification identifier
+     * @return self                  Invoice instance
+     */
+    public function setSpecification(string $specification): self {
+        $this->specification = $specification;
+        return $this;
+    }
+
+
+    /**
+     * Get business process type
+     * @return string|null Business process type
+     */
+    public function getBusinessProcess() {
+        return $this->businessProcess;
+    }
+
+
+    /**
+     * Set business process type
+     * @param  string|null $businessProcess Business process type
+     * @return self                         Invoice instance
+     */
+    public function setBusinessProcess($businessProcess): self {
+        $this->businessProcess = $businessProcess;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice number
+     * @return string|null Invoice number
+     */
+    public function getNumber() {
+        return $this->number;
+    }
+
+
+    /**
+     * Set invoice number
+     * @param  string $number Invoice number
+     * @return self           Invoice instance
+     */
+    public function setNumber(string $number): self {
+        $this->number = $number;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice type code
+     * @return int Invoice type code
+     */
+    public function getType(): int {
+        return $this->type;
+    }
+
+
+    /**
+     * Set invoice type code
+     * @param  int  $typeCode Invoice type code
+     * @return self           Invoice instance
+     */
+    public function setType(int $typeCode): self {
+        $this->type = $typeCode;
+        return $this;
+    }
+
+
+    /**
+     * Get document currency code
+     * @return string Document currency code
+     */
+    public function getCurrency(): string {
+        return $this->currency;
+    }
+
+
+    /**
+     * Set document currency code
+     * @param  string $currencyCode Document currency code
+     * @return self                 Invoice instance
+     */
+    public function setCurrency(string $currencyCode): self {
+        $this->currency = $currencyCode;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice issue date
+     * @return DateTime|null Invoice issue date
+     */
+    public function getIssueDate() {
+        return $this->issueDate;
+    }
+
+
+    /**
+     * Set invoice issue date
+     * @param  DateTime $issueDate Invoice issue date
+     * @return self                Invoice instance
+     */
+    public function setIssueDate(DateTime $issueDate): self {
+        $this->issueDate = $issueDate;
+        return $this;
+    }
+
+
+    /**
+     * Get payment due date
+     * @return DateTime|null Payment due date
+     */
+    public function getDueDate() {
+        return $this->dueDate;
+    }
+
+
+    /**
+     * Set payment due date
+     * @param  DateTime|null $dueDate Payment due date
+     * @return self                   Invoice instance
+     */
+    public function setDueDate($dueDate): self {
+        $this->dueDate = $dueDate;
+        return $this;
+    }
+
+
+    /**
+     * Get tax point date
+     * @return DateTime|null Tax point date
+     */
+    public function getTaxPointDate() {
+        return $this->taxPointDate;
+    }
+
+
+    /**
+     * Set tax point date
+     * @param  DateTime|null $taxPointDate Tax point date
+     * @return self                        Invoice instance
+     */
+    public function setTaxPointDate($taxPointDate): self {
+        $this->taxPointDate = $taxPointDate;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice note
+     * @return string|null Invoice note
+     */
+    public function getNote() {
+        return $this->note;
+    }
+
+
+    /**
+     * Set invoice note
+     * @param  string|null $note Invoice note
+     * @return self              Invoice instance
+     */
+    public function setNote($note): self {
+        $this->note = $note;
+        return $this;
+    }
+
+
+    /**
+     * Get buyer reference
+     * @return string|null Buyer reference
+     */
+    public function getBuyerReference() {
+        return $this->buyerReference;
+    }
+
+
+    /**
+     * Set buyer reference
+     * @param  string|null $buyerReference Buyer reference
+     * @return self                        Invoice instance
+     */
+    public function setBuyerReference($buyerReference): self {
+        $this->buyerReference = $buyerReference;
+        return $this;
+    }
+
+
+    /**
+     * Get purchase order reference
+     * @return string|null Purchase order reference
+     */
+    public function getPurchaseOrderReference() {
+        return $this->purchaseOrderReference;
+    }
+
+
+    /**
+     * Set purchase order reference
+     * @param  string|null $purchaseOrderReference Purchase order reference
+     * @return self                                Invoice instance
+     */
+    public function setPurchaseOrderReference($purchaseOrderReference): self {
+        $this->purchaseOrderReference = $purchaseOrderReference;
+        return $this;
+    }
+
+
+    /**
+     * Get sales order reference
+     * @return string|null Sales order reference
+     */
+    public function getSalesOrderReference() {
+        return $this->salesOrderReference;
+    }
+
+
+    /**
+     * Set sales order reference
+     * @param  string|null $salesOrderReference Sales order reference
+     * @return self                             Invoice instance
+     */
+    public function setSalesOrderReference($salesOrderReference): self {
+        $this->salesOrderReference = $salesOrderReference;
+        return $this;
+    }
+
+
+    /**
+     * Get tender or lot reference
+     * @return string|null Tender or lot reference
+     */
+    public function getTenderOrLotReference() {
+        return $this->tenderOrLotReference;
+    }
+
+
+    /**
+     * Set tender or lot reference
+     * @param  string|null $tenderOrLotReference Tender or lot reference
+     * @return self                              Invoice instance
+     */
+    public function setTenderOrLotReference($tenderOrLotReference): self {
+        $this->tenderOrLotReference = $tenderOrLotReference;
+        return $this;
+    }
+
+
+    /**
+     * Get contract reference
+     * @return string|null Contract reference
+     */
+    public function getContractReference() {
+        return $this->contractReference;
+    }
+
+
+    /**
+     * Set contract reference
+     * @param  string|null $contractReference Contract reference
+     * @return self                           Invoice instance
+     */
+    public function setContractReference($contractReference): self {
+        $this->contractReference = $contractReference;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice prepaid amount
+     * NOTE: may be rounded according to the CIUS specification
+     * @return float Invoice prepaid amount
+     */
+    public function getPaidAmount(): float {
+        return round($this->paidAmount, $this->getDecimals('invoice/paidAmount'));
+    }
+
+
+    /**
+     * Set invoice prepaid amount
+     * @param  float $paidAmount Invoice prepaid amount
+     * @return self              Invoice instance
+     */
+    public function setPaidAmount(float $paidAmount): self {
+        $this->paidAmount = $paidAmount;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice rounding amount
+     * NOTE: may be rounded according to the CIUS specification
+     * @return float Invoice rounding amount
+     */
+    public function getRoundingAmount(): float {
+        return round($this->roundingAmount, $this->getDecimals('invoice/roundingAmount'));
+    }
+
+
+    /**
+     * Set invoice rounding amount
+     * @param  float $roundingAmount Invoice rounding amount
+     * @return self                  Invoice instance
+     */
+    public function setRoundingAmount(float $roundingAmount): self {
+        $this->roundingAmount = $roundingAmount;
+        return $this;
+    }
+
+
+    /**
+     * Get seller
+     * @return Party|null Seller instance
+     */
+    public function getSeller() {
+        return $this->seller;
+    }
+
+
+    /**
+     * Set seller
+     * @param  Party $seller Seller instance
+     * @return self          Invoice instance
+     */
+    public function setSeller(Party $seller): self {
+        $this->seller = $seller;
+        return $this;
+    }
+
+
+    /**
+     * Get buyer
+     * @return Party|null Buyer instance
+     */
+    public function getBuyer() {
+        return $this->buyer;
+    }
+
+
+    /**
+     * Set buyer
+     * @param  Party $buyer Buyer instance
+     * @return self          Invoice instance
+     */
+    public function setBuyer(Party $buyer): self {
+        $this->buyer = $buyer;
+        return $this;
+    }
+
+
+    /**
+     * Get payee
+     * @return Party|null Payee instance
+     */
+    public function getPayee() {
+        return $this->payee;
+    }
+
+
+    /**
+     * Set payee
+     * @param  Party|null $payee Payee instance
+     * @return self              Invoice instance
+     */
+    public function setPayee($payee): self {
+        $this->payee = $payee;
+        return $this;
+    }
+
+
+    /**
+     * Get delivery information
+     * @return Delivery|null Delivery instance
+     */
+    public function getDelivery() {
+        return $this->delivery;
+    }
+
+
+    /**
+     * Set delivery information
+     * @param  Delivery|null $delivery Delivery instance
+     * @return self                    Invoice instance
+     */
+    public function setDelivery($delivery): self {
+        $this->delivery = $delivery;
+        return $this;
+    }
+
+
+    /**
+     * Get payment information
+     * @return Payment|null Payment instance
+     */
+    public function getPayment() {
+        return $this->payment;
+    }
+
+
+    /**
+     * Set payment information
+     * @param  Payment|null $payment Payment instance
+     * @return self                  Invoice instance
+     */
+    public function setPayment($payment): self {
+        $this->payment = $payment;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice lines
+     * @return InvoiceLine[] Invoice lines
+     */
+    public function getLines(): array {
+        return $this->lines;
+    }
+
+
+    /**
+     * Add invoice line
+     * @param  InvoiceLine $line Invoice line instance
+     * @return self              Invoice instance
+     */
+    public function addLine(InvoiceLine $line): self {
+        $this->lines[] = $line;
+        return $this;
+    }
+
+
+    /**
+     * Remove invoice line
+     * @param  int  $index Invoice line index
+     * @return self        Invoice instance
+     * @throws OutOfBoundsException if line index is out of bounds
+     */
+    public function removeLine(int $index): self {
+        if ($index < 0 || $index >= count($this->lines)) {
+            throw new OutOfBoundsException('Could not find line by index inside invoice');
+        }
+        array_splice($this->lines, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all invoice lines
+     * @return self Invoice instance
+     */
+    public function clearLines(): self {
+        $this->lines = [];
+        return $this;
+    }
+
+
+    /**
+     * Get invoice total
+     * @return InvoiceTotals Invoice totals
+     */
+    public function getTotals(): InvoiceTotals {
+        return InvoiceTotals::fromInvoice($this);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/InvoiceLine.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/InvoiceLine.php
new file mode 100644 (file)
index 0000000..ccd5906
--- /dev/null
@@ -0,0 +1,356 @@
+<?php
+namespace Einvoicing;
+
+use Einvoicing\Traits\AllowanceOrChargeTrait;
+use Einvoicing\Traits\AttributesTrait;
+use Einvoicing\Traits\BuyerAccountingReferenceTrait;
+use Einvoicing\Traits\ClassificationIdentifiersTrait;
+use Einvoicing\Traits\PeriodTrait;
+use Einvoicing\Traits\VatTrait;
+use function round;
+
+class InvoiceLine {
+    protected $id = null;
+    protected $orderLineReference = null;
+    protected $name = null;
+    protected $description = null;
+    protected $originCountry = null;
+    protected $note = null;
+    protected $standardIdentifier = null;
+    protected $buyerIdentifier = null;
+    protected $sellerIdentifier = null;
+    protected $quantity = 1;
+    protected $unit = "C62"; // TODO: add constants
+    protected $price = null;
+    protected $baseQuantity = 1;
+
+    use AllowanceOrChargeTrait;
+    use AttributesTrait;
+    use BuyerAccountingReferenceTrait;
+    use ClassificationIdentifiersTrait;
+    use PeriodTrait;
+    use VatTrait;
+
+    /**
+     * Get invoice line identifier
+     * @return string|null
+     */
+    public function getId() {
+        return $this->id;
+    }
+
+
+    /**
+     * Set invoice line identifier
+     * @param  string $id Invoice line identifier
+     * @return self       Invoice line instance
+     */
+    public function setId(string $id): self {
+        $this->id = $id;
+        return $this;
+    }
+
+
+    /**
+     * Get order line reference
+     * @return string|null Order line reference
+     */
+    public function getOrderLineReference() {
+        return $this->orderLineReference;
+    }
+
+
+    /**
+     * Set order line reference
+     * @param  string|null $reference Order line reference
+     * @return self                   Invoice line instance
+     */
+    public function setOrderLineReference($reference): self {
+        $this->orderLineReference = $reference;
+        return $this;
+    }
+
+
+    /**
+     * Get item name
+     * @return string|null Item name
+     */
+    public function getName() {
+        return $this->name;
+    }
+
+
+    /**
+     * Set item name
+     * @param  string $name Item name
+     * @return self         Invoice line instance
+     */
+    public function setName(string $name): self {
+        $this->name = $name;
+        return $this;
+    }
+
+
+    /**
+     * Get item description
+     * @return string|null Item description
+     */
+    public function getDescription() {
+        return $this->description;
+    }
+
+
+    /**
+     * Set item description
+     * @param  string|null $description Item description
+     * @return self                     Invoice line instance
+     */
+    public function setDescription($description): self {
+        $this->description = $description;
+        return $this;
+    }
+
+
+    /**
+     * Get item origin country
+     * @return string|null Item origin country code
+     */
+    public function getOriginCountry() {
+        return $this->originCountry;
+    }
+
+
+    /**
+     * Set item origin country
+     * @param  string|null $originCountry Item origin country code
+     * @return self                       Invoice line instance
+     */
+    public function setOriginCountry($originCountry): self {
+        $this->originCountry = $originCountry;
+        return $this;
+    }
+
+
+    /**
+     * Get invoice line note
+     * @return string|null Invoice line note
+     */
+    public function getNote() {
+        return $this->note;
+    }
+
+
+    /**
+     * Set invoice line note
+     * @param  string|null $note Invoice line note
+     * @return self              Invoice line instance
+     */
+    public function setNote($note): self {
+        $this->note = $note;
+        return $this;
+    }
+
+
+    /**
+     * Get item standard identifier
+     * @return Identifier|null Item standard identifier
+     */
+    public function getStandardIdentifier() {
+        return $this->standardIdentifier;
+    }
+
+
+    /**
+     * Set item standard identifier
+     * @param  Identifier|null $identifier Item standard identifier
+     * @return self                        Invoice line instance
+     */
+    public function setStandardIdentifier($identifier): self {
+        $this->standardIdentifier = $identifier;
+        return $this;
+    }
+
+
+    /**
+     * Get buyer identifier
+     * @return string|null Buyer identifier
+     */
+    public function getBuyerIdentifier() {
+        return $this->buyerIdentifier;
+    }
+
+
+    /**
+     * Set buyer identifier
+     * @param  string|null $identifier Buyer identifier
+     * @return self                    Invoice line instance
+     */
+    public function setBuyerIdentifier($identifier): self {
+        $this->buyerIdentifier = $identifier;
+        return $this;
+    }
+
+
+    /**
+     * Get seller identifier
+     * @return string|null Seller identifier
+     */
+    public function getSellerIdentifier() {
+        return $this->sellerIdentifier;
+    }
+
+
+    /**
+     * Set seller identifier
+     * @param  string|null $identifier Seller identifier
+     * @return self                    Invoice line instance
+     */
+    public function setSellerIdentifier($identifier): self {
+        $this->sellerIdentifier = $identifier;
+        return $this;
+    }
+
+
+    /**
+     * Get quantity
+     * @return float Quantity
+     */
+    public function getQuantity(): float {
+        return $this->quantity;
+    }
+
+
+    /**
+     * Set quantity
+     * @param  float $quantity Quantity
+     * @return self            Invoice line instance
+     */
+    public function setQuantity(float $quantity): self {
+        $this->quantity = $quantity;
+        return $this;
+    }
+
+
+    /**
+     * Get unit code
+     * @return string Unit code
+     */
+    public function getUnit(): string {
+        return $this->unit;
+    }
+
+
+    /**
+     * Set unit code
+     * @param  string $unitCode Unit code
+     * @return self             Invoice line instance
+     */
+    public function setUnit(string $unitCode): self {
+        $this->unit = $unitCode;
+        return $this;
+    }
+
+
+    /**
+     * Get price
+     * @return float|null Price
+     */
+    public function getPrice() {
+        return $this->price;
+    }
+
+
+    /**
+     * Set price
+     * @param  float      $price        Price
+     * @param  float|null $baseQuantity Base quantity
+     * @return self                     Invoice line instance
+     */
+    public function setPrice(float $price, $baseQuantity=null): self {
+        $this->price = $price;
+        if ($baseQuantity !== null) {
+            $this->setBaseQuantity($baseQuantity);
+        }
+        return $this;
+    }
+
+
+    /**
+     * Get base quantity
+     * @return float Base quantity
+     */
+    public function getBaseQuantity(): float {
+        return $this->baseQuantity;
+    }
+
+
+    /**
+     * Set base quantity
+     * @param  float $baseQuantity Base quantity
+     * @return self                Invoice line instance
+     */
+    public function setBaseQuantity(float $baseQuantity): self {
+        $this->baseQuantity = $baseQuantity;
+        return $this;
+    }
+
+
+    /**
+     * Get total net amount (without VAT) before allowances/charges
+     * @param  int        $decimals Number of decimal places
+     * @return float|null           Net amount before allowances/charges
+     */
+    public function getNetAmountBeforeAllowancesCharges(int $decimals=Invoice::DEFAULT_DECIMALS) {
+        if ($this->price === null) {
+            return null;
+        }
+        return round(($this->price / $this->baseQuantity) * $this->quantity, $decimals);
+    }
+
+
+    /**
+     * Get allowances total amount
+     * @param  int   $decimals Number of decimal places
+     * @return float           Allowances total amount
+     */
+    public function getAllowancesAmount(int $decimals=Invoice::DEFAULT_DECIMALS): float {
+        $allowancesAmount = 0;
+        $baseAmount = $this->getNetAmountBeforeAllowancesCharges($decimals) ?? 0;
+        foreach ($this->getAllowances() as $item) {
+            $allowancesAmount += $item->getEffectiveAmount($baseAmount, $decimals);
+        }
+        return $allowancesAmount;
+    }
+
+
+    /**
+     * Get charges total amount
+     * @param  int   $decimals Number of decimal places
+     * @return float           Charges total amount
+     */
+    public function getChargesAmount(int $decimals=Invoice::DEFAULT_DECIMALS): float {
+        $chargesAmount = 0;
+        $baseAmount = $this->getNetAmountBeforeAllowancesCharges($decimals) ?? 0;
+        foreach ($this->getCharges() as $item) {
+            $chargesAmount += $item->getEffectiveAmount($baseAmount, $decimals);
+        }
+        return $chargesAmount;
+    }
+
+
+    /**
+     * Get total net amount (without VAT)
+     * NOTE: inclusive of line level allowances and charges
+     * @param  int        $decimals Number of decimal places
+     * @return float|null           Net amount
+     */
+    public function getNetAmount(int $decimals=Invoice::DEFAULT_DECIMALS) {
+        $netAmount = $this->getNetAmountBeforeAllowancesCharges($decimals);
+        if ($netAmount === null) {
+            return null;
+        }
+        $netAmount -= $this->getAllowancesAmount($decimals);
+        $netAmount += $this->getChargesAmount($decimals);
+        return $netAmount;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/InvoiceReference.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/InvoiceReference.php
new file mode 100644 (file)
index 0000000..ee6634b
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+namespace Einvoicing;
+
+use DateTime;
+
+class InvoiceReference {
+    protected $value;
+    protected $issueDate;
+
+    /**
+     * Class constructor
+     * @param string        $value     Value
+     * @param DateTime|null $issueDate Issue date
+     */
+    public function __construct(string $value, $issueDate=null) {
+        $this->setValue($value);
+        $this->setIssueDate($issueDate);
+    }
+
+
+    /**
+     * Get value
+     * @return string Value
+     */
+    public function getValue(): string {
+        return $this->value;
+    }
+
+
+    /**
+     * Set value
+     * @param  string $value Value
+     * @return self          Invoice reference instance
+     */
+    public function setValue(string $value): self {
+        $this->value = $value;
+        return $this;
+    }
+
+
+    /**
+     * Get issue date
+     * @return DateTime|null Issue date
+     */
+    public function getIssueDate() {
+        return $this->issueDate;
+    }
+
+
+    /**
+     * Set issue date
+     * @param  DateTime|null $issueDate Issue date
+     * @return self                     Invoice reference instance
+     */
+    public function setIssueDate($issueDate): self {
+        $this->issueDate = $issueDate;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Models/InvoiceTotals.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Models/InvoiceTotals.php
new file mode 100644 (file)
index 0000000..05992f2
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+namespace Einvoicing\Models;
+
+use Einvoicing\Invoice;
+use Einvoicing\Traits\VatTrait;
+use function array_values;
+use function round;
+
+class InvoiceTotals {
+    /**
+     * Totals currency code
+     * @var string
+     */
+    public $currency;
+
+    /** 
+     * Sum of all invoice line net amounts
+     * @var float
+     */
+    public $netAmount = 0;
+
+    /** 
+     * Sum of all allowances on document level
+     * @var float
+     */
+    public $allowancesAmount = 0;
+
+    /** 
+     * Sum of all charges on document level
+     * @var float
+     */
+    public $chargesAmount = 0;
+
+    /** 
+     * Total VAT amount for the invoice
+     * @var float
+     */
+    public $vatAmount = 0;
+
+    /** 
+     * Invoice total amount without VAT
+     * @var float
+     */
+    public $taxExclusiveAmount = 0;
+
+    /** 
+     * Invoice total amount with VAT
+     * @var float
+     */
+    public $taxInclusiveAmount = 0;
+    
+    /** 
+     * The sum of amounts which have been paid in advance
+     * @var float
+     */
+    public $paidAmount = 0;
+
+    /** 
+     * The amount to be added to the invoice total to round the amount to be paid
+     * @var float
+     */
+    public $roundingAmount = 0;
+
+    /** 
+     * Amount due for payment
+     * @var float
+     */
+    public $payableAmount = 0;
+
+    /**
+     * Group of business terms providing information about VAT breakdown
+     * @var VatBreakdown[]
+     */
+    public $vatBreakdown = [];
+
+    /**
+     * Create instance from invoice
+     * @param  Invoice $inv Invoice instance
+     * @return self         Totals instance
+     */
+    static public function fromInvoice(Invoice $inv): InvoiceTotals {
+        $totals = new self();
+        $vatMap = [];
+
+        // Set currency code
+        $totals->currency = $inv->getCurrency();
+
+        // Process all invoice lines
+        foreach ($inv->getLines() as $line) {
+            $lineNetAmount = $line->getNetAmount($inv->getDecimals('line/netAmount')) ?? 0;
+            $totals->netAmount += $lineNetAmount;
+            self::updateVatMap($vatMap, $line, $lineNetAmount);
+        }
+
+        // Apply allowance and charge totals
+        $allowancesChargesDecimals = $inv->getDecimals('invoice/allowancesChargesAmount');
+        foreach ($inv->getAllowances() as $item) {
+            $allowanceAmount = $item->getEffectiveAmount($totals->netAmount, $allowancesChargesDecimals);
+            $totals->allowancesAmount += $allowanceAmount;
+            self::updateVatMap($vatMap, $item, -$allowanceAmount);
+        }
+        foreach ($inv->getCharges() as $item) {
+            $chargeAmount = $item->getEffectiveAmount($totals->netAmount, $allowancesChargesDecimals);
+            $totals->chargesAmount += $chargeAmount;
+            self::updateVatMap($vatMap, $item, $chargeAmount);
+        }
+
+        // Calculate VAT amounts
+        foreach ($vatMap as $item) {
+            $item->taxAmount = $item->taxableAmount * ($item->rate / 100);
+            $item->taxAmount = round($item->taxAmount, $inv->getDecimals('invoice/taxAmount'));
+            $totals->vatAmount += $item->taxAmount;
+        }
+
+        // Calculate rest of properties
+        $totals->taxExclusiveAmount = $totals->netAmount - $totals->allowancesAmount + $totals->chargesAmount;
+        $totals->taxInclusiveAmount = $totals->taxExclusiveAmount + $totals->vatAmount;
+        $totals->paidAmount = $inv->getPaidAmount();
+        $totals->roundingAmount = $inv->getRoundingAmount();
+        $totals->payableAmount = $totals->taxInclusiveAmount - $totals->paidAmount + $totals->roundingAmount;
+
+        // Attach VAT breakdown
+        $totals->vatBreakdown = array_values($vatMap);
+
+        return $totals;
+    }
+
+
+    /**
+     * Update VAT map
+     * @param VatBreakdown[string] &$vatMap          VAT map reference
+     * @param VatTrait             $item             Item instance
+     * @param float|null           $rate             VAT rate
+     * @param float                $addTaxableAmount Taxable amount to add
+     */
+    static private function updateVatMap(array &$vatMap, $item, float $addTaxableAmount) {
+        $category = $item->getVatCategory();
+        $rate = $item->getVatRate();
+        $key = "$category:$rate";
+
+        // Initialize VAT breakdown
+        if (!isset($vatMap[$key])) {
+            $vatMap[$key] = new VatBreakdown();
+            $vatMap[$key]->category = $category;
+            $vatMap[$key]->rate = $rate;
+        }
+
+        // Update exemption reason (last item overwrites previous ones)
+        $exemptionReasonCode = $item->getVatExemptionReasonCode();
+        $exemptionReason = $item->getVatExemptionReason();
+        if ($exemptionReasonCode !== null) {
+            $vatMap[$key]->exemptionReasonCode = $exemptionReasonCode;
+        }
+        if ($exemptionReason !== null) {
+            $vatMap[$key]->exemptionReason = $exemptionReason;
+        }
+
+        // Increase taxable amount
+        $vatMap[$key]->taxableAmount += $addTaxableAmount;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Models/VatBreakdown.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Models/VatBreakdown.php
new file mode 100644 (file)
index 0000000..26e85a4
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace Einvoicing\Models;
+
+class VatBreakdown {
+    /**
+     * VAT category code
+     * @var string
+     */
+    public $category;
+
+    /**
+     * VAT rate as a percentage
+     * @var float|null
+     */
+    public $rate;
+
+    /**
+     * VAT exemption reason code
+     * @var string|null
+     */
+    public $exemptionReasonCode = null;
+
+    /**
+     * VAT exemption reason as text
+     * @var string|null
+     */
+    public $exemptionReason = null;
+
+    /**
+     * Sum of all taxable amounts
+     * @var float
+     */
+    public $taxableAmount = 0;
+
+    /**
+     * Total VAT amount
+     * @var float
+     */
+    public $taxAmount = 0;
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Party.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Party.php
new file mode 100644 (file)
index 0000000..95939dd
--- /dev/null
@@ -0,0 +1,208 @@
+<?php
+namespace Einvoicing;
+
+use Einvoicing\Traits\IdentifiersTrait;
+use Einvoicing\Traits\PostalAddressTrait;
+
+class Party {
+    protected $electronicAddress = null;
+    protected $name = null;
+    protected $tradingName = null;
+    protected $companyId = null;
+    protected $vatNumber = null;
+    protected $taxRegistrationId = null;
+    protected $contactName = null;
+    protected $contactPhone = null;
+    protected $contactEmail = null;
+
+    use IdentifiersTrait;
+    use PostalAddressTrait;
+
+    /**
+     * Get electronic address
+     * @return Identifier|null Electronic address
+     */
+    public function getElectronicAddress() {
+        return $this->electronicAddress;
+    }
+
+
+    /**
+     * Set electronic address
+     * @param  Identifier|null $electronicAddress Electronic address
+     * @return self                               Party instance
+     */
+    public function setElectronicAddress($electronicAddress): self {
+        $this->electronicAddress = $electronicAddress;
+        return $this;
+    }
+
+
+    /**
+     * Get party legal name
+     * @return string|null Party legal name
+     */
+    public function getName() {
+        return $this->name;
+    }
+
+
+    /**
+     * Set party legal name
+     * @param  string|null $name Party legal name
+     * @return self              Party instance
+     */
+    public function setName($name): self {
+        $this->name = $name;
+        return $this;
+    }
+
+
+    /**
+     * Get party trading name (also known as business name)
+     * @return string|null Party trading name
+     */
+    public function getTradingName() {
+        return $this->tradingName;
+    }
+
+
+    /**
+     * Set party trading name (also known as business name)
+     * @param  string|null $tradingName Party trading name
+     * @return self                     Party instance
+     */
+    public function setTradingName($tradingName): self {
+        $this->tradingName = $tradingName;
+        return $this;
+    }
+
+    
+    /**
+     * Get party company legal ID
+     * @return Identifier|null Party company legal ID
+     */
+    public function getCompanyId() {
+        return $this->companyId;
+    }
+
+
+    /**
+     * Set party company legal ID
+     * @param  Identifier|null $companyId Party company legal ID
+     * @return self                       Party instance
+     */
+    public function setCompanyId($companyId): self {
+        $this->companyId = $companyId;
+        return $this;
+    }
+
+
+    /**
+     * Get party VAT number
+     * @return string|null Party VAT number
+     */
+    public function getVatNumber() {
+        return $this->vatNumber;
+    }
+
+
+    /**
+     * Set party VAT number
+     * @param  string|null $vatNumber Party VAT number
+     * @return self                   Party instance
+     */
+    public function setVatNumber($vatNumber): self {
+        $this->vatNumber = $vatNumber;
+        return $this;
+    }
+
+
+    /**
+     * Get tax registration ID
+     * @return Identifier|null Tax registration ID
+     */
+    public function getTaxRegistrationId() {
+        return $this->taxRegistrationId;
+    }
+
+
+    /**
+     * Set tax registration ID
+     * @param  Identifier|null $taxRegistrationId Tax registration ID
+     * @return self                               Party instance
+     */
+    public function setTaxRegistrationId($taxRegistrationId): self {
+        $this->taxRegistrationId = $taxRegistrationId;
+        return $this;
+    }
+
+
+    /**
+     * Get contact point name
+     * @return string|null Contact name
+     */
+    public function getContactName() {
+        return $this->contactName;
+    }
+
+
+    /**
+     * Set contact point name
+     * @param  string|null $contactName Contact name
+     * @return self                     This instance
+     */
+    public function setContactName($contactName): self {
+        $this->contactName = $contactName;
+        return $this;
+    }
+
+
+    /**
+     * Get contact point phone number
+     * @return string|null Contact phone number
+     */
+    public function getContactPhone() {
+        return $this->contactPhone;
+    }
+
+
+    /**
+     * Set contact point phone number
+     * @param  string|null $contactPhone Contact phone number
+     * @return self                      This instance
+     */
+    public function setContactPhone($contactPhone): self {
+        $this->contactPhone = $contactPhone;
+        return $this;
+    }
+
+
+    /**
+     * Get contact point email addresss
+     * @return string|null Contact email address
+     */
+    public function getContactEmail() {
+        return $this->contactEmail;
+    }
+
+
+    /**
+     * Set contact point email address
+     * @param  string|null $contactEmail Contact email address
+     * @return self                      This instance
+     */
+    public function setContactEmail($contactEmail): self {
+        $this->contactEmail = $contactEmail;
+        return $this;
+    }
+
+
+    /**
+     * Has contact information
+     * @return boolean TRUE if party has any contact information, FALSE otherwise
+     */
+    public function hasContactInformation(): bool {
+        return ($this->contactName !== null) || ($this->contactPhone !== null) || ($this->contactEmail !== null);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Card.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Card.php
new file mode 100644 (file)
index 0000000..917ae51
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+namespace Einvoicing\Payments;
+
+class Card {
+    protected $pan = null;
+    protected $network = null;
+    protected $holder = null;
+
+    /**
+     * Get card PAN (Primary Account Number)
+     * @return string|null Card PAN
+     */
+    public function getPan() {
+        return $this->pan;
+    }
+
+
+    /**
+     * Set card PAN (Primary Account Number)
+     * @param  string $pan Card PAN
+     * @return self        Card instance
+     */
+    public function setPan(string $pan): self {
+        $this->pan = $pan;
+        return $this;
+    }
+
+
+    /**
+     * Get card network ID
+     * @return string|null Card network ID
+     */
+    public function getNetwork() {
+        return $this->network;
+    }
+
+
+    /**
+     * Set card network ID
+     * @param  string|null $network Card network ID
+     * @return self                 Card instance
+     */
+    public function setNetwork($network): self {
+        $this->network = $network;
+        return $this;
+    }
+
+
+    /**
+     * Get card holder name
+     * @return string|null Card holder name
+     */
+    public function getHolder() {
+        return $this->holder;
+    }
+
+
+    /**
+     * Set card holder name
+     * @param  string|null $holder Card holder name
+     * @return self                Card instance
+     */
+    public function setHolder($holder): self {
+        $this->holder = $holder;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Mandate.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Mandate.php
new file mode 100644 (file)
index 0000000..891b608
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace Einvoicing\Payments;
+
+class Mandate {
+    protected $reference = null;
+    protected $account = null;
+
+    /**
+     * Get mandate reference ID
+     * @return string|null Mandate reference ID
+     */
+    public function getReference() {
+        return $this->reference;
+    }
+
+
+    /**
+     * Set mandate reference ID
+     * @param  string|null $reference Mandate reference ID
+     * @return self                   Mandate instance
+     */
+    public function setReference($reference): self {
+        $this->reference = $reference;
+        return $this;
+    }
+
+
+    /**
+     * Get debited account ID
+     * @return string|null Debited account ID
+     */
+    public function getAccount() {
+        return $this->account;
+    }
+
+
+    /**
+     * Set debited account ID
+     * @param  string|null $account Debited account ID
+     * @return self                 Mandate instance
+     */
+    public function setAccount($account): self {
+        $this->account = $account;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Payment.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Payment.php
new file mode 100644 (file)
index 0000000..36eac34
--- /dev/null
@@ -0,0 +1,180 @@
+<?php
+namespace Einvoicing\Payments;
+
+use OutOfBoundsException;
+use function array_splice;
+use function count;
+
+class Payment {
+    protected $id = null;
+    protected $meansCode = null;
+    protected $meansText = null;
+    protected $terms = null;
+    protected $transfers = [];
+    protected $card = null;
+    protected $mandate = null;
+
+    /**
+     * Get payment ID
+     * @return string|null Payment ID
+     */
+    public function getId() {
+        return $this->id;
+    }
+
+
+    /**
+     * Set payment ID
+     * @param  string|null $id Payment ID
+     * @return self            Payment instance
+     */
+    public function setId($id): self {
+        $this->id = $id;
+        return $this;
+    }
+
+
+    /**
+     * Get payment means code
+     * @return string|null Payment means code
+     */
+    public function getMeansCode() {
+        return $this->meansCode;
+    }
+
+
+    /**
+     * Set payment means code
+     * @param  string $meansCode Payment means code
+     * @return self              Payment instance
+     */
+    public function setMeansCode(string $meansCode): self {
+        $this->meansCode = $meansCode;
+        return $this;
+    }
+
+
+    /**
+     * Get payment means text
+     * @return string|null Payment means text
+     */
+    public function getMeansText() {
+        return $this->meansText;
+    }
+
+
+    /**
+     * Set payment means text
+     * @param  string|null $meansText Payment means text
+     * @return self                   Payment instance
+     */
+    public function setMeansText($meansText): self {
+        $this->meansText = $meansText;
+        return $this;
+    }
+
+
+    /**
+     * Get payment terms
+     * @return string|null Payment terms
+     */
+    public function getTerms() {
+        return $this->terms;
+    }
+
+
+    /**
+     * Set payment terms
+     * @param  string|null $terms Payment terms
+     * @return self               Payment instance
+     */
+    public function setTerms($terms): self {
+        $this->terms = $terms;
+        return $this;
+    }
+
+
+    /**
+     * Get payment transfers
+     * @return Transfer[] Array of transfers
+     */
+    public function getTransfers(): array {
+        return $this->transfers;
+    }
+
+
+    /**
+     * Add payment transfers
+     * @param  Transfer $transfer Transfer instance
+     * @return self               Payment instance
+     */
+    public function addTransfer(Transfer $transfer): self {
+        $this->transfers[] = $transfer;
+        return $this;
+    }
+
+
+    /**
+     * Remove payment transfer
+     * @param  int  $index Transfer index
+     * @return self        Payment instance
+     * @throws OutOfBoundsException if transfer index is out of bounds
+     */
+    public function removeTransfer(int $index): self {
+        if ($index < 0 || $index >= count($this->transfers)) {
+            throw new OutOfBoundsException('Could not find transfer by index');
+        }
+        array_splice($this->transfers, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all payment transfers
+     * @return self Payment instance
+     */
+    public function clearTransfers(): self {
+        $this->transfers = [];
+        return $this;
+    }
+
+
+    /**
+     * Get payment card
+     * @return Card|null Card instance
+     */
+    public function getCard() {
+        return $this->card;
+    }
+
+
+    /**
+     * Set payment card
+     * @param  Card|null $card Card instance
+     * @return self            Payment instance
+     */
+    public function setCard($card): self {
+        $this->card = $card;
+        return $this;
+    }
+
+
+    /**
+     * Get payment mandate
+     * @return Mandate|null Mandate instance
+     */
+    public function getMandate() {
+        return $this->mandate;
+    }
+
+
+    /**
+     * Set payment mandate
+     * @param  Mandate|null $mandate Mandate instance
+     * @return self                  Payment instance
+     */
+    public function setMandate($mandate): self {
+        $this->mandate = $mandate;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Transfer.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Payments/Transfer.php
new file mode 100644 (file)
index 0000000..c2c726f
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+namespace Einvoicing\Payments;
+
+class Transfer {
+    protected $accountId = null;
+    protected $accountName = null;
+    protected $provider = null;
+
+    /**
+     * Get receiving account ID
+     * @return string|null Account ID
+     */
+    public function getAccountId() {
+        return $this->accountId;
+    }
+
+
+    /**
+     * Set receiving account ID
+     * @param  string $accountId Account ID
+     * @return self              Transfer instance
+     */
+    public function setAccountId(string $accountId): self {
+        $this->accountId = $accountId;
+        return $this;
+    }
+
+
+    /**
+     * Get receiving account name
+     * @return string|null Account name
+     */
+    public function getAccountName() {
+        return $this->accountName;
+    }
+
+
+    /**
+     * Set receiving account name
+     * @param  string|null $accountName Account name
+     * @return self                     Transfer instance
+     */
+    public function setAccountName($accountName): self {
+        $this->accountName = $accountName;
+        return $this;
+    }
+
+
+    /**
+     * Get service provider ID
+     * @return string|null Service provider ID
+     */
+    public function getProvider() {
+        return $this->provider;
+    }
+
+
+    /**
+     * Set service provider ID
+     * @param  string|null $provider Service provider ID
+     * @return self                  Transfer instance
+     */
+    public function setProvider($provider): self {
+        $this->provider = $provider;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/AbstractPreset.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/AbstractPreset.php
new file mode 100644 (file)
index 0000000..e391499
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace Einvoicing\Presets;
+
+use Einvoicing\Invoice;
+
+abstract class AbstractPreset {
+    /**
+     * Get specification identifier
+     * @return string Specification identifier
+     */
+    abstract public function getSpecification(): string;
+
+
+    /**
+     * Get additional validation rules
+     * @return array<string,callable> Map of rules
+     */
+    public function getRules(): array {
+        return [];
+    }
+
+
+    /**
+     * Setup invoice
+     * @param Invoice $invoice Invoice instance
+     */
+    public function setupInvoice(Invoice $invoice) {
+        $invoice->setRoundingMatrix(['' => 2]);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusAtGov.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusAtGov.php
new file mode 100644 (file)
index 0000000..45f7b89
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+namespace Einvoicing\Presets;
+
+/**
+ * CIUS-AT-GOV
+ * @author Bundesrechenzentrum (BRZ)
+ * @link https://www.erechnung.gv.at/files/en16931/CIUS-AT-GOV-XS-1.1.0.pdf
+ */
+class CiusAtGov extends CiusAtNat {
+    /**
+     * @inheritdoc
+     */
+    public function getSpecification(): string {
+        return parent::getSpecification() . "#compliant#urn:erechnung.gv.at:CIUS-AT-GOV:1.1.0";
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusAtNat.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusAtNat.php
new file mode 100644 (file)
index 0000000..c20a67b
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+namespace Einvoicing\Presets;
+
+/**
+ * CIUS-AT-NAT
+ * @author Bundesrechenzentrum (BRZ)
+ * @link https://www.erechnung.gv.at/files/en16931/CIUS-AT-NAT-XS-1.0.0.pdf
+ */
+class CiusAtNat extends AbstractPreset {
+    /**
+     * @inheritdoc
+     */
+    public function getSpecification(): string {
+        return "urn:cen.eu:en16931:2017#compliant#urn:erechnung.gv.at:CIUS-ATNAT:1.0.0";
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusEsFace.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusEsFace.php
new file mode 100644 (file)
index 0000000..3b005d2
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+namespace Einvoicing\Presets;
+
+/**
+ * CIUS-ES-FACE
+ * @author Spanish Government
+ * @link https://administracionelectronica.gob.es/ctt/face/descargas
+ */
+class CiusEsFace extends AbstractPreset {
+    /**
+     * @inheritdoc
+     */
+    public function getSpecification(): string {
+        return "urn:cen.eu:en16931:2017#compliant#urn:face.gob.es:CIUS-ES-FACE:1.0.0";
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusIt.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/CiusIt.php
new file mode 100644 (file)
index 0000000..26e63f2
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+namespace Einvoicing\Presets;
+
+/**
+ * CIUS-IT
+ * @author Agenzia delle Entrate (AdE)
+ * @link https://www.agenziaentrate.gov.it/portale/documents/20143/296874/Specifiche+Tecniche+Fatturazione+Europea+v1.1_ENG.pdf
+ */
+class CiusIt extends AbstractPreset {
+    /**
+     * @inheritdoc
+     */
+    public function getSpecification(): string {
+        return "urn:cen.eu:en16931:2017#compliant#urn:fatturapa.gov.it:CIUS-IT:1.0.0";
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/Peppol.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Presets/Peppol.php
new file mode 100644 (file)
index 0000000..a61eb7a
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+namespace Einvoicing\Presets;
+
+use Einvoicing\Invoice;
+
+// @phan-file-suppress PhanPluginInconsistentReturnFunction, PhanPossiblyNonClassMethodCall
+
+/**
+ * PEPPOL BIS Billing 3.0
+ * @author OpenPEPPOL
+ * @link https://docs.peppol.eu/poacc/billing/3.0/
+ */
+class Peppol extends AbstractPreset {
+    /**
+     * @inheritdoc
+     */
+    public function getSpecification(): string {
+        return "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0";
+    }
+
+
+    /**
+     * @inheritdoc
+     */
+    public function getRules(): array {
+        $res = [];
+
+        $res['PEPPOL-EN16931-R003'] = static function(Invoice $inv) {
+            if ($inv->getBuyerReference() !== null) return;
+            if ($inv->getPurchaseOrderReference() !== null) return;
+            return "A buyer reference or purchase order reference MUST be provided.";
+        };
+        $res['PEPPOL-EN16931-R061'] = static function(Invoice $inv) {
+            if ($inv->getPayment() === null) return;
+            if ($inv->getPayment()->getMandate() === null) return;
+            if ($inv->getPayment()->getMandate()->getReference() === null) {
+                return "Mandate reference MUST be provided for direct debit";
+            }
+        };
+        $res['BG-17'] = static function(Invoice $inv) {
+            if ($inv->getPayment() !== null && count($inv->getPayment()->getTransfers()) > 1) {
+                return "An Invoice shall not have multiple credit transfers";
+            }
+        };
+
+        return $res;
+    }
+
+
+    /**
+     * @inheritdoc
+     */
+    public function setupInvoice(Invoice $invoice) {
+        parent::setupInvoice($invoice);
+        $invoice->setBusinessProcess('urn:fdc:peppol.eu:2017:poacc:billing:01:1.0');
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Readers/AbstractReader.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Readers/AbstractReader.php
new file mode 100644 (file)
index 0000000..03eaa22
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+namespace Einvoicing\Readers;
+
+use Einvoicing\Invoice;
+use Einvoicing\Presets\AbstractPreset;
+use InvalidArgumentException;
+use function is_subclass_of;
+use function scandir;
+use function str_replace;
+
+abstract class AbstractReader {
+    private static $defaultPresets = null;
+    protected $additionalPresets = [];
+
+    /**
+     * Load default presets
+     * @return void
+     */
+    private static function loadDefaultPresets() {
+        self::$defaultPresets = [];
+        foreach (scandir(__DIR__ . '/../Presets') as $filename) {
+            $classname = "\\Einvoicing\\Presets\\" . str_replace('.php', '', $filename);
+
+            // Is this a valid preset?
+            if (!is_subclass_of($classname, AbstractPreset::class)) {
+                continue;
+            }
+
+            /** @var AbstractPreset */
+            $preset = new $classname();
+            self::$defaultPresets[$preset->getSpecification()] = $classname;
+        }
+    }
+
+
+    /**
+     * Get preset classname from specification
+     * @param  string      $specification Specification identifier
+     * @return string|null                Preset classname or NULL if not found
+     */
+    protected function getPresetFromSpecification(string $specification) {
+        if (self::$defaultPresets === null) {
+            self::loadDefaultPresets();
+        }
+        return $this->additionalPresets[$specification] ?? self::$defaultPresets[$specification] ?? null;
+    }
+
+
+    /**
+     * Register additional preset
+     * @param  string $classname Preset classname
+     * @return self              This instance
+     * @throws InvalidArgumentException if not a valid preset classname
+     */
+    public function registerPreset(string $classname): self {
+        if (!is_subclass_of($classname, AbstractPreset::class)) {
+            throw new InvalidArgumentException("Cannot register $classname as an invoice preset");
+        }
+        /** @var AbstractPreset */
+        $preset = new $classname();
+        $this->additionalPresets[$preset->getSpecification()] = $classname;
+        return $this;
+    }
+
+
+    /**
+     * Import invoice
+     * @param  string  $document Document contents
+     * @return Invoice           Invoice instance
+     */
+    abstract public function import(string $document): Invoice;
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Readers/UblReader.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Readers/UblReader.php
new file mode 100644 (file)
index 0000000..c549d58
--- /dev/null
@@ -0,0 +1,857 @@
+<?php
+namespace Einvoicing\Readers;
+
+use DateTime;
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Attachment;
+use Einvoicing\Attribute;
+use Einvoicing\Delivery;
+use Einvoicing\Identifier;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\InvoiceReference;
+use Einvoicing\Party;
+use Einvoicing\Payments\Card;
+use Einvoicing\Payments\Mandate;
+use Einvoicing\Payments\Payment;
+use Einvoicing\Payments\Transfer;
+use Einvoicing\Traits\VatTrait;
+use Einvoicing\Writers\UblWriter;
+use InvalidArgumentException;
+use UXML\UXML;
+use function array_filter;
+use function array_map;
+
+class UblReader extends AbstractReader {
+    /**
+     * @inheritdoc
+     * @throws InvalidArgumentException if failed to parse XML
+     */
+    public function import(string $document): Invoice {
+        $invoice = new Invoice();
+
+        // Load XML document
+        $xml = UXML::fromString($document);
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-24: Specification identifier
+        $specificationNode = $xml->get("{{$cbc}}CustomizationID");
+        if ($specificationNode !== null) {
+            $specification = $specificationNode->asText();
+            $invoice->setSpecification($specification);
+
+            // Try to create from preset
+            $presetClassname = $this->getPresetFromSpecification($specification);
+            if ($presetClassname !== null) {
+                $invoice = new Invoice($presetClassname);
+            }
+        }
+
+        // Index tax exemption reasons
+        /** @var array<string, array{code: string|null, reason: string|null}> */
+        $taxExemptions = [];
+        foreach ($xml->getAll("{{$cac}}TaxTotal/{{$cac}}TaxSubtotal/{{$cac}}TaxCategory") as $node) {
+            $exemptionReasonCodeNode = $node->get("{{$cbc}}TaxExemptionReasonCode");
+            $exemptionReasonNode = $node->get("{{$cbc}}TaxExemptionReason");
+            if ($exemptionReasonCodeNode === null && $exemptionReasonNode === null) continue;
+
+            // Get tax subtotal key
+            $category = $node->get("{{$cbc}}ID")->asText(); // @phan-suppress-current-line PhanPossiblyNonClassMethodCall
+            $rate = (float) $node->get("{{$cbc}}Percent")->asText(); // @phan-suppress-current-line PhanPossiblyNonClassMethodCall
+            $key = "$category:$rate";
+
+            // Save reasons
+            $taxExemptions[$key] = [
+                "code" => ($exemptionReasonCodeNode === null) ? null : $exemptionReasonCodeNode->asText(),
+                "reason" => ($exemptionReasonNode === null) ? null : $exemptionReasonNode->asText(),
+            ];
+        }
+
+        // BT-23: Business process type
+        $businessProcessNode = $xml->get("{{$cbc}}ProfileID");
+        if ($businessProcessNode !== null) {
+            $invoice->setBusinessProcess($businessProcessNode->asText());
+        }
+
+        // BT-1: Invoice number
+        $numberNode = $xml->get("{{$cbc}}ID");
+        if ($numberNode !== null) {
+            $invoice->setNumber($numberNode->asText());
+        }
+
+        // BT-2: Issue date
+        $issueDateNode = $xml->get("{{$cbc}}IssueDate");
+        if ($issueDateNode !== null) {
+            $invoice->setIssueDate(new DateTime($issueDateNode->asText()));
+        }
+
+        // BT-9: Due date
+        $dueDateNode = $xml->get("{{$cbc}}DueDate");
+        if ($dueDateNode !== null) {
+            $invoice->setDueDate(new DateTime($dueDateNode->asText()));
+        }
+
+        // BT-3: Invoice type code
+        $typeNode = $xml->get("{{$cbc}}InvoiceTypeCode");
+        if ($typeNode !== null) {
+            $invoice->setType((int) $typeNode->asText());
+        }
+
+        // BT-22: Note
+        $noteNode = $xml->get("{{$cbc}}Note");
+        if ($noteNode !== null) {
+            $invoice->setNote($noteNode->asText());
+        }
+
+        // BT-7: Tax point date
+        $taxPointDateNode = $xml->get("{{$cbc}}TaxPointDate");
+        if ($taxPointDateNode !== null) {
+            $invoice->setTaxPointDate(new DateTime($taxPointDateNode->asText()));
+        }
+
+        // BT-5: Invoice currency code
+        $currencyNode = $xml->get("{{$cbc}}DocumentCurrencyCode");
+        if ($currencyNode !== null) {
+            $invoice->setCurrency($currencyNode->asText());
+        }
+
+        // BT-19: Buyer accounting reference
+        $buyerAccountingReferenceNode = $xml->get("{{$cbc}}AccountingCost");
+        if ($buyerAccountingReferenceNode !== null) {
+            $invoice->setBuyerAccountingReference($buyerAccountingReferenceNode->asText());
+        }
+
+        // BT-10: Buyer reference
+        $buyerReferenceNode = $xml->get("{{$cbc}}BuyerReference");
+        if ($buyerReferenceNode !== null) {
+            $invoice->setBuyerReference($buyerReferenceNode->asText());
+        }
+
+        // BG-14: Invoice period
+        $this->parsePeriodFields($xml, $invoice);
+
+        // BT-13: Purchase order reference
+        $purchaseOrderReferenceNode = $xml->get("{{$cac}}OrderReference/{{$cbc}}ID");
+        if ($purchaseOrderReferenceNode !== null) {
+            $invoice->setPurchaseOrderReference($purchaseOrderReferenceNode->asText());
+        }
+
+        // BT-14: Sales order reference
+        $salesOrderReferenceNode = $xml->get("{{$cac}}OrderReference/{{$cbc}}SalesOrderID");
+        if ($salesOrderReferenceNode !== null) {
+            $invoice->setSalesOrderReference($salesOrderReferenceNode->asText());
+        }
+
+        // BG-3: Preceding invoice references
+        foreach ($xml->getAll("{{$cac}}BillingReference/{{$cac}}InvoiceDocumentReference") as $node) {
+            $invoiceReferenceValueNode = $node->get("{{$cbc}}ID");
+            if ($invoiceReferenceValueNode === null) {
+                continue;
+            }
+            $invoiceReference = new InvoiceReference($invoiceReferenceValueNode->asText());
+            $invoiceReferenceIssueDateNode = $node->get("{{$cbc}}IssueDate");
+            if ($invoiceReferenceIssueDateNode !== null) {
+                $invoiceReference->setIssueDate(new DateTime($invoiceReferenceIssueDateNode->asText()));
+            }
+            $invoice->addPrecedingInvoiceReference($invoiceReference);
+        }
+
+        // BT-17: Tender or lot reference
+        $tenderOrLotReferenceNode = $xml->get("{{$cac}}OriginatorDocumentReference/{{$cbc}}ID");
+        if ($tenderOrLotReferenceNode !== null) {
+            $invoice->setTenderOrLotReference($tenderOrLotReferenceNode->asText());
+        }
+
+        // BT-12: Contract reference
+        $contractReferenceNode = $xml->get("{{$cac}}ContractDocumentReference/{{$cbc}}ID");
+        if ($contractReferenceNode !== null) {
+            $invoice->setContractReference($contractReferenceNode->asText());
+        }
+
+        // BG-24: Attachment nodes
+        foreach ($xml->getAll("{{$cac}}AdditionalDocumentReference") as $node) {
+            $invoice->addAttachment($this->parseAttachmentNode($node));
+        }
+
+        // Seller node
+        $sellerNode = $xml->get("{{$cac}}AccountingSupplierParty/{{$cac}}Party");
+        if ($sellerNode !== null) {
+            $invoice->setSeller($this->parseSellerOrBuyerNode($sellerNode));
+        }
+
+        // Buyer node
+        $buyerNode = $xml->get("{{$cac}}AccountingCustomerParty/{{$cac}}Party");
+        if ($buyerNode !== null) {
+            $invoice->setBuyer($this->parseSellerOrBuyerNode($buyerNode));
+        }
+
+        // Payee node
+        $payeeNode = $xml->get("{{$cac}}PayeeParty");
+        if ($payeeNode !== null) {
+            $invoice->setPayee($this->parsePayeeNode($payeeNode));
+        }
+
+        // Delivery node
+        $deliveryNode = $xml->get("{{$cac}}Delivery");
+        if ($deliveryNode !== null) {
+            $invoice->setDelivery($this->parseDeliveryNode($deliveryNode));
+        }
+
+        // Payment nodes
+        $payment = $this->parsePaymentNodes($xml);
+        $invoice->setPayment($payment);
+
+        // Allowances and charges
+        foreach ($xml->getAll("{{$cac}}AllowanceCharge") as $node) {
+            $this->addAllowanceOrCharge($invoice, $node, $taxExemptions);
+        }
+
+        // BT-113: Paid amount
+        $paidAmountNode = $xml->get("{{$cac}}LegalMonetaryTotal/{{$cbc}}PrepaidAmount");
+        if ($paidAmountNode !== null) {
+            $invoice->setPaidAmount((float) $paidAmountNode->asText());
+        }
+
+        // BT-114: Rounding amount
+        $roundingAmountNode = $xml->get("{{$cac}}LegalMonetaryTotal/{{$cbc}}PayableRoundingAmount");
+        if ($roundingAmountNode !== null) {
+            $invoice->setRoundingAmount((float) $roundingAmountNode->asText());
+        }
+
+        // Invoice lines
+        foreach ($xml->getAll("{{$cac}}InvoiceLine") as $node) {
+            $invoice->addLine($this->parseInvoiceLine($node, $taxExemptions));
+        }
+
+        return $invoice;
+    }
+
+
+    /**
+     * Parse identifier node
+     * @param  UXML       $xml        XML node
+     * @param  string     $schemeAttr Scheme attribute name
+     * @return Identifier             Identifier instance
+     */
+    private function parseIdentifierNode(UXML $xml, string $schemeAttr="schemeID"): Identifier {
+        $value = $xml->asText();
+        $scheme = $xml->element()->hasAttribute($schemeAttr) ? $xml->element()->getAttribute($schemeAttr) : null;
+        return new Identifier($value, $scheme);
+    }
+
+
+    /**
+     * Parse period fields
+     * @param UXML                $xml    XML node
+     * @param Invoice|InvoiceLine $target Destination instance
+     */
+    private function parsePeriodFields(UXML $xml, $target) {
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // Period start date
+        $startDateNode = $xml->get("{{$cac}}InvoicePeriod/{{$cbc}}StartDate");
+        if ($startDateNode !== null) {
+            $target->setPeriodStartDate(new DateTime($startDateNode->asText()));
+        }
+
+        // Period end date
+        $endDateNode = $xml->get("{{$cac}}InvoicePeriod/{{$cbc}}EndDate");
+        if ($endDateNode !== null) {
+            $target->setPeriodEndDate(new DateTime($endDateNode->asText()));
+        }
+    }
+
+
+    /**
+     * Parse postal address fields
+     * @param UXML           $xml    XML node
+     * @param Delivery|Party $target Destination instance
+     */
+    private function parsePostalAddressFields(UXML $xml, $target) {
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // Postal address
+        $addressNodes = array_filter([
+            $xml->get("{{$cbc}}StreetName"),
+            $xml->get("{{$cbc}}AdditionalStreetName"),
+            $xml->get("{{$cac}}AddressLine/{{$cbc}}Line")
+        ]);
+        $addressLines = array_map(function($node) {
+            return $node->asText();
+        }, $addressNodes);
+        // @phan-suppress-next-line PhanThrowTypeAbsentForCall
+        $target->setAddress($addressLines);
+
+        // City name
+        $cityNode = $xml->get("{{$cbc}}CityName");
+        if ($cityNode !== null) {
+            $target->setCity($cityNode->asText());
+        }
+
+        // Postal code
+        $postalCodeNode = $xml->get("{{$cbc}}PostalZone");
+        if ($postalCodeNode !== null) {
+            $target->setPostalCode($postalCodeNode->asText());
+        }
+
+        // Subdivision
+        $subdivisionNode = $xml->get("{{$cbc}}CountrySubentity");
+        if ($subdivisionNode !== null) {
+            $target->setSubdivision($subdivisionNode->asText());
+        }
+
+        // Country
+        $countryNode = $xml->get("{{$cac}}Country/{{$cbc}}IdentificationCode");
+        if ($countryNode !== null) {
+            $target->setCountry($countryNode->asText());
+        }
+    }
+
+
+    /**
+     * Parse seller or buyer node
+     * @param  UXML  $xml XML node
+     * @return Party      Party instance
+     */
+    private function parseSellerOrBuyerNode(UXML $xml): Party {
+        $party = new Party();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // Electronic address
+        $electronicAddressNode = $xml->get("{{$cbc}}EndpointID");
+        if ($electronicAddressNode !== null) {
+            $party->setElectronicAddress($this->parseIdentifierNode($electronicAddressNode));
+        }
+
+        // Additional identifiers
+        foreach ($xml->getAll("{{$cac}}PartyIdentification/{{$cbc}}ID") as $identifierNode) {
+            $party->addIdentifier($this->parseIdentifierNode($identifierNode));
+        }
+
+        // Trading name
+        $tradingNameNode = $xml->get("{{$cac}}PartyName/{{$cbc}}Name");
+        if ($tradingNameNode !== null) {
+            $party->setTradingName($tradingNameNode->asText());
+        }
+
+        // Postal address
+        $addressNode = $xml->get("{{$cac}}PostalAddress");
+        if ($addressNode !== null) {
+            $this->parsePostalAddressFields($addressNode, $party);
+        }
+
+        // VAT number and tax registration identifier
+        foreach ($xml->getAll("{{$cac}}PartyTaxScheme") as $taxNode) {
+            $companyIdNode = $taxNode->get("{{$cbc}}CompanyID");
+            if ($companyIdNode === null) continue;
+            $companyId = $companyIdNode->asText();
+
+            $taxSchemeNode = $taxNode->get("{{$cac}}TaxScheme/{{$cbc}}ID");
+            $taxScheme = ($taxSchemeNode === null) ? null : $taxSchemeNode->asText();
+
+            if ($taxScheme === "VAT") {
+                $party->setVatNumber($companyId);
+            } else {
+                $party->setTaxRegistrationId(new Identifier($companyId, $taxScheme));
+            }
+        }
+
+        // Legal name
+        $legalNameNode = $xml->get("{{$cac}}PartyLegalEntity/{{$cbc}}RegistrationName");
+        if ($legalNameNode !== null) {
+            $party->setName($legalNameNode->asText());
+        }
+        
+        // Company ID
+        $companyIdNode = $xml->get("{{$cac}}PartyLegalEntity/{{$cbc}}CompanyID");
+        if ($companyIdNode !== null) {
+            $party->setCompanyId($this->parseIdentifierNode($companyIdNode));
+        }
+
+        // Contact name
+        $contactNameNode = $xml->get("{{$cac}}Contact/{{$cbc}}Name");
+        if ($contactNameNode !== null) {
+            $party->setContactName($contactNameNode->asText());
+        }
+
+        // Contact phone
+        $contactPhoneNode = $xml->get("{{$cac}}Contact/{{$cbc}}Telephone");
+        if ($contactPhoneNode !== null) {
+            $party->setContactPhone($contactPhoneNode->asText());
+        }
+
+        // Contact email
+        $contactEmailNode = $xml->get("{{$cac}}Contact/{{$cbc}}ElectronicMail");
+        if ($contactEmailNode !== null) {
+            $party->setContactEmail($contactEmailNode->asText());
+        }
+
+        return $party;
+    }
+
+
+    /**
+     * Parse payee node
+     * @param  UXML  $xml XML node
+     * @return Party      Party instance
+     */
+    private function parsePayeeNode(UXML $xml): Party {
+        $party = new Party();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // Additional identifiers
+        foreach ($xml->getAll("{{$cac}}PartyIdentification/{{$cbc}}ID") as $identifierNode) {
+            $party->addIdentifier($this->parseIdentifierNode($identifierNode));
+        }
+
+        // Party name
+        $nameNode = $xml->get("{{$cac}}PartyName/{{$cbc}}Name");
+        if ($nameNode !== null) {
+            $party->setName($nameNode->asText());
+        }
+
+        // Company ID
+        $companyIdNode = $xml->get("{{$cac}}PartyLegalEntity/{{$cbc}}CompanyID");
+        if ($companyIdNode !== null) {
+            $party->setCompanyId($this->parseIdentifierNode($companyIdNode));
+        }
+
+        return $party;
+    }
+
+
+    /**
+     * Parse delivery node
+     * @param  UXML     $xml XML node
+     * @return Delivery      Delivery instance
+     */
+    private function parseDeliveryNode(UXML $xml): Delivery {
+        $delivery = new Delivery();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-72: Actual delivery date
+        $dateNode = $xml->get("{{$cbc}}ActualDeliveryDate");
+        if ($dateNode !== null) {
+            $delivery->setDate(new DateTime($dateNode->asText()));
+        }
+
+        // BT-71: Delivery location identifier
+        $locationIdentifierNode = $xml->get("{{$cac}}DeliveryLocation/{{$cbc}}ID");
+        if ($locationIdentifierNode !== null) {
+            $delivery->setLocationIdentifier($this->parseIdentifierNode($locationIdentifierNode));
+        }
+
+        // Delivery postal address
+        $addressNode = $xml->get("{{$cac}}DeliveryLocation/{{$cac}}Address");
+        if ($addressNode !== null) {
+            $this->parsePostalAddressFields($addressNode, $delivery);
+        }
+
+        // BT-70: Deliver name
+        $nameNode = $xml->get("{{$cac}}DeliveryParty/{{$cac}}PartyName/{{$cbc}}Name");
+        if ($nameNode !== null) {
+            $delivery->setName($nameNode->asText());
+        }
+
+        return $delivery;
+    }
+
+
+    /**
+     * Parse payment nodes
+     * @param  UXML         $xml XML node
+     * @return Payment|null      Payment instance or NULL if not found
+     */
+    private function parsePaymentNodes(UXML $xml) {
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // Get root nodes
+        $meansNode = $xml->get("{{$cac}}PaymentMeans");
+        $termsNode = $xml->get("{{$cac}}PaymentTerms/{{$cbc}}Note");
+        if ($meansNode === null && $termsNode === null) return null;
+
+        $payment = new Payment();
+
+        // BT-81: Payment means code
+        // BT-82: Payment means name
+        $meansCodeNode = $xml->get("{{$cac}}PaymentMeans/{{$cbc}}PaymentMeansCode");
+        if ($meansCodeNode !== null) {
+            $payment->setMeansCode($meansCodeNode->asText());
+            if ($meansCodeNode->element()->hasAttribute('name')) {
+                $payment->setMeansText($meansCodeNode->element()->getAttribute('name'));
+            }
+        }
+
+        // BT-83: Payment ID
+        $paymentIdNode = $xml->get("{{$cac}}PaymentMeans/{{$cbc}}PaymentID");
+        if ($paymentIdNode !== null) {
+            $payment->setId($paymentIdNode->asText());
+        }
+
+        // BG-18: Payment card
+        $cardNode = $xml->get("{{$cac}}PaymentMeans/{{$cac}}CardAccount");
+        if ($cardNode !== null) {
+            $payment->setCard($this->parsePaymentCardNode($cardNode));
+        }
+
+        // BG-17: Payment transfers
+        $transferNodes = $xml->getAll("{{$cac}}PaymentMeans/{{$cac}}PayeeFinancialAccount");
+        foreach ($transferNodes as $transferNode) {
+            $payment->addTransfer($this->parsePaymentTransferNode($transferNode));
+        }
+
+        // BG-19: Payment mandate
+        $mandateNode = $xml->get("{{$cac}}PaymentMeans/{{$cac}}PaymentMandate");
+        if ($mandateNode !== null) {
+            $payment->setMandate($this->parsePaymentMandateNode($mandateNode));
+        }
+
+        // BT-20: Payment terms
+        if ($termsNode !== null) {
+            $payment->setTerms($termsNode->asText());
+        }
+
+        return $payment;
+    }
+
+
+    /**
+     * Parse payment card node
+     * @param  UXML $xml Payment card node
+     * @return Card      Card instance
+     */
+    private function parsePaymentCardNode(UXML $xml): Card {
+        $card = new Card();
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-87: Card PAN
+        $panNode = $xml->get("{{$cbc}}PrimaryAccountNumberID");
+        if ($panNode !== null) {
+            $card->setPan($panNode->asText());
+        }
+
+        // Card network
+        $networkNode = $xml->get("{{$cbc}}NetworkID");
+        if ($networkNode !== null) {
+            $card->setNetwork($networkNode->asText());
+        }
+
+        // BT-88: Holder name
+        $holderNode = $xml->get("{{$cbc}}HolderName");
+        if ($holderNode !== null) {
+            $card->setHolder($holderNode->asText());
+        }
+
+        return $card;
+    }
+
+
+    /**
+     * Parse payment transfer node
+     * @param  UXML     $xml Payment transfer node
+     * @return Transfer      Transfer instance
+     */
+    private function parsePaymentTransferNode(UXML $xml): Transfer {
+        $transfer = new Transfer();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-84: Receiving account ID
+        $accountIdNode = $xml->get("{{$cbc}}ID");
+        if ($accountIdNode !== null) {
+            $transfer->setAccountId($accountIdNode->asText());
+        }
+
+        // BT-85: Receiving account name
+        $accountNameNode = $xml->get("{{$cbc}}Name");
+        if ($accountNameNode !== null) {
+            $transfer->setAccountName($accountNameNode->asText());
+        }
+
+        // BT-86: Service provider ID
+        $providerNode = $xml->get("{{$cac}}FinancialInstitutionBranch/{{$cbc}}ID");
+        if ($providerNode !== null) {
+            $transfer->setProvider($providerNode->asText());
+        }
+
+        return $transfer;
+    }
+
+
+    /**
+     * Parse payment mandate node
+     * @param  UXML    $xml Payment mandate node
+     * @return Mandate      Mandate instance
+     */
+    private function parsePaymentMandateNode(UXML $xml): Mandate {
+        $mandate = new Mandate();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-89: Mandate reference
+        $referenceNode = $xml->get("{{$cbc}}ID");
+        if ($referenceNode !== null) {
+            $mandate->setReference($referenceNode->asText());
+        }
+
+        // BT-91: Debited account
+        $accountNode = $xml->get("{{$cac}}PayerFinancialAccount/{{$cbc}}ID");
+        if ($accountNode !== null) {
+            $mandate->setAccount($accountNode->asText());
+        }
+
+        return $mandate;
+    }
+
+
+    /**
+     * Set VAT attributes
+     * @param VatTrait $target         Target instance
+     * @param UXML     $xml            XML node
+     * @param array    &$taxExemptions Tax exemption reasons
+     */
+    private function setVatAttributes($target, UXML $xml, array $taxExemptions) {
+        $cbc = UblWriter::NS_CBC;
+
+        // Tax category
+        $taxCategoryNode = $xml->get("{{$cbc}}ID");
+        if ($taxCategoryNode !== null) {
+            $target->setVatCategory($taxCategoryNode->asText());
+        }
+
+        // Tax rate
+        $taxRateNode = $xml->get("{{$cbc}}Percent");
+        if ($taxRateNode !== null) {
+            $target->setVatRate((float) $taxRateNode->asText());
+        }
+
+        // Tax exemption reasons
+        $key = "{$target->getVatCategory()}:{$target->getVatRate()}";
+        $target->setVatExemptionReasonCode($taxExemptions[$key]['code'] ?? null);
+        $target->setVatExemptionReason($taxExemptions[$key]['reason'] ?? null);
+    }
+
+
+    /**
+     * Add allowance or charge
+     * @param Invoice|InvoiceLine $target         Target instance
+     * @param UXML                $xml            XML node
+     * @param array               &$taxExemptions Tax exemption reasons
+     */
+    private function addAllowanceOrCharge($target, UXML $xml, array &$taxExemptions) {
+        $allowanceOrCharge = new AllowanceOrCharge();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // Add instance to invoice
+        if ($xml->get("{{$cbc}}ChargeIndicator")->asText() === "true") { // @phan-suppress-current-line PhanPossiblyNonClassMethodCall
+            $target->addCharge($allowanceOrCharge);
+        } else {
+            $target->addAllowance($allowanceOrCharge);
+        }
+
+        // Reason code
+        $reasonCodeNode = $xml->get("{{$cbc}}AllowanceChargeReasonCode");
+        if ($reasonCodeNode !== null) {
+            $allowanceOrCharge->setReasonCode($reasonCodeNode->asText());
+        }
+
+        // Reason text
+        $reasonTextNode = $xml->get("{{$cbc}}AllowanceChargeReason");
+        if ($reasonTextNode !== null) {
+            $allowanceOrCharge->setReason($reasonTextNode->asText());
+        }
+
+        // Amount
+        $factorNode = $xml->get("{{$cbc}}MultiplierFactorNumeric");
+        if ($factorNode === null) {
+            $amount = (float) $xml->get("{{$cbc}}Amount")->asText(); // @phan-suppress-current-line PhanPossiblyNonClassMethodCall
+            $allowanceOrCharge->setAmount($amount);
+        } else {
+            $percent = (float) $factorNode->asText();
+            $allowanceOrCharge->markAsPercentage()->setAmount($percent);
+        }
+
+        // VAT attributes
+        $vatNode = $xml->get("{{$cac}}TaxCategory");
+        if ($vatNode !== null) {
+            $this->setVatAttributes($allowanceOrCharge, $vatNode, $taxExemptions);
+        }
+    }
+
+
+    /**
+     * Parse invoice line
+     * @param  UXML        $xml            XML node
+     * @param  array       &$taxExemptions Tax exemption reasons
+     * @return InvoiceLine                 Invoice line instance
+     */
+    private function parseInvoiceLine(UXML $xml, array &$taxExemptions): InvoiceLine {
+        $line = new InvoiceLine();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-126: Invoice line identifier
+        $lineId = $xml->get("{{$cbc}}ID");
+        if ($lineId !== null) {
+            $line->setId($lineId->asText());
+        }
+
+        // BT-127: Invoice line note
+        $noteNode = $xml->get("{{$cbc}}Note");
+        if ($noteNode !== null) {
+            $line->setNote($noteNode->asText());
+        }
+
+        // Quantity
+        $quantityNode = $xml->get("{{$cbc}}InvoicedQuantity");
+        if ($quantityNode !== null) {
+            $line->setQuantity((float) $quantityNode->asText());
+            $line->setUnit($quantityNode->element()->getAttribute('unitCode'));
+        }
+
+        // BT-133: Buyer accounting reference
+        $buyerAccountingReferenceNode = $xml->get("{{$cbc}}AccountingCost");
+        if ($buyerAccountingReferenceNode !== null) {
+            $line->setBuyerAccountingReference($buyerAccountingReferenceNode->asText());
+        }
+
+        // BG-26: Invoice line period
+        $this->parsePeriodFields($xml, $line);
+
+        // BT-132: Order line reference
+        $orderLineReferenceNode = $xml->get("{{$cac}}OrderLineReference/{{$cbc}}LineID");
+        if ($orderLineReferenceNode !== null) {
+            $line->setOrderLineReference($orderLineReferenceNode->asText());
+        }
+
+        // Allowances and charges
+        foreach ($xml->getAll("{{$cac}}AllowanceCharge") as $node) {
+            $this->addAllowanceOrCharge($line, $node, $taxExemptions);
+        }
+
+        // BT-154: Item description
+        $descriptionNode = $xml->get("{{$cac}}Item/{{$cbc}}Description");
+        if ($descriptionNode !== null) {
+            $line->setDescription($descriptionNode->asText());
+        }
+
+        // BT-153: Item name
+        $nameNode = $xml->get("{{$cac}}Item/{{$cbc}}Name");
+        if ($nameNode !== null) {
+            $line->setName($nameNode->asText());
+        }
+
+        // BT-156: Buyer identifier
+        $buyerIdentifierNode = $xml->get("{{$cac}}Item/{{$cac}}BuyersItemIdentification/{{$cbc}}ID");
+        if ($buyerIdentifierNode !== null) {
+            $line->setBuyerIdentifier($buyerIdentifierNode->asText());
+        }
+
+        // BT-155: Seller identifier
+        $sellerIdentifierNode = $xml->get("{{$cac}}Item/{{$cac}}SellersItemIdentification/{{$cbc}}ID");
+        if ($sellerIdentifierNode !== null) {
+            $line->setSellerIdentifier($sellerIdentifierNode->asText());
+        }
+
+        // BT-157: Standard identifier
+        $standardIdentifierNode = $xml->get("{{$cac}}Item/{{$cac}}StandardItemIdentification/{{$cbc}}ID");
+        if ($standardIdentifierNode !== null) {
+            $line->setStandardIdentifier($this->parseIdentifierNode($standardIdentifierNode));
+        }
+
+        // BT-159: Item origin country
+        $originCountryNode = $xml->get("{{$cac}}Item/{{$cac}}OriginCountry/{{$cbc}}IdentificationCode");
+        if ($originCountryNode !== null) {
+            $line->setOriginCountry($originCountryNode->asText());
+        }
+
+        // BT-158: Item classification identifiers
+        $classNodes = $xml->getAll("{{$cac}}Item/{{$cac}}CommodityClassification/{{$cbc}}ItemClassificationCode");
+        foreach ($classNodes as $classNode) {
+            $line->addClassificationIdentifier($this->parseIdentifierNode($classNode, 'listID'));
+        }
+
+        // Price amount
+        $priceNode = $xml->get("{{$cac}}Price/{{$cbc}}PriceAmount");
+        if ($priceNode !== null) {
+            $line->setPrice((float) $priceNode->asText());
+        }
+
+        // Base quantity
+        $baseQuantityNode = $xml->get("{{$cac}}Price/{{$cbc}}BaseQuantity");
+        if ($baseQuantityNode !== null) {
+            $line->setBaseQuantity((float) $baseQuantityNode->asText());
+        }
+
+        // VAT attributes
+        $vatNode = $xml->get("{{$cac}}Item/{{$cac}}ClassifiedTaxCategory");
+        if ($vatNode !== null) {
+            $this->setVatAttributes($line, $vatNode, $taxExemptions);
+        }
+
+        // BG-32: Item attributes
+        $attributeNodes = $xml->getAll("{{$cac}}Item/{{$cac}}AdditionalItemProperty");
+        foreach ($attributeNodes as $attributeNode) {
+            $attributeNameNode = $attributeNode->get("{{$cbc}}Name");
+            $attributeValueNode = $attributeNode->get("{{$cbc}}Value");
+            if ($attributeNameNode !== null && $attributeValueNode !== null) {
+                $line->addAttribute(new Attribute($attributeNameNode->asText(), $attributeValueNode->asText()));
+            }
+        }
+
+        return $line;
+    }
+
+    /**
+     * Parse attachment node
+     * @param  UXML       $xml XML node
+     * @return Attachment      Attachment instance
+     */
+    private function parseAttachmentNode(UXML $xml): Attachment {
+        $attachment = new Attachment();
+        $cac = UblWriter::NS_CAC;
+        $cbc = UblWriter::NS_CBC;
+
+        // BT-122: Supporting document reference
+        $identifierNode = $xml->get("{{$cbc}}ID");
+        if ($identifierNode !== null) {
+            $attachment->setId($this->parseIdentifierNode($identifierNode));
+        }
+
+        // BT-123: Supporting document description
+        $descriptionNode = $xml->get("{{$cbc}}DocumentDescription");
+        if ($descriptionNode !== null) {
+            $attachment->setDescription($descriptionNode->asText());
+        }
+
+        // BT-125: Attached document
+        $embeddedDocumentNode = $xml->get("{{$cac}}Attachment/{{$cbc}}EmbeddedDocumentBinaryObject");
+        if ($embeddedDocumentNode !== null) {
+            $embeddedDocumentElement = $embeddedDocumentNode->element();
+            // @phan-suppress-next-line PhanPossiblyFalseTypeArgument
+            $attachment->setContents(base64_decode($embeddedDocumentNode->asText()));
+            if ($embeddedDocumentElement->hasAttribute('mimeCode')) {
+                $attachment->setMimeCode($embeddedDocumentElement->getAttribute('mimeCode'));
+            }
+            if ($embeddedDocumentElement->hasAttribute('filename')) {
+                $attachment->setFilename($embeddedDocumentElement->getAttribute('filename'));
+            }
+        }
+
+        // BT-124: External document location
+        $externalDocumentNode = $xml->get("{{$cac}}Attachment/{{$cac}}ExternalReference/{{$cbc}}URI");
+        if ($externalDocumentNode !== null) {
+            $attachment->setExternalUrl($externalDocumentNode->asText());
+        }
+
+        return $attachment;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AllowanceOrChargeTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AllowanceOrChargeTrait.php
new file mode 100644 (file)
index 0000000..9687fce
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\AllowanceOrCharge;
+use OutOfBoundsException;
+use function array_splice;
+use function count;
+
+trait AllowanceOrChargeTrait {
+    protected $allowances = [];
+    protected $charges = [];
+
+    /**
+     * Get allowances
+     * @return AllowanceOrCharge[] Array of allowances
+     */
+    public function getAllowances(): array {
+        return $this->allowances;
+    }
+
+
+    /**
+     * Add allowance
+     * @param  AllowanceOrCharge $allowance Allowance instance
+     * @return self                         This instance
+     */
+    public function addAllowance(AllowanceOrCharge $allowance): self {
+        $this->allowances[] = $allowance;
+        return $this;
+    }
+
+
+    /**
+     * Remove allowance
+     * @param  int  $index Allowance index
+     * @return self        This instance
+     * @throws OutOfBoundsException if allowance index is out of bounds
+     */
+    public function removeAllowance(int $index): self {
+        if ($index < 0 || $index >= count($this->allowances)) {
+            throw new OutOfBoundsException('Could not find allowance by index');
+        }
+        array_splice($this->allowances, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all allowances
+     * @return self This instance
+     */
+    public function clearAllowances(): self {
+        $this->allowances = [];
+        return $this;
+    }
+
+
+    /**
+     * Get charges
+     * @return AllowanceOrCharge[] Array of charges
+     */
+    public function getCharges(): array {
+        return $this->charges;
+    }
+
+
+    /**
+     * Add charge
+     * @param  AllowanceOrCharge $charge Charge instance
+     * @return self                      This instance
+     */
+    public function addCharge(AllowanceOrCharge $charge): self {
+        $this->charges[] = $charge;
+        return $this;
+    }
+
+
+    /**
+     * Remove charge
+     * @param  int  $index Charge index
+     * @return self        This instance
+     * @throws OutOfBoundsException if charge index is out of bounds
+     */
+    public function removeCharge(int $index): self {
+        if ($index < 0 || $index >= count($this->charges)) {
+            throw new OutOfBoundsException('Could not find charge by index');
+        }
+        array_splice($this->charges, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all charges
+     * @return self This instance
+     */
+    public function clearCharges(): self {
+        $this->charges = [];
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AttachmentsTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AttachmentsTrait.php
new file mode 100644 (file)
index 0000000..6ab05dd
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\Attachment;
+use OutOfBoundsException;
+
+trait AttachmentsTrait {
+    protected $attachments = [];
+
+    /**
+     * Get attachments
+     * @return Attachment[] Array of attachments
+     */
+    public function getAttachments(): array {
+        return $this->attachments;
+    }
+
+
+    /**
+     * Add attachment
+     * @param  Attachment $attachment Attachment
+     * @return self                   This instance
+     */
+    public function addAttachment(Attachment $attachment): self {
+        $this->attachments[] = $attachment;
+        return $this;
+    }
+
+
+    /**
+     * Remove attachment
+     * @param  int  $index Attachment index
+     * @return self        This instance
+     * @throws OutOfBoundsException if attachment index is out of bounds
+     */
+    public function removeAttachment(int $index): self {
+        if ($index < 0 || $index >= count($this->attachments)) {
+            throw new OutOfBoundsException('Could not find attachment by index');
+        }
+        array_splice($this->attachments, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all attachments
+     * @return self This instance
+     */
+    public function clearAttachments(): self {
+        $this->attachments = [];
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AttributesTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/AttributesTrait.php
new file mode 100644 (file)
index 0000000..016367d
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\Attribute;
+use OutOfBoundsException;
+use function array_splice;
+use function count;
+
+trait AttributesTrait {
+    protected $attributes = [];
+
+    /**
+     * Get attributes
+     * @return Attribute[] Array of attributes
+     */
+    public function getAttributes(): array {
+        return $this->attributes;
+    }
+
+
+    /**
+     * Add attribute
+     * @param  Attribute $attribute Attribute instance
+     * @return self                 This instance
+     */
+    public function addAttribute(Attribute $attribute): self {
+        $this->attributes[] = $attribute;
+        return $this;
+    }
+
+
+    /**
+     * Remove attribute
+     * @param  int  $index Attribute index
+     * @return self        This instance
+     * @throws OutOfBoundsException if attribute index is out of bounds
+     */
+    public function removeAttribute(int $index): self {
+        if ($index < 0 || $index >= count($this->attributes)) {
+            throw new OutOfBoundsException('Could not find attribute by index');
+        }
+        array_splice($this->attributes, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all attributes
+     * @return self This instance
+     */
+    public function clearAttributes(): self {
+        $this->attributes = [];
+        return $this;
+    }
+
+
+    /**
+     * Get attribute value
+     * @param  string      $name Attribute name
+     * @return string|null       Value from occurrence with given name or NULL if not found
+     */
+    public function getAttribute(string $name) {
+        foreach ($this->attributes as $attribute) {
+            if ($attribute->getName() === $name) {
+                return $attribute->getValue();
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * Set attribute value
+     * @param  string      $name  Attribute name
+     * @param  string|null $value New attribute value for first found occurrence, NULL to remove
+     * @return self               This instance
+     * @suppress PhanThrowTypeAbsentForCall, PhanTypeMismatchArgumentNullable
+     */
+    public function setAttribute(string $name, $value): self {
+        $index = null;
+        $attribute = null;
+        foreach ($this->attributes as $i=>$a) {
+            if ($a->getName() === $name) {
+                $index = $i;
+                $attribute = $a;
+                break;
+            }
+        }
+
+        if ($attribute === null && $value !== null) {
+            $this->addAttribute(new Attribute($name, $value));
+        } elseif ($attribute !== null && $value !== null) {
+            $attribute->setValue($value);
+        } elseif ($attribute !== null && $value === null) {
+            $this->removeAttribute($index);
+        }
+
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/BuyerAccountingReferenceTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/BuyerAccountingReferenceTrait.php
new file mode 100644 (file)
index 0000000..31b26b3
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+namespace Einvoicing\Traits;
+
+trait BuyerAccountingReferenceTrait {
+    protected $buyerAccountingReference = null;
+
+    /**
+     * Get buyer accounting reference
+     * @return string|null Buyer accounting reference
+     */
+    public function getBuyerAccountingReference() {
+        return $this->buyerAccountingReference;
+    }
+
+
+    /**
+     * Set buyer accounting reference
+     * @param  string|null $buyerAccountingReference Buyer accounting reference
+     * @return self                                  This instance
+     */
+    public function setBuyerAccountingReference($buyerAccountingReference): self {
+        $this->buyerAccountingReference = $buyerAccountingReference;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/ClassificationIdentifiersTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/ClassificationIdentifiersTrait.php
new file mode 100644 (file)
index 0000000..d2991a7
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\Identifier;
+use OutOfBoundsException;
+use function array_splice;
+use function count;
+
+trait ClassificationIdentifiersTrait {
+    protected $classIdentifiers = [];
+
+    /**
+     * Get classification identifiers
+     * @return Identifier[] Array of identifiers
+     */
+    public function getClassificationIdentifiers(): array {
+        return $this->classIdentifiers;
+    }
+
+
+    /**
+     * Add classification identifier
+     * @param  Identifier $identifier Identifier instance
+     * @return self                   This instance
+     */
+    public function addClassificationIdentifier(Identifier $identifier): self {
+        $this->classIdentifiers[] = $identifier;
+        return $this;
+    }
+
+
+    /**
+     * Remove classification identifier
+     * @param  int  $index Identifier index
+     * @return self        This instance
+     * @throws OutOfBoundsException if identifier index is out of bounds
+     */
+    public function removeClassificationIdentifier(int $index): self {
+        if ($index < 0 || $index >= count($this->classIdentifiers)) {
+            throw new OutOfBoundsException('Could not find classification identifier by index');
+        }
+        array_splice($this->classIdentifiers, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all classification identifiers
+     * @return self This instance
+     */
+    public function clearClassificationIdentifiers(): self {
+        $this->classIdentifiers = [];
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/IdentifiersTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/IdentifiersTrait.php
new file mode 100644 (file)
index 0000000..37f50af
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\Identifier;
+use OutOfBoundsException;
+use function array_splice;
+use function count;
+
+trait IdentifiersTrait {
+    protected $identifiers = [];
+
+    /**
+     * Get additional identifiers
+     * @return Identifier[] Array of identifiers
+     */
+    public function getIdentifiers(): array {
+        return $this->identifiers;
+    }
+
+
+    /**
+     * Add additional identifier
+     * @param  Identifier $identifier Identifier instance
+     * @return self                   This instance
+     */
+    public function addIdentifier(Identifier $identifier): self {
+        $this->identifiers[] = $identifier;
+        return $this;
+    }
+
+
+    /**
+     * Remove additional identifier
+     * @param  int  $index Identifier index
+     * @return self        This instance
+     * @throws OutOfBoundsException if identifier index is out of bounds
+     */
+    public function removeIdentifier(int $index): self {
+        if ($index < 0 || $index >= count($this->identifiers)) {
+            throw new OutOfBoundsException('Could not find identifier by index');
+        }
+        array_splice($this->identifiers, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all additional identifiers
+     * @return self This instance
+     */
+    public function clearIdentifiers(): self {
+        $this->identifiers = [];
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/InvoiceValidationTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/InvoiceValidationTrait.php
new file mode 100644 (file)
index 0000000..5a775c0
--- /dev/null
@@ -0,0 +1,228 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\Exceptions\ValidationException;
+use Einvoicing\Invoice;
+use function array_merge;
+use function in_array;
+
+// @phan-file-suppress PhanPluginInconsistentReturnFunction, PhanPossiblyNonClassMethodCall
+
+trait InvoiceValidationTrait {
+    /**
+     * Validate invoice
+     * @throws ValidationException if failed to pass validation
+     * @return void
+     */
+    public function validate() {
+        $rules = $this->getRules();
+        foreach ($rules as $ruleId=>$rule) {
+            $errorMessage = $rule($this);
+            if (!empty($errorMessage)) {
+                throw new ValidationException($errorMessage, $ruleId);
+            }
+        }
+    }
+
+
+    /**
+     * Get effective validation rules
+     * @return array<string,callable> Map of rules
+     * @suppress PhanUndeclaredProperty
+     */
+    private function getRules(): array {
+        $rules = $this->getDefaultRules();
+        if ($this->preset !== null) {
+            $rules = array_merge($rules, $this->preset->getRules());
+        }
+        return $rules;
+    }
+
+
+    /**
+     * Get EN16931 validation rules
+     * @return array<string,callable> Map of rules
+     */
+    private function getDefaultRules(): array {
+        $res = [];
+
+        $res['BR-01'] = static function(Invoice $inv) {
+            if ($inv->getSpecification() === null) return "An Invoice shall have a Specification identifier (BT-24)";
+        };
+        $res['BR-02'] = static function(Invoice $inv) {
+            if ($inv->getNumber() === null) return "An Invoice shall have an Invoice number (BT-1)";
+        };
+        $res['BR-03'] = static function(Invoice $inv) {
+            if ($inv->getIssueDate() === null) return "An Invoice shall have an Invoice issue date (BT-2)";
+        };
+        $res['BR-06'] = static function(Invoice $inv) {
+            if ($inv->getSeller() === null) return "Missing Seller from Invoice";
+            if ($inv->getSeller()->getName() === null) return "An Invoice shall contain the Seller name (BT-27)";
+        };
+        $res['BR-07'] = static function(Invoice $inv) {
+            if ($inv->getBuyer() === null) return "Missing Buyer from Invoice";
+            if ($inv->getBuyer()->getName() === null) return "An Invoice shall contain the Buyer name (BT-44)";
+        };
+        $res['BR-09'] = static function(Invoice $inv) {
+            if ($inv->getSeller()->getCountry() === null) {
+                return "The Seller postal address shall contain a Seller country code (BT-40)";
+            }
+        };
+        $res['BR-11'] = static function(Invoice $inv) {
+            if ($inv->getBuyer()->getCountry() === null) {
+                return "The Buyer postal address shall contain a Buyer country code (BT-55)";
+            }
+        };
+        $res['BR-16'] = static function(Invoice $inv) {
+            if (empty($inv->getLines())) return "An Invoice shall have at least one Invoice line (BG-25)";
+        };
+        $res['BR-17'] = static function(Invoice $inv) {
+            if ($inv->getPayee() === null) return;
+            if ($inv->getSeller()->getName() === $inv->getPayee()->getName()) return;
+            if ($inv->getPayee()->getName() === null) {
+                return "The Payee name shall be provided in the Invoice, if the Payee is different from the Seller";
+            }
+        };
+        $res['BR-25'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                if ($line->getName() === null) return "Each Invoice line (BG-25) shall contain the Item name (BT-153)";
+            }
+        };
+        $res['BR-26'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                if ($line->getPrice() === null) {
+                    return "Each Invoice line (BG-25) shall contain the Item net price (BT-146)";
+                }
+            }
+        };
+        $res['BR-27'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                if ($line->getPrice() < 0) return "The Item net price (BT-146) shall NOT be negative";
+            }
+        };
+        $res['BR-31'] = static function(Invoice $inv) {
+            foreach ($inv->getAllowances() as $allowance) {
+                if ($allowance->getAmount() === null) {
+                    return "Each Document level allowance shall have a Document level allowance amount (BT-92)";
+                }
+            }
+        };
+        $res['BR-33'] = static function(Invoice $inv) {
+            foreach ($inv->getAllowances() as $allowance) {
+                if ($allowance->getReasonCode() === null && $allowance->getReason() === null) {
+                    return "Each Document level allowance shall have a Document level allowance reason (BT-97) " .
+                        "or a Document level allowance reason code (BT-98)";
+                }
+            }
+        };
+        $res['BR-36'] = static function(Invoice $inv) {
+            foreach ($inv->getCharges() as $charge) {
+                if ($charge->getAmount() === null) {
+                    return "Each Document level charge shall have a Document level charge amount (BT-99)";
+                }
+            }
+        };
+        $res['BR-38'] = static function(Invoice $inv) {
+            foreach ($inv->getCharges() as $charge) {
+                if ($charge->getReasonCode() === null && $charge->getReason() === null) {
+                    return "Each Document level charge shall have a Document level charge reason (BT-104) " .
+                        "or a Document level charge reason code (BT-105)";
+                }
+            }
+        };
+        $res['BR-41'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                foreach ($line->getAllowances() as $allowance) {
+                    if ($allowance->getAmount() === null) {
+                        return "Each Invoice line allowance shall have an Invoice line allowance amount (BT-136)";
+                    }
+                }
+            }
+        };
+        $res['BR-42'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                foreach ($line->getAllowances() as $allowance) {
+                    if ($allowance->getReasonCode() === null && $allowance->getReason() === null) {
+                        return "Each Invoice line allowance shall have an Invoice line allowance reason (BT-139) " .
+                            "or an Invoice line allowance reason code (BT-140)";
+                    }
+                }
+            }
+        };
+        $res['BR-43'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                foreach ($line->getCharges() as $charge) {
+                    if ($charge->getAmount() === null) {
+                        return "Each Invoice line charge shall have an Invoice line charge amount (BT-141)";
+                    }
+                }
+            }
+        };
+        $res['BR-44'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                foreach ($line->getCharges() as $charge) {
+                    if ($charge->getReasonCode() === null && $charge->getReason() === null) {
+                        return "Each Invoice line charge shall have an Invoice line charge reason " .
+                            "or an invoice line allowance reason code";
+                    }
+                }
+            }
+        };
+        $res['BR-49'] = static function(Invoice $inv) {
+            if ($inv->getPayment() !== null && $inv->getPayment()->getMeansCode() === null) {
+                return "A Payment instruction (BG-16) shall specify the Payment means type code (BT-81)";
+            }
+        };
+        $res['BR-50'] = static function(Invoice $inv) {
+            if ($inv->getPayment() === null) return;
+            foreach ($inv->getPayment()->getTransfers() as $transfer) {
+                if ($transfer->getAccountId() === null) {
+                    return "A Payment account identifier (BT-84) shall be present if Credit transfer (BG-17) " .
+                        "information is provided in the Invoice";
+                }
+            }
+        };
+        $res['BR-51'] = static function(Invoice $inv) {
+            if ($inv->getPayment() === null) return;
+            if ($inv->getPayment()->getCard() === null) return;
+            if ($inv->getPayment()->getCard()->getPan() === null) {
+                return "The last 4 to 6 digits of the Payment card primary account number (BT-87) " .
+                    "shall be present if Payment card information (BG-18) is provided in the Invoice";
+            }
+        };
+        $res['BR-52'] = static function(Invoice $inv) {
+            foreach ($inv->getAttachments() as $attachment) {
+                if ($attachment->getId() === null) {
+                    return "Each Additional supporting document shall contain a Supporting document reference (BT-122)";
+                }
+            }
+        };
+        $res['BR-61'] = static function(Invoice $inv) {
+            if ($inv->getPayment() === null) return;
+            if (!in_array($inv->getPayment()->getMeansCode(), ['30', '58'])) return;
+            if (empty($inv->getPayment()->getTransfers())) {
+                return "If the Payment means type code (BT-81) means SEPA credit transfer, Local credit transfer or " .
+                    "Non-SEPA international credit transfer, the Payment account identifier (BT-84) shall be present";
+            }
+        };
+        $res['BR-64'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                if ($line->getStandardIdentifier() === null) continue;
+                if ($line->getStandardIdentifier()->getScheme() === null) {
+                    return "The Item standard identifier (BT-157) shall have a Scheme identifier";
+                }
+            }
+        };
+        $res['BR-65'] = static function(Invoice $inv) {
+            foreach ($inv->getLines() as $line) {
+                foreach ($line->getClassificationIdentifiers() as $identifier) {
+                    if ($identifier->getScheme() === null) {
+                        return "The Item classification identifier (BT-158) shall have a Scheme identifier";
+                    }
+                }
+            }
+        };
+
+        return $res;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PeriodTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PeriodTrait.php
new file mode 100644 (file)
index 0000000..c3eaa6f
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+namespace Einvoicing\Traits;
+
+use DateTime;
+
+trait PeriodTrait {
+    protected $periodStartDate = null;
+    protected $periodEndDate = null;
+
+    /**
+     * Get period start date
+     * @return DateTime|null Period start date
+     */
+    public function getPeriodStartDate() {
+        return $this->periodStartDate;
+    }
+
+
+    /**
+     * Set period start date
+     * @param  DateTime|null $periodStartDate Period start date
+     * @return self                           This instance
+     */
+    public function setPeriodStartDate($periodStartDate): self {
+        $this->periodStartDate = $periodStartDate;
+        return $this;
+    }
+
+
+    /**
+     * Get period end date
+     * @return DateTime|null Period end date
+     */
+    public function getPeriodEndDate() {
+        return $this->periodEndDate;
+    }
+
+
+    /**
+     * Set period end date
+     * @param  DateTime|null $periodEndDate Period end date
+     * @return self                         This instance
+     */
+    public function setPeriodEndDate($periodEndDate): self {
+        $this->periodEndDate = $periodEndDate;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PostalAddressTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PostalAddressTrait.php
new file mode 100644 (file)
index 0000000..157d982
--- /dev/null
@@ -0,0 +1,116 @@
+<?php
+namespace Einvoicing\Traits;
+
+use InvalidArgumentException;
+use function count;
+
+trait PostalAddressTrait {
+    protected $address = [];
+    protected $city = null;
+    protected $postalCode = null;
+    protected $subdivision = null;
+    protected $country = null;
+
+    /**
+     * Get address lines
+     * @return string[] Address lines (up to 3 lines)
+     */
+    public function getAddress(): array {
+        return $this->address;
+    }
+
+
+    /**
+     * Set address lines
+     * @param  string[] $addressLines Address lines (up to 3 lines)
+     * @return self                   This instance
+     * @throws InvalidArgumentException if more than 3 lines are provided
+     */
+    public function setAddress(array $addressLines): self {
+        if (count($addressLines) > 3) {
+            throw new InvalidArgumentException('Address cannot have more than 3 lines');
+        }
+        $this->address = $addressLines;
+        return $this;
+    }
+
+
+    /**
+     * Get city name
+     * @return string|null City name
+     */
+    public function getCity() {
+        return $this->city;
+    }
+
+
+    /**
+     * Set city name
+     * @param  string|null $city City name
+     * @return self              This instance
+     */
+    public function setCity($city): self {
+        $this->city = $city;
+        return $this;
+    }
+
+
+    /**
+     * Get postal code
+     * @return string|null Postal code
+     */
+    public function getPostalCode() {
+        return $this->postalCode;
+    }
+
+
+    /**
+     * Set postal code
+     * @param  string|null $postalCode Postal code
+     * @return self                    This instance
+     */
+    public function setPostalCode($postalCode): self {
+        $this->postalCode = $postalCode;
+        return $this;
+    }
+
+
+    /**
+     * Get country subdivision (region, province, etc.)
+     * @return string|null Country subdivision
+     */
+    public function getSubdivision() {
+        return $this->subdivision;
+    }
+
+
+    /**
+     * Set country subdivision (region, province, etc.)
+     * @param  string|null $subdivision Country subdivision
+     * @return self                     This instance
+     */
+    public function setSubdivision($subdivision): self {
+        $this->subdivision = $subdivision;
+        return $this;
+    }
+
+
+    /**
+     * Get country code
+     * @return string|null Country code
+     */
+    public function getCountry() {
+        return $this->country;
+    }
+
+
+    /**
+     * Set country code
+     * @param  string|null $countryCode Country code
+     * @return self                     This instance
+     */
+    public function setCountry($countryCode): self {
+        $this->country = $countryCode;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PrecedingInvoiceReferencesTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/PrecedingInvoiceReferencesTrait.php
new file mode 100644 (file)
index 0000000..3f17cb6
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+namespace Einvoicing\Traits;
+
+use Einvoicing\InvoiceReference;
+use OutOfBoundsException;
+
+trait PrecedingInvoiceReferencesTrait {
+    protected $precedingInvoiceReferences = [];
+
+    /**
+     * Get preceding invoice references
+     * @return InvoiceReference[] Array of preceding invoice references
+     */
+    public function getPrecedingInvoiceReferences(): array {
+        return $this->precedingInvoiceReferences;
+    }
+
+
+    /**
+     * Add preceding invoice reference
+     * @param  InvoiceReference $reference Preceding invoice reference
+     * @return self                        This instance
+     */
+    public function addPrecedingInvoiceReference(InvoiceReference $reference): self {
+        $this->precedingInvoiceReferences[] = $reference;
+        return $this;
+    }
+
+
+    /**
+     * Remove preceding invoice reference
+     * @param  int  $index Preceding invoice reference index
+     * @return self        This instance
+     * @throws OutOfBoundsException if preceding invoice reference index is out of bounds
+     */
+    public function removePrecedingInvoiceReference(int $index): self {
+        if ($index < 0 || $index >= count($this->precedingInvoiceReferences)) {
+            throw new OutOfBoundsException('Could not find preceding invoice reference by index');
+        }
+        array_splice($this->precedingInvoiceReferences, $index, 1);
+        return $this;
+    }
+
+
+    /**
+     * Clear all preceding invoice references
+     * @return self This instance
+     */
+    public function clearPrecedingInvoiceReferences(): self {
+        $this->precedingInvoiceReferences = [];
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/VatTrait.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Traits/VatTrait.php
new file mode 100644 (file)
index 0000000..e8b2c95
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace Einvoicing\Traits;
+
+trait VatTrait {
+    protected $vatCategory = "S"; // TODO: add constants
+    protected $vatRate = null;
+    protected $vatExemptionReasonCode = null;
+    protected $vatExemptionReason = null;
+
+    /**
+     * Get VAT category code
+     * @return string VAT category code
+     */
+    public function getVatCategory(): string {
+        return $this->vatCategory;
+    }
+
+
+    /**
+     * Set VAT category code
+     * @param  string $categoryCode VAT category code
+     * @return self                 This instance
+     */
+    public function setVatCategory(string $categoryCode): self {
+        $this->vatCategory = $categoryCode;
+        return $this;
+    }
+
+
+    /**
+     * Get VAT rate
+     * @return float|null VAT rate as a percentage or NULL when not subject to VAT
+     */
+    public function getVatRate() {
+        return $this->vatRate;
+    }
+
+
+    /**
+     * Set VAT rate
+     * @param  float|null $rate VAT rate as a percentage or NULL when not subject to VAT
+     * @return self             This instance
+     */
+    public function setVatRate($rate): self {
+        $this->vatRate = $rate;
+        return $this;
+    }
+
+
+    /**
+     * Get VAT exemption reason code
+     * @return string|null VAT exemption reason code
+     */
+    public function getVatExemptionReasonCode() {
+        return $this->vatExemptionReasonCode;
+    }
+
+
+    /**
+     * Set VAT exemption reason code
+     * @param  string|null $reasonCode VAT exemption reason code
+     * @return self                    This instance
+     */
+    public function setVatExemptionReasonCode($reasonCode): self {
+        $this->vatExemptionReasonCode = $reasonCode;
+        return $this;
+    }
+
+
+    /**
+     * Get VAT exemption reason
+     * @return string|null VAT exemption reason expressed as text
+     */
+    public function getVatExemptionReason() {
+        return $this->vatExemptionReason;
+    }
+
+
+    /**
+     * Set VAT exemption reason
+     * @param  string|null $reason VAT exemption reason expressed as text
+     * @return self                This instance
+     */
+    public function setVatExemptionReason($reason): self {
+        $this->vatExemptionReason = $reason;
+        return $this;
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Writers/AbstractWriter.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Writers/AbstractWriter.php
new file mode 100644 (file)
index 0000000..c9f0ffa
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+namespace Einvoicing\Writers;
+
+use Einvoicing\Invoice;
+
+abstract class AbstractWriter {
+    /**
+     * Export invoice
+     * @param  Invoice $invoice Invoice instance
+     * @return string           Export contents
+     */
+    abstract public function export(Invoice $invoice): string;
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Writers/UblWriter.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/src/Writers/UblWriter.php
new file mode 100644 (file)
index 0000000..3e1071e
--- /dev/null
@@ -0,0 +1,940 @@
+<?php
+namespace Einvoicing\Writers;
+
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Attachment;
+use Einvoicing\Delivery;
+use Einvoicing\Identifier;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\Models\InvoiceTotals;
+use Einvoicing\Party;
+use Einvoicing\Payments\Card;
+use Einvoicing\Payments\Mandate;
+use Einvoicing\Payments\Payment;
+use Einvoicing\Payments\Transfer;
+use UXML\UXML;
+use function in_array;
+
+class UblWriter extends AbstractWriter {
+    const NS_INVOICE = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2";
+    const NS_CAC = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2";
+    const NS_CBC = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2";
+
+    /**
+     * @inheritdoc
+     */
+    public function export(Invoice $invoice): string {
+        $xml = UXML::newInstance('Invoice', null, [
+            'xmlns' => self::NS_INVOICE,
+            'xmlns:cac' => self::NS_CAC,
+            'xmlns:cbc' => self::NS_CBC
+        ]);
+
+        // BT-24: Specification identifier
+        $specificationIdentifier = $invoice->getSpecification();
+        if ($specificationIdentifier !== null) {
+            $xml->add('cbc:CustomizationID', $specificationIdentifier);
+        }
+
+        // BT-23: Business process type
+        $businessProcessType = $invoice->getBusinessProcess();
+        if ($businessProcessType !== null) {
+            $xml->add('cbc:ProfileID', $businessProcessType);
+        }
+
+        // BT-1: Invoice number
+        $number = $invoice->getNumber();
+        if ($number !== null) {
+            $xml->add('cbc:ID', $number);
+        }
+
+        // BT-2: Issue date
+        $issueDate = $invoice->getIssueDate();
+        if ($issueDate !== null) {
+            $xml->add('cbc:IssueDate', $issueDate->format('Y-m-d'));
+        }
+
+        // BT-9: Due date
+        $dueDate = $invoice->getDueDate();
+        if ($dueDate !== null) {
+            $xml->add('cbc:DueDate', $dueDate->format('Y-m-d'));
+        }
+
+        // BT-3: Invoice type code
+        $xml->add('cbc:InvoiceTypeCode', (string) $invoice->getType());
+
+        // BT-22: Note
+        $note = $invoice->getNote();
+        if ($note !== null) {
+            $xml->add('cbc:Note', $note);
+        }
+
+        // BT-7: Tax point date
+        $taxPointDate = $invoice->getTaxPointDate();
+        if ($taxPointDate !== null) {
+            $xml->add('cbc:TaxPointDate', $taxPointDate->format('Y-m-d'));
+        }
+
+        // BT-5: Invoice currency code
+        $xml->add('cbc:DocumentCurrencyCode', $invoice->getCurrency());
+
+        // BT-19: Buyer accounting reference
+        $buyerAccountingReference = $invoice->getBuyerAccountingReference();
+        if ($buyerAccountingReference !== null) {
+            $xml->add('cbc:AccountingCost', $buyerAccountingReference);
+        }
+
+        // BT-10: Buyer reference
+        $buyerReference = $invoice->getBuyerReference();
+        if ($buyerReference !== null) {
+            $xml->add('cbc:BuyerReference', $buyerReference);
+        }
+
+        // BG-14: Invoice period
+        $this->addPeriodNode($xml, $invoice);
+
+        // Order reference node
+        $this->addOrderReferenceNode($xml, $invoice);
+
+        // BG-3: Preceding invoice reference
+        foreach ($invoice->getPrecedingInvoiceReferences() as $invoiceReference) {
+            $invoiceDocumentReferenceNode = $xml->add('cac:BillingReference')->add('cac:InvoiceDocumentReference');
+            $invoiceDocumentReferenceNode->add('cbc:ID', $invoiceReference->getValue());
+            $invoiceReferenceIssueDate = $invoiceReference->getIssueDate();
+            if ($invoiceReferenceIssueDate !== null) {
+                $invoiceDocumentReferenceNode->add('cbc:IssueDate', $invoiceReferenceIssueDate->format('Y-m-d'));
+            }
+        }
+
+        // BT-17: Tender or lot reference
+        $tenderOrLotReference = $invoice->getTenderOrLotReference();
+        if ($tenderOrLotReference !== null) {
+            $xml->add('cac:OriginatorDocumentReference')->add('cbc:ID', $tenderOrLotReference);
+        }
+
+        // BT-12: Contract reference
+        $contractReference = $invoice->getContractReference();
+        if ($contractReference !== null) {
+            $xml->add('cac:ContractDocumentReference')->add('cbc:ID', $contractReference);
+        }
+
+        // BG-24: Attachments node
+        foreach ($invoice->getAttachments() as $attachment) {
+            $this->addAttachmentNode($xml, $attachment);
+        }
+
+        // Seller node
+        $seller = $invoice->getSeller();
+        if ($seller !== null) {
+            $this->addSellerOrBuyerNode($xml->add('cac:AccountingSupplierParty'), $seller);
+        }
+
+        // Buyer node
+        $buyer = $invoice->getBuyer();
+        if ($buyer !== null) {
+            $this->addSellerOrBuyerNode($xml->add('cac:AccountingCustomerParty'), $buyer);
+        }
+
+        // Payee node
+        $payee = $invoice->getPayee();
+        if ($payee !== null) {
+            $this->addPayeeNode($xml, $payee);
+        }
+
+        // Delivery node
+        $delivery = $invoice->getDelivery();
+        if ($delivery !== null) {
+            $this->addDeliveryNode($xml, $delivery);
+        }
+
+        // Payment nodes
+        $payment = $invoice->getPayment();
+        if ($payment !== null) {
+            $this->addPaymentNodes($xml, $payment);
+        }
+
+        // Allowances and charges
+        foreach ($invoice->getAllowances() as $item) {
+            $this->addAllowanceOrCharge($xml, $item, false, $invoice);
+        }
+        foreach ($invoice->getCharges() as $item) {
+            $this->addAllowanceOrCharge($xml, $item, true, $invoice);
+        }
+
+        // Invoice totals
+        $totals = $invoice->getTotals();
+        $this->addTaxTotalNode($xml, $totals);
+        $this->addDocumentTotalsNode($xml, $totals);
+
+        // Invoice lines
+        $lines = $invoice->getLines();
+        $lastGenId = 0;
+        $usedIds = [];
+        foreach ($lines as $line) {
+            $lineId = $line->getId();
+            if ($lineId !== null) {
+                $usedIds[] = $lineId;
+            }
+        }
+        foreach ($lines as $line) {
+            $this->addLineNode($xml, $line, $invoice, $lastGenId, $usedIds);
+        }
+
+        return $xml->asXML();
+    }
+
+
+    /**
+     * Add identifier node
+     * @param UXML       $parent     Parent element
+     * @param string     $name       New node name
+     * @param Identifier $identifier Identifier instance
+     * @param string     $schemeAttr Scheme attribute name
+     */
+    private function addIdentifierNode(UXML $parent, string $name, Identifier $identifier, string $schemeAttr="schemeID") {
+        $scheme = $identifier->getScheme();
+        $attrs = ($scheme === null) ? [] : ["$schemeAttr" => $scheme];
+        $parent->add($name, $identifier->getValue(), $attrs);
+    }
+
+
+    /**
+     * Add period node
+     * @param UXML                $parent Parent element
+     * @param Invoice|InvoiceLine $source Source instance
+     */
+    private function addPeriodNode(UXML $parent, $source) {
+        $startDate = $source->getPeriodStartDate();
+        $endDate = $source->getPeriodEndDate();
+        if ($startDate === null && $endDate === null) return;
+
+        $xml = $parent->add('cac:InvoicePeriod');
+
+        // Period start date
+        if ($startDate !== null) {
+            $xml->add('cbc:StartDate', $startDate->format('Y-m-d'));
+        }
+
+        // Period end date
+        if ($endDate !== null) {
+            $xml->add('cbc:EndDate', $endDate->format('Y-m-d'));
+        }
+    }
+
+
+    /**
+     * Add order reference node
+     * @param UXML    $parent  Parent element
+     * @param Invoice $invoice Invoice instance
+     */
+    private function addOrderReferenceNode(UXML $parent, Invoice $invoice) {
+        $purchaseOrderReference = $invoice->getPurchaseOrderReference();
+        $salesOrderReference = $invoice->getSalesOrderReference();
+        if ($purchaseOrderReference === null && $salesOrderReference === null) return;
+
+        $orderReferenceNode = $parent->add('cac:OrderReference');
+
+        // BT-13: Purchase order reference
+        if ($purchaseOrderReference !== null) {
+            $orderReferenceNode->add('cbc:ID', $purchaseOrderReference);
+        }
+
+        // BT-14: Sales order reference
+        if ($salesOrderReference !== null) {
+            $orderReferenceNode->add('cbc:SalesOrderID', $salesOrderReference);
+        }
+    }
+
+
+    /**
+     * Add amount node
+     * @param UXML   $parent   Parent element
+     * @param string $name     New node name
+     * @param float  $amount   Amount
+     * @param string $currency Currency code
+     */
+    private function addAmountNode(UXML $parent, string $name, float $amount, string $currency) {
+        $parent->add($name, (string) $amount, ['currencyID' => $currency]);
+    }
+
+
+    /**
+     * Add VAT node
+     * @param UXML        $parent              Parent element
+     * @param string      $name                New node name
+     * @param string      $category            VAT category
+     * @param float|null  $rate                VAT rate
+     * @param string|null $exemptionReasonCode VAT exemption reason code
+     * @param string|null $exemptionReason     VAT exemption reason as text
+     */
+    private function addVatNode(
+        UXML $parent, string $name, string $category, $rate,
+        $exemptionReasonCode=null, $exemptionReason=null
+    ) {
+        $xml = $parent->add($name);
+
+        // VAT category
+        $xml->add('cbc:ID', $category);
+
+        // VAT rate
+        if ($rate !== null) {
+            $xml->add('cbc:Percent', (string) $rate);
+        }
+
+        // Exemption reason code
+        if ($exemptionReasonCode !== null) {
+            $xml->add('cbc:TaxExemptionReasonCode', $exemptionReasonCode);
+        }
+
+        // Exemption reason (as text)
+        if ($exemptionReason !== null) {
+            $xml->add('cbc:TaxExemptionReason', $exemptionReason);
+        }
+
+        // Tax scheme
+        $xml->add('cac:TaxScheme')->add('cbc:ID', 'VAT');
+    }
+
+
+    /**
+     * Add postal address node
+     * @param  UXML           $parent Parent element
+     * @param  string         $name   New node name
+     * @param  Delivery|Party $source Source instance
+     * @return UXML                   Postal address node
+     */
+    private function addPostalAddressNode(UXML $parent, string $name, $source) {
+        $xml = $parent->add($name);
+
+        // Street name
+        $addressLines = $source->getAddress();
+        if (isset($addressLines[0])) {
+            $xml->add('cbc:StreetName', $addressLines[0]);
+        }
+
+        // Additional street name
+        if (isset($addressLines[1])) {
+            $xml->add('cbc:AdditionalStreetName', $addressLines[1]);
+        }
+
+        // City name
+        $cityName = $source->getCity();
+        if ($cityName !== null) {
+            $xml->add('cbc:CityName', $cityName);
+        }
+
+        // Postal code
+        $postalCode = $source->getPostalCode();
+        if ($postalCode !== null) {
+            $xml->add('cbc:PostalZone', $postalCode);
+        }
+
+        // Subdivision
+        $subdivision = $source->getSubdivision();
+        if ($subdivision !== null) {
+            $xml->add('cbc:CountrySubentity', $subdivision);
+        }
+
+        // Address line (third address line)
+        if (isset($addressLines[2])) {
+            $xml->add('cac:AddressLine')->add('cbc:Line', $addressLines[2]);
+        }
+
+        // Country
+        $country = $source->getCountry();
+        if ($country !== null) {
+            $xml->add('cac:Country')->add('cbc:IdentificationCode', $country);
+        }
+
+        return $xml;
+    }
+
+
+    /**
+     * Add seller or buyer node
+     * @param UXML  $parent Invoice element
+     * @param Party $party  Party instance
+     */
+    private function addSellerOrBuyerNode(UXML $parent, Party $party) {
+        $xml = $parent->add('cac:Party');
+
+        // Electronic address
+        $electronicAddress = $party->getElectronicAddress();
+        if ($electronicAddress !== null) {
+            $this->addIdentifierNode($xml, 'cbc:EndpointID', $electronicAddress);
+        }
+
+        // Additional identifiers
+        foreach ($party->getIdentifiers() as $identifier) {
+            $identifierNode = $xml->add('cac:PartyIdentification');
+            $this->addIdentifierNode($identifierNode, 'cbc:ID', $identifier);
+        }
+
+        // Trading name
+        $tradingName = $party->getTradingName();
+        if ($tradingName !== null) {
+            $xml->add('cac:PartyName')->add('cbc:Name', $tradingName);
+        }
+
+        // Postal address node
+        $this->addPostalAddressNode($xml, 'cac:PostalAddress', $party);
+
+        // VAT number
+        $vatNumber = $party->getVatNumber();
+        if ($vatNumber !== null) {
+            $taxNode = $xml->add('cac:PartyTaxScheme');
+            $taxNode->add('cbc:CompanyID', $vatNumber);
+            $taxNode->add('cac:TaxScheme')->add('cbc:ID', 'VAT');
+        }
+
+        // Tax registration identifier
+        $taxRegistrationId = $party->getTaxRegistrationId();
+        if ($taxRegistrationId !== null) {
+            $taxRegistrationNode = $xml->add('cac:PartyTaxScheme');
+            $taxRegistrationNode->add('cbc:CompanyID', $taxRegistrationId->getValue());
+            $taxRegistrationScheme = $taxRegistrationId->getScheme();
+            if ($taxRegistrationScheme !== null) {
+                $taxRegistrationNode->add('cac:TaxScheme')->add('cbc:ID', $taxRegistrationScheme);
+            }
+        }
+
+        // Initial legal entity node
+        $legalEntityNode = $xml->add('cac:PartyLegalEntity');
+
+        // Legal name
+        $legalName = $party->getName();
+        if ($legalName !== null) {
+            $legalEntityNode->add('cbc:RegistrationName', $legalName);
+        }
+
+        // Company ID
+        $companyId = $party->getCompanyId();
+        if ($companyId !== null) {
+            $this->addIdentifierNode($legalEntityNode, 'cbc:CompanyID', $companyId);
+        }
+
+        // Contact point
+        if ($party->hasContactInformation()) {
+            $contactNode = $xml->add('cac:Contact');
+            
+            $contactName = $party->getContactName();
+            if ($contactName !== null) {
+                $contactNode->add('cbc:Name', $contactName);
+            }
+
+            $contactPhone = $party->getContactPhone();
+            if ($contactPhone !== null) {
+                $contactNode->add('cbc:Telephone', $contactPhone);
+            }
+
+            $contactEmail = $party->getContactEmail();
+            if ($contactEmail !== null) {
+                $contactNode->add('cbc:ElectronicMail', $contactEmail);
+            }
+        }
+    }
+
+
+    /**
+     * Add payee node
+     * @param UXML  $parent Invoice element
+     * @param Party $party  Party instance
+     */
+    private function addPayeeNode(UXML $parent, Party $party) {
+        $xml = $parent->add('cac:PayeeParty');
+
+        // Additional identifiers
+        foreach ($party->getIdentifiers() as $identifier) {
+            $identifierNode = $xml->add('cac:PartyIdentification');
+            $this->addIdentifierNode($identifierNode, 'cbc:ID', $identifier);
+        }
+
+        // Party name
+        $name = $party->getName();
+        if ($name !== null) {
+            $xml->add('cac:PartyName')->add('cbc:Name', $name);
+        }
+
+        // Company ID
+        $companyId = $party->getCompanyId();
+        if ($companyId !== null) {
+            $legalEntityNode = $xml->add('cac:PartyLegalEntity');
+            $this->addIdentifierNode($legalEntityNode, 'cbc:CompanyID', $companyId);
+        }
+    }
+
+
+    /**
+     * Add delivery node
+     * @param UXML     $parent   Invoice element
+     * @param Delivery $delivery Delivery instance
+     */
+    private function addDeliveryNode(UXML $parent, Delivery $delivery) {
+        $xml = $parent->add('cac:Delivery');
+
+        // BT-72: Actual delivery date
+        $date = $delivery->getDate();
+        if ($date !== null) {
+            $xml->add('cbc:ActualDeliveryDate', $date->format('Y-m-d'));
+        }
+
+        // Initial delivery location node
+        $locationNode = $xml->add('cac:DeliveryLocation');
+
+        // BT-71: Delivery location identifier
+        $locationIdentifier = $delivery->getLocationIdentifier();
+        if ($locationIdentifier !== null) {
+            $this->addIdentifierNode($locationNode, 'cbc:ID', $locationIdentifier);
+        }
+
+        // Delivery postal address
+        $addressNode = $this->addPostalAddressNode($locationNode, 'cac:Address', $delivery);
+        if ($addressNode->isEmpty()) {
+            $addressNode->remove();
+        }
+
+        // BT-70: Deliver name
+        $name = $delivery->getName();
+        if ($name !== null) {
+            $xml->add('cac:DeliveryParty')->add('cac:PartyName')->add('cbc:Name', $name);
+        }
+
+        // Remove location node if empty
+        if ($locationNode->isEmpty()) {
+            $locationNode->remove();
+        }
+    }
+
+
+    /**
+     * Add payment nodes
+     * @param UXML    $parent  Invoice element
+     * @param Payment $payment Payment instance
+     */
+    private function addPaymentNodes(UXML $parent, Payment $payment) {
+        $xml = $parent->add('cac:PaymentMeans');
+
+        // BT-81: Payment means code
+        // BT-82: Payment means name
+        $meansCode = $payment->getMeansCode();
+        if ($meansCode !== null) {
+            $meansText = $payment->getMeansText();
+            $attrs = ($meansText === null) ? [] : ['name' => $meansText];
+            $xml->add('cbc:PaymentMeansCode', $meansCode, $attrs);
+        }
+
+        // BT-83: Payment ID
+        $paymentId = $payment->getId();
+        if ($paymentId !== null) {
+            $xml->add('cbc:PaymentID', $paymentId);
+        }
+
+        // BG-18: Payment card
+        $card = $payment->getCard();
+        if ($card !== null) {
+            $this->addPaymentCardNode($xml, $card);
+        }
+
+        // BG-17: Payment transfers
+        foreach ($payment->getTransfers() as $transfer) {
+            $this->addPaymentTransferNode($xml, $transfer);
+        }
+
+        // BG-19: Payment mandate
+        $mandate = $payment->getMandate();
+        if ($mandate !== null) {
+            $this->addPaymentMandateNode($xml, $mandate);
+        }
+
+        // Remove PaymentMeans node if empty
+        if ($xml->isEmpty()) {
+            $xml->remove();
+        }
+
+        // BT-20: Payment terms
+        $terms = $payment->getTerms();
+        if ($terms !== null) {
+            $parent->add('cac:PaymentTerms')->add('cbc:Note', $terms);
+        }
+    }
+
+
+    /**
+     * Add payment card node
+     * @param UXML $parent PaymentMeans element
+     * @param Card $card   Card instance
+     */
+    private function addPaymentCardNode(UXML $parent, Card $card) {
+        $xml = $parent->add('cac:CardAccount');
+
+        // BT-87: Card PAN
+        $pan = $card->getPan();
+        if ($pan !== null) {
+            $xml->add('cbc:PrimaryAccountNumberID', $pan);
+        }
+
+        // Card network
+        $network = $card->getNetwork();
+        if ($network !== null) {
+            $xml->add('cbc:NetworkID', $network);
+        }
+
+        // BT-88: Holder name
+        $holder = $card->getHolder();
+        if ($holder !== null) {
+            $xml->add('cbc:HolderName', $holder);
+        }
+    }
+
+
+    /**
+     * Add payment transfer node
+     * @param UXML     $parent   PaymentMeans element
+     * @param Transfer $transfer Transfer instance
+     */
+    private function addPaymentTransferNode(UXML $parent, Transfer $transfer) {
+        $xml = $parent->add('cac:PayeeFinancialAccount');
+
+        // BT-84: Receiving account ID
+        $accountId = $transfer->getAccountId();
+        if ($accountId !== null) {
+            $xml->add('cbc:ID', $accountId);
+        }
+
+        // BT-85: Receiving account name
+        $accountName = $transfer->getAccountName();
+        if ($accountName !== null) {
+            $xml->add('cbc:Name', $accountName);
+        }
+
+        // BT-86: Service provider ID
+        $provider = $transfer->getProvider();
+        if ($provider !== null) {
+            $xml->add('cac:FinancialInstitutionBranch')->add('cbc:ID', $provider);
+        }
+    }
+
+
+    /**
+     * Add payment mandate node
+     * @param UXML    $parent  PaymentMeans element
+     * @param Mandate $mandate Mandate instance
+     */
+    private function addPaymentMandateNode(UXML $parent, Mandate $mandate) {
+        $xml = $parent->add('cac:PaymentMandate');
+
+        // BT-89: Mandate reference
+        $reference = $mandate->getReference();
+        if ($reference !== null) {
+            $xml->add('cbc:ID', $reference);
+        }
+
+        // BT-91: Debited account
+        $account = $mandate->getAccount();
+        if ($account !== null) {
+            $xml->add('cac:PayerFinancialAccount')->add('cbc:ID', $account);
+        }
+    }
+
+
+    /**
+     * Add allowance or charge
+     * @param UXML              $parent   Parent element
+     * @param AllowanceOrCharge $item     Allowance or charge instance
+     * @param boolean           $isCharge Is charge (TRUE) or allowance (FALSE)
+     * @param Invoice           $invoice  Invoice instance
+     * @param InvoiceLine|null  $line     Invoice line or NULL in case of at document level
+     */
+    private function addAllowanceOrCharge(
+        UXML $parent,
+        AllowanceOrCharge $item,
+        bool $isCharge,
+        Invoice $invoice,
+        $line=null
+    ) {
+        $atDocumentLevel = ($line === null);
+        $xml = $parent->add('cac:AllowanceCharge');
+
+        // Charge indicator
+        $xml->add('cbc:ChargeIndicator', $isCharge ? 'true' : 'false');
+
+        // Reason code
+        $reasonCode = $item->getReasonCode();
+        if ($reasonCode !== null) {
+            $xml->add('cbc:AllowanceChargeReasonCode', $reasonCode);
+        }
+
+        // Reason text
+        $reasonText = $item->getReason();
+        if ($reasonText !== null) {
+            $xml->add('cbc:AllowanceChargeReason', $reasonText);
+        }
+
+        // Percentage
+        if ($item->isPercentage()) {
+            $xml->add('cbc:MultiplierFactorNumeric', (string) $item->getAmount());
+        }
+
+        // Amount
+        $baseAmount = $atDocumentLevel ?
+            $invoice->getTotals()->netAmount :
+            $line->getNetAmount($invoice->getDecimals('line/netAmount')) ?? 0; // @phan-suppress-current-line PhanPossiblyNonClassMethodCall
+        $amount = $item->getEffectiveAmount($baseAmount, $invoice->getDecimals('line/allowanceChargeAmount'));
+        $this->addAmountNode($xml, 'cbc:Amount', $amount, $invoice->getCurrency());
+
+        // Base amount
+        if ($item->isPercentage()) {
+            $this->addAmountNode($xml, 'cbc:BaseAmount', $baseAmount, $invoice->getCurrency());
+        }
+
+        // Tax category
+        if ($atDocumentLevel) {
+            $this->addVatNode($xml, 'cac:TaxCategory', $item->getVatCategory(), $item->getVatRate());
+        }
+    }
+
+
+    /**
+     * Add tax total node
+     * @param UXML          $parent Parent element
+     * @param InvoiceTotals $totals Invoice totals
+     */
+    private function addTaxTotalNode(UXML $parent, InvoiceTotals $totals) {
+        $xml = $parent->add('cac:TaxTotal');
+
+        // Add tax amount
+        $this->addAmountNode($xml, 'cbc:TaxAmount', $totals->vatAmount, $totals->currency);
+
+        // Add each tax details
+        foreach ($totals->vatBreakdown as $item) {
+            $vatBreakdownNode = $xml->add('cac:TaxSubtotal');
+            $this->addAmountNode($vatBreakdownNode, 'cbc:TaxableAmount', $item->taxableAmount, $totals->currency);
+            $this->addAmountNode($vatBreakdownNode, 'cbc:TaxAmount', $item->taxAmount, $totals->currency);
+            $this->addVatNode($vatBreakdownNode, 'cac:TaxCategory', $item->category, $item->rate,
+                $item->exemptionReasonCode, $item->exemptionReason);
+        }
+    }
+
+
+    /**
+     * Add document totals node
+     * @param UXML          $parent Parent element
+     * @param InvoiceTotals $totals Invoice totals
+     */
+    private function addDocumentTotalsNode(UXML $parent, InvoiceTotals $totals) {
+        $xml = $parent->add('cac:LegalMonetaryTotal');
+
+        // Build totals matrix
+        $totalsMatrix = [
+            "cbc:LineExtensionAmount" => $totals->netAmount,
+            "cbc:TaxExclusiveAmount" => $totals->taxExclusiveAmount,
+            "cbc:TaxInclusiveAmount" => $totals->taxInclusiveAmount
+        ];
+        if ($totals->allowancesAmount > 0) {
+            $totalsMatrix['cbc:AllowanceTotalAmount'] = $totals->allowancesAmount;
+        }
+        if ($totals->chargesAmount > 0) {
+            $totalsMatrix['cbc:ChargeTotalAmount'] = $totals->chargesAmount;
+        }
+        if ($totals->paidAmount > 0) {
+            $totalsMatrix['cbc:PrepaidAmount'] = $totals->paidAmount;
+        }
+        if ($totals->roundingAmount > 0) {
+            $totalsMatrix['cbc:PayableRoundingAmount'] = $totals->roundingAmount;
+        }
+        $totalsMatrix['cbc:PayableAmount'] = $totals->payableAmount;
+
+        // Create and append XML nodes
+        foreach ($totalsMatrix as $field=>$amount) {
+            $this->addAmountNode($xml, $field, $amount, $totals->currency);
+        }
+    }
+
+
+    /**
+     * Add invoice line
+     * @param UXML        $parent     Parent XML element
+     * @param InvoiceLine $line       Invoice line
+     * @param Invoice     $invoice    Invoice instance
+     * @param int         &$lastGenId Last used auto-generated ID
+     * @param string[]    &$usedIds   Used invoice line IDs
+     */
+    private function addLineNode(UXML $parent, InvoiceLine $line, Invoice $invoice, int &$lastGenId, array &$usedIds) {
+        $xml = $parent->add('cac:InvoiceLine');
+
+        // BT-126: Invoice line identifier
+        $lineId = $line->getId();
+        if ($lineId === null) {
+            do {
+                $lineId = (string) ++$lastGenId;
+            } while (in_array($lineId, $usedIds));
+        }
+        $xml->add('cbc:ID', $lineId);
+
+        // BT-127: Invoice line note
+        $note = $line->getNote();
+        if ($note !== null) {
+            $xml->add('cbc:Note', $note);
+        }
+
+        // BT-129: Invoiced quantity
+        $xml->add('cbc:InvoicedQuantity', (string) $line->getQuantity(), ['unitCode' => $line->getUnit()]);
+
+        // BT-131: Line net amount
+        $netAmount = $line->getNetAmount($invoice->getDecimals('line/netAmount'));
+        if ($netAmount !== null) {
+            $this->addAmountNode($xml, 'cbc:LineExtensionAmount', $netAmount, $invoice->getCurrency());
+        }
+
+        // BT-133: Buyer accounting reference
+        $buyerAccountingReference = $line->getBuyerAccountingReference();
+        if ($buyerAccountingReference !== null) {
+            $xml->add('cbc:AccountingCost', $buyerAccountingReference);
+        }
+
+        // BG-26: Invoice line period
+        $this->addPeriodNode($xml, $line);
+
+        // BT-132: Order line reference
+        $orderLineReference = $line->getOrderLineReference();
+        if ($orderLineReference !== null) {
+            $xml->add('cac:OrderLineReference')->add('cbc:LineID', $orderLineReference);
+        }
+
+        // Allowances and charges
+        foreach ($line->getAllowances() as $item) {
+            $this->addAllowanceOrCharge($xml, $item, false, $invoice, $line);
+        }
+        foreach ($line->getCharges() as $item) {
+            $this->addAllowanceOrCharge($xml, $item, true, $invoice, $line);
+        }
+
+        // Initial item node
+        $itemNode = $xml->add('cac:Item');
+
+        // BT-154: Item description
+        $description = $line->getDescription();
+        if ($description !== null) {
+            $itemNode->add('cbc:Description', $description);
+        }
+
+        // BT-153: Item name
+        $name = $line->getName();
+        if ($name !== null) {
+            $itemNode->add('cbc:Name', $name);
+        }
+
+        // BT-156: Buyer identifier
+        $buyerIdentifier = $line->getBuyerIdentifier();
+        if ($buyerIdentifier !== null) {
+            $itemNode->add('cac:BuyersItemIdentification')->add('cbc:ID', $buyerIdentifier);
+        }
+
+        // BT-155: Seller identifier
+        $sellerIdentifier = $line->getSellerIdentifier();
+        if ($sellerIdentifier !== null) {
+            $itemNode->add('cac:SellersItemIdentification')->add('cbc:ID', $sellerIdentifier);
+        }
+
+        // BT-157: Standard identifier
+        $standardIdentifier = $line->getStandardIdentifier();
+        if ($standardIdentifier !== null) {
+            $this->addIdentifierNode($itemNode->add('cac:StandardItemIdentification'), 'cbc:ID', $standardIdentifier);
+        }
+
+        // BT-159: Item origin country
+        $originCountry = $line->getOriginCountry();
+        if ($originCountry !== null) {
+            $itemNode->add('cac:OriginCountry')->add('cbc:IdentificationCode', $originCountry);
+        }
+
+        // BT-158: Item classification identifiers
+        foreach ($line->getClassificationIdentifiers() as $identifier) {
+            $classNode = $itemNode->add('cac:CommodityClassification');
+            $this->addIdentifierNode($classNode, 'cbc:ItemClassificationCode', $identifier, 'listID');
+        }
+
+        // VAT node
+        $this->addVatNode($itemNode, 'cac:ClassifiedTaxCategory', $line->getVatCategory(), $line->getVatRate());
+
+        // BG-32: Item attributes
+        foreach ($line->getAttributes() as $attribute) {
+            $attributeNode = $itemNode->add('cac:AdditionalItemProperty');
+            $attributeNode->add('cbc:Name', $attribute->getName());
+            $attributeNode->add('cbc:Value', $attribute->getValue());
+        }
+
+        // Initial price node
+        $priceNode = $xml->add('cac:Price');
+
+        // Price amount
+        $price = $line->getPrice();
+        if ($price !== null) {
+            $this->addAmountNode($priceNode, 'cbc:PriceAmount', $price, $invoice->getCurrency());
+        }
+
+        // Base quantity
+        $baseQuantity = $line->getBaseQuantity();
+        if ($baseQuantity != 1) {
+            $priceNode->add('cbc:BaseQuantity', (string) $baseQuantity, ['unitCode' => $line->getUnit()]);
+        }
+
+        return $xml;
+    }
+
+    /**
+     * Add attachment node
+     * @param UXML       $parent     Parent element
+     * @param Attachment $attachment Attachment instance
+     */
+    private function addAttachmentNode(UXML $parent, Attachment $attachment) {
+        $xml = $parent->add('cac:AdditionalDocumentReference');
+        $isInvoiceObjectReference = (!$attachment->hasExternalUrl() && !$attachment->hasContents());
+
+        // BT-122: Supporting document reference
+        $identifier = $attachment->getId();
+        if ($identifier !== null) {
+            $this->addIdentifierNode($xml, 'cbc:ID', $identifier);
+        }
+
+        // BT-18: Document type code
+        if ($isInvoiceObjectReference) {
+            // Code "130" MUST be used to indicate an invoice object reference
+            // Not used for other additional documents
+            $xml->add('cbc:DocumentTypeCode', '130');
+        }
+
+        // BT-123: Supporting document description
+        $description = $attachment->getDescription();
+        if ($description !== null) {
+            $xml->add('cbc:DocumentDescription', $description);
+        }
+
+        // Attachment inner node
+        if ($isInvoiceObjectReference) {
+            return; // Skip inner node in this case
+        }
+        $attXml = $xml->add('cac:Attachment');
+
+        // BT-125: Attached document
+        if ($attachment->hasContents()) {
+            $attrs = [];
+            $mimeCode = $attachment->getMimeCode();
+            $filename = $attachment->getFilename();
+            if ($mimeCode !== null) {
+                $attrs['mimeCode'] = $mimeCode;
+            }
+            if ($filename !== null) {
+                $attrs['filename'] = $filename;
+            }
+            $attXml->add('cbc:EmbeddedDocumentBinaryObject', base64_encode($attachment->getContents()), $attrs);
+        }
+
+        // BT-124: External document location
+        $externalUrl = $attachment->getExternalUrl();
+        if ($externalUrl !== null) {
+            $attXml->add('cac:ExternalReference')->add('cbc:URI', $externalUrl);
+        }
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/AttachmentTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/AttachmentTest.php
new file mode 100644 (file)
index 0000000..b7021fb
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace Tests;
+
+use Einvoicing\Attachment;
+use Einvoicing\Identifier;
+use PHPUnit\Framework\TestCase;
+
+final class AttachmentTest extends TestCase {
+    /**
+     * @return void
+     */
+    public function testCanReadAndModifyFields() {
+        $attachment = (new Attachment)
+            ->setId(new Identifier('INV123'))
+            ->setDescription('Invoice INV123')
+            ->setExternalUrl('https://example.com')
+            ->setFilename('INV123.txt')
+            ->setMimeCode('text/plain')
+            ->setContents('This is a sample text string');
+
+        $this->assertSame('INV123', $attachment->getId()->getValue());
+        $this->assertSame('Invoice INV123', $attachment->getDescription());
+        $this->assertSame('https://example.com', $attachment->getExternalUrl());
+        $this->assertSame('INV123.txt', $attachment->getFilename());
+        $this->assertSame('text/plain', $attachment->getMimeCode());
+        $this->assertSame('This is a sample text string', $attachment->getContents());
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/IntegrationTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/IntegrationTest.php
new file mode 100644 (file)
index 0000000..e7723e8
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+namespace Tests\Integration;
+
+use DOMDocument;
+use Einvoicing\Readers\UblReader;
+use Einvoicing\Writers\UblWriter;
+use PHPUnit\Framework\TestCase;
+use const LIBXML_NOERROR;
+use function file_get_contents;
+
+final class IntegrationTest extends TestCase {
+    /** @var UblReader */
+    private $reader;
+
+    /** @var UblWriter */
+    private $writer;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->reader = new UblReader();
+        $this->writer = new UblWriter();
+    }
+
+    protected function normalize(string $xml): string {
+        $doc = new DOMDocument();
+        $doc->preserveWhiteSpace = false;
+        $doc->loadXML($xml, LIBXML_NOERROR);
+        return $doc->C14N();
+    }
+
+    /**
+     * @return void
+     */
+    protected function importAndExportInvoice(string $xmlPath) {
+        $inputXml = file_get_contents($xmlPath);
+        $invoice = $this->reader->import($inputXml);
+        $outputXml = $this->writer->export($invoice);
+
+        $this->assertEquals(
+            $this->normalize($inputXml),
+            $this->normalize($outputXml)
+        );
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRecreatePeppolBaseExample() {
+        $this->importAndExportInvoice(__DIR__ . "/peppol-base.xml");
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRecreatePeppolVatExample() {
+        $this->importAndExportInvoice(__DIR__ . "/peppol-vat-s.xml");
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRecreatePeppolAllowanceExample() {
+        $this->importAndExportInvoice(__DIR__ . "/peppol-allowance.xml");
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-allowance.xml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-allowance.xml
new file mode 100644 (file)
index 0000000..afd415e
--- /dev/null
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Based on https://github.com/OpenPEPPOL/peppol-bis-invoice-3/blob/master/rules/examples/Allowance-example.xml -->
+<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
+    xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
+    xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
+    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
+    <cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
+    <cbc:ID>Snippet1</cbc:ID>
+    <cbc:IssueDate>2017-11-13</cbc:IssueDate>
+    <cbc:DueDate>2017-12-01</cbc:DueDate>
+    <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
+    <cbc:Note>Please note we have a new phone number: 22 22 22 22</cbc:Note>
+    <cbc:TaxPointDate>2017-12-01</cbc:TaxPointDate>
+    <cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
+    <cbc:AccountingCost>4025:123:4343</cbc:AccountingCost>
+    <cbc:BuyerReference>0150abc</cbc:BuyerReference>
+    <cac:InvoicePeriod>
+        <cbc:StartDate>2017-12-01</cbc:StartDate>
+        <cbc:EndDate>2017-12-31</cbc:EndDate>
+    </cac:InvoicePeriod>
+    <cac:AccountingSupplierParty>
+        <cac:Party>
+            <cbc:EndpointID schemeID="0088">7300010000001</cbc:EndpointID>
+            <cac:PartyIdentification>
+                <cbc:ID>99887766</cbc:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <cbc:Name>SupplierTradingName Ltd.</cbc:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <cbc:StreetName>Main street 1</cbc:StreetName>
+                <cbc:AdditionalStreetName>Postbox 123</cbc:AdditionalStreetName>
+                <cbc:CityName>London</cbc:CityName>
+                <cbc:PostalZone>GB 123 EW</cbc:PostalZone>
+                <cac:Country>
+                    <cbc:IdentificationCode>GB</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>GB1232434</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>SE555555555501</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>TAX</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <cbc:RegistrationName>SupplierOfficialName Ltd</cbc:RegistrationName>
+                <cbc:CompanyID>GB983294</cbc:CompanyID>
+            </cac:PartyLegalEntity>
+        </cac:Party>
+    </cac:AccountingSupplierParty>
+    <cac:AccountingCustomerParty>
+        <cac:Party>
+            <cbc:EndpointID schemeID="0002">4598375937</cbc:EndpointID>
+            <cac:PartyIdentification>
+                <cbc:ID schemeID="0002">4598375937</cbc:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <cbc:Name>BuyerTradingName AS</cbc:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <cbc:StreetName>Hovedgatan 32</cbc:StreetName>
+                <cbc:AdditionalStreetName>Po box 878</cbc:AdditionalStreetName>
+                <cbc:CityName>Stockholm</cbc:CityName>
+                <cbc:PostalZone>456 34</cbc:PostalZone>
+                <cbc:CountrySubentity>Södermalm</cbc:CountrySubentity>
+                <cac:Country>
+                    <cbc:IdentificationCode>SE</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>SE4598375937</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <cbc:RegistrationName>Buyer Official Name</cbc:RegistrationName>
+                <cbc:CompanyID schemeID="0183">39937423947</cbc:CompanyID>
+            </cac:PartyLegalEntity>
+            <cac:Contact>
+                <cbc:Name>Lisa Johnson</cbc:Name>
+                <cbc:Telephone>23434234</cbc:Telephone>
+                <cbc:ElectronicMail>lj@buyer.se</cbc:ElectronicMail>
+            </cac:Contact>
+        </cac:Party>
+    </cac:AccountingCustomerParty>
+    <cac:Delivery>
+        <cbc:ActualDeliveryDate>2017-11-01</cbc:ActualDeliveryDate>
+        <cac:DeliveryLocation>
+            <cbc:ID schemeID="0088">7300010000001</cbc:ID>
+            <cac:Address>
+                <cbc:StreetName>Delivery street 2</cbc:StreetName>
+                <cbc:AdditionalStreetName>Building 56</cbc:AdditionalStreetName>
+                <cbc:CityName>Stockholm</cbc:CityName>
+                <cbc:PostalZone>21234</cbc:PostalZone>
+                <cbc:CountrySubentity>Södermalm</cbc:CountrySubentity>
+                <cac:AddressLine>
+                    <cbc:Line>Gate 15</cbc:Line>
+                </cac:AddressLine>
+                <cac:Country>
+                    <cbc:IdentificationCode>SE</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:Address>
+        </cac:DeliveryLocation>
+        <cac:DeliveryParty>
+            <cac:PartyName>
+                <cbc:Name>Delivery party Name</cbc:Name>
+            </cac:PartyName>
+        </cac:DeliveryParty>
+    </cac:Delivery>
+    <cac:PaymentMeans>
+        <cbc:PaymentMeansCode name="Credit transfer">30</cbc:PaymentMeansCode>
+        <cbc:PaymentID>Snippet1</cbc:PaymentID>
+        <cac:PayeeFinancialAccount>
+            <cbc:ID>IBAN32423940</cbc:ID>
+            <cbc:Name>AccountName</cbc:Name>
+            <cac:FinancialInstitutionBranch>
+                <cbc:ID>BIC324098</cbc:ID>
+            </cac:FinancialInstitutionBranch>
+        </cac:PayeeFinancialAccount>
+    </cac:PaymentMeans>
+    <cac:PaymentTerms>
+        <cbc:Note>Payment within 10 days, 2% discount</cbc:Note>
+    </cac:PaymentTerms>
+    <cac:AllowanceCharge>
+        <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
+        <cbc:AllowanceChargeReasonCode>95</cbc:AllowanceChargeReasonCode>
+        <cbc:AllowanceChargeReason>Discount</cbc:AllowanceChargeReason>
+        <cbc:Amount currencyID="EUR">200</cbc:Amount>
+        <cac:TaxCategory>
+            <cbc:ID>S</cbc:ID>
+            <cbc:Percent>25</cbc:Percent>
+            <cac:TaxScheme>
+                <cbc:ID>VAT</cbc:ID>
+            </cac:TaxScheme>
+        </cac:TaxCategory>
+    </cac:AllowanceCharge>
+    <cac:AllowanceCharge>
+        <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
+        <cbc:AllowanceChargeReasonCode>CG</cbc:AllowanceChargeReasonCode>
+        <cbc:AllowanceChargeReason>Cleaning</cbc:AllowanceChargeReason>
+        <cbc:MultiplierFactorNumeric>20</cbc:MultiplierFactorNumeric>
+        <cbc:Amount currencyID="EUR">1189.8</cbc:Amount>
+        <cbc:BaseAmount currencyID="EUR">5949</cbc:BaseAmount>
+        <cac:TaxCategory>
+            <cbc:ID>S</cbc:ID>
+            <cbc:Percent>25</cbc:Percent>
+            <cac:TaxScheme>
+                <cbc:ID>VAT</cbc:ID>
+            </cac:TaxScheme>
+        </cac:TaxCategory>
+    </cac:AllowanceCharge>
+    <cac:TaxTotal>
+        <cbc:TaxAmount currencyID="EUR">1484.7</cbc:TaxAmount>
+        <cac:TaxSubtotal>
+            <cbc:TaxableAmount currencyID="EUR">5938.8</cbc:TaxableAmount>
+            <cbc:TaxAmount currencyID="EUR">1484.7</cbc:TaxAmount>
+            <cac:TaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:TaxSubtotal>
+        <cac:TaxSubtotal>
+            <cbc:TaxableAmount currencyID="EUR">1000</cbc:TaxableAmount>
+            <cbc:TaxAmount currencyID="EUR">0</cbc:TaxAmount>
+            <cac:TaxCategory>
+                <cbc:ID>E</cbc:ID>
+                <cbc:Percent>0</cbc:Percent>
+                <cbc:TaxExemptionReason>Reason for tax exempt</cbc:TaxExemptionReason>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:TaxSubtotal>
+    </cac:TaxTotal>
+    <cac:LegalMonetaryTotal>
+        <cbc:LineExtensionAmount currencyID="EUR">5949</cbc:LineExtensionAmount>
+        <cbc:TaxExclusiveAmount currencyID="EUR">6938.8</cbc:TaxExclusiveAmount>
+        <cbc:TaxInclusiveAmount currencyID="EUR">8423.5</cbc:TaxInclusiveAmount>
+        <cbc:AllowanceTotalAmount currencyID="EUR">200</cbc:AllowanceTotalAmount>
+        <cbc:ChargeTotalAmount currencyID="EUR">1189.8</cbc:ChargeTotalAmount>
+        <cbc:PrepaidAmount currencyID="EUR">1000</cbc:PrepaidAmount>
+        <cbc:PayableAmount currencyID="EUR">7423.5</cbc:PayableAmount>
+    </cac:LegalMonetaryTotal>
+    <cac:InvoiceLine>
+        <cbc:ID>1</cbc:ID>
+        <cbc:Note>Testing note on line level</cbc:Note>
+        <cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
+        <cbc:LineExtensionAmount currencyID="EUR">4040</cbc:LineExtensionAmount>
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
+        <cac:AllowanceCharge>
+            <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
+            <cbc:AllowanceChargeReasonCode>95</cbc:AllowanceChargeReasonCode>
+            <cbc:AllowanceChargeReason>Discount</cbc:AllowanceChargeReason>
+            <cbc:Amount currencyID="EUR">101</cbc:Amount>
+        </cac:AllowanceCharge>
+        <cac:AllowanceCharge>
+            <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
+            <cbc:AllowanceChargeReasonCode>CG</cbc:AllowanceChargeReasonCode>
+            <cbc:AllowanceChargeReason>Cleaning</cbc:AllowanceChargeReason>
+            <cbc:MultiplierFactorNumeric>1</cbc:MultiplierFactorNumeric>
+            <cbc:Amount currencyID="EUR">40.4</cbc:Amount>
+            <cbc:BaseAmount currencyID="EUR">4040</cbc:BaseAmount>
+        </cac:AllowanceCharge>
+        <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:SellersItemIdentification>
+                <cbc:ID>97iugug876</cbc:ID>
+            </cac:SellersItemIdentification>
+            <cac:OriginCountry>
+                <cbc:IdentificationCode>NO</cbc:IdentificationCode>
+            </cac:OriginCountry>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">09348023</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+        </cac:Item>
+        <cac:Price>
+            <cbc:PriceAmount currencyID="EUR">410</cbc:PriceAmount>
+        </cac:Price>
+    </cac:InvoiceLine>
+    <cac:InvoiceLine>
+        <cbc:ID>2</cbc:ID>
+        <cbc:Note>Testing note on line level</cbc:Note>
+        <cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
+        <cbc:LineExtensionAmount currencyID="EUR">1000</cbc:LineExtensionAmount>
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
+        <cac:InvoicePeriod>
+            <cbc:StartDate>2017-12-01</cbc:StartDate>
+            <cbc:EndDate>2017-12-05</cbc:EndDate>
+        </cac:InvoicePeriod>
+        <cac:OrderLineReference>
+            <cbc:LineID>124</cbc:LineID>
+        </cac:OrderLineReference>
+        <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:SellersItemIdentification>
+                <cbc:ID>97iugug876</cbc:ID>
+            </cac:SellersItemIdentification>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">86776</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>E</cbc:ID>
+                <cbc:Percent>0</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+            <cac:AdditionalItemProperty>
+                <cbc:Name>AdditionalItemName</cbc:Name>
+                <cbc:Value>AdditionalItemValue</cbc:Value>
+            </cac:AdditionalItemProperty>
+        </cac:Item>
+        <cac:Price>
+            <cbc:PriceAmount currencyID="EUR">200</cbc:PriceAmount>
+            <cbc:BaseQuantity unitCode="C62">2</cbc:BaseQuantity>
+        </cac:Price>
+    </cac:InvoiceLine>
+    <cac:InvoiceLine>
+        <cbc:ID>a-custom-identifier</cbc:ID>
+        <cbc:Note>Testing note on line level</cbc:Note>
+        <cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
+        <cbc:LineExtensionAmount currencyID="EUR">909</cbc:LineExtensionAmount>
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
+        <cac:InvoicePeriod>
+            <cbc:StartDate>2017-12-01</cbc:StartDate>
+            <cbc:EndDate>2017-12-05</cbc:EndDate>
+        </cac:InvoicePeriod>
+        <cac:OrderLineReference>
+            <cbc:LineID>124</cbc:LineID>
+        </cac:OrderLineReference>
+        <cac:AllowanceCharge>
+            <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
+            <cbc:AllowanceChargeReasonCode>95</cbc:AllowanceChargeReasonCode>
+            <cbc:AllowanceChargeReason>Discount</cbc:AllowanceChargeReason>
+            <cbc:Amount currencyID="EUR">101</cbc:Amount>
+        </cac:AllowanceCharge>
+        <cac:AllowanceCharge>
+            <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
+            <cbc:AllowanceChargeReasonCode>CG</cbc:AllowanceChargeReasonCode>
+            <cbc:AllowanceChargeReason>Charge</cbc:AllowanceChargeReason>
+            <cbc:MultiplierFactorNumeric>1</cbc:MultiplierFactorNumeric>
+            <cbc:Amount currencyID="EUR">9.09</cbc:Amount>
+            <cbc:BaseAmount currencyID="EUR">909</cbc:BaseAmount>
+        </cac:AllowanceCharge>
+        <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:SellersItemIdentification>
+                <cbc:ID>97iugug876</cbc:ID>
+            </cac:SellersItemIdentification>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">86776</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+            <cac:AdditionalItemProperty>
+                <cbc:Name>AdditionalItemName</cbc:Name>
+                <cbc:Value>AdditionalItemValue</cbc:Value>
+            </cac:AdditionalItemProperty>
+        </cac:Item>
+        <cac:Price>
+            <cbc:PriceAmount currencyID="EUR">100</cbc:PriceAmount>
+        </cac:Price>
+    </cac:InvoiceLine>
+</Invoice>
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-base.xml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-base.xml
new file mode 100644 (file)
index 0000000..f4110b7
--- /dev/null
@@ -0,0 +1,250 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Based on https://github.com/OpenPEPPOL/peppol-bis-invoice-3/blob/master/rules/examples/base-example.xml -->
+<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
+    xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
+    xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
+    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
+    <cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
+    <cbc:ID>Snippet1</cbc:ID>
+    <cbc:IssueDate>2017-11-13</cbc:IssueDate>
+    <cbc:DueDate>2017-12-01</cbc:DueDate>
+    <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
+    <cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
+    <cbc:AccountingCost>4025:123:4343</cbc:AccountingCost>
+    <cbc:BuyerReference>0150abc</cbc:BuyerReference>
+    <cac:OrderReference>
+        <cbc:ID>854777</cbc:ID>
+    </cac:OrderReference>
+    <cac:BillingReference>
+        <cac:InvoiceDocumentReference>
+            <cbc:ID>INV-122</cbc:ID>
+            <cbc:IssueDate>2021-09-21</cbc:IssueDate>
+        </cac:InvoiceDocumentReference>
+    </cac:BillingReference>
+    <cac:BillingReference>
+        <cac:InvoiceDocumentReference>
+            <cbc:ID>INV-123</cbc:ID>
+        </cac:InvoiceDocumentReference>
+    </cac:BillingReference>
+    <cac:OriginatorDocumentReference>
+        <cbc:ID>PPID-123</cbc:ID>
+    </cac:OriginatorDocumentReference>
+    <cac:ContractDocumentReference>
+        <cbc:ID>123Contractref</cbc:ID>
+    </cac:ContractDocumentReference>
+    <cac:AdditionalDocumentReference>
+        <cbc:ID>INV-123</cbc:ID>
+        <cbc:DocumentTypeCode>130</cbc:DocumentTypeCode>
+    </cac:AdditionalDocumentReference>
+    <cac:AdditionalDocumentReference>
+        <cbc:ID>ATT-4321</cbc:ID>
+        <cbc:DocumentDescription>A link to an external attachment</cbc:DocumentDescription>
+        <cac:Attachment>
+            <cac:ExternalReference>
+                <cbc:URI>https://www.example.com/document.pdf</cbc:URI>
+            </cac:ExternalReference>
+        </cac:Attachment>
+    </cac:AdditionalDocumentReference>
+    <cac:AdditionalDocumentReference>
+        <cbc:ID>ATT-1234</cbc:ID>
+        <cac:Attachment>
+            <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="ATT-1234.pdf">VGhlIGF0dGFjaG1lbnQgcmF3IGNvbnRlbnRz</cbc:EmbeddedDocumentBinaryObject>  
+        </cac:Attachment>
+    </cac:AdditionalDocumentReference>
+    <cac:AccountingSupplierParty>
+        <cac:Party>
+            <cbc:EndpointID schemeID="0088">9482348239847239874</cbc:EndpointID>
+            <cac:PartyIdentification>
+                <cbc:ID>99887766</cbc:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <cbc:Name>SupplierTradingName Ltd.</cbc:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <cbc:StreetName>Main street 1</cbc:StreetName>
+                <cbc:AdditionalStreetName>Postbox 123</cbc:AdditionalStreetName>
+                <cbc:CityName>London</cbc:CityName>
+                <cbc:PostalZone>GB 123 EW</cbc:PostalZone>
+                <cac:Country>
+                    <cbc:IdentificationCode>GB</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>GB1232434</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <cbc:RegistrationName>SupplierOfficialName Ltd</cbc:RegistrationName>
+                <cbc:CompanyID>GB983294</cbc:CompanyID>
+            </cac:PartyLegalEntity>
+        </cac:Party>
+    </cac:AccountingSupplierParty>
+    <cac:AccountingCustomerParty>
+        <cac:Party>
+            <cbc:EndpointID schemeID="0002">FR23342</cbc:EndpointID>
+            <cac:PartyIdentification>
+                <cbc:ID schemeID="0002">FR23342</cbc:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <cbc:Name>BuyerTradingName AS</cbc:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <cbc:StreetName>Hovedgatan 32</cbc:StreetName>
+                <cbc:AdditionalStreetName>Po box 878</cbc:AdditionalStreetName>
+                <cbc:CityName>Stockholm</cbc:CityName>
+                <cbc:PostalZone>456 34</cbc:PostalZone>
+                <cac:Country>
+                    <cbc:IdentificationCode>SE</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>SE4598375937</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <cbc:RegistrationName>Buyer Official Name</cbc:RegistrationName>
+                <cbc:CompanyID schemeID="0183">39937423947</cbc:CompanyID>
+            </cac:PartyLegalEntity>
+            <cac:Contact>
+                <cbc:Name>Lisa Johnson</cbc:Name>
+                <cbc:Telephone>23434234</cbc:Telephone>
+                <cbc:ElectronicMail>lj@buyer.se</cbc:ElectronicMail>
+            </cac:Contact>
+        </cac:Party>
+    </cac:AccountingCustomerParty>
+    <cac:Delivery>
+        <cbc:ActualDeliveryDate>2017-11-01</cbc:ActualDeliveryDate>
+        <cac:DeliveryLocation>
+            <cbc:ID schemeID="0088">9483759475923478</cbc:ID>
+            <cac:Address>
+                <cbc:StreetName>Delivery street 2</cbc:StreetName>
+                <cbc:AdditionalStreetName>Building 56</cbc:AdditionalStreetName>
+                <cbc:CityName>Stockholm</cbc:CityName>
+                <cbc:PostalZone>21234</cbc:PostalZone>
+                <cac:Country>
+                    <cbc:IdentificationCode>SE</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:Address>
+        </cac:DeliveryLocation>
+        <cac:DeliveryParty>
+            <cac:PartyName>
+                <cbc:Name>Delivery party Name</cbc:Name>
+            </cac:PartyName>
+        </cac:DeliveryParty>
+    </cac:Delivery>
+    <cac:PaymentMeans>
+        <cbc:PaymentMeansCode name="Credit transfer">30</cbc:PaymentMeansCode>
+        <cbc:PaymentID>Snippet1</cbc:PaymentID>
+        <cac:PayeeFinancialAccount>
+            <cbc:ID>IBAN32423940</cbc:ID>
+            <cbc:Name>AccountName</cbc:Name>
+            <cac:FinancialInstitutionBranch>
+                <cbc:ID>BIC324098</cbc:ID>
+            </cac:FinancialInstitutionBranch>
+        </cac:PayeeFinancialAccount>
+    </cac:PaymentMeans>
+    <cac:PaymentTerms>
+        <cbc:Note>Payment within 10 days, 2% discount</cbc:Note>
+    </cac:PaymentTerms>
+        <cac:AllowanceCharge>
+            <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
+            <cbc:AllowanceChargeReason>Insurance</cbc:AllowanceChargeReason>
+            <cbc:Amount currencyID="EUR">25</cbc:Amount>
+            <cac:TaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:AllowanceCharge>
+    <cac:TaxTotal>
+        <cbc:TaxAmount currencyID="EUR">331.25</cbc:TaxAmount>
+        <cac:TaxSubtotal>
+            <cbc:TaxableAmount currencyID="EUR">1325</cbc:TaxableAmount>
+            <cbc:TaxAmount currencyID="EUR">331.25</cbc:TaxAmount>
+            <cac:TaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:TaxSubtotal>
+    </cac:TaxTotal>
+    <cac:LegalMonetaryTotal>
+        <cbc:LineExtensionAmount currencyID="EUR">1300</cbc:LineExtensionAmount>
+        <cbc:TaxExclusiveAmount currencyID="EUR">1325</cbc:TaxExclusiveAmount>
+        <cbc:TaxInclusiveAmount currencyID="EUR">1656.25</cbc:TaxInclusiveAmount>
+        <cbc:ChargeTotalAmount currencyID="EUR">25</cbc:ChargeTotalAmount>
+        <cbc:PayableAmount currencyID="EUR">1656.25</cbc:PayableAmount>
+    </cac:LegalMonetaryTotal>
+    
+<cac:InvoiceLine>
+        <cbc:ID>1</cbc:ID>
+    <cbc:InvoicedQuantity unitCode="DAY">7</cbc:InvoicedQuantity>
+    <cbc:LineExtensionAmount currencyID= "EUR">2800</cbc:LineExtensionAmount>
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
+       <cac:OrderLineReference>
+            <cbc:LineID>123</cbc:LineID>
+        </cac:OrderLineReference>
+    <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:StandardItemIdentification>
+                <cbc:ID schemeID="0088">21382183120983</cbc:ID>
+            </cac:StandardItemIdentification>
+            <cac:OriginCountry>
+                <cbc:IdentificationCode>NO</cbc:IdentificationCode>
+            </cac:OriginCountry>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">09348023</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+        </cac:Item>
+    <cac:Price>
+        <cbc:PriceAmount currencyID="EUR">400</cbc:PriceAmount>
+    </cac:Price>
+    </cac:InvoiceLine>
+<cac:InvoiceLine>
+    <cbc:ID>2</cbc:ID>
+    <cbc:InvoicedQuantity unitCode="DAY">-3</cbc:InvoicedQuantity>
+    <cbc:LineExtensionAmount currencyID="EUR">-1500</cbc:LineExtensionAmount>
+    <cac:OrderLineReference>
+        <cbc:LineID>123</cbc:LineID>
+    </cac:OrderLineReference>
+    <cac:Item>
+        <cbc:Description>Description 2</cbc:Description>
+        <cbc:Name>item name 2</cbc:Name>
+        <cac:StandardItemIdentification>
+            <cbc:ID schemeID="0088">21382183120983</cbc:ID>
+        </cac:StandardItemIdentification>
+        <cac:OriginCountry>
+            <cbc:IdentificationCode>NO</cbc:IdentificationCode>
+        </cac:OriginCountry>
+        <cac:CommodityClassification>
+            <cbc:ItemClassificationCode listID="SRV">09348023</cbc:ItemClassificationCode>
+        </cac:CommodityClassification>
+        <cac:ClassifiedTaxCategory>
+            <cbc:ID>S</cbc:ID>
+            <cbc:Percent>25</cbc:Percent>
+            <cac:TaxScheme>
+                <cbc:ID>VAT</cbc:ID>
+            </cac:TaxScheme>
+        </cac:ClassifiedTaxCategory>
+    </cac:Item>
+    <cac:Price>
+        <cbc:PriceAmount currencyID="EUR">500</cbc:PriceAmount>
+    </cac:Price>
+</cac:InvoiceLine>
+</Invoice>
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-vat-s.xml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Integration/peppol-vat-s.xml
new file mode 100644 (file)
index 0000000..150a159
--- /dev/null
@@ -0,0 +1,296 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Based on https://github.com/OpenPEPPOL/peppol-bis-invoice-3/blob/master/rules/examples/Vat-category-S.xml -->
+<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
+    xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
+    xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
+    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>
+    <cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
+    <cbc:ID>Snippet1</cbc:ID>
+    <cbc:IssueDate>2017-11-13</cbc:IssueDate>
+    <cbc:DueDate>2017-12-01</cbc:DueDate>
+    <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
+    <cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
+    <cbc:AccountingCost>4025:123:4343</cbc:AccountingCost>
+    <cbc:BuyerReference>0150abc</cbc:BuyerReference>
+    <cac:AccountingSupplierParty>
+        <cac:Party>
+            <cbc:EndpointID schemeID="0088">7300010000001</cbc:EndpointID>
+            <cac:PartyIdentification>
+                <cbc:ID>99887766</cbc:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <cbc:Name>SupplierTradingName Ltd.</cbc:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <cbc:StreetName>Main street 1</cbc:StreetName>
+                <cbc:AdditionalStreetName>Postbox 123</cbc:AdditionalStreetName>
+                <cbc:CityName>London</cbc:CityName>
+                <cbc:PostalZone>GB 123 EW</cbc:PostalZone>
+                <cac:Country>
+                    <cbc:IdentificationCode>GB</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>GB1232434</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <cbc:RegistrationName>SupplierOfficialName Ltd</cbc:RegistrationName>
+                <cbc:CompanyID>GB983294</cbc:CompanyID>  
+            </cac:PartyLegalEntity>
+            <cac:Contact>
+                <cbc:Name>John Doe</cbc:Name>
+                <cbc:Telephone>9384203984</cbc:Telephone>
+                <cbc:ElectronicMail>john.doe@foo.bar</cbc:ElectronicMail>
+            </cac:Contact>
+        </cac:Party>
+    </cac:AccountingSupplierParty>
+
+    <cac:AccountingCustomerParty>
+        <cac:Party>
+            <cbc:EndpointID schemeID="0002">FR23342</cbc:EndpointID>
+            <cac:PartyIdentification>
+                <cbc:ID schemeID="0002">FR23342</cbc:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <cbc:Name>BuyerTradingName AS</cbc:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <cbc:StreetName>Hovedgatan 32</cbc:StreetName>
+                <cbc:AdditionalStreetName>Po box 878</cbc:AdditionalStreetName>
+                <cbc:CityName>Stockholm</cbc:CityName>
+                <cbc:PostalZone>456 34</cbc:PostalZone>
+             <cac:Country>
+                    <cbc:IdentificationCode>SE</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <cbc:CompanyID>SE4598375937</cbc:CompanyID>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <cbc:RegistrationName>Buyer Official Name</cbc:RegistrationName>
+                <cbc:CompanyID schemeID="0183">39937423947</cbc:CompanyID>
+            </cac:PartyLegalEntity>
+        </cac:Party>
+    </cac:AccountingCustomerParty>
+    <cac:Delivery>
+        <cbc:ActualDeliveryDate>2017-11-01</cbc:ActualDeliveryDate>
+        <cac:DeliveryLocation>
+            <cbc:ID schemeID="0088">7300010000001</cbc:ID>
+            <cac:Address>
+                <cbc:StreetName>Delivery street 2</cbc:StreetName>
+                <cbc:AdditionalStreetName>Building 56</cbc:AdditionalStreetName>
+                <cbc:CityName>Stockholm</cbc:CityName>
+                <cbc:PostalZone>21234</cbc:PostalZone>
+                <cbc:CountrySubentity>Södermalm</cbc:CountrySubentity>
+                <cac:AddressLine>
+                    <cbc:Line>Gate 15</cbc:Line>
+                </cac:AddressLine>
+                <cac:Country>
+                    <cbc:IdentificationCode>SE</cbc:IdentificationCode>
+                </cac:Country>
+            </cac:Address>
+        </cac:DeliveryLocation>
+        <cac:DeliveryParty>
+            <cac:PartyName>
+                <cbc:Name>Delivery party Name</cbc:Name>
+            </cac:PartyName>
+        </cac:DeliveryParty>
+    </cac:Delivery>
+    <cac:PaymentMeans>
+        <cbc:PaymentMeansCode name="Credit transfer">30</cbc:PaymentMeansCode>
+        <cbc:PaymentID>Snippet1</cbc:PaymentID>
+        <cac:PayeeFinancialAccount>
+            <cbc:ID>IBAN32423940</cbc:ID>
+            <cbc:Name>AccountName</cbc:Name>
+            <cac:FinancialInstitutionBranch>
+                <cbc:ID>BIC324098</cbc:ID>
+            </cac:FinancialInstitutionBranch>
+        </cac:PayeeFinancialAccount>
+    </cac:PaymentMeans>
+    <cac:PaymentTerms>
+        <cbc:Note>Payment within 10 days, 2% discount</cbc:Note>
+    </cac:PaymentTerms>
+    
+    <cac:AllowanceCharge>
+        <cbc:ChargeIndicator>false</cbc:ChargeIndicator>
+        <cbc:AllowanceChargeReason>Discount</cbc:AllowanceChargeReason>
+        <cbc:Amount currencyID="EUR">100</cbc:Amount>
+        <cac:TaxCategory>
+            <cbc:ID>S</cbc:ID>
+            <cbc:Percent>25</cbc:Percent>
+            <cac:TaxScheme>
+                <cbc:ID>VAT</cbc:ID>
+            </cac:TaxScheme>
+        </cac:TaxCategory>
+    </cac:AllowanceCharge>
+
+    <cac:AllowanceCharge>
+        <cbc:ChargeIndicator>true</cbc:ChargeIndicator>
+        <cbc:AllowanceChargeReason>Cleaning</cbc:AllowanceChargeReason>
+        <cbc:Amount currencyID="EUR">200</cbc:Amount>
+        <cac:TaxCategory>
+            <cbc:ID>S</cbc:ID>
+            <cbc:Percent>25</cbc:Percent>
+            <cac:TaxScheme>
+                <cbc:ID>VAT</cbc:ID>
+            </cac:TaxScheme>
+        </cac:TaxCategory>
+    </cac:AllowanceCharge>
+    <cac:TaxTotal>
+        <cbc:TaxAmount currencyID="EUR">1550</cbc:TaxAmount>
+        
+        <cac:TaxSubtotal>
+            <cbc:TaxableAmount currencyID="EUR">5000</cbc:TaxableAmount>
+            <cbc:TaxAmount currencyID="EUR">1250</cbc:TaxAmount>
+            <cac:TaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:TaxSubtotal>
+        
+        <cac:TaxSubtotal>
+            <cbc:TaxableAmount currencyID="EUR">2000</cbc:TaxableAmount>
+            <cbc:TaxAmount currencyID="EUR">300</cbc:TaxAmount>
+            <cac:TaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>15</cbc:Percent>        
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:TaxSubtotal>
+    </cac:TaxTotal>
+   
+    <cac:LegalMonetaryTotal>
+        <cbc:LineExtensionAmount currencyID="EUR">6900</cbc:LineExtensionAmount>
+        <cbc:TaxExclusiveAmount currencyID="EUR">7000</cbc:TaxExclusiveAmount>
+        <cbc:TaxInclusiveAmount currencyID="EUR">8550</cbc:TaxInclusiveAmount>
+        <cbc:AllowanceTotalAmount currencyID="EUR">100</cbc:AllowanceTotalAmount>
+        <cbc:ChargeTotalAmount currencyID="EUR">200</cbc:ChargeTotalAmount>
+        <cbc:PayableAmount currencyID="EUR">8550</cbc:PayableAmount>
+    </cac:LegalMonetaryTotal>
+   
+   
+    <cac:InvoiceLine>
+    <cbc:ID>1</cbc:ID>
+        <cbc:Note>Testing note on line level</cbc:Note>
+        <cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
+        <cbc:LineExtensionAmount currencyID="EUR">4000</cbc:LineExtensionAmount>
+    
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
+        <cac:InvoicePeriod>
+            <cbc:StartDate>2017-12-01</cbc:StartDate>
+            <cbc:EndDate>2017-12-05</cbc:EndDate>
+        </cac:InvoicePeriod>
+        <cac:OrderLineReference>
+            <cbc:LineID>123</cbc:LineID>
+        </cac:OrderLineReference>
+        <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:SellersItemIdentification>
+                <cbc:ID>97iugug876</cbc:ID>
+            </cac:SellersItemIdentification>
+            <cac:StandardItemIdentification>
+                <cbc:ID schemeID="0088">7300010000001</cbc:ID>
+            </cac:StandardItemIdentification>
+            <cac:OriginCountry>
+                <cbc:IdentificationCode>NO</cbc:IdentificationCode>
+            </cac:OriginCountry>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">09348023</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>     
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+         
+        </cac:Item>
+        <cac:Price>
+            <cbc:PriceAmount currencyID="EUR">400</cbc:PriceAmount>
+        </cac:Price>
+    </cac:InvoiceLine>
+    
+    <cac:InvoiceLine>
+        <cbc:ID>2</cbc:ID>
+        <cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
+        <cbc:LineExtensionAmount currencyID="EUR">2000</cbc:LineExtensionAmount> 
+
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>
+        <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:SellersItemIdentification>
+                <cbc:ID>97iugug876</cbc:ID>
+            </cac:SellersItemIdentification>
+            <cac:StandardItemIdentification>
+                <cbc:ID schemeID="0088">7300010000001</cbc:ID>
+            </cac:StandardItemIdentification>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">86776</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>
+   
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>15</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+        </cac:Item>
+        <cac:Price>
+            <cbc:PriceAmount currencyID="EUR">200</cbc:PriceAmount>
+        </cac:Price>
+    </cac:InvoiceLine>
+
+    <cac:InvoiceLine>
+        <cbc:ID>3</cbc:ID>
+        <cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
+        <cbc:LineExtensionAmount currencyID="EUR">900</cbc:LineExtensionAmount>    
+
+        <cbc:AccountingCost>Konteringsstreng</cbc:AccountingCost>     
+        <cac:Item>
+            <cbc:Description>Description of item</cbc:Description>
+            <cbc:Name>item name</cbc:Name>
+            <cac:SellersItemIdentification>
+                <cbc:ID>97iugug876</cbc:ID>
+            </cac:SellersItemIdentification>
+            <cac:StandardItemIdentification>
+                <cbc:ID schemeID="0160">873649827489</cbc:ID>
+            </cac:StandardItemIdentification>
+            <cac:CommodityClassification>
+                <cbc:ItemClassificationCode listID="SRV">86776</cbc:ItemClassificationCode>
+            </cac:CommodityClassification>
+            <cac:ClassifiedTaxCategory>
+                <cbc:ID>S</cbc:ID>
+                <cbc:Percent>25</cbc:Percent>
+                <cac:TaxScheme>
+                    <cbc:ID>VAT</cbc:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+            <cac:AdditionalItemProperty>
+                <cbc:Name>AdditionalItemName</cbc:Name>
+                <cbc:Value>AdditionalItemValue</cbc:Value>
+            </cac:AdditionalItemProperty>
+        </cac:Item>
+        <cac:Price>
+            <cbc:PriceAmount currencyID="EUR">90</cbc:PriceAmount>
+        </cac:Price>
+
+    </cac:InvoiceLine>    
+</Invoice>
+
+
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/InvoiceLineTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/InvoiceLineTest.php
new file mode 100644 (file)
index 0000000..2ed4b28
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace Tests;
+
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\InvoiceLine;
+use PHPUnit\Framework\TestCase;
+
+final class InvoiceLineTest extends TestCase {
+    /** @var InvoiceLine */
+    private $line;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->line = new InvoiceLine();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanSetPriceWithCustomBaseQuantity() {
+        $this->line->setBaseQuantity(5)->setPrice(123.45);
+        $this->assertEquals(5, $this->line->getBaseQuantity());
+        $this->line->setPrice(543.21, 2);
+        $this->assertEquals(2, $this->line->getBaseQuantity());
+    }
+
+    /**
+     * @return void
+     */
+    public function testTotalAmountsAreCalculatedCorrectly() {
+        $allowance = (new AllowanceOrCharge)->setAmount(20.2);
+        $charge = (new AllowanceOrCharge)->setAmount(5)->markAsPercentage();
+        $this->line
+            ->setPrice(50, 2)
+            ->setQuantity(10)
+            ->setVatRate(21)
+            ->addAllowance($allowance)
+            ->addCharge($charge);
+        $this->assertEquals(250,   $this->line->getNetAmountBeforeAllowancesCharges());
+        $this->assertEquals(20.2,  $this->line->getAllowancesAmount());
+        $this->assertEquals(12.5,  $this->line->getChargesAmount());
+        $this->assertEquals(242.3, $this->line->getNetAmount());
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/InvoiceTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/InvoiceTest.php
new file mode 100644 (file)
index 0000000..85cf112
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+namespace Tests;
+
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\Presets\Peppol;
+use InvalidArgumentException;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class InvoiceTest extends TestCase {
+    /** @var Invoice */
+    private $invoice;
+
+    /** @var InvoiceLine */
+    private $line;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->invoice = (new Invoice)->setRoundingMatrix(['' => 2]);
+        $this->line = new InvoiceLine();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanCreateInvoiceFromPreset() {
+        $invoice = new Invoice(Peppol::class);
+        $this->assertEquals((new Peppol)->getSpecification(), $invoice->getSpecification());
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotCreateInvoiceFromInvalidPreset() {
+        $this->expectException(InvalidArgumentException::class);
+        new Invoice(self::class);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanReadAndWriteLines() {
+        $this->assertSame($this->line, $this->invoice->addLine($this->line)->getLines()[0]);
+        $this->invoice->removeLine(0);
+        $this->assertEmpty($this->invoice->getLines());
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveLines() {
+        $this->invoice
+            ->addLine(new InvoiceLine)
+            ->addLine($this->line)
+            ->addLine(new InvoiceLine)
+            ->removeLine(2)
+            ->removeLine(0);
+        $this->assertSame($this->line, $this->invoice->getLines()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsLines() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->invoice->addLine(new InvoiceLine)->removeLine(1);
+    }
+
+    /**
+     * @return void
+     */
+    public function testDecimalMatrixIsUsed() {
+        $this->invoice->setRoundingMatrix([
+            "invoice/paidAmount" => 4,
+            "line/netAmount" => 8,
+            "" => 3
+        ])->setPaidAmount(123.456789)
+          ->setRoundingAmount(987.654321)
+          ->addLine((new InvoiceLine)->setPrice(12.121212121))
+          ->addLine((new InvoiceLine)->setPrice(34.343434343));
+
+        $this->assertEquals(123.4568,    $this->invoice->getPaidAmount());
+        $this->assertEquals(987.654,     $this->invoice->getRoundingAmount());
+        $this->assertEquals(46.46464646, $this->invoice->getTotals()->netAmount);
+    }
+
+    /**
+     * @return void
+     */
+    public function testTotalAmountsAreCalculatedCorrectly() {
+        $allowance = (new AllowanceOrCharge)->setAmount(12.34);
+        $charge = (new AllowanceOrCharge)->setAmount(7.5)->markAsPercentage();
+        $firstLine = (new InvoiceLine)->setPrice(100)->setVatRate(10);
+        $secondLine = (new InvoiceLine)->setPrice(200.5)->setVatRate(21);
+        $this->invoice->clearLines()
+            ->setPaidAmount(10.2)
+            ->addLine($firstLine)
+            ->addLine($secondLine)
+            ->addAllowance($allowance)
+            ->addCharge($charge);
+
+        $totals = $this->invoice->getTotals();
+        $this->assertEquals(300.5,  $totals->netAmount);
+        $this->assertEquals(12.34,  $totals->allowancesAmount);
+        $this->assertEquals(22.54,  $totals->chargesAmount);
+        $this->assertEquals(52.11,  $totals->vatAmount);
+        $this->assertEquals(310.7,  $totals->taxExclusiveAmount);
+        $this->assertEquals(362.81, $totals->taxInclusiveAmount);
+        $this->assertEquals(10.2,   $totals->paidAmount);
+        $this->assertEquals(0,      $totals->roundingAmount);
+        $this->assertEquals(352.61, $totals->payableAmount);
+        $this->assertEquals(10,     $totals->vatBreakdown[0]->taxAmount);
+        $this->assertEquals(42.11,  $totals->vatBreakdown[1]->taxAmount);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Models/InvoiceTotalsTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Models/InvoiceTotalsTest.php
new file mode 100644 (file)
index 0000000..4ca1f5f
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+namespace Tests\Models;
+
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\Models\InvoiceTotals;
+use PHPUnit\Framework\TestCase;
+
+final class InvoiceTotalsTest extends TestCase {
+    /** @var Invoice */
+    private $invoice;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->invoice = new Invoice();
+    }
+
+    /**
+     * @return void
+     */
+    public function testClassConstructors() {
+        $line = (new InvoiceLine())
+            ->setName('Test Line')
+            ->setPrice(100);
+        $this->invoice->addLine($line);
+
+        $totalsA = InvoiceTotals::fromInvoice($this->invoice);
+        $totalsB = $this->invoice->getTotals();
+        $this->assertInstanceOf(InvoiceTotals::class, $totalsA);
+        $this->assertInstanceOf(InvoiceTotals::class, $totalsB);
+        $this->assertEquals(100, $totalsA->payableAmount);
+        $this->assertEquals(100, $totalsB->payableAmount);
+    }
+
+    /**
+     * @return void
+     */
+    public function testVatExemptionReasons() {
+        $firstLine = (new InvoiceLine())
+            ->setName('Line #1')
+            ->setVatCategory('E')
+            ->setVatExemptionReasonCode('VATEX-EU-O')
+            ->setVatExemptionReason('Not subject to VAT');
+        $secondLine = (new InvoiceLine())
+            ->setName('Line #2')
+            ->setVatCategory('E')
+            ->setVatRate(0)
+            ->setVatExemptionReasonCode('VATEX-EU-132-1P');
+        $thirdLine = (clone $firstLine)
+            ->setName('Line #3');
+        $allowance = (new AllowanceOrCharge())
+            ->setReason('Allowance')
+            ->setAmount(100)
+            ->setVatCategory('E')
+            ->setVatExemptionReason('Another reason expressed as text');
+
+        $this->invoice
+            ->addLine($firstLine)
+            ->addLine($secondLine)
+            ->addLine($thirdLine)
+            ->addAllowance($allowance);
+        $totals = $this->invoice->getTotals();
+
+        $this->assertEquals('VATEX-EU-O', $totals->vatBreakdown[0]->exemptionReasonCode);
+        $this->assertEquals('Another reason expressed as text', $totals->vatBreakdown[0]->exemptionReason);
+        $this->assertEquals(null, $totals->vatBreakdown[1]->exemptionReason);
+        $this->assertEquals('VATEX-EU-132-1P', $totals->vatBreakdown[1]->exemptionReasonCode);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/PartyTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/PartyTest.php
new file mode 100644 (file)
index 0000000..80d63f0
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+namespace Tests;
+
+use Einvoicing\Party;
+use InvalidArgumentException;
+use PHPUnit\Framework\TestCase;
+use function implode;
+
+final class PartyTest extends TestCase {
+    /** @var Party */
+    private $party;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->party = new Party();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanReadAndWriteAddress() {
+        $this->party->setAddress(['a', 'b']);
+        $this->assertEquals('a:b', implode(':', $this->party->getAddress()));
+        $this->party->setAddress(['x', 'y', 'z']);
+        $this->assertEquals('x:y:z', implode(':', $this->party->getAddress()));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotHaveAnAddressWithMoreThanThreeLines() {
+        $this->expectException(InvalidArgumentException::class);
+        $this->party->setAddress(['a', 'b', 'c', 'd']);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Payments/PaymentTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Payments/PaymentTest.php
new file mode 100644 (file)
index 0000000..a50d668
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace Tests\Payments;
+
+use Einvoicing\Payments\Payment;
+use Einvoicing\Payments\Transfer;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class PaymentTest extends TestCase {
+    /** @var Payment */
+    private $payment;
+
+    /** @var Transfer */
+    private $transfer;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->payment = new Payment();
+        $this->transfer = new Transfer();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveTransfers() {
+        $this->payment
+            ->addTransfer(new Transfer())
+            ->addTransfer($this->transfer)
+            ->addTransfer(new Transfer())
+            ->removeTransfer(2)
+            ->removeTransfer(0);
+        $this->assertSame($this->transfer, $this->payment->getTransfers()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsTransfer() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->payment->addTransfer($this->transfer)->removeTransfer(1);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Readers/UblReaderTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Readers/UblReaderTest.php
new file mode 100644 (file)
index 0000000..f6aca36
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace Tests\Readers;
+
+use Einvoicing\Readers\UblReader;
+use PHPUnit\Framework\TestCase;
+use function file_get_contents;
+
+final class UblReaderTest extends TestCase {
+    const DOCUMENT_PATH = __DIR__ . "/peppol-example.xml";
+
+    /** @var UblReader */
+    private $reader;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->reader = new UblReader();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanReadInvoice() {
+        $invoice = $this->reader->import(file_get_contents(self::DOCUMENT_PATH));
+        $invoice->validate();
+
+        $lines = $invoice->getLines();
+        $this->assertEquals('1', $lines[0]->getId());
+        $this->assertEquals('2', $lines[1]->getId());
+
+        $totals = $invoice->getTotals();
+        $this->assertEquals(1300, $totals->netAmount);
+        $this->assertEquals(1325, $totals->taxExclusiveAmount);
+        $this->assertEquals(331.25, $totals->vatAmount);
+        $this->assertEquals(0, $totals->allowancesAmount);
+        $this->assertEquals(25, $totals->chargesAmount);
+        $this->assertEquals(1656.25, $totals->payableAmount);
+        $this->assertEquals('S', $totals->vatBreakdown[0]->category);
+        $this->assertEquals(25, $totals->vatBreakdown[0]->rate);
+        $this->assertEquals('INV-123', $invoice->getPrecedingInvoiceReferences()[0]->getValue());
+        $this->assertEquals('This is a sample string', $invoice->getAttachments()[0]->getContents());
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Readers/peppol-example.xml b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Readers/peppol-example.xml
new file mode 100644 (file)
index 0000000..d56efac
--- /dev/null
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Downloaded from https://git.io/JUQHB -->
+<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
+    xmlns:ns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
+    xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
+    <ns:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</ns:CustomizationID>
+    <ns:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</ns:ProfileID>
+    <ns:ID>Snippet1</ns:ID>
+    <ns:IssueDate>2017-11-13</ns:IssueDate>
+    <ns:DueDate>2017-12-01</ns:DueDate>
+    <ns:InvoiceTypeCode>380</ns:InvoiceTypeCode>
+    <ns:DocumentCurrencyCode>EUR</ns:DocumentCurrencyCode>
+    <ns:AccountingCost>4025:123:4343</ns:AccountingCost>
+    <ns:BuyerReference>0150abc</ns:BuyerReference>
+    <cac:BillingReference>
+        <cac:InvoiceDocumentReference>
+            <ns:ID>INV-123</ns:ID>
+        </cac:InvoiceDocumentReference>
+    </cac:BillingReference>
+    <cac:AdditionalDocumentReference>
+        <ns:ID>ABC-123</ns:ID>
+        <ns:DocumentDescription>Invoice ABC-123</ns:DocumentDescription>
+        <cac:Attachment>
+            <ns:EmbeddedDocumentBinaryObject mimeCode="text/plain" filename="att.txt">VGhpcyBpcyBhIHNhbXBsZSBzdHJpbmc=</ns:EmbeddedDocumentBinaryObject>
+        </cac:Attachment>
+    </cac:AdditionalDocumentReference>
+    <cac:AccountingSupplierParty>
+        <cac:Party>
+            <ns:EndpointID schemeID="0088">9482348239847239874</ns:EndpointID>
+            <cac:PartyIdentification>
+                <ns:ID>99887766</ns:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <ns:Name>SupplierTradingName Ltd.</ns:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <ns:StreetName>Main street 1</ns:StreetName>
+                <ns:AdditionalStreetName>Postbox 123</ns:AdditionalStreetName>
+                <ns:CityName>London</ns:CityName>
+                <ns:PostalZone>GB 123 EW</ns:PostalZone>
+                <cac:Country>
+                    <ns:IdentificationCode>GB</ns:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <ns:CompanyID>GB1232434</ns:CompanyID>
+                <cac:TaxScheme>
+                    <ns:ID>VAT</ns:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <ns:RegistrationName>SupplierOfficialName Ltd</ns:RegistrationName>
+                <ns:CompanyID>GB983294</ns:CompanyID>
+            </cac:PartyLegalEntity>
+        </cac:Party>
+    </cac:AccountingSupplierParty>
+    <cac:AccountingCustomerParty>
+        <cac:Party>
+            <ns:EndpointID schemeID="0002">FR23342</ns:EndpointID>
+            <cac:PartyIdentification>
+                <ns:ID schemeID="0002">FR23342</ns:ID>
+            </cac:PartyIdentification>
+            <cac:PartyName>
+                <ns:Name>BuyerTradingName AS</ns:Name>
+            </cac:PartyName>
+            <cac:PostalAddress>
+                <ns:StreetName>Hovedgatan 32</ns:StreetName>
+                <ns:AdditionalStreetName>Po box 878</ns:AdditionalStreetName>
+                <ns:CityName>Stockholm</ns:CityName>
+                <ns:PostalZone>456 34</ns:PostalZone>
+                <cac:Country>
+                    <ns:IdentificationCode>SE</ns:IdentificationCode>
+                </cac:Country>
+            </cac:PostalAddress>
+            <cac:PartyTaxScheme>
+                <ns:CompanyID>SE4598375937</ns:CompanyID>
+                <cac:TaxScheme>
+                    <ns:ID>VAT</ns:ID>
+                </cac:TaxScheme>
+            </cac:PartyTaxScheme>
+            <cac:PartyLegalEntity>
+                <ns:RegistrationName>Buyer Official Name</ns:RegistrationName>
+                <ns:CompanyID schemeID="0183">39937423947</ns:CompanyID>
+            </cac:PartyLegalEntity>
+            <cac:Contact>
+                <ns:Name>Lisa Johnson</ns:Name>
+                <ns:Telephone>23434234</ns:Telephone>
+                <ns:ElectronicMail>lj@buyer.se</ns:ElectronicMail>
+            </cac:Contact>
+        </cac:Party>
+    </cac:AccountingCustomerParty>
+    <cac:Delivery>
+        <ns:ActualDeliveryDate>2017-11-01</ns:ActualDeliveryDate>
+        <cac:DeliveryLocation>
+            <ns:ID schemeID="0088">9483759475923478</ns:ID>
+            <cac:Address>
+                <ns:StreetName>Delivery street 2</ns:StreetName>
+                <ns:AdditionalStreetName>Building 56</ns:AdditionalStreetName>
+                <ns:CityName>Stockholm</ns:CityName>
+                <ns:PostalZone>21234</ns:PostalZone>
+                <cac:Country>
+                    <ns:IdentificationCode>SE</ns:IdentificationCode>
+                </cac:Country>
+            </cac:Address>
+        </cac:DeliveryLocation>
+        <cac:DeliveryParty>
+            <cac:PartyName>
+                <ns:Name>Delivery party Name</ns:Name>
+            </cac:PartyName>
+        </cac:DeliveryParty>
+    </cac:Delivery>
+    <cac:PaymentMeans>
+        <ns:PaymentMeansCode name="Credit transfer">30</ns:PaymentMeansCode>
+        <ns:PaymentID>Snippet1</ns:PaymentID>
+        <cac:PayeeFinancialAccount>
+            <ns:ID>IBAN32423940</ns:ID>
+            <ns:Name>AccountName</ns:Name>
+            <cac:FinancialInstitutionBranch>
+                <ns:ID>BIC324098</ns:ID>
+            </cac:FinancialInstitutionBranch>
+        </cac:PayeeFinancialAccount>
+    </cac:PaymentMeans>
+    <cac:PaymentTerms>
+        <ns:Note>Payment within 10 days, 2% discount</ns:Note>
+    </cac:PaymentTerms>
+        <cac:AllowanceCharge>
+            <ns:ChargeIndicator>true</ns:ChargeIndicator>
+            <ns:AllowanceChargeReason>Insurance</ns:AllowanceChargeReason>
+            <ns:Amount currencyID="EUR">25</ns:Amount>
+            <cac:TaxCategory>
+                <ns:ID>S</ns:ID>
+                <ns:Percent>25.0</ns:Percent>
+                <cac:TaxScheme>
+                    <ns:ID>VAT</ns:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:AllowanceCharge>
+    <cac:TaxTotal>
+        <ns:TaxAmount currencyID="EUR">331.25</ns:TaxAmount>
+        <cac:TaxSubtotal>
+            <ns:TaxableAmount currencyID="EUR">1325</ns:TaxableAmount>
+            <ns:TaxAmount currencyID="EUR">331.25</ns:TaxAmount>
+            <cac:TaxCategory>
+                <ns:ID>S</ns:ID>
+                <ns:Percent>25.0</ns:Percent>
+                <cac:TaxScheme>
+                    <ns:ID>VAT</ns:ID>
+                </cac:TaxScheme>
+            </cac:TaxCategory>
+        </cac:TaxSubtotal>
+    </cac:TaxTotal>
+    <cac:LegalMonetaryTotal>
+        <ns:LineExtensionAmount currencyID="EUR">1300</ns:LineExtensionAmount>
+        <ns:TaxExclusiveAmount currencyID="EUR">1325</ns:TaxExclusiveAmount>
+        <ns:TaxInclusiveAmount currencyID="EUR">1656.25</ns:TaxInclusiveAmount>
+        <ns:ChargeTotalAmount currencyID="EUR">25</ns:ChargeTotalAmount>
+        <ns:PayableAmount currencyID="EUR">1656.25</ns:PayableAmount>
+    </cac:LegalMonetaryTotal>
+    
+<cac:InvoiceLine>
+        <ns:ID>1</ns:ID>
+    <ns:InvoicedQuantity unitCode="DAY">7</ns:InvoicedQuantity>
+    <ns:LineExtensionAmount currencyID= "EUR">2800</ns:LineExtensionAmount>
+        <ns:AccountingCost>Konteringsstreng</ns:AccountingCost>
+       <cac:OrderLineReference>
+            <ns:LineID>123</ns:LineID>
+        </cac:OrderLineReference>
+    <cac:Item>
+            <ns:Description>Description of item</ns:Description>
+            <ns:Name>item name</ns:Name>
+            <cac:StandardItemIdentification>
+                <ns:ID schemeID="0088">21382183120983</ns:ID>
+            </cac:StandardItemIdentification>
+            <cac:OriginCountry>
+                <ns:IdentificationCode>NO</ns:IdentificationCode>
+            </cac:OriginCountry>
+            <cac:CommodityClassification>
+                <ns:ItemClassificationCode listID="SRV">09348023</ns:ItemClassificationCode>
+            </cac:CommodityClassification>
+            <cac:ClassifiedTaxCategory>
+                <ns:ID>S</ns:ID>
+                <ns:Percent>25.0</ns:Percent>
+                <cac:TaxScheme>
+                    <ns:ID>VAT</ns:ID>
+                </cac:TaxScheme>
+            </cac:ClassifiedTaxCategory>
+        </cac:Item>
+    <cac:Price>
+        <ns:PriceAmount currencyID="EUR">400</ns:PriceAmount>
+    </cac:Price>
+    </cac:InvoiceLine>
+<cac:InvoiceLine>
+    <ns:ID>2</ns:ID>
+    <ns:InvoicedQuantity unitCode="DAY">-3</ns:InvoicedQuantity>
+    <ns:LineExtensionAmount currencyID="EUR">-1500</ns:LineExtensionAmount>
+    <cac:OrderLineReference>
+        <ns:LineID>123</ns:LineID>
+    </cac:OrderLineReference>
+    <cac:Item>
+        <ns:Description>Description 2</ns:Description>
+        <ns:Name>item name 2</ns:Name>
+        <cac:StandardItemIdentification>
+            <ns:ID schemeID="0088">21382183120983</ns:ID>
+        </cac:StandardItemIdentification>
+        <cac:OriginCountry>
+            <ns:IdentificationCode>NO</ns:IdentificationCode>
+        </cac:OriginCountry>
+        <cac:CommodityClassification>
+            <ns:ItemClassificationCode listID="SRV">09348023</ns:ItemClassificationCode>
+        </cac:CommodityClassification>
+        <cac:ClassifiedTaxCategory>
+            <ns:ID>S</ns:ID>
+            <ns:Percent>25.0</ns:Percent>
+            <cac:TaxScheme>
+                <ns:ID>VAT</ns:ID>
+            </cac:TaxScheme>
+        </cac:ClassifiedTaxCategory>
+    </cac:Item>
+    <cac:Price>
+        <ns:PriceAmount currencyID="EUR">500</ns:PriceAmount>
+    </cac:Price>
+</cac:InvoiceLine>
+</Invoice>
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AllowanceOrChargeTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AllowanceOrChargeTraitTest.php
new file mode 100644 (file)
index 0000000..78d6408
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Invoice;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class AllowanceOrChargeTraitTest extends TestCase {
+    /** @var Invoice */
+    private $invoice;
+
+    /** @var AllowanceOrCharge */
+    private $allowance;
+
+    /** @var AllowanceOrCharge */
+    private $charge;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->invoice = new Invoice();
+        $this->allowance = new AllowanceOrCharge();
+        $this->charge = new AllowanceOrCharge();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveAllowances() {
+        $this->invoice
+            ->addAllowance(new AllowanceOrCharge)
+            ->addAllowance($this->allowance)
+            ->addAllowance(new AllowanceOrCharge)
+            ->removeAllowance(2)
+            ->removeAllowance(0);
+        $this->assertSame($this->allowance, $this->invoice->getAllowances()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsAllowances() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->invoice->addAllowance($this->allowance)->removeAllowance(1);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveCharges() {
+        $this->invoice
+            ->addCharge(new AllowanceOrCharge)
+            ->addCharge($this->charge)
+            ->addCharge(new AllowanceOrCharge)
+            ->removeCharge(2)
+            ->removeCharge(0);
+        $this->assertSame($this->charge, $this->invoice->getCharges()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsCharges() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->invoice->addCharge($this->charge)->removeCharge(1);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AttachmentsTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AttachmentsTraitTest.php
new file mode 100644 (file)
index 0000000..7ad823d
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\Attachment;
+use Einvoicing\Invoice;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class AttachmentsTraitTest extends TestCase {
+    /** @var Invoice */
+    private $invoice;
+
+    /** @var Attachment */
+    private $attachment;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->invoice = new Invoice();
+        $this->attachment = new Attachment();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveAttachments() {
+        $this->invoice
+            ->addAttachment(new Attachment)
+            ->addAttachment(new Attachment)
+            ->addAttachment($this->attachment)
+            ->addAttachment(new Attachment)
+            ->removeAttachment(3)
+            ->removeAttachment(1);
+        $this->assertSame($this->attachment, $this->invoice->getAttachments()[1]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsAttachment() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->invoice->addAttachment($this->attachment)->removeAttachment(1);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AttributesTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/AttributesTraitTest.php
new file mode 100644 (file)
index 0000000..a1c5ce5
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\Attribute;
+use Einvoicing\InvoiceLine;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class AttributesTraitTest extends TestCase {
+    /** @var InvoiceLine */
+    private $line;
+
+    /** @var Attribute */
+    private $attribute;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->line = new InvoiceLine();
+        $this->attribute = new Attribute('TestName', 'A0123456789');
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveAttributes() {
+        $this->line
+            ->addAttribute(new Attribute('Name A', '#0'))
+            ->addAttribute($this->attribute)
+            ->addAttribute(new Attribute('Name B', '#2'))
+            ->removeAttribute(2)
+            ->removeAttribute(0);
+        $this->assertSame($this->attribute, $this->line->getAttributes()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsAttribute() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->line->addAttribute($this->attribute)->removeAttribute(1);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanHaveMultipleAttributesWithSameName() {
+        $this->line
+            ->addAttribute(new Attribute('Name', '123'))
+            ->addAttribute(new Attribute('Name', '321'));
+        $this->assertEquals('123', $this->line->getAttributes()[0]->getValue());
+        $this->assertEquals('321', $this->line->getAttributes()[1]->getValue());
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanGetValueFromFirstOccurence() {
+        $this->line
+            ->addAttribute(new Attribute('Name', '123'))
+            ->addAttribute(new Attribute('Another Name', 'ABC'))
+            ->addAttribute(new Attribute('Name', '321'));
+        $this->assertEquals('123', $this->line->getAttribute('Name'));
+        $this->assertEquals('ABC', $this->line->getAttribute('Another Name'));
+        $this->assertNull($this->line->getAttribute('Unused Name'));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanSetValueToFirstOccurrence() {
+        $this->line
+            ->addAttribute(new Attribute('Name', '123'))
+            ->addAttribute(new Attribute('Name', '321'))
+            ->setAttribute('Name', 'New value')
+            ->setAttribute('Unused Name', null)
+            ->setAttribute('Other Name', 'Other value');
+        $this->assertEquals('New value', $this->line->getAttributes()[0]->getValue());
+        $this->assertEquals('321', $this->line->getAttributes()[1]->getValue());
+        $this->assertEquals('Other value', $this->line->getAttributes()[2]->getValue());
+
+        $this->line->setAttribute('Name', null);
+        $this->assertEquals('321', $this->line->getAttributes()[0]->getValue());
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/ClassificationIdentifiersTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/ClassificationIdentifiersTraitTest.php
new file mode 100644 (file)
index 0000000..f1e1a20
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\Identifier;
+use Einvoicing\InvoiceLine;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class ClassificationIdentifiersTraitTest extends TestCase {
+    /** @var InvoiceLine */
+    private $line;
+
+    /** @var Identifier */
+    private $identifier;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->line = new InvoiceLine();
+        $this->identifier = new Identifier('ABCDE');
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveClassificationIdentifiers() {
+        $this->line
+            ->addClassificationIdentifier(new Identifier('#0'))
+            ->addClassificationIdentifier($this->identifier)
+            ->addClassificationIdentifier(new Identifier('#2'))
+            ->removeClassificationIdentifier(2)
+            ->removeClassificationIdentifier(0);
+        $this->assertSame($this->identifier, $this->line->getClassificationIdentifiers()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsClassificationIdentifier() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->line
+            ->addClassificationIdentifier($this->identifier)
+            ->removeClassificationIdentifier(1);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/IdentifiersTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/IdentifiersTraitTest.php
new file mode 100644 (file)
index 0000000..bc87ada
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\Identifier;
+use Einvoicing\Party;
+use OutOfBoundsException;
+use PHPUnit\Framework\TestCase;
+
+final class IdentifiersTraitTest extends TestCase {
+    /** @var Party */
+    private $party;
+
+    /** @var Identifier */
+    private $identifier;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->party = new Party();
+        $this->identifier = new Identifier('A0123456789');
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveIdentifiers() {
+        $this->party
+            ->addIdentifier(new Identifier('#0'))
+            ->addIdentifier($this->identifier)
+            ->addIdentifier(new Identifier('#2'))
+            ->removeIdentifier(2)
+            ->removeIdentifier(0);
+        $this->assertSame($this->identifier, $this->party->getIdentifiers()[0]);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCannotRemoveOutOfBoundsIdentifier() {
+        $this->expectException(OutOfBoundsException::class);
+        $this->party->addIdentifier($this->identifier)->removeIdentifier(1);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/InvoiceValidationTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/InvoiceValidationTraitTest.php
new file mode 100644 (file)
index 0000000..cf4df7d
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\Exceptions\ValidationException;
+use Einvoicing\Invoice;
+use PHPUnit\Framework\TestCase;
+
+final class InvoiceValidationTraitTest extends TestCase {
+    /** @var Invoice */
+    private $invoice;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->invoice = new Invoice();
+    }
+
+    /**
+     * @return void
+     */
+    public function testThrowsExceptionOnInvalidInvoice() {
+        $this->expectException(ValidationException::class);
+        $this->invoice->validate();
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/VatTraitTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Traits/VatTraitTest.php
new file mode 100644 (file)
index 0000000..41b1619
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+namespace Tests\Traits;
+
+use Einvoicing\InvoiceLine;
+use PHPUnit\Framework\TestCase;
+
+final class VatTraitTest extends TestCase {
+    /** @var InvoiceLine */
+    private $line;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->line = new InvoiceLine();
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanReadAndWriteRate() {
+        $this->line->setVatRate(10);
+        $this->assertEquals(10, $this->line->getVatRate());
+        $this->line->setVatRate(0);
+        $this->assertEquals(0, $this->line->getVatRate());
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanReadAndWriteExemptions() {
+        $category = "E";
+        $reason = "Supply of transport services for sick or injured persons";
+        $reasonCode = "VATEX-EU-132-1P";
+        $this->line->setVatCategory($category);
+        $this->assertEquals($category, $this->line->getVatCategory());
+        $this->line->setVatExemptionReason($reason);
+        $this->assertEquals($reason, $this->line->getVatExemptionReason());
+        $this->line->setVatExemptionReasonCode($reasonCode);
+        $this->assertEquals($reasonCode, $this->line->getVatExemptionReasonCode());
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Writers/UblWriterTest.php b/htdocs/custom/peppol/vendor/josemmo/einvoicing/tests/Writers/UblWriterTest.php
new file mode 100644 (file)
index 0000000..b2e6c66
--- /dev/null
@@ -0,0 +1,165 @@
+<?php
+namespace Tests\Writers;
+
+use DateTime;
+use Einvoicing\AllowanceOrCharge;
+use Einvoicing\Attachment;
+use Einvoicing\Identifier;
+use Einvoicing\Invoice;
+use Einvoicing\InvoiceLine;
+use Einvoicing\InvoiceReference;
+use Einvoicing\Party;
+use Einvoicing\Presets\Peppol;
+use Einvoicing\Writers\UblWriter;
+use PHPUnit\Framework\TestCase;
+use UXML\UXML;
+use const CURLOPT_HTTPHEADER;
+use const CURLOPT_POSTFIELDS;
+use const CURLOPT_RETURNTRANSFER;
+use const CURLOPT_URL;
+use function array_map;
+use function curl_close;
+use function curl_exec;
+use function curl_init;
+use function curl_setopt_array;
+use function random_int;
+use function strpos;
+use function time;
+
+final class UblWriterTest extends TestCase {
+    /** @var UblWriter */
+    private $writer;
+
+    /**
+     * @return void
+     */
+    protected function setUp() {
+        $this->writer = new UblWriter();
+    }
+
+    private function getSampleInvoice(): Invoice {
+        $seller = (new Party)
+            ->setElectronicAddress(new Identifier('9482348239847239874', '0088'))
+            ->setCompanyId(new Identifier('COMPANY_ID', '0183'))
+            ->setName('Seller Name Ltd.')
+            ->setTradingName('Seller Name')
+            ->setVatNumber('ESA00000000')
+            ->setAddress(['Fake Street 123'])
+            ->setCity('Springfield')
+            ->setCountry('ES');
+
+        $buyer = (new Party)
+            ->setElectronicAddress(new Identifier('ES12345', '0002'))
+            ->setName('Buyer Name Ltd.')
+            ->setCountry('ES');
+        
+        $complexLine = (new InvoiceLine)
+            ->setName('Line #1')
+            ->setDescription('The description for the first line')
+            ->setPrice(10.5, 5)
+            ->setQuantity(27)
+            ->setVatRate(21)
+            ->addCharge((new AllowanceOrCharge)->setReason('Handling and shipping')->setAmount(10.1234));
+
+        $externalAttachment = (new Attachment)
+            ->setId(new Identifier('ATT-4321'))
+            ->setDescription('A link to an external attachment')
+            ->setExternalUrl('https://www.example.com/document.pdf');
+        $embeddedAttachment = (new Attachment)
+            ->setId(new Identifier('ATT-1234'))
+            ->setFilename('ATT-1234.pdf')
+            ->setMimeCode('application/pdf')
+            ->setContents('The attachment raw contents');
+
+        $invoice = new Invoice(Peppol::class);
+        $invoice->setNumber('ABC-123')
+            ->setIssueDate(new DateTime('-3 days'))
+            ->setDueDate(new DateTime('+30 days'))
+            ->setBuyerReference('REF-0172637')
+            ->addPrecedingInvoiceReference(new InvoiceReference('INV-123'))
+            ->setTenderOrLotReference('PPID-123')
+            ->setContractReference('123Contractref')
+            ->setSeller($seller)
+            ->setBuyer($buyer)
+            ->addLine($complexLine)
+            ->addLine((new InvoiceLine)->setName('Line #2')->setPrice(40, 2)->setVatRate(21)->setQuantity(4))
+            ->addLine((new InvoiceLine)->setName('Line #3')->setPrice(0.56)->setVatRate(10)->setQuantity(2))
+            ->addLine((new InvoiceLine)->setName('Line #4')->setPrice(0.56)->setVatRate(10)->setQuantity(2))
+            ->addAllowance((new AllowanceOrCharge)->setReason('5% discount')->setAmount(5)->markAsPercentage()->setVatRate(21))
+            ->addAttachment((new Attachment)->setId(new Identifier('INV-123', 'ABT')))
+            ->addAttachment($externalAttachment)
+            ->addAttachment($embeddedAttachment);
+        
+        return $invoice;
+    }
+
+    private function validateInvoice(string $contents, string $type): bool {
+        // Build SOAP request
+        $req  = '<?xml version="1.0" encoding="UTF-8"?>';
+        $req .= '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"';
+        $req .= ' xmlns:v1="http://www.gitb.com/vs/v1/" xmlns:v11="http://www.gitb.com/core/v1/">';
+        $req .= '<soapenv:Body>';
+        $req .= '<v1:ValidateRequest>';
+        $req .= '<sessionId>' . time() . '-' . random_int(0, 9999) . '</sessionId>';
+        $req .= '<input name="type" embeddingMethod="STRING"><v11:value>' . $type . '</v11:value></input>';
+        $req .= '<input name="xml" embeddingMethod="STRING"><v11:value>';
+        $req .= '<![CDATA[' . $contents . ']]>';
+        $req .= '</v11:value></input>';
+        $req .= '</v1:ValidateRequest>';
+        $req .= '</soapenv:Body>';
+        $req .= '<soapenv:Envelope>';
+
+        // Send cURL request
+        $ch = curl_init();
+        curl_setopt_array($ch, [
+            CURLOPT_URL => 'https://www.itb.ec.europa.eu/invoice/api/validation',
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_POSTFIELDS => $req,
+            CURLOPT_HTTPHEADER => ['Content-Type: application/xml']
+        ]);
+        $res = curl_exec($ch);
+        curl_close($ch);
+
+        // Validate response
+        return (strpos($res, '<ns3:result>SUCCESS</ns3:result>') !== false);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanGenerateValidInvoice() {
+        $invoice = $this->getSampleInvoice();
+        $invoice->validate();
+        $contents = $this->writer->export($invoice);
+        $this->assertTrue($this->validateInvoice($contents, 'ubl'));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanHaveLinesWithForcedDuplicateIdentifiers() {
+        $invoice = $this->getSampleInvoice();
+        $invoice->getLines()[1]->setId('DuplicateId');
+        $invoice->getLines()[2]->setId('DuplicateId');
+        $invoice->getLines()[3]->setId('DuplicateId');
+        $xml = UXML::fromString($this->writer->export($invoice));
+        $actualLineIds = array_map(function(UXML $item) {
+            return $item->asText();
+        }, $xml->getAll('cac:InvoiceLine/cbc:ID'));
+        $this->assertEquals(['1', 'DuplicateId', 'DuplicateId', 'DuplicateId'], $actualLineIds);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanAutogenerateInvoiceLineIdentifiers() {
+        $invoice = $this->getSampleInvoice();
+        $invoice->getLines()[1]->setId('1');
+        $invoice->getLines()[2]->setId('AnotherCustomId');
+        $xml = UXML::fromString($this->writer->export($invoice));
+        $actualLineIds = array_map(function(UXML $item) {
+            return $item->asText();
+        }, $xml->getAll('cac:InvoiceLine/cbc:ID'));
+        $this->assertEquals(['2', '1', 'AnotherCustomId', '3'], $actualLineIds);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/.editorconfig b/htdocs/custom/peppol/vendor/josemmo/uxml/.editorconfig
new file mode 100644 (file)
index 0000000..d566184
--- /dev/null
@@ -0,0 +1,15 @@
+# This file is for unifying the coding style for different editors and IDEs
+# editorconfig.org
+
+root = true
+charset = utf-8
+trim_trailing_whitespace = true
+
+[*]
+end_of_line = lf
+indent_style = space
+indent_size = 4
+insert_final_newline = true
+
+[*.yml]
+indent_size = 2
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/.gitattributes b/htdocs/custom/peppol/vendor/josemmo/uxml/.gitattributes
new file mode 100644 (file)
index 0000000..94f480d
--- /dev/null
@@ -0,0 +1 @@
+* text=auto eol=lf
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/.github/workflows/ci.yml b/htdocs/custom/peppol/vendor/josemmo/uxml/.github/workflows/ci.yml
new file mode 100644 (file)
index 0000000..6235b80
--- /dev/null
@@ -0,0 +1,40 @@
+name: CI
+
+on: [push, pull_request]
+
+jobs:
+  tests:
+    name: Run tests
+    runs-on: ubuntu-latest
+    continue-on-error: ${{ matrix.experimental || false }}
+    strategy:
+      matrix:
+        php-version: ['7.1', '7.2', '7.3', '7.4', '8.0']
+        include:
+          - php-version: '8.1'
+            experimental: true
+    steps:
+      # Download code from repository
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+      # Setup PHP
+      - name: Setup PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php-version }}
+          coverage: none
+          extensions: ast-stable
+
+      # Setup Composer
+      - name: Setup Composer
+        run: composer validate --strict && composer install --ignore-platform-reqs
+
+      # Run static analyzer
+      - name: Run static analyzer
+        if: ${{ success() && matrix.php-version != '7.1' }}
+        run: vendor/bin/phan --color --no-progress-bar
+
+      # Run tests
+      - name: Run tests
+        run: vendor/bin/simple-phpunit --testdox
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/.gitignore b/htdocs/custom/peppol/vendor/josemmo/uxml/.gitignore
new file mode 100644 (file)
index 0000000..dfd6caa
--- /dev/null
@@ -0,0 +1,2 @@
+/vendor
+composer.lock
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/.phan/config.php b/htdocs/custom/peppol/vendor/josemmo/uxml/.phan/config.php
new file mode 100644 (file)
index 0000000..62fb9c5
--- /dev/null
@@ -0,0 +1,190 @@
+<?php
+use Phan\Issue;
+
+/**
+ * This configuration will be read and overlaid on top of the
+ * default configuration. Command line arguments will be applied
+ * after this file is read.
+ *
+ * @see https://github.com/phan/phan/wiki/Phan-Config-Settings for all configurable options
+ * @see src/Phan/Config.php for the configurable options in this version of Phan
+ *
+ * A Note About Paths
+ * ==================
+ *
+ * Files referenced from this file should be defined as
+ *
+ * ```
+ *   Config::projectPath('relative_path/to/file')
+ * ```
+ *
+ * where the relative path is relative to the root of the
+ * project which is defined as either the working directory
+ * of the phan executable or a path passed in via the CLI
+ * '-d' flag.
+ */
+return [
+    // The PHP version that the codebase will be checked for compatibility against.
+    // For best results, the PHP binary used to run Phan should have the same PHP version.
+    // (Phan relies on Reflection for some types, param counts,
+    // and checks for undefined classes/methods/functions)
+    //
+    // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`,
+    // `'8.0'`, `'8.1'`, `null`.
+    // If this is set to `null`,
+    // then Phan assumes the PHP version which is closest to the minor version
+    // of the php executable used to execute Phan.
+    //
+    // Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
+    // (See `backward_compatibility_checks` for additional options)
+    'target_php_version' => null,
+
+    // A list of directories that should be parsed for class and
+    // method information. After excluding the directories
+    // defined in exclude_analysis_directory_list, the remaining
+    // files will be statically analyzed for errors.
+    //
+    // Thus, both first-party and third-party code being used by
+    // your application should be included in this list.
+    'directory_list' => [
+        'src',
+        'vendor',
+    ],
+
+    // A directory list that defines files that will be excluded
+    // from static analysis, but whose class and method
+    // information should be included.
+    //
+    // Generally, you'll want to include the directories for
+    // third-party code (such as "vendor/") in this list.
+    //
+    // n.b.: If you'd like to parse but not analyze 3rd
+    //       party code, directories containing that code
+    //       should be added to both the `directory_list`
+    //       and `exclude_analysis_directory_list` arrays.
+    'exclude_analysis_directory_list' => [
+        'vendor',
+    ],
+
+    // If enabled, Phan will warn if **any** type in a method invocation's object
+    // is definitely not an object,
+    // or if **any** type in an invoked expression is not a callable.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    'strict_method_checking' => true,
+
+    // If enabled, Phan will warn if **any** type in the argument's union type
+    // cannot be cast to a type in the parameter's expected union type.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    'strict_param_checking' => true,
+
+    // If enabled, Phan will warn if **any** type in a property assignment's union type
+    // cannot be cast to a type in the property's declared union type.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions, due to \ast\Node being difficult to type check)
+    'strict_property_checking' => true,
+
+    // If enabled, Phan will warn if **any** type in a returned value's union type
+    // cannot be cast to the declared return type.
+    // Setting this to true will introduce numerous false positives
+    // (and reveal some bugs).
+    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions, due to \ast\Node being difficult to type check)
+    'strict_return_checking' => true,
+
+    // If enabled, Phan will warn if **any** type of the object expression for a property access
+    // does not contain that property.
+    'strict_object_checking' => true,
+
+    // If enabled, check all methods that override a
+    // parent method to make sure its signature is
+    // compatible with the parent's. This check
+    // can add quite a bit of time to the analysis.
+    // This will also check if final methods are overridden, etc.
+    'analyze_signature_compatibility' => true,
+
+    // If true, check to make sure the return type declared
+    // in the doc-block (if any) matches the return type
+    // declared in the method signature.
+    'check_docblock_signature_return_type_match' => true,
+
+    // If true, check to make sure the param types declared
+    // in the doc-block (if any) matches the param types
+    // declared in the method signature.
+    'check_docblock_signature_param_type_match' => true,
+
+    // Set to true in order to attempt to detect dead
+    // (unreferenced) code. Keep in mind that the
+    // results will only be a guess given that classes,
+    // properties, constants and methods can be referenced
+    // as variables (like `$class->$property` or
+    // `$class->$method()`) in ways that we're unable
+    // to make sense of.
+    //
+    // To more aggressively detect dead code,
+    // you may want to set `dead_code_detection_prefer_false_negative` to `false`.
+    'dead_code_detection' => true,
+
+    // Set to true in order to attempt to detect redundant and impossible conditions.
+    //
+    // This has some false positives involving loops,
+    // variables set in branches of loops, and global variables.
+    'redundant_condition_detection' => true,
+
+    // Set to true in order to attempt to detect error-prone truthiness/falsiness checks.
+    //
+    // This is not suitable for all codebases.
+    'error_prone_truthy_condition_detection' => true,
+
+    // Enable or disable support for generic templated
+    // class types.
+    'generic_types_enabled' => true,
+
+    // If enabled, warn about throw statement where the exception types
+    // are not documented in the PHPDoc of functions, methods, and closures.
+    'warn_about_undocumented_throw_statements' => true,
+
+    // If enabled (and `warn_about_undocumented_throw_statements` is enabled),
+    // Phan will warn about function/closure/method invocations that have `@throws`
+    // that aren't caught or documented in the invoking method.
+    'warn_about_undocumented_exceptions_thrown_by_invoked_functions' => true,
+
+    // The minimum severity level to report on. This can be
+    // set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
+    // Issue::SEVERITY_CRITICAL.
+    'minimum_severity' => Issue::SEVERITY_LOW,
+
+    // Add any issue types (such as `'PhanUndeclaredMethod'`)
+    // to this list to inhibit them from being reported.
+    'suppress_issue_types' => [
+        'PhanUnreferencedClass',
+        'PhanUnreferencedPublicMethod',
+    ],
+
+    // A list of plugin files to execute.
+    // Plugins which are bundled with Phan can be added here by providing their name
+    // (e.g. 'AlwaysReturnPlugin')
+    //
+    // Documentation about available bundled plugins can be found
+    // at https://github.com/phan/phan/tree/v4/.phan/plugins
+    //
+    // Alternately, you can pass in the full path to a PHP file
+    // with the plugin's implementation.
+    // (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php')
+    'plugins' => [
+        'AlwaysReturnPlugin', // Checks if a function, closure or method unconditionally returns.
+        'DollarDollarPlugin',
+        'DuplicateArrayKeyPlugin',
+        'DuplicateExpressionPlugin',
+        'EmptyStatementListPlugin',
+        'InlineHTMLPlugin',
+        'LoopVariableReusePlugin',
+        'PreferNamespaceUsePlugin',
+        'PregRegexCheckerPlugin',
+        'PrintfCheckerPlugin',
+        'SleepCheckerPlugin',
+        'UnreachableCodePlugin', // Checks for syntactically unreachable statements in the global scope or function bodies.
+        'UseReturnValuePlugin',
+    ],
+];
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/LICENSE b/htdocs/custom/peppol/vendor/josemmo/uxml/LICENSE
new file mode 100644 (file)
index 0000000..4e7d522
--- /dev/null
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020-present José M. Moreno <josemmo@pm.me> (https://github.com/josemmo)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/README.md b/htdocs/custom/peppol/vendor/josemmo/uxml/README.md
new file mode 100644 (file)
index 0000000..f5533d5
--- /dev/null
@@ -0,0 +1,207 @@
+# Uncomplicated XML
+[![Build Status](https://github.com/josemmo/uxml/workflows/CI/badge.svg)](https://github.com/josemmo/uxml/actions)
+[![Latest Version](https://img.shields.io/packagist/v/josemmo/uxml)](https://packagist.org/packages/josemmo/uxml)
+[![Minimum PHP Version](https://img.shields.io/packagist/php-v/josemmo/uxml)](#installation)
+[![License](https://img.shields.io/github/license/josemmo/uxml)](LICENSE)
+
+UXML is an *extremely* simple PHP library for manipulating XML documents with ease while keeping overhead to a bare minimum.
+
+It consist of just a single class which uses the PHP built-in `DOMElement` and `DOMDocument` classes under the hood.
+
+## Installation
+
+### Using Composer
+```
+composer install josemmo/uxml
+```
+
+### Without Composer
+Download source files from the GitHub repository:
+```
+git clone https://github.com/josemmo/uxml.git
+```
+
+Use the UXML class in your app:
+```php
+use UXML\UXML;
+require_once __DIR__ . "/uxml/src/UXML.php";
+```
+
+## FAQ
+**Why use this instead of [sabre/xml](https://github.com/sabre-io/xml) or [FluidXML](https://github.com/servo-php/fluidxml)?**\
+Both those options are great and if they fit your project you should definetely use them! However, in my case I needed something more lightweight to put on top of [LibXML's DOM](https://www.php.net/manual/en/book.dom.php) to provide an alternative syntax.
+
+**Is UXML compatible with `DOMElement`?**\
+Yes, indeed! You can get the original `DOMElement` instance from an `UXML` object and vice versa.
+
+**I want UXML to do "X". Can you implement it?**\
+My main goal with this project is not to implement all possible behaviors in the XML specification, you can use the DOM or SimpleXML libraries for that.
+
+## Usage
+
+### Create a new document
+UXML does not distinguish between XML documents (`DOMDocument`) and elements (`DOMElement`). Instead, you can create a new document like so:
+```php
+$xml = \UXML\UXML::newInstance('RootTagName');
+```
+
+You can also wrap an already existing `DOMElement`:
+```php
+$domElement = new DOMElement('TagName');
+$xml = \UXML\UXML::fromElement($domElement);
+```
+
+### Load an XML document from source
+By loading an XML string, UXML will return the root element of the document tree:
+```php
+$source = <<<XML
+<fruits>
+    <fruit>Banana</fruit>
+    <fruit>Apple</fruit>
+    <fruit>Tomato</fruit>
+</fruits>
+XML;
+$xml = \UXML\UXML::fromString($source);
+```
+
+### Add elements to a node
+When adding an element, UXML will return a reference to the newly created element:
+```php
+$xml = \UXML\UXML::newInstance('Parent');
+$child = $xml->add('Child');
+echo $child; // <Child />
+echo $xml;   // <Parent><Child /></Parent>
+```
+
+You can also define a value:
+```php
+$child = $xml->add('Child', 'Hello World!');
+echo $child; // <Child>Hello World!</Child>
+```
+
+And even attributes or namespaces:
+```php
+$feed = \UXML\UXML::newInstance('feed', null, [
+    'xmlns' => 'http://www.w3.org/2005/Atom'
+]);
+echo $feed; // <feed xmlns="http://www.w3.org/2005/Atom" />
+
+$link = $feed->add('link', 'Wow!', [
+    'href' => 'https://www.example.com'
+]);
+echo $link; // <link href="https://www.example.com">Wow!</link>
+```
+
+### Element chaining
+Because with every element insertion a reference to the new element is returned, you can chain multiple of these calls to create a tree:
+```php
+$xml = \UXML\UXML::newInstance('people');
+$xml->add('person')->add('name', 'Jane Doe');
+echo $xml; // <people>
+           //     <person>
+           //         <name>Jane Doe</name>
+           //     </person>
+           // </people>
+```
+
+### Export XML source
+Besides casting `UXML` objects to a `string`, there is a method for exporting the XML source of an element and its children:
+```php
+$xml->asXML();
+```
+
+By default, exported strings include an XML declaration (except when casting `UXML` instances to a `string`).
+
+### Find XML elements
+UXML allows you to use XPath 1.0 queries to get a particular element from a document:
+```php
+$xml = \UXML\UXML::newInstance('person');
+$xml->add('name', 'Jane');
+$xml->add('surname', 'Doe');
+$xml->add('color', 'green', ['hex' => '#0f0']);
+
+echo $xml->get('*[@hex]'); // <color hex="#0f0">green</color>
+var_dump($xml->get('birthday')); // NULL
+```
+
+Or even multiple elements:
+```php
+$xml = \UXML\UXML::fromString('<a><b>1</b><b>2</b><b>3</b></a>');
+foreach ($xml->getAll('b') as $elem) {
+    echo "Element says: " . $elem->asText() . "\n";
+}
+```
+
+Note all XPath queries are **relative to current element**:
+```php
+$source = <<<XML
+<movie>
+    <name>Inception</name>
+    <year>2010</year>
+    <director>
+        <name>Christopher</name>
+        <surname>Nolan</surname>
+        <year>1970</year>
+    </director>
+</movie>
+XML;
+$xml = \UXML\UXML::fromString($source);
+
+echo $xml->get('director/year'); // <year>1970</year>
+echo $xml->get('director')->get('year'); // <year>1970</year>
+echo $xml->get('year'); // <year>2010</year>
+echo $xml->get('director')->get('//year'); // <year>2010</year>
+```
+
+### Remove XML elements
+Elements can be removed from the XML tree by calling the `remove()` method on them.
+After an element is removed, it becomes unusable:
+```php
+$source = <<<XML
+<project>
+    <public>
+        <name>Alpha</name>
+    </public>
+    <confidential>
+        <budget>1,000,000 USD</budget>
+    </confidential>
+</project>
+XML;
+$xml = \UXML\UXML::fromString($source);
+$xml->get('confidential')->remove();
+echo $xml; // <project><public><name>Alpha</name></public></project>
+```
+
+### Namespaces
+Namespaces are assigned in the same way as other attributes:
+```php
+$xml->add('TagName', null, [
+    'xmlns' => 'https://example.com',
+    'xmlns:abc' => 'urn:abc',
+    'attribute' => 'value'
+])->add('abc:Child', 'Name');
+echo $xml; // <TagName xmlns="https://example.com"
+           //  xmlns:abc="urn:abc"
+           //  attribute="value">
+           //     <abc:Child>Name</abc:Child>
+           // </TagName>
+```
+
+However, when querying elements, the prefix defined in the document may not be the one you are expecting:
+```php
+$xml = \UXML\UXML::fromString('<a xmlns:ns="urn:abc"><ns:b /></a>');
+echo $xml->get('ns:b'); // <ns:b />
+echo $xml->get('abc:b'); // Is NULL as the prefix does not exist
+```
+
+To fix this, you can make use of [clark notation](https://sabre.io/xml/clark-notation/) inside the XPath query:
+```php
+echo $xml->get('{urn:abc}b'); // <ns:b />
+```
+
+### Advanced XML manipulation
+For any other document manipulation outside the scope of this library, you can always interact with the `DOMElement` instance:
+```php
+$xml = \UXML\UXML::newInstance('Test');
+$xml->element(); // Returns a [DOMElement] object
+```
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/composer.json b/htdocs/custom/peppol/vendor/josemmo/uxml/composer.json
new file mode 100644 (file)
index 0000000..1a2bd3c
--- /dev/null
@@ -0,0 +1,32 @@
+{
+    "name": "josemmo/uxml",
+    "description": "Uncomplicated XML manipulation library with a clean and concise syntax",
+    "keywords": ["xml"],
+    "license": "MIT",
+    "homepage": "https://github.com/josemmo/uxml",
+    "authors": [
+        {
+            "name": "José Miguel Moreno",
+            "email": "josemmo@pm.me",
+            "homepage": "https://github.com/josemmo"
+        }
+    ],
+    "autoload": {
+        "psr-4": {
+            "UXML\\": "src/"
+        }
+    },
+    "autoload-dev": {
+        "psr-4": {
+            "Tests\\": "tests/"
+        }
+    },
+    "require": {
+        "php": ">=7.1",
+        "lib-libxml": "*"
+    },
+    "require-dev": {
+        "phan/phan": "^5.0",
+        "symfony/phpunit-bridge": "^5.3"
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/phpunit.xml b/htdocs/custom/peppol/vendor/josemmo/uxml/phpunit.xml
new file mode 100644 (file)
index 0000000..b53a53e
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<phpunit cacheResult="false" colors="true" bootstrap="vendor/autoload.php" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
+    <coverage processUncoveredFiles="true">
+        <include>
+            <directory suffix=".php">src</directory>
+        </include>
+    </coverage>
+    <testsuites>
+        <testsuite name="Tests">
+            <directory>tests</directory>
+        </testsuite>
+    </testsuites>
+</phpunit>
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/src/UXML.php b/htdocs/custom/peppol/vendor/josemmo/uxml/src/UXML.php
new file mode 100644 (file)
index 0000000..7ebc8d2
--- /dev/null
@@ -0,0 +1,242 @@
+<?php
+namespace UXML;
+
+use DOMDocument;
+use DOMElement;
+use DOMException;
+use DOMXPath;
+use InvalidArgumentException;
+use function count;
+use function preg_replace_callback;
+use function strpos;
+
+class UXML {
+    const NS_PREFIX = "__uxml_ns_";
+    /** @var DOMElement */
+    protected $element;
+
+    /**
+     * Create instance from XML string
+     * @param  string $xmlString XML string
+     * @return self              Root XML element
+     * @throws InvalidArgumentException if failed to parse XML
+     */
+    public static function fromString(string $xmlString): self {
+        $doc = new DOMDocument();
+        $doc->preserveWhiteSpace = false;
+        if ($doc->loadXML($xmlString) === false) {
+            throw new InvalidArgumentException('Failed to parse XML string');
+        }
+        return new self($doc->documentElement);
+    }
+
+
+    /**
+     * Create instance from DOM element
+     * @param  DOMElement $element DOM element
+     * @return self                Wrapped element as a UXML instance
+     * @suppress PhanUndeclaredProperty
+     */
+    public static function fromElement(DOMElement $element): self {
+        return $element->uxml ?? new self($element);
+    }
+
+
+    /**
+     * Create new instance
+     * @param  string           $name  Element tag name
+     * @param  string|null      $value Element value or NULL for empty
+     * @param  array            $attrs Element attributes
+     * @param  DOMDocument|null $doc   Document instance
+     * @return self                    New instance
+     * @throws DOMException if failed to create new instance
+     */
+    public static function newInstance(string $name, $value=null, array $attrs=[], $doc=null): self {
+        $targetDoc = ($doc === null) ? new DOMDocument() : $doc;
+        $domElement = $targetDoc->createElement($name);
+        if ($domElement === false) {
+            throw new DOMException('Failed to create DOMElement');
+        }
+
+        // Set content
+        if ($value !== null) {
+            $domElement->textContent = $value;
+        }
+
+        // Set attributes
+        foreach ($attrs as $attrName=>$attrValue) {
+            if ($attrName === "xmlns" || strpos($attrName, 'xmlns:') === 0) {
+                $domElement->setAttributeNS('http://www.w3.org/2000/xmlns/', $attrName, $attrValue);
+            } else {
+                $domElement->setAttribute($attrName, $attrValue);
+            }
+        }
+
+        // Create instance
+        return new self($domElement);
+    }
+
+
+    /**
+     * Class constructor
+     * @param DOMElement $element DOM Element instance
+     * @suppress PhanUndeclaredProperty
+     */
+    private function __construct(DOMElement $element) {
+        $this->element = $element;
+        $this->element->uxml = $this;
+    }
+
+
+    /**
+     * Get DOM element instance
+     * @return DOMElement DOM element instance
+     */
+    public function element(): DOMElement {
+        return $this->element;
+    }
+
+
+    /**
+     * Get parent element
+     * @return self Parent element instance or this instance if it has no parent
+     */
+    public function parent(): self {
+        $parentNode = $this->element->parentNode;
+        return ($parentNode !== null && $parentNode instanceof DOMElement) ? self::fromElement($parentNode) : $this;
+    }
+
+
+    /**
+     * Is empty
+     * @return boolean TRUE if the element has no inner content, FALSE otherwise
+     */
+    public function isEmpty(): bool {
+        return ($this->element->childNodes->length === 0);
+    }
+
+
+    /**
+     * Add child element
+     * @param  string      $name  New element tag name
+     * @param  string|null $value New element value or NULL for empty
+     * @param  array       $attrs New element attributes
+     * @return self               New element instance
+     * @throws DOMException if failed to create child element
+     */
+    public function add(string $name, $value=null, array $attrs=[]): self {
+        $child = self::newInstance($name, $value, $attrs, $this->element->ownerDocument);
+        $this->element->appendChild($child->element);
+        return $child;
+    }
+
+
+    /**
+     * Find elements
+     * @param  string   $xpath XPath query relative to this element
+     * @param  int|null $limit Maximum number of results to return
+     * @return self[]          Matched elements
+     */
+    public function getAll(string $xpath, $limit=null): array {
+        $namespaces = [];
+        $xpath = preg_replace_callback('/{(.+?)}/', static function($match) use (&$namespaces) {
+            $ns = $match[1];
+            if (!isset($namespaces[$ns])) {
+                $namespaces[$ns] = self::NS_PREFIX . count($namespaces);
+            }
+            return $namespaces[$ns] . ":";
+        }, $xpath);
+
+        // Create instance
+        // @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal
+        $xpathInstance = new DOMXPath($this->element->ownerDocument);
+        foreach ($namespaces as $ns=>$prefix) {
+            $xpathInstance->registerNamespace($prefix, $ns);
+        }
+
+        // Parse results
+        $res = [];
+        $domNodes = $xpathInstance->query($xpath, $this->element);
+        foreach ($domNodes as $domNode) {
+            if (!$domNode instanceof DOMElement) continue;
+            $res[] = self::fromElement($domNode);
+            if (($limit !== null) && (--$limit <= 0)) break;
+        }
+
+        return $res;
+    }
+
+
+    /**
+     * Find one element
+     * @param  string    $xpath XPath query relative to this element
+     * @return $this|null First matched element or NULL if not found
+     */
+    public function get(string $xpath) {
+        $res = $this->getAll($xpath, 1);
+        return $res[0] ?? null;
+    }
+
+
+    /**
+     * Remove this element
+     *
+     * After calling this method on an instance it will become unusable.
+     * Calling it on a root element will have no effect.
+     * @return void
+     */
+    public function remove() {
+        $parent = $this->element->parentNode;
+        if ($parent !== null) {
+            $parent->removeChild($this->element);
+        }
+    }
+
+
+    /**
+     * Export element and children as text
+     * @return string Text representation
+     */
+    public function asText(): string {
+        return $this->element->textContent;
+    }
+
+
+    /**
+     * Export as XML string
+     * @param  string|null $version  Document version, NULL for no declaration
+     * @param  string      $encoding Document encoding
+     * @param  boolean     $format   Format output
+     * @return string                XML string
+     */
+    public function asXML($version="1.0", string $encoding="UTF-8", bool $format=true): string {
+        $doc = new DOMDocument();
+
+        // Define document properties
+        if ($version === null) {
+            $doc->xmlStandalone = true;
+        } else {
+            $doc->xmlVersion = $version;
+        }
+        $doc->encoding = $encoding;
+        $doc->formatOutput = $format;
+
+        // Export XML string
+        $rootNode = $doc->importNode($this->element, true);
+        if ($rootNode !== false) {
+            $doc->appendChild($rootNode);
+        }
+        $res = ($version === null) ? $doc->saveXML($doc->documentElement) : $doc->saveXML();
+        unset($doc);
+
+        return $res;
+    }
+
+
+    /**
+     * @inheritdoc
+     */
+    public function __toString(): string {
+        return $this->asXML(null, 'UTF-8', false);
+    }
+}
diff --git a/htdocs/custom/peppol/vendor/josemmo/uxml/tests/UXMLTest.php b/htdocs/custom/peppol/vendor/josemmo/uxml/tests/UXMLTest.php
new file mode 100644 (file)
index 0000000..b3a43d3
--- /dev/null
@@ -0,0 +1,200 @@
+<?php
+namespace Tests;
+
+use DOMElement;
+use DOMException;
+use UXML\UXML;
+use PHPUnit\Framework\TestCase;
+
+final class UXMLTest extends TestCase {
+    /**
+     * Element list to text
+     * @param  UXML[] $elements Array of elements
+     * @return string           Text content of elements separated by commas
+     */
+    private function listToText(array $elements): string {
+        return implode(',', array_map(function(UXML $elem) {
+            return $elem->asText();
+        }, $elements));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanCreateElements() {
+        $xml = UXML::newInstance('RootTagName');
+        $this->assertEquals('<RootTagName/>', $xml);
+
+        $xml = UXML::fromElement(new DOMElement('TagName'));
+        $this->assertEquals('<TagName/>', $xml);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanHandleSpecialCharacters() {
+        $xml = UXML::newInstance('Test', 'A&a Co. > B&b Ltd.');
+        $this->assertEquals('<Test>A&amp;a Co. &gt; B&amp;b Ltd.</Test>', $xml);
+
+        $this->expectException(DOMException::class);
+        UXML::newInstance('Test&Fail', 'Not a valid tag name');
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanExportXml() {
+        $xml = UXML::newInstance('Root');
+        $this->assertEquals('<Root/>', (string) $xml);
+        $this->assertEquals('<Root/>', $xml->asXML(null));
+        $this->assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Root/>\n", $xml->asXML());
+        $this->assertEquals("<?xml version=\"1.1\" encoding=\"ISO-8859-1\"?>\n<Root/>\n", $xml->asXML('1.1', 'ISO-8859-1'));
+
+        $xml = UXML::fromString('<a><b>1</b><b>2</b></a>');
+        $this->assertEquals("<a>\n  <b>1</b>\n  <b>2</b>\n</a>", $xml->asXML(null));
+        $this->assertEquals('<a><b>1</b><b>2</b></a>', (string) $xml);
+        $this->assertEquals('<a><b>1</b><b>2</b></a>', $xml->asXML(null, 'UTF-8', false));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanLoadXml() {
+        $source  = "<fruits>";
+        $source .= "<fruit>Banana</fruit>";
+        $source .= "<fruit>Apple</fruit>";
+        $source .= "<fruit>Orange</fruit>";
+        $source .= "<optional>";
+        $source .= "<fruit>Tomato</fruit>";
+        $source .= "</optional>";
+        $source .= "</fruits>";
+        $xml = UXML::fromString($source);
+        $this->assertEquals($source, $xml);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanAddElements() {
+        $xml = UXML::newInstance('Parent');
+        $childA = $xml->add('ChildA', 'Name');
+        $childB = $xml->add('Wrapper')->add('ChildB');
+        $this->assertEquals('<ChildA>Name</ChildA>', $childA);
+        $this->assertEquals('<ChildB/>', $childB);
+        $this->assertEquals('<Parent><ChildA>Name</ChildA><Wrapper><ChildB/></Wrapper></Parent>', $xml);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanHandleAttributes() {
+        $feed = UXML::newInstance('feed', null, [
+            'xmlns' => 'urn:atom',
+            'xmlns:a' => 'urn:testns'
+        ]);
+        $feed->add('link', 'Wow!', ['a:href' => 'urn']);
+        $this->assertEquals('<feed xmlns="urn:atom" xmlns:a="urn:testns"><link a:href="urn">Wow!</link></feed>', $feed);
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanGetSingleElement() {
+        $source = <<<XML
+<movie>
+    <name lang="en-US">Inception</name>
+    <year>2010</year>
+    <director>
+        <name>Christopher</name>
+        <surname>Nolan</surname>
+        <year>1970</year>
+    </director>
+</movie>
+XML;
+        $xml = UXML::fromString($source);
+
+        $this->assertEquals('<year>1970</year>', $xml->get('director/year'));
+        $this->assertEquals('<year>1970</year>', $xml->get('director')->get('year'));
+        $this->assertEquals('<year>2010</year>', $xml->get('year'));
+        $this->assertEquals('<year>2010</year>', $xml->get('director')->get('//year'));
+        $this->assertEquals('<name lang="en-US">Inception</name>', $xml->get('*[@lang]'));
+        $this->assertNull($xml->get('genre'));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanGetAllElements() {
+        $source = <<<XML
+<root>
+    <a>
+        <b>1</b>
+        <b>2</b>
+        <c>-1</c>
+        <b>3</b>
+        <c>-2</c>
+        <d>Inf</d>
+    </a>
+    <b>4</b>
+    <c>-3</c>
+</root>
+XML;
+        $xml = UXML::fromString($source);
+
+        $this->assertEquals('1,2,3',    $this->listToText($xml->getAll('a/b')));
+        $this->assertEquals('1,2',      $this->listToText($xml->getAll('a/b', 2)));
+        $this->assertEquals('-3',       $this->listToText($xml->getAll('c')));
+        $this->assertEquals('-1,-2,-3', $this->listToText($xml->getAll('//c')));
+        $this->assertEmpty($xml->getAll('d'));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanHandleClarkNotation() {
+        $xml = UXML::fromString('<a xmlns:ns="urn:abc"><ns:b /><ns:c /></a>');
+        $this->assertEquals('<ns:b xmlns:ns="urn:abc"/>', $xml->get('{urn:abc}b'));
+        $this->assertSame($xml->get('{urn:abc}b'), $xml->get('ns:b'));
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanGetParent() {
+        $root = UXML::newInstance('Root');
+        $level1 = $root->add('Level1');
+        $level2 = $level1->add('Level2');
+        $level3 = $level2->add('Level3');
+        $this->assertSame($level2, $level3->parent());
+        $this->assertSame($level1, $level2->parent());
+        $this->assertSame($root, $level1->parent());
+        $this->assertSame($root, $root->parent());
+        $this->assertSame($root, $level3->parent()->parent()->parent()->parent());
+    }
+
+    /**
+     * @return void
+     */
+    public function testCanRemoveElements() {
+        $source = <<<XML
+<root>
+    <a>1</a>
+    <a>2</a>
+    <a>3</a>
+    <b>4</b>
+    <b>5</b>
+    <b>6</b>
+    <a>7</a>
+    <a>8</a>
+    <b>9</b>
+    <a>10</a>
+</root>
+XML;
+        $xml = UXML::fromString($source);
+        foreach ($xml->getAll('a') as $item) {
+            $item->remove();
+        }
+        $this->assertEmpty($xml->getAll('a'));
+        $this->assertEquals('<root><b>4</b><b>5</b><b>6</b><b>9</b></root>', $xml);
+    }
+}
index ee86620..6899a90 100755 (executable)
@@ -185,25 +185,17 @@ if ($result < 0) {
        exit(-1);
 }
 
-$qualifiedjobs = array();
-foreach ($object->lines as $val) {
-       if (!verifCond($val->test)) {
-               continue;
-       }
-       $qualifiedjobs[] = $val;
-}
-
 // TODO Duplicate code. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
 
-$nbofjobs = count($qualifiedjobs);
+$nbofjobs = count($object->lines);
 $nbofjobslaunchedok = 0;
 $nbofjobslaunchedko = 0;
 
-if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
+if (is_array($object->lines) && (count($object->lines) > 0)) {
        $savconf = dol_clone($conf);
 
        // Loop over job
-       foreach ($qualifiedjobs as $line) {
+       foreach ($object->lines as $line) {
                dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG);
                echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label;
 
@@ -245,6 +237,10 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
                        }
                }
 
+               if (!verifCond($line->test)) {
+                       continue;
+               }
+
                //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
                if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) {
                        echo " - qualified";
index f427e42..558c1a3 100755 (executable)
@@ -71,6 +71,8 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI)) {
        $conf->global->MAILING_LIMIT_SENDBYCLI = 0;
 }
 
+$langs->loadLangs(array("main", "mails"));
+
 
 /*
  * Main
@@ -80,7 +82,7 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI)) {
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
 
 if (!empty($conf->global->MAILING_DELAY)) {
-       print 'A delay of '.((float) $conf->global->MAILING_DELAY * 1000000).' millisecond has been set between each email'."\n";
+       print 'A delay of '.((float) $conf->global->MAILING_DELAY * 1000000).' seconds has been set between each email'."\n";
 }
 
 if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {