refactor of money utils with new money2 package

This commit is contained in:
Arseni
2026-03-13 03:17:29 +03:00
parent b4eb1437f6
commit 0091191d97
72 changed files with 453 additions and 982 deletions

View File

@@ -1,31 +1,28 @@
import 'package:flutter/widgets.dart';
import 'package:pshared/models/ledger/account.dart';
import 'package:pshared/models/money.dart';
import 'package:pshared/models/payment/wallet.dart';
import 'package:pshared/utils/currency.dart';
import 'package:pshared/utils/money.dart';
import 'package:pweb/utils/money_display.dart';
String walletBalance(BuildContext context, Wallet wallet) {
return formatMoneyUi(
return formatAmountUi(
context,
Money(
amount: amountToString(wallet.balance),
currency: currencyCodeToString(wallet.currency),
),
amount: wallet.balance,
currency: currencyCodeToString(wallet.currency),
);
}
String ledgerBalance(BuildContext context, LedgerAccount account) {
final money = account.balance?.balance;
final effectiveCurrency = (money?.currency.trim().isNotEmpty ?? false)
? money!.currency
final effectiveCurrency = (money?.currency.isoCode.trim().isNotEmpty ?? false)
? money!.currency.isoCode
: account.currency;
final effectiveMoney =
money ?? parseMoneyWithCurrencyCode('0', effectiveCurrency);
return formatMoneyUi(
context,
Money(amount: money?.amount ?? '', currency: effectiveCurrency),
);
return formatMoneyUi(context, effectiveMoney);
}