fix for quote and operations addition

This commit is contained in:
Arseni
2026-03-13 16:07:22 +03:00
parent 34a7edd50c
commit 530432e3f8
13 changed files with 200 additions and 359 deletions

View File

@@ -27,11 +27,15 @@ class OperationHistoryTile extends StatelessWidget {
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context)!;
final theme = Theme.of(context);
final title = resolveOperationTitle(loc, operation.code);
final operationLabel = operation.label?.trim();
final title = (operationLabel != null && operationLabel.isNotEmpty)
? operationLabel
: resolveOperationTitle(loc, operation.code);
// final operationComment = operation.comment?.trim();
final stateView = resolveStepStateView(context, operation.state);
final completedAt = formatCompletedAt(context, operation.completedAt);
final amount = formatMoneyUi(context, operation.amount);
final convertedAmount = formatMoneyUi(context, operation.convertedAmount);
final canDownload = canDownloadDocument && onDownloadDocument != null;
return Column(
@@ -52,17 +56,6 @@ class OperationHistoryTile extends StatelessWidget {
StepStateChip(view: stateView),
],
),
if (operationLabel != null &&
operationLabel.isNotEmpty &&
operationLabel != title) ...[
const SizedBox(height: 4),
Text(
operationLabel,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
const SizedBox(height: 6),
Text(
'${loc.completedAtLabel}: $completedAt',
@@ -77,6 +70,24 @@ class OperationHistoryTile extends StatelessWidget {
color: theme.colorScheme.onSurfaceVariant,
),
),
if (operation.convertedAmount != null) ...[
const SizedBox(height: 4),
Text(
'${loc.toAmountColumn}: $convertedAmount',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
// if (operationComment != null && operationComment.isNotEmpty) ...[
// const SizedBox(height: 4),
// Text(
// '${loc.comment}: $operationComment',
// style: theme.textTheme.bodySmall?.copyWith(
// color: theme.colorScheme.onSurfaceVariant,
// ),
// ),
// ],
if (canDownload) ...[
const SizedBox(height: 8),
TextButton.icon(

View File

@@ -58,7 +58,7 @@ class OperationRow {
DataCell(Text(op.cardNumber ?? '-')),
DataCell(Text(op.name)),
DataCell(Text(dateLabel)),
DataCell(Text(op.comment)),
// DataCell(Text(op.comment)),
],
);
}

View File

@@ -1,85 +0,0 @@
import 'package:pshared/models/payment/operation.dart';
import 'package:pshared/models/payment/status.dart';
class OperationService {
Future<List<OperationItem>> fetchOperations() async {
await Future.delayed(const Duration(milliseconds: 500));
return [
OperationItem(
status: OperationStatus.error,
fileName: 'cards_payout_sample_june.csv',
amount: 10,
currency: 'EUR',
toAmount: 10,
toCurrency: 'EUR',
payId: '860163800',
cardNumber: null,
name: 'John Snow',
date: DateTime(2025, 7, 14, 19, 59, 2),
comment: 'EUR visa',
),
OperationItem(
status: OperationStatus.processing,
fileName: 'cards_payout_sample_june.csv',
amount: 10,
currency: 'EUR',
toAmount: 10,
toCurrency: 'EUR',
payId: '860163700',
cardNumber: null,
name: 'Baltasar Gelt',
date: DateTime(2025, 7, 14, 19, 59, 2),
comment: 'EUR master',
),
OperationItem(
status: OperationStatus.error,
fileName: 'cards_payout_sample_june.csv',
amount: 10,
currency: 'EUR',
toAmount: 10,
toCurrency: 'EUR',
payId: '40000000****0077',
cardNumber: '40000000****0077',
name: 'John Snow',
date: DateTime(2025, 7, 14, 19, 23, 22),
comment: 'EUR visa',
),
OperationItem(
status: OperationStatus.success,
fileName: null,
amount: 10,
currency: 'EUR',
toAmount: 10,
toCurrency: 'EUR',
payId: '54133300****0019',
cardNumber: '54133300****0019',
name: 'Baltasar Gelt',
date: DateTime(2025, 7, 14, 19, 23, 21),
comment: 'EUR master',
),
OperationItem(
status: OperationStatus.success,
fileName: null,
amount: 130,
currency: 'EUR',
toAmount: 130,
toCurrency: 'EUR',
payId: '54134300****0019',
cardNumber: '54153300****0019',
name: 'Ivan Brokov',
date: DateTime(2025, 7, 15, 19, 23, 21),
comment: 'EUR master 2',
),
];
}
// Add real API:
// Future<List<OperationItem>> fetchOperations() async {
// final response = await _httpClient.get('/api/operations');
// return (response.data as List)
// .map((json) => OperationItem.fromJson(json))
// .toList();
// }
}

View File

@@ -23,14 +23,15 @@ OperationItem mapPaymentToOperation(Payment payment) {
final payId = _firstNonEmpty([payment.paymentRef]) ?? '-';
final name =
_firstNonEmpty([payment.lastQuote?.quoteRef, payment.paymentRef]) ?? '-';
final comment =
_firstNonEmpty([
payment.comment,
payment.failureReason,
payment.failureCode,
payment.state,
]) ??
'';
// final comment =
// _firstNonEmpty([
// ...payment.operations.map((operation) => operation.comment),
// payment.comment,
// payment.failureReason,
// payment.failureCode,
// payment.state,
// ]) ??
// '';
final operationDocument = _resolveOperationDocument(payment);
return OperationItem(
@@ -47,7 +48,7 @@ OperationItem mapPaymentToOperation(Payment payment) {
cardNumber: null,
name: name,
date: resolvePaymentDate(payment),
comment: comment,
// comment: comment,
);
}