import 'package:flutter/widgets.dart';

import 'package:pshared/models/ledger/account.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 formatAmountUi(
    context,
    amount: wallet.balance,
    currency: currencyCodeToString(wallet.currency),
  );
}

String ledgerBalance(BuildContext context, LedgerAccount account) {
  final money = account.balance?.balance;
  final effectiveCurrency = (money?.currency.isoCode.trim().isNotEmpty ?? false)
      ? money!.currency.isoCode
      : account.currency;
  final effectiveMoney =
      money ?? parseMoneyWithCurrencyCode('0', effectiveCurrency);

  return formatMoneyUi(context, effectiveMoney);
}
