Multiple Wallet support, history of each wallet and updated payment page
This commit is contained in:
74
frontend/pweb/lib/models/wallet_transaction.dart
Normal file
74
frontend/pweb/lib/models/wallet_transaction.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:pshared/models/payment/status.dart';
|
||||
|
||||
import 'package:pweb/models/currency.dart';
|
||||
|
||||
|
||||
enum WalletTransactionType { topUp, payout }
|
||||
|
||||
extension WalletTransactionTypeX on WalletTransactionType {
|
||||
String label(BuildContext context) {
|
||||
switch (this) {
|
||||
case WalletTransactionType.topUp:
|
||||
return 'Top up';
|
||||
case WalletTransactionType.payout:
|
||||
return 'Payout';
|
||||
}
|
||||
}
|
||||
|
||||
String get sign => this == WalletTransactionType.topUp ? '+' : '-';
|
||||
}
|
||||
|
||||
class WalletTransaction {
|
||||
final String id;
|
||||
final String walletId;
|
||||
final WalletTransactionType type;
|
||||
final OperationStatus status;
|
||||
final double amount;
|
||||
final Currency currency;
|
||||
final DateTime date;
|
||||
final String description;
|
||||
final String? counterparty;
|
||||
final double? balanceAfter;
|
||||
|
||||
const WalletTransaction({
|
||||
required this.id,
|
||||
required this.walletId,
|
||||
required this.type,
|
||||
required this.status,
|
||||
required this.amount,
|
||||
required this.currency,
|
||||
required this.date,
|
||||
required this.description,
|
||||
this.counterparty,
|
||||
this.balanceAfter,
|
||||
});
|
||||
|
||||
bool get isTopUp => type == WalletTransactionType.topUp;
|
||||
|
||||
WalletTransaction copyWith({
|
||||
String? id,
|
||||
String? walletId,
|
||||
WalletTransactionType? type,
|
||||
OperationStatus? status,
|
||||
double? amount,
|
||||
Currency? currency,
|
||||
DateTime? date,
|
||||
String? description,
|
||||
String? counterparty,
|
||||
double? balanceAfter,
|
||||
}) {
|
||||
return WalletTransaction(
|
||||
id: id ?? this.id,
|
||||
walletId: walletId ?? this.walletId,
|
||||
type: type ?? this.type,
|
||||
status: status ?? this.status,
|
||||
amount: amount ?? this.amount,
|
||||
currency: currency ?? this.currency,
|
||||
date: date ?? this.date,
|
||||
description: description ?? this.description,
|
||||
counterparty: counterparty ?? this.counterparty,
|
||||
balanceAfter: balanceAfter ?? this.balanceAfter,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user