Skip to content

UBLExtensions implementation along with additional namespaces#148

Open
hevesi wants to merge 6 commits intonum-num:masterfrom
clearvis-io:ubl-extensions
Open

UBLExtensions implementation along with additional namespaces#148
hevesi wants to merge 6 commits intonum-num:masterfrom
clearvis-io:ubl-extensions

Conversation

@hevesi
Copy link
Copy Markdown

@hevesi hevesi commented Jan 8, 2026

Added support for UBLExtensions tag with also adding additional namespaces to the root Invoice element.

UBLExtensions tag was required for croatian e-invoicing.

This tag is optional and the inclusion of adding additional namespaces is required because the extensions can use new namespaces (the croatian FINA fiscalization did use).

Changes

  • Added Extension.php class implementing XmlSerializable and XmlDeserializable
  • Added addExtension, setExtensions, and getExtensions methods to Invoice.php
  • Modified Generator.php to include the ext: namespace when extensions are present and it now accepts additional custom namespaces (e.g., hrextac) via the $additionalNamespaces parameter

Usage Example

$extension = (new \NumNum\UBL\Extension())
    ->setContent([
        'hrextac:HRFISK20Data' => [
            'hrextac:HRTaxTotal' => [ /* ... */ ],
            'hrextac:HRLegalMonetaryTotal' => [ /* ... */ ]
        ]
    ])
    ->setAttributes([
        'xmlns:cct' => 'urn:un:unece:uncefact:data:specification:CoreComponentTypeSchemaModule:2',
        // ...
    ]);

$invoice->addExtension($extension);

$generator->invoice($invoice, 'EUR', [
    'urn:mfin.gov.hr:schema:xsd:HRExtensionAggregateComponents-1' => 'hrextac'
]);

Hevesi Gergő added 6 commits January 6, 2026 13:00
- Add Extension class with content and attributes support
- Add extensions property to Invoice with getter/setter methods
- Add EXT namespace constant to Schema class
- Update Generator to conditionally include ext namespace and support additional namespaces
- Update Reader to deserialize UBLExtension elements
- Add ExtensionTest demonstrating extension usage with custom namespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant