removed legacy from bff
This commit is contained in:
@@ -2,19 +2,20 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:pshared/models/money.dart';
|
||||
import 'package:pshared/models/payment/payment.dart';
|
||||
import 'package:pshared/models/payment/quote/quote.dart';
|
||||
import 'package:pshared/models/payment/quote/status_type.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
import 'package:pshared/provider/payment/multiple/provider.dart';
|
||||
import 'package:pshared/provider/payment/multiple/quotation.dart';
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
import 'package:pshared/utils/money.dart';
|
||||
import 'package:pshared/utils/payment/quote_helpers.dart';
|
||||
|
||||
import 'package:pweb/models/payment/multiple_payouts/csv_row.dart';
|
||||
import 'package:pweb/models/payment/multiple_payouts/state.dart';
|
||||
import 'package:pweb/utils/payment/multiple_csv_parser.dart';
|
||||
import 'package:pweb/utils/payment/multiple_intent_builder.dart';
|
||||
|
||||
|
||||
class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
final MultipleCsvParser _csvParser;
|
||||
final MultipleIntentBuilder _intentBuilder;
|
||||
@@ -34,10 +35,7 @@ class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
}) : _csvParser = csvParser ?? MultipleCsvParser(),
|
||||
_intentBuilder = intentBuilder ?? MultipleIntentBuilder();
|
||||
|
||||
void update(
|
||||
MultiQuotationProvider quotation,
|
||||
MultiPaymentProvider payment,
|
||||
) {
|
||||
void update(MultiQuotationProvider quotation, MultiPaymentProvider payment) {
|
||||
_bindQuotation(quotation);
|
||||
_payment = payment;
|
||||
}
|
||||
@@ -60,7 +58,9 @@ class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
if (quotation.isLoading) return QuoteStatusType.loading;
|
||||
if (quotation.error != null) return QuoteStatusType.error;
|
||||
if (quotation.quotation == null) return QuoteStatusType.missing;
|
||||
if (_isQuoteExpired(quotation.quoteExpiresAt)) return QuoteStatusType.expired;
|
||||
if (_isQuoteExpired(quotation.quoteExpiresAt)) {
|
||||
return QuoteStatusType.expired;
|
||||
}
|
||||
return QuoteStatusType.active;
|
||||
}
|
||||
|
||||
@@ -78,10 +78,10 @@ class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
|
||||
Money? aggregateDebitAmountFor(Wallet? sourceWallet) {
|
||||
if (_rows.isEmpty) return null;
|
||||
return _moneyForSourceCurrency(
|
||||
_quotation?.quotation?.aggregate?.debitAmounts,
|
||||
sourceWallet,
|
||||
final totals = aggregateMoneyByCurrency(
|
||||
_quoteItems().map((quote) => quote.amounts?.sourceDebitTotal),
|
||||
);
|
||||
return _moneyForSourceCurrency(totals, sourceWallet);
|
||||
}
|
||||
|
||||
Money? get requestedSentAmount {
|
||||
@@ -99,18 +99,16 @@ class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
|
||||
Money? aggregateSettlementAmountFor(Wallet? sourceWallet) {
|
||||
if (_rows.isEmpty) return null;
|
||||
return _moneyForSourceCurrency(
|
||||
_quotation?.quotation?.aggregate?.expectedSettlementAmounts,
|
||||
sourceWallet,
|
||||
final totals = aggregateMoneyByCurrency(
|
||||
_quoteItems().map((quote) => quote.amounts?.destinationSettlement),
|
||||
);
|
||||
return _moneyForSourceCurrency(totals, sourceWallet);
|
||||
}
|
||||
|
||||
Money? aggregateFeeAmountFor(Wallet? sourceWallet) {
|
||||
if (_rows.isEmpty) return null;
|
||||
return _moneyForSourceCurrency(
|
||||
_quotation?.quotation?.aggregate?.expectedFeeTotals,
|
||||
sourceWallet,
|
||||
);
|
||||
final totals = aggregateMoneyByCurrency(_quoteItems().map(quoteFeeTotal));
|
||||
return _moneyForSourceCurrency(totals, sourceWallet);
|
||||
}
|
||||
|
||||
double? aggregateFeePercentFor(Wallet? sourceWallet) {
|
||||
@@ -256,10 +254,7 @@ class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
};
|
||||
}
|
||||
|
||||
Money? _moneyForSourceCurrency(
|
||||
List<Money>? values,
|
||||
Wallet? sourceWallet,
|
||||
) {
|
||||
Money? _moneyForSourceCurrency(List<Money>? values, Wallet? sourceWallet) {
|
||||
if (values == null || values.isEmpty) return null;
|
||||
|
||||
if (sourceWallet != null) {
|
||||
@@ -274,6 +269,9 @@ class MultiplePayoutsProvider extends ChangeNotifier {
|
||||
return values.first;
|
||||
}
|
||||
|
||||
List<PaymentQuote> _quoteItems() =>
|
||||
_quotation?.quotation?.items ?? const <PaymentQuote>[];
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_quotation?.removeListener(_onQuotationChanged);
|
||||
|
||||
Reference in New Issue
Block a user