Files
sendico/frontend/pshared/lib/data/dto/ledger/role.dart
2026-01-30 16:54:56 +01:00

108 lines
2.5 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
enum LedgerAccountRoleDTO {
@JsonValue('unspecified')
unspecified,
@JsonValue('operating')
operating,
@JsonValue('hold')
hold,
@JsonValue('transit')
transit,
@JsonValue('settlement')
settlement,
@JsonValue('clearing')
clearing,
@JsonValue('pending')
pending,
@JsonValue('reserve')
reserve,
@JsonValue('liquidity')
liquidity,
@JsonValue('fee')
fee,
@JsonValue('chargeback')
chargeback,
@JsonValue('adjustment')
adjustment,
}
LedgerAccountRoleDTO ledgerAccountRoleFromJson(Object? value) {
final raw = value?.toString() ?? '';
var normalized = raw.trim().toLowerCase();
const prefix = 'account_role_';
if (normalized.startsWith(prefix)) {
normalized = normalized.substring(prefix.length);
}
switch (normalized) {
case 'operating':
return LedgerAccountRoleDTO.operating;
case 'hold':
return LedgerAccountRoleDTO.hold;
case 'transit':
return LedgerAccountRoleDTO.transit;
case 'settlement':
return LedgerAccountRoleDTO.settlement;
case 'clearing':
return LedgerAccountRoleDTO.clearing;
case 'pending':
return LedgerAccountRoleDTO.pending;
case 'reserve':
return LedgerAccountRoleDTO.reserve;
case 'liquidity':
return LedgerAccountRoleDTO.liquidity;
case 'fee':
return LedgerAccountRoleDTO.fee;
case 'chargeback':
return LedgerAccountRoleDTO.chargeback;
case 'adjustment':
return LedgerAccountRoleDTO.adjustment;
case 'unspecified':
case '':
return LedgerAccountRoleDTO.unspecified;
default:
return LedgerAccountRoleDTO.unspecified;
}
}
String ledgerAccountRoleToJson(LedgerAccountRoleDTO value) {
switch (value) {
case LedgerAccountRoleDTO.operating:
return 'operating';
case LedgerAccountRoleDTO.hold:
return 'hold';
case LedgerAccountRoleDTO.transit:
return 'transit';
case LedgerAccountRoleDTO.settlement:
return 'settlement';
case LedgerAccountRoleDTO.clearing:
return 'clearing';
case LedgerAccountRoleDTO.pending:
return 'pending';
case LedgerAccountRoleDTO.reserve:
return 'reserve';
case LedgerAccountRoleDTO.liquidity:
return 'liquidity';
case LedgerAccountRoleDTO.fee:
return 'fee';
case LedgerAccountRoleDTO.chargeback:
return 'chargeback';
case LedgerAccountRoleDTO.adjustment:
return 'adjustment';
case LedgerAccountRoleDTO.unspecified:
return 'unspecified';
}
}