Method ManualEinvoice():createFromString() Professional
Creates an invoice from a CII XML string.
:createFromString( <cXml> ) --> oInvoice
A new ManualEinvoice object with the data of the document.
Creates a new ManualEinvoice object from a CII XML document which is passed as a character string. Since XRechnung and ZUGFeRD documents share the same CII content model, both formats are supported.
The method parses <cXml> and verifies that the root element of the document is rsm:CrossIndustryInvoice. Each element which can be written by the internal CII serializer of this library is then assigned to the new invoice through the corresponding builder method, such as :setSeller() or :addLineItem().
The VAT category and the VAT rate of each invoice line are taken over unchanged from the document. A CII document always contains the resolved VAT category, but not the kind of the line or the other information from which the automatic scenarios derive the category. For this reason, the imported invoice is always a ManualEinvoice object.
The resulting invoice object can be used like any other invoice:
Reading - The invoice data can be read via the getter methods of the AbstractEinvoice() class.
Validation - The method :validate() checks the invoice. In addition to the usual rules, it compares the totals stated in the document with the values recalculated by this library from the invoice lines, and reports any mismatch under the rules BR-CO-10 to BR-CO-17.
Serialization - The methods :toXRechnung() and :toZugferd() create a new XML document.
Note: A serialized document is not byte-identical to the imported document. The order of the elements follows the internal serializer of this library, and the exemption statement of an invoice line is generated from the seller's country profile, since CII does not repeat it for each line. This is expected behavior.
If the XML declaration specifies the encoding UTF-8, the document is converted from UTF-8 before it is parsed. Other encodings, such as windows-1252, ISO-8859-1 or ISO-8859-2, are accepted on a best-effort basis, regardless of whether they are declared.
A runtime error is raised if the XML document is malformed, if it is not a CII invoice document with the root element rsm:CrossIndustryInvoice, or if it is encoded in UTF-16 or UTF-32.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.