refactor of money utils with new money2 package
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user