ledger top up functionality and few small fixes for project architechture and design
This commit is contained in:
26
frontend/pweb/lib/models/dashboard/balance_item.dart
Normal file
26
frontend/pweb/lib/models/dashboard/balance_item.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
|
||||
sealed class BalanceItem {
|
||||
const BalanceItem();
|
||||
|
||||
const factory BalanceItem.wallet(Wallet wallet) = WalletBalanceItem;
|
||||
const factory BalanceItem.ledger(LedgerAccount account) = LedgerBalanceItem;
|
||||
const factory BalanceItem.addAction() = AddBalanceActionItem;
|
||||
}
|
||||
|
||||
final class WalletBalanceItem extends BalanceItem {
|
||||
final Wallet wallet;
|
||||
|
||||
const WalletBalanceItem(this.wallet);
|
||||
}
|
||||
|
||||
final class LedgerBalanceItem extends BalanceItem {
|
||||
final LedgerAccount account;
|
||||
|
||||
const LedgerBalanceItem(this.account);
|
||||
}
|
||||
|
||||
final class AddBalanceActionItem extends BalanceItem {
|
||||
const AddBalanceActionItem();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
class OperationDocumentRequestModel {
|
||||
final String gatewayService;
|
||||
final String operationRef;
|
||||
|
||||
const OperationDocumentRequestModel({
|
||||
required this.gatewayService,
|
||||
required this.operationRef,
|
||||
});
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
enum PaymentState {
|
||||
success,
|
||||
failed,
|
||||
cancelled,
|
||||
processing,
|
||||
unknown,
|
||||
}
|
||||
|
||||
PaymentState paymentStateFromRaw(String? raw) {
|
||||
final trimmed = (raw ?? '').trim().toUpperCase();
|
||||
final normalized = trimmed.startsWith('PAYMENT_STATE_')
|
||||
? trimmed.substring('PAYMENT_STATE_'.length)
|
||||
: trimmed;
|
||||
|
||||
switch (normalized) {
|
||||
case 'SUCCESS':
|
||||
return PaymentState.success;
|
||||
case 'FAILED':
|
||||
return PaymentState.failed;
|
||||
case 'CANCELLED':
|
||||
return PaymentState.cancelled;
|
||||
case 'PROCESSING':
|
||||
return PaymentState.processing;
|
||||
default:
|
||||
return PaymentState.unknown;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
class OperationDocumentInfo {
|
||||
final String operationRef;
|
||||
final String gatewayService;
|
||||
|
||||
const OperationDocumentInfo({
|
||||
required this.operationRef,
|
||||
required this.gatewayService,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user