en16931_ubl 0.1.4 copy "en16931_ubl: ^0.1.4" to clipboard
en16931_ubl: ^0.1.4 copied to clipboard

Writes and reads the European electronic invoice as UBL 2.1, the syntax Peppol and most of Europe carry. Works on the EN 16931 semantic model.

example/example.dart

// ignore_for_file: avoid_print

import 'package:en16931/en16931.dart';
import 'package:en16931_ubl/en16931_ubl.dart';

/// Builds an invoice, checks it, and writes it out as UBL.
void main() {
  final invoice = Invoice.fromLines(
    number: '2026-0042',
    issueDate: DateTime(2026, 9, 13),
    dueDate: DateTime(2026, 10, 13),
    seller: const Seller(
      name: 'COMAPPS SRL',
      vatIdentifier: 'BE0123456789',
      electronicAddress: Identifier(
        '0123456789',
        scheme: Scheme.belgianEnterprise,
      ),
      address: Address(city: 'Bruxelles', postalCode: '1000', country: 'BE'),
    ),
    buyer: const Buyer(
      name: 'Client SA',
      electronicAddress: Identifier(
        '0987654321',
        scheme: Scheme.belgianEnterprise,
      ),
      address: Address(city: 'Namur', postalCode: '5000', country: 'BE'),
    ),
    lines: [
      InvoiceLine.of(
        id: '1',
        item: const Item(name: 'Consulting'),
        quantity: 8,
        unitPrice: 150.00,
        vatRate: 21,
        unit: UnitCode.hour,
      ),
    ],
  );

  final violations = validate(invoice);
  if (violations.isNotEmpty) {
    for (final violation in violations) {
      print(violation);
    }
    return;
  }

  final xml = writeUbl(invoice);
  print(xml);

  // What the other side does with it.
  receive(xml);
}

/// Reads a UBL document back and reports what its issuer got wrong.
void receive(String xml) {
  final invoice = readUbl(xml);
  print('${invoice.number} from ${invoice.seller.name}');
  final violations = validate(invoice);
  if (violations.isEmpty) {
    print('  nothing to object to');
    return;
  }
  for (final violation in violations) {
    print('  $violation');
  }
}
0
likes
160
points
250
downloads

Documentation

API reference

Publisher

verified publishercomapps.be

Weekly Downloads

Writes and reads the European electronic invoice as UBL 2.1, the syntax Peppol and most of Europe carry. Works on the EN 16931 semantic model.

Homepage
Repository (GitHub)
View/report issues

Topics

#einvoicing #en16931 #ubl #peppol #invoice

License

MIT (license)

Dependencies

decimal, en16931, xml

More

Packages that depend on en16931_ubl