few fixes and made sure ledger widget displays the name of ledger wallet

This commit is contained in:
Arseni
2026-03-05 01:48:53 +03:00
parent c59538869b
commit 519a2b1304
18 changed files with 293 additions and 249 deletions

View File

@@ -9,22 +9,33 @@ import 'package:pshared/models/ledger/account.dart';
extension LedgerAccountDTOMapper on LedgerAccountDTO {
LedgerAccount toDomain() => LedgerAccount(
ledgerAccountRef: ledgerAccountRef,
organizationRef: organizationRef,
ownerRef: ownerRef,
accountCode: accountCode,
accountType: accountType.toDomain(),
currency: currency,
status: status.toDomain(),
allowNegative: allowNegative,
role: role.toDomain(),
metadata: metadata,
createdAt: createdAt,
updatedAt: updatedAt,
describable: describable?.toDomain() ?? newDescribable(name: '', description: null),
balance: balance?.toDomain(),
);
LedgerAccount toDomain() {
final mappedDescribable = describable?.toDomain();
final fallbackName = metadata?['name']?.trim() ?? '';
final name = mappedDescribable?.name.trim().isNotEmpty == true
? mappedDescribable!.name
: fallbackName;
return LedgerAccount(
ledgerAccountRef: ledgerAccountRef,
organizationRef: organizationRef,
ownerRef: ownerRef,
accountCode: accountCode,
accountType: accountType.toDomain(),
currency: currency,
status: status.toDomain(),
allowNegative: allowNegative,
role: role.toDomain(),
metadata: metadata,
createdAt: createdAt,
updatedAt: updatedAt,
describable: newDescribable(
name: name,
description: mappedDescribable?.description,
),
balance: balance?.toDomain(),
);
}
}
extension LedgerAccountModelMapper on LedgerAccount {