refactor of money utils with new money2 package
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'package:pshared/utils/money.dart';
|
||||
|
||||
import 'package:pweb/models/payment/multiple_payouts/csv_row.dart';
|
||||
|
||||
|
||||
@@ -82,8 +80,8 @@ class MultipleCsvParser {
|
||||
throw FormatException('CSV row ${i + 1}: amount is required');
|
||||
}
|
||||
|
||||
final parsedAmount = parseMoneyAmount(amount, fallback: double.nan);
|
||||
if (parsedAmount.isNaN || parsedAmount <= 0) {
|
||||
final parsedAmount = double.tryParse(amount);
|
||||
if (parsedAmount == null || parsedAmount <= 0) {
|
||||
throw FormatException(
|
||||
'CSV row ${i + 1}: amount must be greater than 0',
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -6,6 +5,7 @@ import 'package:pshared/models/payment/kind.dart';
|
||||
import 'package:pshared/models/payment/methods/card.dart';
|
||||
import 'package:pshared/models/payment/methods/data.dart';
|
||||
import 'package:pshared/models/payment/settlement_mode.dart';
|
||||
import 'package:pshared/utils/money.dart';
|
||||
import 'package:pshared/utils/payment/fx_helpers.dart';
|
||||
|
||||
import 'package:pweb/models/payment/multiple_payouts/csv_row.dart';
|
||||
@@ -30,7 +30,12 @@ class MultipleIntentBuilder {
|
||||
.map((entry) {
|
||||
final rowIndex = entry.key;
|
||||
final row = entry.value;
|
||||
final amount = Money(amount: row.amount, currency: _currency);
|
||||
final amount = parseMoneyWithCurrencyCode(row.amount, _currency);
|
||||
if (amount == null) {
|
||||
throw FormatException(
|
||||
'Invalid CSV amount at row ${rowIndex + 1}: ${row.amount}',
|
||||
);
|
||||
}
|
||||
final destination = CardPaymentMethod(
|
||||
pan: row.pan,
|
||||
firstName: row.firstName,
|
||||
|
||||
Reference in New Issue
Block a user