recipient saving
This commit is contained in:
@@ -3,4 +3,6 @@ import 'package:pshared/models/payment/type.dart';
|
||||
|
||||
abstract class PaymentMethodData {
|
||||
PaymentType get type;
|
||||
}
|
||||
}
|
||||
|
||||
typedef MethodMap = Map<PaymentType, PaymentMethodData?>;
|
||||
@@ -1,7 +1,12 @@
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:pshared/data/mapper/payment/method.dart';
|
||||
import 'package:pshared/models/describable.dart';
|
||||
import 'package:pshared/models/organization/bound.dart';
|
||||
import 'package:pshared/models/payment/methods/data.dart';
|
||||
import 'package:pshared/models/payment/methods/type.dart';
|
||||
import 'package:pshared/models/permissions/bound.dart';
|
||||
import 'package:pshared/models/storable.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/recipient/provider.dart';
|
||||
import 'package:pshared/provider/template.dart';
|
||||
@@ -49,6 +54,23 @@ class PaymentMethodsProvider extends GenericProvider<PaymentMethod> {
|
||||
cascade: true,
|
||||
);
|
||||
|
||||
Future<PaymentMethod> create({
|
||||
required String reacipientRef,
|
||||
required PaymentMethodData data,
|
||||
required String name,
|
||||
}) => createObject(
|
||||
_organizations.current.id,
|
||||
PaymentMethod(
|
||||
storable: newStorable(),
|
||||
permissionBound: newPermissionBound(
|
||||
organizationBound: newOrganizationBound(organizationRef: _organizations.current.id),
|
||||
),
|
||||
recipientRef: reacipientRef,
|
||||
data: data,
|
||||
describable: newDescribable(name: name),
|
||||
).toDTO().toJson(),
|
||||
);
|
||||
|
||||
|
||||
Future<void> makeMain(PaymentMethod method) {
|
||||
// TODO: create separate backend method to manage main payment method
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
import 'package:pshared/data/mapper/organization/bound.dart';
|
||||
import 'package:pshared/models/recipient/filter.dart';
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
import 'package:pshared/models/recipient/status.dart';
|
||||
import 'package:pshared/models/recipient/type.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/template.dart';
|
||||
import 'package:pshared/service/recipient/service.dart';
|
||||
@@ -51,6 +53,20 @@ class RecipientsProvider extends GenericProvider<Recipient> {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<Recipient> create({
|
||||
required String name,
|
||||
required String email,
|
||||
}) async => createObject(
|
||||
_organizations.current.id,
|
||||
newRecipient(
|
||||
organizationRef: _organizations.current.id,
|
||||
email: email,
|
||||
name: name,
|
||||
status: RecipientStatus.ready,
|
||||
type: RecipientType.internal,
|
||||
).toDTO().toJson(),
|
||||
);
|
||||
|
||||
void updateProviders(OrganizationsProvider organizations) {
|
||||
_organizations = organizations;
|
||||
if (_organizations.isOrganizationSet) {
|
||||
|
||||
Reference in New Issue
Block a user