Files
sendico/frontend/pshared/lib/data/dto/ledger/status.dart
2026-01-23 02:48:10 +01:00

45 lines
1.1 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
enum LedgerAccountStatusDTO {
@JsonValue('unspecified')
unspecified,
@JsonValue('active')
active,
@JsonValue('frozen')
frozen,
}
LedgerAccountStatusDTO ledgerAccountStatusFromJson(Object? value) {
final raw = value?.toString() ?? '';
var normalized = raw.trim().toLowerCase();
const prefix = 'account_status_';
if (normalized.startsWith(prefix)) {
normalized = normalized.substring(prefix.length);
}
switch (normalized) {
case 'active':
return LedgerAccountStatusDTO.active;
case 'frozen':
return LedgerAccountStatusDTO.frozen;
case 'unspecified':
case '':
return LedgerAccountStatusDTO.unspecified;
default:
return LedgerAccountStatusDTO.unspecified;
}
}
String ledgerAccountStatusToJson(LedgerAccountStatusDTO value) {
switch (value) {
case LedgerAccountStatusDTO.active:
return 'active';
case LedgerAccountStatusDTO.frozen:
return 'frozen';
case LedgerAccountStatusDTO.unspecified:
return 'unspecified';
}
}