- ZUGFeRD/Factur-X (CII-Syntax) to PEPPOL (UBL-Syntax)
The code in this project is provided under the MIT license.
Caution
This library is currently still considered experimental and should therefore be used with caution. I would be happy for an issue to be posted if bugs are found.
With horstoeko/zugferdublbridge
you can convert the Factur-X/ZUGFeRD-CII-Syntax to PEPPOL UBL-Syntax and visa versa.
This package has no dependencies.
There is one recommended way to install horstoeko/zugferdublbridge
via Composer:
- adding the dependency to your
composer.json
file:
"require": {
..
"horstoeko/zugferdublbridge":"^1",
..
},
For detailed eplanation you may have a look in the examples of this package and the documentation attached to every release.
use horstoeko\zugferdublbridge\XmlConverterCiiToUbl;
$sourceXmlFilename = '/path/to/cii.xml.file';
$destinationXmlFilename = '/path/to/ubl.xml.file'
XmlConverterCiiToUbl::fromFile($sourceXmlFilename)->convert()->saveXmlFile($destinationXmlFilename);
use horstoeko\zugferdublbridge\XmlConverterCiiToUbl;
$xmlContent = '<xml>....</xml>';
$destinationXmlFilename = '/path/to/ubl.xml.file'
XmlConverterCiiToUbl::fromString($xmlContent)->convert()->saveXmlFile($destinationXmlFilename);
use horstoeko\zugferdublbridge\XmlConverterCiiToUbl;
$sourceXmlFilename = '/path/to/cii.xml.file';
$converterXmlString = XmlConverterCiiToUbl::fromFile($sourceXmlFilename)->convert()->saveXmlString();
use horstoeko\zugferdublbridge\XmlConverterUblToCii;
$sourceXmlFilename = '/path/to/ubl.xml.file';
$destinationXmlFilename = '/path/to/cii.xml.file'
XmlConverterUblToCii::fromFile($sourceXmlFilename)->convert()->saveXmlFile($destinationXmlFilename);
use horstoeko\zugferdublbridge\XmlConverterUblToCii;
$xmlContent = '<xml>....</xml>';
$destinationXmlFilename = '/path/to/cii.xml.file'
XmlConverterUblToCii::fromString($xmlContent)->convert()->saveXmlFile($destinationXmlFilename);
use horstoeko\zugferdublbridge\XmlConverterUblToCii;
$sourceXmlFilename = '/path/to/ubl.xml.file';
$converterXmlString = XmlConverterUblToCii::fromFile($sourceXmlFilename)->convert()->saveXmlString();
You can convert the output of horstoko/zugferd
to UBL using this library:
use horstoeko\zugferd\ZugferdDocumentBuilder;
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;
use horstoeko\zugferdublbridge\XmlConverterCiiToUbl;
$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_EN16931);
$document
->setDocumentInformation("471102", "380", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
----
$destinationXmlFilename = '/path/to/ubl.xml.file'
XmlConverterCiiToUbl::fromString($document->getContent())->convert()->saveXmlFile($destinationXmlFilename);
You can convert a UBL document and handle it with horstoko/zugferd
use horstoeko\zugferd\ZugferdDocumentReader;
use horstoeko\zugferdublbridge\XmlConverterUblToCii;
$sourceXmlFilename = '/path/to/ubl.xml.file';
$converterXmlString = XmlConverterUblToCii::fromFile($sourceXmlFilename)->convert()->saveXmlString();
$document = ZugferdDocumentReader::readAndGuessFromContent($converterXmlString);
$document->getDocumentInformation(
$documentno,
$documenttypecode,
$documentdate,
$duedate,
$invoiceCurrency,
$taxCurrency,
$documentname,
$documentlanguage,
$effectiveSpecifiedPeriod
);
echo "The Invoice No. is {$documentno}" . PHP_EOL;