TRON -> TRON_MAINNET
This commit is contained in:
@@ -104,6 +104,7 @@ class _OperationHistoryPageState extends State<OperationHistoryPage> {
|
||||
toAmount: toAmount,
|
||||
toCurrency: toCurrency,
|
||||
payId: payId,
|
||||
paymentRef: payment.paymentRef,
|
||||
cardNumber: null,
|
||||
name: name,
|
||||
date: _resolvePaymentDate(payment),
|
||||
@@ -141,6 +142,7 @@ class _OperationHistoryPageState extends State<OperationHistoryPage> {
|
||||
return OperationStatus.processing;
|
||||
|
||||
case 'settled':
|
||||
case 'success':
|
||||
return OperationStatus.success;
|
||||
|
||||
case 'failed':
|
||||
|
||||
@@ -1,23 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/models/payment/operation.dart';
|
||||
import 'package:pshared/models/payment/status.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/service/payment/documents.dart';
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
import 'package:pweb/pages/report/table/badge.dart';
|
||||
import 'package:pweb/utils/download.dart';
|
||||
import 'package:pweb/utils/error/snackbar.dart';
|
||||
|
||||
|
||||
class OperationRow {
|
||||
static DataRow build(OperationItem op, BuildContext context) {
|
||||
final isUnknownDate = op.date.millisecondsSinceEpoch == 0;
|
||||
final localDate = op.date.toLocal();
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
final dateLabel = isUnknownDate
|
||||
? '-'
|
||||
: '${TimeOfDay.fromDateTime(localDate).format(context)}\n'
|
||||
'${localDate.toIso8601String().split("T").first}';
|
||||
|
||||
final canDownload = op.status == OperationStatus.success &&
|
||||
(op.paymentRef ?? '').trim().isNotEmpty;
|
||||
|
||||
final documentCell = canDownload
|
||||
? TextButton.icon(
|
||||
onPressed: () => _downloadAct(context, op),
|
||||
icon: const Icon(Icons.download),
|
||||
label: Text(loc.downloadAct),
|
||||
)
|
||||
: Text(op.fileName ?? '');
|
||||
|
||||
return DataRow(cells: [
|
||||
DataCell(OperationStatusBadge(status: op.status)),
|
||||
DataCell(Text(op.fileName ?? '')),
|
||||
DataCell(documentCell),
|
||||
DataCell(Text('${amountToString(op.amount)} ${op.currency}')),
|
||||
DataCell(Text('${amountToString(op.toAmount)} ${op.toCurrency}')),
|
||||
DataCell(Text(op.payId)),
|
||||
@@ -27,4 +47,28 @@ class OperationRow {
|
||||
DataCell(Text(op.comment)),
|
||||
]);
|
||||
}
|
||||
|
||||
static Future<void> _downloadAct(BuildContext context, OperationItem op) async {
|
||||
final organizations = context.read<OrganizationsProvider>();
|
||||
if (!organizations.isOrganizationSet) {
|
||||
return;
|
||||
}
|
||||
final paymentRef = (op.paymentRef ?? '').trim();
|
||||
if (paymentRef.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
await executeActionWithNotification(
|
||||
context: context,
|
||||
action: () async {
|
||||
final file = await PaymentDocumentsService.getAct(
|
||||
organizations.current.id,
|
||||
paymentRef,
|
||||
);
|
||||
await downloadFile(file);
|
||||
},
|
||||
errorMessage: loc.downloadActError,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user