Invoice.fromJson constructor
Implementation
factory Invoice.fromJson(Map<String, dynamic> j) {
final einvoice = j['einvoice'];
final metadaten = j['metadata'];
final related = j['related'];
final brand = j['brand'];
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 is Map && 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 is Map && related['invoiceId'] is String ? related['invoiceId'] as String : null,
language: _text(j, 'language') == 'en' ? 'en' : 'de',
brandId: brand is Map && brand['id'] is String ? brand['id'] as String : null,
brandName: brand is Map && brand['name'] is String ? brand['name'] as String : null,
);
}