feat: Refactor bank account handling in billing and staff modules
- Introduced new bank account entities: BusinessBankAccount and StaffBankAccount. - Updated bank account adapter to handle new entities. - Removed legacy BankAccount entity and its adapter. - Implemented use case for fetching bank accounts in billing repository. - Updated BillingBloc and BillingState to include bank accounts. - Refactored PaymentMethodCard to display bank account information. - Adjusted actions widget layout for better UI consistency. - Updated staff bank account repository and use cases to utilize new entity structure. - Ensured all references to bank accounts in the codebase are updated to the new structure.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Abstract base class for all types of bank accounts.
|
||||
abstract class BankAccount extends Equatable {
|
||||
/// Creates a [BankAccount].
|
||||
const BankAccount({
|
||||
required this.id,
|
||||
required this.bankName,
|
||||
required this.isPrimary,
|
||||
this.last4,
|
||||
});
|
||||
|
||||
/// Unique identifier.
|
||||
final String id;
|
||||
|
||||
/// Name of the bank or provider.
|
||||
final String bankName;
|
||||
|
||||
/// Whether this is the primary payment method.
|
||||
final bool isPrimary;
|
||||
|
||||
/// Last 4 digits of the account/card.
|
||||
final String? last4;
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[id, bankName, isPrimary, last4];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'bank_account.dart';
|
||||
|
||||
/// Domain model representing a business bank account or payment method.
|
||||
class BusinessBankAccount extends BankAccount {
|
||||
/// Creates a [BusinessBankAccount].
|
||||
const BusinessBankAccount({
|
||||
required super.id,
|
||||
required super.bankName,
|
||||
required String last4,
|
||||
required super.isPrimary,
|
||||
this.expiryTime,
|
||||
}) : super(last4: last4);
|
||||
|
||||
/// Expiration date if applicable.
|
||||
final DateTime? expiryTime;
|
||||
|
||||
@override
|
||||
List<Object?> get props => <Object?>[
|
||||
...super.props,
|
||||
expiryTime,
|
||||
];
|
||||
|
||||
/// Getter for non-nullable last4 in Business context.
|
||||
@override
|
||||
String get last4 => super.last4!;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'bank_account.dart';
|
||||
|
||||
/// Type of staff bank account.
|
||||
enum StaffBankAccountType {
|
||||
/// Checking account.
|
||||
checking,
|
||||
|
||||
/// Savings account.
|
||||
savings,
|
||||
|
||||
/// Other type.
|
||||
other,
|
||||
}
|
||||
|
||||
/// Domain entity representing a staff's bank account.
|
||||
class StaffBankAccount extends BankAccount {
|
||||
/// Creates a [StaffBankAccount].
|
||||
const StaffBankAccount({
|
||||
required super.id,
|
||||
required this.userId,
|
||||
required super.bankName,
|
||||
required this.accountNumber,
|
||||
required this.accountName,
|
||||
required super.isPrimary,
|
||||
super.last4,
|
||||
this.sortCode,
|
||||
this.type = StaffBankAccountType.checking,
|
||||
});
|
||||
|
||||
/// User identifier.
|
||||
final String userId;
|
||||
|
||||
/// Full account number.
|
||||
final String accountNumber;
|
||||
|
||||
/// Name of the account holder.
|
||||
final String accountName;
|
||||
|
||||
/// Sort code (optional).
|
||||
final String? sortCode;
|
||||
|
||||
/// Account type.
|
||||
final StaffBankAccountType type;
|
||||
|
||||
@override
|
||||
List<Object?> get props =>
|
||||
<Object?>[...super.props, userId, accountNumber, accountName, sortCode, type];
|
||||
}
|
||||
Reference in New Issue
Block a user