front dev update

This commit is contained in:
Stephan D
2026-01-30 16:54:56 +01:00
parent 51f5b0804a
commit 102c5d3668
31 changed files with 755 additions and 74 deletions

View File

@@ -2,6 +2,7 @@ import 'package:json_annotation/json_annotation.dart';
import 'package:pshared/data/dto/describable.dart';
import 'package:pshared/data/dto/ledger/balance.dart';
import 'package:pshared/data/dto/ledger/role.dart';
import 'package:pshared/data/dto/ledger/status.dart';
import 'package:pshared/data/dto/ledger/type.dart';
@@ -20,7 +21,8 @@ class LedgerAccountDTO {
@JsonKey(fromJson: ledgerAccountStatusFromJson, toJson: ledgerAccountStatusToJson)
final LedgerAccountStatusDTO status;
final bool allowNegative;
final bool isSettlement;
@JsonKey(fromJson: ledgerAccountRoleFromJson, toJson: ledgerAccountRoleToJson)
final LedgerAccountRoleDTO role;
final Map<String, String>? metadata;
final DateTime? createdAt;
final DateTime? updatedAt;
@@ -38,7 +40,7 @@ class LedgerAccountDTO {
required this.currency,
required this.status,
required this.allowNegative,
required this.isSettlement,
required this.role,
this.metadata,
this.createdAt,
this.updatedAt,

View File

@@ -0,0 +1,107 @@
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';
}
}

View File

@@ -1,6 +1,7 @@
import 'package:pshared/data/dto/ledger/account.dart';
import 'package:pshared/data/mapper/describable.dart';
import 'package:pshared/data/mapper/ledger/balance.dart';
import 'package:pshared/data/mapper/ledger/role.dart';
import 'package:pshared/data/mapper/ledger/status.dart';
import 'package:pshared/data/mapper/ledger/type.dart';
import 'package:pshared/models/describable.dart';
@@ -17,7 +18,7 @@ extension LedgerAccountDTOMapper on LedgerAccountDTO {
currency: currency,
status: status.toDomain(),
allowNegative: allowNegative,
isSettlement: isSettlement,
role: role.toDomain(),
metadata: metadata,
createdAt: createdAt,
updatedAt: updatedAt,
@@ -36,7 +37,7 @@ extension LedgerAccountModelMapper on LedgerAccount {
currency: currency,
status: status.toDTO(),
allowNegative: allowNegative,
isSettlement: isSettlement,
role: role.toDTO(),
metadata: metadata,
createdAt: createdAt,
updatedAt: updatedAt,

View File

@@ -0,0 +1,65 @@
import 'package:pshared/data/dto/ledger/role.dart';
import 'package:pshared/models/ledger/role.dart';
extension LedgerAccountRoleDTOMapper on LedgerAccountRoleDTO {
LedgerAccountRole toDomain() {
switch (this) {
case LedgerAccountRoleDTO.unspecified:
return LedgerAccountRole.unspecified;
case LedgerAccountRoleDTO.operating:
return LedgerAccountRole.operating;
case LedgerAccountRoleDTO.hold:
return LedgerAccountRole.hold;
case LedgerAccountRoleDTO.transit:
return LedgerAccountRole.transit;
case LedgerAccountRoleDTO.settlement:
return LedgerAccountRole.settlement;
case LedgerAccountRoleDTO.clearing:
return LedgerAccountRole.clearing;
case LedgerAccountRoleDTO.pending:
return LedgerAccountRole.pending;
case LedgerAccountRoleDTO.reserve:
return LedgerAccountRole.reserve;
case LedgerAccountRoleDTO.liquidity:
return LedgerAccountRole.liquidity;
case LedgerAccountRoleDTO.fee:
return LedgerAccountRole.fee;
case LedgerAccountRoleDTO.chargeback:
return LedgerAccountRole.chargeback;
case LedgerAccountRoleDTO.adjustment:
return LedgerAccountRole.adjustment;
}
}
}
extension LedgerAccountRoleModelMapper on LedgerAccountRole {
LedgerAccountRoleDTO toDTO() {
switch (this) {
case LedgerAccountRole.unspecified:
return LedgerAccountRoleDTO.unspecified;
case LedgerAccountRole.operating:
return LedgerAccountRoleDTO.operating;
case LedgerAccountRole.hold:
return LedgerAccountRoleDTO.hold;
case LedgerAccountRole.transit:
return LedgerAccountRoleDTO.transit;
case LedgerAccountRole.settlement:
return LedgerAccountRoleDTO.settlement;
case LedgerAccountRole.clearing:
return LedgerAccountRoleDTO.clearing;
case LedgerAccountRole.pending:
return LedgerAccountRoleDTO.pending;
case LedgerAccountRole.reserve:
return LedgerAccountRoleDTO.reserve;
case LedgerAccountRole.liquidity:
return LedgerAccountRoleDTO.liquidity;
case LedgerAccountRole.fee:
return LedgerAccountRoleDTO.fee;
case LedgerAccountRole.chargeback:
return LedgerAccountRoleDTO.chargeback;
case LedgerAccountRole.adjustment:
return LedgerAccountRoleDTO.adjustment;
}
}
}

View File

@@ -90,6 +90,8 @@ ChainNetwork chainNetworkFromValue(String? value) {
return ChainNetwork.ethereumMainnet;
case 'arbitrum_one':
return ChainNetwork.arbitrumOne;
case 'arbitrum_sepolia':
return ChainNetwork.arbitrumSepolia;
case 'tron_mainnet':
return ChainNetwork.tronMainnet;
case 'tron_nile':
@@ -111,6 +113,8 @@ String chainNetworkToValue(ChainNetwork chain) {
return 'tron_mainnet';
case ChainNetwork.tronNile:
return 'tron_nile';
case ChainNetwork.arbitrumSepolia:
return 'arbitrum_sepolia';
case ChainNetwork.unspecified:
return 'unspecified';
}