Invoice.fromJson constructor

Invoice.fromJson(
  1. Map<String, dynamic> j
)

Implementation

factory Invoice.fromJson(Map<String, dynamic> j) {
  final einvoice = _objektOderNull(j, 'einvoice');
  final nachweis = _objektOderNull(j, 'vatIdProof');
  final risiko = _objektOderNull(j, 'vatIdRisk');
  final metadaten = j['metadata'];
  final related = _objektOderNull(j, 'related');
  final brand = _objektOderNull(j, 'brand');
  final customer = _objektOderNull(j, 'customer');
  return Invoice(
    id: _pflicht<String>(j, 'id'),
    number: _pflicht<String>(j, 'number'),
    docType: _pflicht<String>(j, 'docType'),
    status: _pflicht<String>(j, 'status'),
    totals: InvoiceTotals.fromJson(_objekt(j, 'totals')),
    invoiceDate: _text(j, 'invoiceDate'),
    dueDate: _text(j, 'dueDate'),
    customerId: _text(j, 'customerId'),
    statusUrl: _text(j, 'statusUrl'),
    statusPassword: _text(j, 'statusPassword'),
    einvoiceLevel: einvoice != null && einvoice['level'] is String ? einvoice['level'] as String : null,
    metadata: metadaten is Map
        ? {for (final e in metadaten.entries) if (e.value is String) '${e.key}': e.value as String}
        : const {},
    items: j['items'] is List ? [for (final p in _liste(j, 'items')) InvoiceItem.fromJson(p)] : null,
    paidCents: _ganz(j, 'paidCents'),
    openCents: _ganz(j, 'openCents'),
    overdue: j['overdue'] is bool ? j['overdue'] as bool : null,
    writtenOff: j['writtenOff'] is bool ? j['writtenOff'] as bool : null,
    creditNotes: j['creditNotes'] is List ? [for (final c in _liste(j, 'creditNotes')) CreditNoteSummary.fromJson(c)] : null,
    relatedInvoiceId: related != null && related['invoiceId'] is String ? related['invoiceId'] as String : null,
    relatedNumber: related != null && related['number'] is String ? related['number'] as String : null,
    language: _text(j, 'language') == 'en' ? 'en' : 'de',
    brandId: brand != null && brand['id'] is String ? brand['id'] as String : null,
    brandName: brand != null && brand['name'] is String ? brand['name'] as String : null,
    einvoice: einvoice != null ? EInvoiceStatus.fromJson(einvoice) : null,
    taxScheme: _text(j, 'taxScheme'),
    payments: j['payments'] is List ? [for (final z in _liste(j, 'payments')) InvoiceDetailPayment.fromJson(z)] : null,
    writeOffReasonCode: _text(j, 'writeOffReasonCode'),
    customer: customer != null ? InvoiceRecipient.fromJson(customer) : null,
    reverseChargeReason: _text(j, 'reverseChargeReason'),
    taxCountry: _text(j, 'taxCountry'),
    priceMode: _text(j, 'priceMode'),
    serviceStart: _text(j, 'serviceStart'),
    serviceEnd: _text(j, 'serviceEnd'),
    paymentTermDays: _ganz(j, 'paymentTermDays'),
    orderReference: _text(j, 'orderReference'),
    source: _text(j, 'source'),
    createdAt: _text(j, 'createdAt'),
    finalizedAt: _text(j, 'finalizedAt'),
    vatIdProof: nachweis != null ? InvoiceVatIdProof.fromJson(nachweis) : null,
    vatIdRisk: risiko != null ? InvoiceVatIdRisk.fromJson(risiko) : null,
  );
}