SEND063
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:pshared/models/payment/execution_operation.dart';
|
||||
import 'package:pshared/models/payment/payment.dart';
|
||||
import 'package:pshared/models/payment/status.dart';
|
||||
import 'package:pshared/provider/payment/payments.dart';
|
||||
import 'package:pweb/models/documents/operation.dart';
|
||||
|
||||
import 'package:pweb/utils/payment/operation_code.dart';
|
||||
import 'package:pweb/utils/report/payment_mapper.dart';
|
||||
|
||||
|
||||
class PaymentDetailsController extends ChangeNotifier {
|
||||
PaymentDetailsController({required String paymentId})
|
||||
: _paymentId = paymentId;
|
||||
: _paymentId = paymentId;
|
||||
|
||||
PaymentsProvider? _payments;
|
||||
String _paymentId;
|
||||
@@ -25,10 +28,34 @@ class PaymentDetailsController extends ChangeNotifier {
|
||||
if (current == null) return false;
|
||||
final status = statusFromPayment(current);
|
||||
final paymentRef = current.paymentRef ?? '';
|
||||
return status == OperationStatus.success &&
|
||||
paymentRef.trim().isNotEmpty;
|
||||
return status == OperationStatus.success && paymentRef.trim().isNotEmpty;
|
||||
}
|
||||
|
||||
OperationDocumentRequestModel? operationDocumentRequest(
|
||||
PaymentExecutionOperation operation,
|
||||
) {
|
||||
final current = _payment;
|
||||
if (current == null) return null;
|
||||
|
||||
final paymentRef = current.paymentRef?.trim() ?? '';
|
||||
if (paymentRef.isEmpty) return null;
|
||||
|
||||
final operationRef = operation.operationRef;
|
||||
if (operationRef == null || operationRef.isEmpty) return null;
|
||||
|
||||
final pair = parseOperationCodePair(operation.code);
|
||||
if (pair == null) return null;
|
||||
if (pair.operation != 'card_payout' || pair.action != 'send') return null;
|
||||
|
||||
return OperationDocumentRequestModel(
|
||||
paymentRef: paymentRef,
|
||||
operationRef: operationRef,
|
||||
);
|
||||
}
|
||||
|
||||
bool canDownloadOperationDocument(PaymentExecutionOperation operation) =>
|
||||
operationDocumentRequest(operation) != null;
|
||||
|
||||
void update(PaymentsProvider provider, String paymentId) {
|
||||
if (_paymentId != paymentId) {
|
||||
_paymentId = paymentId;
|
||||
|
||||
Reference in New Issue
Block a user