CashregisterEntry.fromJson constructor

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

Implementation

factory CashregisterEntry.fromJson(Map<String, dynamic> j) {
  String? text(Object? v) => v is String && v.isNotEmpty ? v : null;
  final ob = j['onboarding'];
  final o = ob is Map ? ob : const {};
  return CashregisterEntry(
    id: text(j['id']) ?? '',
    label: text(j['label']),
    description: text(j['description']),
    createTime: text(j['create_time']),
    signatureId: text(j['signature_id']),
    token: text(j['token']),
    finalReceiptId: text(j['final_receipt_id']),
    decommissioned: j['decommissioned'] == true,
    licenses: j['licenses'] is num ? (j['licenses'] as num).toInt() : null,
    monthlyReportJournal: j['monthly_report_journal'] == true,
    stockLocationId: text(j['stockLocationId']),
    autoLogout: CashregisterAutoLogout.fromJson(j['autoLogout']),
    onboarding: CashregisterOnboarding(
      cashboxRegistered: o['cashbox_registered'] == true,
      startReceiptCreated: o['start_receipt_created'] == true,
      startReceiptTransmitted: o['start_receipt_transmitted'] == true,
      cashboxRegisteredAt: text(o['cashbox_registered_at']),
      startReceiptCreatedAt: text(o['start_receipt_created_at']),
      startReceiptTransmittedAt: text(o['start_receipt_transmitted_at']),
    ),
  );
}