factur_x 0.1.2 copy "factur_x: ^0.1.2" to clipboard
factur_x: ^0.1.2 copied to clipboard

A Dart library to generate Factur-X (ZUGFeRD) invoices. Compliant with the German "E-Rechnungspflicht".

example/lib/example.dart

import 'dart:io';

import 'package:example/service/partner/anna.dart';
import 'package:factur_x/simple.dart';

void main() async {
  xmlOnly();
  await fullPdf();
}

void xmlOnly() {
  String facturXml = buildFacturXml(
    invoiceNumber: '2020-01',
    issueDate: DateTime(2020, 1, 1),
    deliveryDate: DeliveryDate.date(DateTime(2020, 1, 1)),
    dueDate: DateTime(2020, 1, 31),
    seller: InvoiceParty(
      name: 'Max Mustermann',
      street: 'Musterstraße 1',
      postcode: '12345',
      city: 'Berlin',
      countryCode: 'DE',
      vatId: 'DE 123 456 789',
      email: 'info@example.com',
    ),
    buyer: InvoiceParty(
      name: 'Max Consumer',
      street: 'Consumerstraße 1',
      postcode: '12345',
      city: 'Berlin',
      countryCode: 'DE',
    ),
    itemList: InvoiceItemList(
      items: [
        InvoiceLineItem(
          lineId: '1',
          name: 'Some Work',
          unitPrice: 50,
          quantity: 3,
        ),
      ],
    ),
    paymentInfo: PaymentInfo(
      iban: 'DE12 3456 7890 1234 5678 90',
    ),
  );

  File('example.xml').writeAsStringSync(facturXml);
  print('XML created: example.xml');
}

/// Generates a full PDF with embedded XML and saves it as 'example.pdf'.
/// The PDF is compliant with Factur-X and PDF/A standards.
///
/// Uses the pdf package under the hood.
Future<void> fullPdf() async {
  FacturSimpleConfig.defaultVat = 16;

  final pdfBytes = await createAnnaPdf(
    date: DateTime(2024, 6, 1),
    workDescription: 'Entwicklung einer Beispielrechnung',
    hours: 10,
  );

  File('example.pdf').writeAsBytesSync(pdfBytes);

  print('PDF created: example.pdf');
  print('Factur-X compliance: https://app.b2brouter.net/de/validation');
  print('                 or: https://www.e-rechnungs-checker.de/');
  print(
    '   PDF/A compliance: https://www.pdfforge.org/online/de/pdfa-validieren',
  );
}
0
likes
160
points
47
downloads

Documentation

API reference

Publisher

verified publishertienisto.com

Weekly Downloads

A Dart library to generate Factur-X (ZUGFeRD) invoices. Compliant with the German "E-Rechnungspflicht".

Repository

Topics

#tax #invoice #accounting #xml #pdf

License

MIT (license)

Dependencies

intl

More

Packages that depend on factur_x