Generator of ZUGFeRD XML
Summary
This crate generates an XML with the ZUGFeRD specification that can be embedded in PDF to generate E-invoice compliant with the EU regulations.
[!WARNING] This crate is pretty much work in progress.
Although you can generate a minimum and basic levels XML, this crate is more of a starting point and an invitation for feedback and collaboration. Breaking changes are not intended, but are not impossible either.
Installation
Add the crate:
cargo add zugferd
Import the crate:
use ;
[!WARNING] Although you can populate data into structs without the invoice builder, at this point I strongly suggest you use it. Breaking changes may occure. Besides, it takes care of conversion from Strings.
Initialize and pass first data:
let mut invoice_builder = new;
invoice_builder.set_business_process
.set_invoice_type_code
.set_invoice_nr
.set_date_of_issue
.set_buyer_reference
.set_sellers_name
.set_sellers_specified_legal_organization
.set_sellers_postal_trade_address_country_code
.set_sellers_specified_tax_registration
.set_buyers_name
.set_buyers_specified_legal_organization
.set_buyers_order_specified_document
.set_invoice_currency_code;
You can always check if the provided data enough for the specified level. (At this stage only "minimum", "basic wl" and "basic" are supported.)
match invoice_builder.all_fields_are_set
Or simply
invoice_builder.all_fields_are_set?;
Calculate your data further, for example:
let sum_net: f64 = 100.0;
let tax: f64 = sum_net * 19.0 /100.0;
let sum_gross: f64 = sum_net + tax;
let customer_paid_already: f64 = 50.0;
Pass missing data to the instance:
invoice_builder
.set_monetary_summation_tax_basis_total_amount
.set_monetary_summation_tax_total_amount
.set_monetary_summation_grand_total_amount
.set_monetary_summation_due_payable_amount;
Generate XML:
let mut xml_string: String = Stringnew;
match invoice_builder.to_xml_string
println!;
Please check main.rs for further examples.
Roadmap
- generation of minimum level
- generation of basic level without lines
- generation of basic level
- generation of EN 16931 level
- generation of extended level
- validation of all levels
- parsing of all levels
- embedding the generated XML into PDF/A-3 files