accounts creation
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/discovery Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/gateway_mntx Pipeline was successful
ci/woodpecker/push/gateway_chain Pipeline was successful
ci/woodpecker/push/gateway_tgsettle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/discovery Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/gateway_mntx Pipeline was successful
ci/woodpecker/push/gateway_chain Pipeline was successful
ci/woodpecker/push/gateway_tgsettle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
This commit is contained in:
@@ -4,8 +4,10 @@ import 'dart:math';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
|
||||
import 'package:pshared/models/currency.dart';
|
||||
import 'package:pshared/models/describable.dart';
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/resource.dart';
|
||||
@@ -159,6 +161,30 @@ class LedgerAccountsProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> create({
|
||||
required Describable describable,
|
||||
required Currency currency,
|
||||
String? ownerRef,
|
||||
}) async {
|
||||
final org = _organizations;
|
||||
if (org == null || !org.isOrganizationSet) return;
|
||||
|
||||
_applyResource(_resource.copyWith(isLoading: true, error: null), notify: true);
|
||||
|
||||
try {
|
||||
await _service.create(
|
||||
organizationRef: org.current.id,
|
||||
currency: currency,
|
||||
describable: describable,
|
||||
ownerRef: ownerRef,
|
||||
);
|
||||
await loadAccountsWithBalances();
|
||||
} catch (e) {
|
||||
_applyResource(_resource.copyWith(isLoading: false, error: toException(e)), notify: true);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- internals ----------
|
||||
|
||||
void _applyResource(Resource<List<LedgerAccount>> newResource, {required bool notify}) {
|
||||
|
||||
Reference in New Issue
Block a user