ExCius.InvoiceXmlParser (ExCius v0.3.2)
View SourceParses UBL 2.1 Invoice XML documents back to the parameter structure used by ExCius.RequestParams.
This module provides the reverse transformation of ExCius.InvoiceTemplateXML, taking a UBL Invoice XML document and extracting the data into the same parameter structure that can be validated and used by the ExCius system.
Features
- Parses complete UBL 2.1 Invoice XML documents
- Extracts all invoice data including supplier, customer, tax, and line information
- Handles optional fields gracefully
- Converts UBL enum values back to internal representations
- Parses mandatory operator notes back to operator_name
- Supports Croatian CIUS-2025 compliant invoices
Usage
xml_content = File.read!("invoice.xml")
{:ok, params} = ExCius.InvoiceXmlParser.parse(xml_content)
# The params can now be used with RequestParams
{:ok, validated_params} = ExCius.RequestParams.new(params)Supported Elements
- Invoice identification and dates
- Supplier and customer party information
- Tax calculations and categories
- Payment terms and methods
- Invoice lines with items and pricing
- Notes (including operator notes and user notes)
Summary
Functions
Parses a UBL Invoice XML document and returns parameter structure.
Functions
Parses a UBL Invoice XML document and returns parameter structure.
Takes a UBL 2.1 Invoice XML document as a string and extracts all the invoice data into the parameter structure expected by ExCius.RequestParams.
Parameters
xml_content- The UBL Invoice XML document as a string
Returns
{:ok, params}- Successfully parsed parameters map{:error, reason}- Parsing failed with error reason
Examples
iex> xml = "<?xml version=\"1.0\"?>..."
iex> {:ok, params} = ExCius.InvoiceXmlParser.parse(xml)
iex> params.id
"5-P1-1"