ledger account service basis
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
import 'package:pshared/data/dto/wallet/money.dart';
|
import 'package:pshared/data/dto/money.dart';
|
||||||
|
|
||||||
part 'balance.g.dart';
|
part 'balance.g.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import 'package:json_annotation/json_annotation.dart';
|
|
||||||
|
|
||||||
part 'money.g.dart';
|
|
||||||
|
|
||||||
|
|
||||||
@JsonSerializable()
|
|
||||||
class MoneyDTO {
|
|
||||||
final String amount;
|
|
||||||
final String currency;
|
|
||||||
|
|
||||||
const MoneyDTO({
|
|
||||||
required this.amount,
|
|
||||||
required this.currency,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory MoneyDTO.fromJson(Map<String, dynamic> json) => _$MoneyDTOFromJson(json);
|
|
||||||
Map<String, dynamic> toJson() => _$MoneyDTOToJson(this);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:pshared/data/dto/payment/money.dart';
|
import 'package:pshared/data/dto/payment/money.dart';
|
||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
|
|
||||||
|
|
||||||
extension MoneyMapper on Money {
|
extension MoneyMapper on Money {
|
||||||
MoneyDTO toDTO() => MoneyDTO(
|
MoneyDTO toDTO() => MoneyDTO(
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:pshared/data/dto/wallet/balance.dart';
|
import 'package:pshared/data/dto/wallet/balance.dart';
|
||||||
import 'package:pshared/data/mapper/wallet/money.dart';
|
import 'package:pshared/data/mapper/money.dart';
|
||||||
import 'package:pshared/models/wallet/balance.dart';
|
import 'package:pshared/models/wallet/balance.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import 'package:pshared/data/dto/wallet/money.dart';
|
|
||||||
import 'package:pshared/models/wallet/money.dart';
|
|
||||||
|
|
||||||
|
|
||||||
extension MoneyDTOMapper on MoneyDTO {
|
|
||||||
WalletMoney toDomain() => WalletMoney(
|
|
||||||
amount: amount,
|
|
||||||
currency: currency,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import 'package:pshared/data/dto/wallet/balance.dart';
|
import 'package:pshared/data/dto/wallet/balance.dart';
|
||||||
import 'package:pshared/data/dto/wallet/wallet.dart';
|
import 'package:pshared/data/dto/wallet/wallet.dart';
|
||||||
|
import 'package:pshared/data/mapper/money.dart';
|
||||||
import 'package:pshared/data/mapper/wallet/asset.dart';
|
import 'package:pshared/data/mapper/wallet/asset.dart';
|
||||||
import 'package:pshared/data/mapper/wallet/balance.dart';
|
import 'package:pshared/data/mapper/wallet/balance.dart';
|
||||||
import 'package:pshared/data/mapper/wallet/money.dart';
|
|
||||||
import 'package:pshared/models/describable.dart';
|
import 'package:pshared/models/describable.dart';
|
||||||
import 'package:pshared/models/wallet/wallet.dart';
|
import 'package:pshared/models/wallet/wallet.dart';
|
||||||
|
|
||||||
|
|
||||||
extension WalletDTOMapper on WalletDTO {
|
extension WalletDTOMapper on WalletDTO {
|
||||||
WalletModel toDomain({WalletBalanceDTO? balance}) => WalletModel(
|
WalletModel toDomain({WalletBalanceDTO? balance}) => WalletModel(
|
||||||
walletRef: walletRef,
|
walletRef: walletRef,
|
||||||
|
|||||||
58
frontend/pshared/lib/models/ledger/account.dart
Normal file
58
frontend/pshared/lib/models/ledger/account.dart
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import 'package:pshared/models/describable.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class LedgerAccount implements Describable {
|
||||||
|
final String ledgerAccountRef;
|
||||||
|
final String organizationRef;
|
||||||
|
final String? ownerRef;
|
||||||
|
final String accountCode;
|
||||||
|
final String accountType;
|
||||||
|
final String currency;
|
||||||
|
final String status;
|
||||||
|
final bool allowNegative;
|
||||||
|
final bool isSettlement;
|
||||||
|
final Map<String, String>? metadata;
|
||||||
|
final DateTime? createdAt;
|
||||||
|
final DateTime? updatedAt;
|
||||||
|
final Describable describable;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get name => describable.name;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get description => describable.description;
|
||||||
|
|
||||||
|
const LedgerAccount({
|
||||||
|
required this.ledgerAccountRef,
|
||||||
|
required this.organizationRef,
|
||||||
|
this.ownerRef,
|
||||||
|
required this.accountCode,
|
||||||
|
required this.accountType,
|
||||||
|
required this.currency,
|
||||||
|
required this.status,
|
||||||
|
required this.allowNegative,
|
||||||
|
required this.isSettlement,
|
||||||
|
this.metadata,
|
||||||
|
this.createdAt,
|
||||||
|
this.updatedAt,
|
||||||
|
required this.describable,
|
||||||
|
});
|
||||||
|
|
||||||
|
LedgerAccount copyWith({
|
||||||
|
Describable? describable,
|
||||||
|
}) => LedgerAccount(
|
||||||
|
ledgerAccountRef: ledgerAccountRef,
|
||||||
|
organizationRef: organizationRef,
|
||||||
|
ownerRef: ownerRef,
|
||||||
|
accountCode: accountCode,
|
||||||
|
accountType: accountType,
|
||||||
|
currency: currency,
|
||||||
|
status: status,
|
||||||
|
allowNegative: allowNegative,
|
||||||
|
isSettlement: isSettlement,
|
||||||
|
metadata: metadata,
|
||||||
|
createdAt: createdAt,
|
||||||
|
updatedAt: updatedAt,
|
||||||
|
describable: describable ?? this.describable,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
|
|
||||||
|
|
||||||
class FeeLine {
|
class FeeLine {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
|
|
||||||
|
|
||||||
class NetworkFee {
|
class NetworkFee {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
|
|
||||||
|
|
||||||
class FxQuote {
|
class FxQuote {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'package:pshared/models/payment/fx/intent.dart';
|
|||||||
import 'package:pshared/models/payment/kind.dart';
|
import 'package:pshared/models/payment/kind.dart';
|
||||||
import 'package:pshared/models/payment/customer.dart';
|
import 'package:pshared/models/payment/customer.dart';
|
||||||
import 'package:pshared/models/payment/methods/data.dart';
|
import 'package:pshared/models/payment/methods/data.dart';
|
||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
import 'package:pshared/models/payment/settlement_mode.dart';
|
import 'package:pshared/models/payment/settlement_mode.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
|
|
||||||
|
|
||||||
class PaymentQuoteAggregate {
|
class PaymentQuoteAggregate {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:pshared/models/payment/fees/line.dart';
|
import 'package:pshared/models/payment/fees/line.dart';
|
||||||
import 'package:pshared/models/payment/fx/quote.dart';
|
import 'package:pshared/models/payment/fx/quote.dart';
|
||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
import 'package:pshared/models/payment/fees/network.dart';
|
import 'package:pshared/models/payment/fees/network.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'package:pshared/models/wallet/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
|
|
||||||
|
|
||||||
class WalletBalance {
|
class WalletBalance {
|
||||||
final WalletMoney? available;
|
final Money? available;
|
||||||
final WalletMoney? pendingInbound;
|
final Money? pendingInbound;
|
||||||
final WalletMoney? pendingOutbound;
|
final Money? pendingOutbound;
|
||||||
final DateTime? calculatedAt;
|
final DateTime? calculatedAt;
|
||||||
|
|
||||||
const WalletBalance({
|
const WalletBalance({
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
class WalletMoney {
|
|
||||||
final String amount;
|
|
||||||
final String currency;
|
|
||||||
|
|
||||||
const WalletMoney({
|
|
||||||
required this.amount,
|
|
||||||
required this.currency,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:pshared/models/describable.dart';
|
import 'package:pshared/models/describable.dart';
|
||||||
|
import 'package:pshared/models/money.dart';
|
||||||
import 'package:pshared/models/wallet/asset.dart';
|
import 'package:pshared/models/wallet/asset.dart';
|
||||||
import 'package:pshared/models/wallet/balance.dart';
|
import 'package:pshared/models/wallet/balance.dart';
|
||||||
import 'package:pshared/models/wallet/money.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class WalletModel implements Describable {
|
class WalletModel implements Describable {
|
||||||
@@ -15,7 +15,7 @@ class WalletModel implements Describable {
|
|||||||
final DateTime? createdAt;
|
final DateTime? createdAt;
|
||||||
final DateTime? updatedAt;
|
final DateTime? updatedAt;
|
||||||
final WalletBalance? balance;
|
final WalletBalance? balance;
|
||||||
final WalletMoney? availableMoney;
|
final Money? availableMoney;
|
||||||
final Describable describable;
|
final Describable describable;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -40,8 +40,6 @@ class WalletModel implements Describable {
|
|||||||
});
|
});
|
||||||
|
|
||||||
WalletModel copyWith({
|
WalletModel copyWith({
|
||||||
WalletBalance? balance,
|
|
||||||
WalletMoney? availableMoney,
|
|
||||||
Describable? describable,
|
Describable? describable,
|
||||||
}) => WalletModel(
|
}) => WalletModel(
|
||||||
walletRef: walletRef,
|
walletRef: walletRef,
|
||||||
@@ -53,8 +51,8 @@ class WalletModel implements Describable {
|
|||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
createdAt: createdAt,
|
createdAt: createdAt,
|
||||||
updatedAt: updatedAt,
|
updatedAt: updatedAt,
|
||||||
balance: balance ?? this.balance,
|
balance: balance,
|
||||||
availableMoney: availableMoney ?? this.availableMoney,
|
availableMoney: availableMoney,
|
||||||
describable: describable ?? this.describable,
|
describable: describable ?? this.describable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import 'package:pshared/models/payment/fx/side.dart';
|
|||||||
import 'package:pshared/models/payment/kind.dart';
|
import 'package:pshared/models/payment/kind.dart';
|
||||||
import 'package:pshared/models/payment/methods/managed_wallet.dart';
|
import 'package:pshared/models/payment/methods/managed_wallet.dart';
|
||||||
import 'package:pshared/models/payment/methods/type.dart';
|
import 'package:pshared/models/payment/methods/type.dart';
|
||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
import 'package:pshared/models/payment/settlement_mode.dart';
|
import 'package:pshared/models/payment/settlement_mode.dart';
|
||||||
import 'package:pshared/models/payment/intent.dart';
|
import 'package:pshared/models/payment/intent.dart';
|
||||||
import 'package:pshared/models/recipient/recipient.dart';
|
import 'package:pshared/models/recipient/recipient.dart';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:pshared/data/mapper/payment/intent/payment.dart';
|
|||||||
import 'package:pshared/models/asset.dart';
|
import 'package:pshared/models/asset.dart';
|
||||||
import 'package:pshared/models/payment/intent.dart';
|
import 'package:pshared/models/payment/intent.dart';
|
||||||
import 'package:pshared/models/payment/quote/quote.dart';
|
import 'package:pshared/models/payment/quote/quote.dart';
|
||||||
import 'package:pshared/models/payment/money.dart';
|
import 'package:pshared/models/money.dart';
|
||||||
import 'package:pshared/provider/organizations.dart';
|
import 'package:pshared/provider/organizations.dart';
|
||||||
import 'package:pshared/provider/payment/amount.dart';
|
import 'package:pshared/provider/payment/amount.dart';
|
||||||
import 'package:pshared/provider/payment/flow.dart';
|
import 'package:pshared/provider/payment/flow.dart';
|
||||||
|
|||||||
31
frontend/pshared/lib/service/ledger.dart
Normal file
31
frontend/pshared/lib/service/ledger.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import 'package:pshared/api/responses/wallet_balance.dart';
|
||||||
|
import 'package:pshared/api/responses/wallets.dart';
|
||||||
|
import 'package:pshared/data/mapper/wallet/response.dart';
|
||||||
|
import 'package:pshared/models/wallet/balance.dart';
|
||||||
|
import 'package:pshared/models/wallet/wallet.dart';
|
||||||
|
import 'package:pshared/service/authorization/service.dart';
|
||||||
|
import 'package:pshared/service/services.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class LedgerService {
|
||||||
|
static const String _objectType = Services.ledger;
|
||||||
|
|
||||||
|
static Future<List<WalletModel>> list(String organizationRef) async {
|
||||||
|
final json = await AuthorizationService.getGETResponse(
|
||||||
|
_objectType,
|
||||||
|
'/$organizationRef',
|
||||||
|
);
|
||||||
|
return WalletsResponse.fromJson(json).toDomain();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<WalletBalance> getBalance({
|
||||||
|
required String organizationRef,
|
||||||
|
required String walletRef,
|
||||||
|
}) async {
|
||||||
|
final json = await AuthorizationService.getGETResponse(
|
||||||
|
_objectType,
|
||||||
|
'/$organizationRef/$walletRef/balance',
|
||||||
|
);
|
||||||
|
return WalletBalanceResponse.fromJson(json).toDomain();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ class Services {
|
|||||||
static const String permission = 'permissions';
|
static const String permission = 'permissions';
|
||||||
static const String storage = 'storage';
|
static const String storage = 'storage';
|
||||||
static const String chainWallets = 'chain_wallets';
|
static const String chainWallets = 'chain_wallets';
|
||||||
|
static const String ledger = 'ledger_accounts';
|
||||||
|
|
||||||
static const String recipients = 'recipients';
|
static const String recipients = 'recipients';
|
||||||
static const String paymentMethods = 'payment_methods';
|
static const String paymentMethods = 'payment_methods';
|
||||||
|
|||||||
Reference in New Issue
Block a user