feat: Implement BalanceRepository for group balance calculations feat: Create ExpenseRepository for managing expenses feat: Add services for handling expenses and storage operations fix: Update import paths for models in repositories and services refactor: Rename CountContent to AccountContent in HomePage chore: Add StorageService for image upload and management
58 lines
1.4 KiB
Dart
58 lines
1.4 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
class ExpenseSplit extends Equatable {
|
|
final String userId;
|
|
final String userName;
|
|
final double amount;
|
|
final bool isPaid;
|
|
final DateTime? paidAt;
|
|
|
|
const ExpenseSplit({
|
|
required this.userId,
|
|
required this.userName,
|
|
required this.amount,
|
|
this.isPaid = false,
|
|
this.paidAt,
|
|
});
|
|
|
|
factory ExpenseSplit.fromMap(Map<String, dynamic> map) {
|
|
return ExpenseSplit(
|
|
userId: map['userId'] ?? '',
|
|
userName: map['userName'] ?? '',
|
|
amount: (map['amount'] as num?)?.toDouble() ?? 0.0,
|
|
isPaid: map['isPaid'] ?? false,
|
|
paidAt: map['paidAt'] != null
|
|
? DateTime.fromMillisecondsSinceEpoch(map['paidAt'])
|
|
: null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'userId': userId,
|
|
'userName': userName,
|
|
'amount': amount,
|
|
'isPaid': isPaid,
|
|
'paidAt': paidAt?.millisecondsSinceEpoch,
|
|
};
|
|
}
|
|
|
|
ExpenseSplit copyWith({
|
|
String? userId,
|
|
String? userName,
|
|
double? amount,
|
|
bool? isPaid,
|
|
DateTime? paidAt,
|
|
}) {
|
|
return ExpenseSplit(
|
|
userId: userId ?? this.userId,
|
|
userName: userName ?? this.userName,
|
|
amount: amount ?? this.amount,
|
|
isPaid: isPaid ?? this.isPaid,
|
|
paidAt: paidAt ?? this.paidAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [userId, userName, amount, isPaid];
|
|
} |