import 'package:pshared/models/ledger/account.dart'; import 'package:pshared/models/payment/wallet.dart'; enum PaymentSourceType { wallet, ledger } class PaymentSource { final PaymentSourceType type; final Wallet? wallet; final LedgerAccount? ledgerAccount; const PaymentSource._({required this.type, this.wallet, this.ledgerAccount}); const PaymentSource.wallet(Wallet wallet) : this._(type: PaymentSourceType.wallet, wallet: wallet); const PaymentSource.ledger(LedgerAccount account) : this._(type: PaymentSourceType.ledger, ledgerAccount: account); String get id => switch (type) { PaymentSourceType.wallet => wallet!.id, PaymentSourceType.ledger => ledgerAccount!.ledgerAccountRef, }; String get key => '${type.name}:$id'; String get name => switch (type) { PaymentSourceType.wallet => wallet!.name, PaymentSourceType.ledger => ledgerAccount!.name, }; }