added comment for payment, changed intent and added amount ui in operations

This commit is contained in:
Arseni
2026-03-12 00:09:38 +03:00
parent ddc2f1facc
commit 13b84e1e0f
26 changed files with 271 additions and 298 deletions

View File

@@ -45,12 +45,12 @@ class MultipleCsvParser {
'expiry_year',
]);
final amountIndex = _resolveHeaderIndex(header, const ['amount', 'sum']);
final commentIndex = _resolveHeaderIndex(header, const ['comment']);
if (panIndex < 0 ||
firstNameIndex < 0 ||
lastNameIndex < 0 ||
(expDateIndex < 0 &&
(expMonthIndex < 0 || expYearIndex < 0)) ||
(expDateIndex < 0 && (expMonthIndex < 0 || expYearIndex < 0)) ||
amountIndex < 0) {
throw FormatException(
'CSV header must contain pan, first_name, last_name, amount columns and either exp_date/expiry or exp_month and exp_year',
@@ -67,6 +67,7 @@ class MultipleCsvParser {
final expMonthRaw = _cell(raw, expMonthIndex);
final expYearRaw = _cell(raw, expYearIndex);
final amount = _normalizeAmount(_cell(raw, amountIndex));
final comment = commentIndex >= 0 ? _cell(raw, commentIndex) : '';
if (pan.isEmpty) {
throw FormatException('CSV row ${i + 1}: pan is required');
@@ -117,6 +118,7 @@ class MultipleCsvParser {
expMonth: expMonth,
expYear: expYear,
amount: amount,
comment: _normalizeComment(comment),
),
);
}
@@ -206,6 +208,11 @@ class MultipleCsvParser {
return value.trim().replaceAll(' ', '').replaceAll(',', '.');
}
String? _normalizeComment(String value) {
final normalized = value.trim();
return normalized.isEmpty ? null : normalized;
}
_ExpiryDate _parseExpiryDate(String value, int rowNumber) {
final match = RegExp(r'^\s*(\d{1,2})\s*/\s*(\d{2})\s*$').firstMatch(value);
if (match == null) {

View File

@@ -1,4 +1,5 @@
import 'package:pshared/models/money.dart';
import 'package:pshared/models/payment/customer.dart';
import 'package:pshared/models/payment/fees/treatment.dart';
import 'package:pshared/models/payment/intent.dart';
import 'package:pshared/models/payment/kind.dart';
@@ -9,6 +10,7 @@ import 'package:pshared/utils/payment/fx_helpers.dart';
import 'package:pweb/models/payment/multiple_payouts/csv_row.dart';
class MultipleIntentBuilder {
static const String _currency = 'RUB';
@@ -23,22 +25,33 @@ class MultipleIntentBuilder {
);
return rows
.map((row) {
.asMap()
.entries
.map((entry) {
final rowIndex = entry.key;
final row = entry.value;
final amount = Money(amount: row.amount, currency: _currency);
final destination = CardPaymentMethod(
pan: row.pan,
firstName: row.firstName,
lastName: row.lastName,
expMonth: row.expMonth,
expYear: row.expYear,
);
return PaymentIntent(
kind: PaymentKind.payout,
source: sourceMethod,
destination: CardPaymentMethod(
pan: row.pan,
firstName: row.firstName,
lastName: row.lastName,
expMonth: row.expMonth,
expYear: row.expYear,
),
destination: destination,
amount: amount,
feeTreatment: FeeTreatment.addToSource,
settlementMode: SettlementMode.fixReceived,
fx: fxIntent,
comment: row.comment,
customer: Customer(
id: 'csv_row_${rowIndex + 1}',
firstName: destination.firstName,
lastName: destination.lastName,
),
);
})
.toList(growable: false);