fix for quote and operations addition
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:uuid/uuid.dart';
|
||||
import 'package:pshared/api/requests/payment/quotes.dart';
|
||||
import 'package:pshared/data/mapper/payment/intent/payment.dart';
|
||||
import 'package:pshared/models/payment/intent.dart';
|
||||
import 'package:pshared/models/payment/kind.dart';
|
||||
import 'package:pshared/models/payment/quote/quotes.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/payment/auto_refresh.dart';
|
||||
@@ -12,6 +13,7 @@ import 'package:pshared/provider/resource.dart';
|
||||
import 'package:pshared/service/payment/multiple.dart';
|
||||
import 'package:pshared/utils/exception.dart';
|
||||
|
||||
|
||||
class MultiQuotationProvider extends ChangeNotifier {
|
||||
static const Duration _autoRefreshLead = Duration(seconds: 5);
|
||||
|
||||
@@ -77,6 +79,11 @@ class MultiQuotationProvider extends ChangeNotifier {
|
||||
if (intents.isEmpty) {
|
||||
throw StateError('At least one payment intent is required');
|
||||
}
|
||||
if (intents.any((intent) => !_isQuotable(intent))) {
|
||||
throw StateError(
|
||||
'Each payment intent must include kind, source, destination, and amount',
|
||||
);
|
||||
}
|
||||
|
||||
_lastIntents = List<PaymentIntent>.from(intents);
|
||||
_lastPreviewOnly = previewOnly;
|
||||
@@ -135,6 +142,13 @@ class MultiQuotationProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _isQuotable(PaymentIntent intent) {
|
||||
if (intent.kind == PaymentKind.unspecified) return false;
|
||||
if (intent.source == null) return false;
|
||||
if (intent.destination == null) return false;
|
||||
return intent.amount != null;
|
||||
}
|
||||
|
||||
void _setResource(Resource<PaymentQuotes> quotation) {
|
||||
_quotation = quotation;
|
||||
_syncAutoRefresh();
|
||||
|
||||
Reference in New Issue
Block a user