getInvoiceXml method

Future<InvoiceXml> getInvoiceXml(
  1. String invoiceId, {
  2. String format = 'ubl',
})

Die E-Rechnung als XML; format ubl (Peppol) oder cii. Zurück kommt die Antwort, wie der Server sie sendet: der Text, das Format und der Dateiname (invoice-<Nummer>.xml). Fehlt eines davon oder ist das Format keines aus einvoiceFormats, ist die Antwort kaputt.

Implementation

Future<InvoiceXml> getInvoiceXml(String invoiceId, {String format = 'ubl'}) async {
  const name = Aufrufe.getInvoiceXml;
  final daten = await _transport.call(name, {'invoiceId': invoiceId, 'format': format});
  final xml = daten['xml'];
  final gesendet = daten['format'];
  final filename = daten['filename'];
  if (xml is! String || xml.isEmpty) {
    throw const KasseneckValidationError(name, 'Antwort ohne xml', 'response');
  }
  if (gesendet is! String || !einvoiceFormats.contains(gesendet)) {
    throw const KasseneckValidationError(name, 'Antwort ohne gültiges format', 'response');
  }
  if (filename is! String || filename.isEmpty) {
    throw const KasseneckValidationError(name, 'Antwort ohne filename', 'response');
  }
  return InvoiceXml(xml: xml, format: gesendet, filename: filename);
}