Fixed billing fees unreachable error propagation. Added USDT ledger creation. Fixed ledger boundaries operation types
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/discovery"
|
||||
"github.com/tech/sendico/pkg/ledgerconv"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/model/account_role"
|
||||
@@ -23,7 +24,36 @@ import (
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
const ledgerConnectorID = "ledger"
|
||||
const (
|
||||
ledgerConnectorID = "ledger"
|
||||
ledgerRailName = "LEDGER"
|
||||
|
||||
opParamOperation = "operation"
|
||||
opParamToMoney = "to_money"
|
||||
opParamAmount = "amount"
|
||||
opParamCurrency = "currency"
|
||||
opParamOrganizationRef = "organization_ref"
|
||||
opParamAccountType = "account_type"
|
||||
opParamStatus = "status"
|
||||
opParamAllowNegative = "allow_negative"
|
||||
opParamRole = "role"
|
||||
opParamDescription = "description"
|
||||
opParamMetadata = "metadata"
|
||||
opParamCharges = "charges"
|
||||
opParamEventTime = "event_time"
|
||||
opParamContraLedgerAccountRef = "contra_ledger_account_ref"
|
||||
opParamLedgerAccountRef = "ledger_account_ref"
|
||||
opParamLineType = "line_type"
|
||||
opParamAccountCode = "account_code"
|
||||
opParamIsSettlement = "is_settlement"
|
||||
|
||||
txMetaPaymentPlanID = "payment_plan_id"
|
||||
txMetaFromRail = "from_rail"
|
||||
txMetaToRail = "to_rail"
|
||||
txMetaExternalReference = "external_reference_id"
|
||||
txMetaFXRateUsed = "fx_rate_used"
|
||||
txMetaFeeAmount = "fee_amount"
|
||||
)
|
||||
|
||||
// Client exposes typed helpers around the ledger gRPC API.
|
||||
type Client interface {
|
||||
@@ -36,6 +66,8 @@ type Client interface {
|
||||
ListConnectorAccounts(ctx context.Context, req *connectorv1.ListAccountsRequest) (*connectorv1.ListAccountsResponse, error)
|
||||
PostCreditWithCharges(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error)
|
||||
PostDebitWithCharges(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error)
|
||||
PostExternalCreditWithCharges(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error)
|
||||
PostExternalDebitWithCharges(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error)
|
||||
TransferInternal(ctx context.Context, req *ledgerv1.TransferRequest) (*ledgerv1.PostResponse, error)
|
||||
ApplyFXWithCharges(ctx context.Context, req *ledgerv1.FXRequest) (*ledgerv1.PostResponse, error)
|
||||
|
||||
@@ -148,7 +180,7 @@ func (c *ledgerClient) CreateTransaction(ctx context.Context, tx rail.LedgerTx)
|
||||
metadata := ledgerTxMetadata(tx.Metadata, tx)
|
||||
extraParams := map[string]interface{}{}
|
||||
if op := strings.TrimSpace(tx.Operation); op != "" {
|
||||
extraParams["operation"] = op
|
||||
extraParams[opParamOperation] = op
|
||||
}
|
||||
if len(extraParams) == 0 {
|
||||
extraParams = nil
|
||||
@@ -204,13 +236,13 @@ func (c *ledgerClient) CreateAccount(ctx context.Context, req *ledgerv1.CreateAc
|
||||
return nil, merrors.InvalidArgument("ledger: currency is required")
|
||||
}
|
||||
params := map[string]interface{}{
|
||||
"organization_ref": strings.TrimSpace(req.GetOrganizationRef()),
|
||||
"account_type": req.GetAccountType().String(),
|
||||
"status": req.GetStatus().String(),
|
||||
"allow_negative": req.GetAllowNegative(),
|
||||
opParamOrganizationRef: strings.TrimSpace(req.GetOrganizationRef()),
|
||||
opParamAccountType: req.GetAccountType().String(),
|
||||
opParamStatus: req.GetStatus().String(),
|
||||
opParamAllowNegative: req.GetAllowNegative(),
|
||||
}
|
||||
if role := req.GetRole(); role != ledgerv1.AccountRole_ACCOUNT_ROLE_UNSPECIFIED {
|
||||
params["role"] = role.String()
|
||||
params[opParamRole] = role.String()
|
||||
}
|
||||
label := ""
|
||||
if desc := req.GetDescribable(); desc != nil {
|
||||
@@ -218,12 +250,12 @@ func (c *ledgerClient) CreateAccount(ctx context.Context, req *ledgerv1.CreateAc
|
||||
if desc.Description != nil {
|
||||
trimmed := strings.TrimSpace(desc.GetDescription())
|
||||
if trimmed != "" {
|
||||
params["description"] = trimmed
|
||||
params[opParamDescription] = trimmed
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(req.GetMetadata()) > 0 {
|
||||
params["metadata"] = mapStringToInterface(req.GetMetadata())
|
||||
params[opParamMetadata] = mapStringToInterface(req.GetMetadata())
|
||||
}
|
||||
resp, err := c.client.OpenAccount(ctx, &connectorv1.OpenAccountRequest{
|
||||
Kind: connectorv1.AccountKind_LEDGER_ACCOUNT,
|
||||
@@ -277,6 +309,30 @@ func (c *ledgerClient) PostDebitWithCharges(ctx context.Context, req *ledgerv1.P
|
||||
return c.submitLedgerOperation(ctx, connectorv1.OperationType_DEBIT, req.GetLedgerAccountRef(), "", req.GetMoney(), req)
|
||||
}
|
||||
|
||||
func (c *ledgerClient) PostExternalCreditWithCharges(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error) {
|
||||
return c.submitLedgerOperationWithExtras(
|
||||
ctx,
|
||||
connectorv1.OperationType_CREDIT,
|
||||
"",
|
||||
req.GetLedgerAccountRef(),
|
||||
req.GetMoney(),
|
||||
req,
|
||||
map[string]interface{}{opParamOperation: discovery.OperationExternalCredit},
|
||||
)
|
||||
}
|
||||
|
||||
func (c *ledgerClient) PostExternalDebitWithCharges(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error) {
|
||||
return c.submitLedgerOperationWithExtras(
|
||||
ctx,
|
||||
connectorv1.OperationType_DEBIT,
|
||||
req.GetLedgerAccountRef(),
|
||||
"",
|
||||
req.GetMoney(),
|
||||
req,
|
||||
map[string]interface{}{opParamOperation: discovery.OperationExternalDebit},
|
||||
)
|
||||
}
|
||||
|
||||
func (c *ledgerClient) TransferInternal(ctx context.Context, req *ledgerv1.TransferRequest) (*ledgerv1.PostResponse, error) {
|
||||
return c.submitLedgerOperation(ctx, connectorv1.OperationType_TRANSFER, req.GetFromLedgerAccountRef(), req.GetToLedgerAccountRef(), req.GetMoney(), req)
|
||||
}
|
||||
@@ -292,7 +348,7 @@ func (c *ledgerClient) ApplyFXWithCharges(ctx context.Context, req *ledgerv1.FXR
|
||||
}
|
||||
params := ledgerOperationParams(req.GetOrganizationRef(), req.GetDescription(), req.GetMetadata(), req.GetCharges(), req.GetEventTime())
|
||||
params["rate"] = strings.TrimSpace(req.GetRate())
|
||||
params["to_money"] = map[string]interface{}{"amount": req.GetToMoney().GetAmount(), "currency": req.GetToMoney().GetCurrency()}
|
||||
params[opParamToMoney] = map[string]interface{}{opParamAmount: req.GetToMoney().GetAmount(), opParamCurrency: req.GetToMoney().GetCurrency()}
|
||||
operation := &connectorv1.Operation{
|
||||
Type: connectorv1.OperationType_FX,
|
||||
IdempotencyKey: strings.TrimSpace(req.GetIdempotencyKey()),
|
||||
@@ -466,7 +522,7 @@ func (c *ledgerClient) submitLedgerOperationWithExtras(ctx context.Context, opTy
|
||||
|
||||
params := ledgerOperationParams(orgRef, description, metadata, charges, eventTime)
|
||||
if contraRef != "" {
|
||||
params["contra_ledger_account_ref"] = strings.TrimSpace(contraRef)
|
||||
params[opParamContraLedgerAccountRef] = strings.TrimSpace(contraRef)
|
||||
}
|
||||
if len(extraParams) > 0 {
|
||||
for key, value := range extraParams {
|
||||
@@ -534,17 +590,17 @@ func accountRoleFromLedgerProto(role ledgerv1.AccountRole) account_role.AccountR
|
||||
|
||||
func ledgerOperationParams(orgRef, description string, metadata map[string]string, charges []*ledgerv1.PostingLine, eventTime *timestamppb.Timestamp) map[string]interface{} {
|
||||
params := map[string]interface{}{
|
||||
"organization_ref": strings.TrimSpace(orgRef),
|
||||
"description": strings.TrimSpace(description),
|
||||
opParamOrganizationRef: strings.TrimSpace(orgRef),
|
||||
opParamDescription: strings.TrimSpace(description),
|
||||
}
|
||||
if len(metadata) > 0 {
|
||||
params["metadata"] = mapStringToInterface(metadata)
|
||||
params[opParamMetadata] = mapStringToInterface(metadata)
|
||||
}
|
||||
if len(charges) > 0 {
|
||||
params["charges"] = chargesToInterface(charges)
|
||||
params[opParamCharges] = chargesToInterface(charges)
|
||||
}
|
||||
if eventTime != nil {
|
||||
params["event_time"] = eventTime.AsTime().UTC().Format(time.RFC3339Nano)
|
||||
params[opParamEventTime] = eventTime.AsTime().UTC().Format(time.RFC3339Nano)
|
||||
}
|
||||
return params
|
||||
}
|
||||
@@ -580,25 +636,25 @@ func ledgerAccountFromConnector(account *connectorv1.Account) *ledgerv1.LedgerAc
|
||||
details = account.GetProviderDetails().AsMap()
|
||||
}
|
||||
accountType := ledgerv1.AccountType_ACCOUNT_TYPE_UNSPECIFIED
|
||||
if v := strings.TrimSpace(fmt.Sprint(details["account_type"])); v != "" {
|
||||
if v := strings.TrimSpace(fmt.Sprint(details[opParamAccountType])); v != "" {
|
||||
accountType = parseAccountType(v)
|
||||
}
|
||||
status := ledgerv1.AccountStatus_ACCOUNT_STATUS_UNSPECIFIED
|
||||
if v := strings.TrimSpace(fmt.Sprint(details["status"])); v != "" {
|
||||
if v := strings.TrimSpace(fmt.Sprint(details[opParamStatus])); v != "" {
|
||||
status = parseAccountStatus(v)
|
||||
}
|
||||
allowNegative := false
|
||||
if v, ok := details["allow_negative"].(bool); ok {
|
||||
if v, ok := details[opParamAllowNegative].(bool); ok {
|
||||
allowNegative = v
|
||||
}
|
||||
role := ledgerv1.AccountRole_ACCOUNT_ROLE_UNSPECIFIED
|
||||
if v := strings.TrimSpace(fmt.Sprint(details["role"])); v != "" {
|
||||
if v := strings.TrimSpace(fmt.Sprint(details[opParamRole])); v != "" {
|
||||
if parsed, ok := ledgerconv.ParseAccountRole(v); ok {
|
||||
role = parsed
|
||||
}
|
||||
}
|
||||
if role == ledgerv1.AccountRole_ACCOUNT_ROLE_UNSPECIFIED {
|
||||
switch v := details["is_settlement"].(type) {
|
||||
switch v := details[opParamIsSettlement].(type) {
|
||||
case bool:
|
||||
if v {
|
||||
role = ledgerv1.AccountRole_ACCOUNT_ROLE_SETTLEMENT
|
||||
@@ -609,13 +665,13 @@ func ledgerAccountFromConnector(account *connectorv1.Account) *ledgerv1.LedgerAc
|
||||
}
|
||||
}
|
||||
}
|
||||
accountCode := strings.TrimSpace(fmt.Sprint(details["account_code"]))
|
||||
accountCode := strings.TrimSpace(fmt.Sprint(details[opParamAccountCode]))
|
||||
accountID := ""
|
||||
if ref := account.GetRef(); ref != nil {
|
||||
accountID = strings.TrimSpace(ref.GetAccountId())
|
||||
}
|
||||
organizationRef := strings.TrimSpace(account.GetOwnerRef())
|
||||
if v := strings.TrimSpace(fmt.Sprint(details["organization_ref"])); v != "" {
|
||||
if v := strings.TrimSpace(fmt.Sprint(details[opParamOrganizationRef])); v != "" {
|
||||
organizationRef = v
|
||||
}
|
||||
describable := account.GetDescribable()
|
||||
@@ -674,7 +730,7 @@ func operationDescription(op *connectorv1.Operation) string {
|
||||
if op == nil || op.GetParams() == nil {
|
||||
return ""
|
||||
}
|
||||
if value, ok := op.GetParams().AsMap()["description"]; ok {
|
||||
if value, ok := op.GetParams().AsMap()[opParamDescription]; ok {
|
||||
return strings.TrimSpace(fmt.Sprint(value))
|
||||
}
|
||||
return ""
|
||||
@@ -731,10 +787,10 @@ func chargesToInterface(charges []*ledgerv1.PostingLine) []interface{} {
|
||||
continue
|
||||
}
|
||||
result = append(result, map[string]interface{}{
|
||||
"ledger_account_ref": strings.TrimSpace(line.GetLedgerAccountRef()),
|
||||
"amount": strings.TrimSpace(line.GetMoney().GetAmount()),
|
||||
"currency": strings.TrimSpace(line.GetMoney().GetCurrency()),
|
||||
"line_type": line.GetLineType().String(),
|
||||
opParamLedgerAccountRef: strings.TrimSpace(line.GetLedgerAccountRef()),
|
||||
opParamAmount: strings.TrimSpace(line.GetMoney().GetAmount()),
|
||||
opParamCurrency: strings.TrimSpace(line.GetMoney().GetCurrency()),
|
||||
opParamLineType: line.GetLineType().String(),
|
||||
})
|
||||
}
|
||||
if len(result) == 0 {
|
||||
@@ -793,7 +849,7 @@ func (c *ledgerClient) callContext(ctx context.Context) (context.Context, contex
|
||||
}
|
||||
|
||||
func isLedgerRail(value string) bool {
|
||||
return strings.EqualFold(strings.TrimSpace(value), "LEDGER")
|
||||
return strings.EqualFold(strings.TrimSpace(value), ledgerRailName)
|
||||
}
|
||||
|
||||
func cloneMoney(input *moneyv1.Money) *moneyv1.Money {
|
||||
@@ -823,22 +879,22 @@ func ledgerTxMetadata(base map[string]string, tx rail.LedgerTx) map[string]strin
|
||||
meta = map[string]string{}
|
||||
}
|
||||
if val := strings.TrimSpace(tx.PaymentPlanID); val != "" {
|
||||
meta["payment_plan_id"] = val
|
||||
meta[txMetaPaymentPlanID] = val
|
||||
}
|
||||
if val := strings.TrimSpace(tx.FromRail); val != "" {
|
||||
meta["from_rail"] = val
|
||||
meta[txMetaFromRail] = val
|
||||
}
|
||||
if val := strings.TrimSpace(tx.ToRail); val != "" {
|
||||
meta["to_rail"] = val
|
||||
meta[txMetaToRail] = val
|
||||
}
|
||||
if val := strings.TrimSpace(tx.ExternalReferenceID); val != "" {
|
||||
meta["external_reference_id"] = val
|
||||
meta[txMetaExternalReference] = val
|
||||
}
|
||||
if val := strings.TrimSpace(tx.FXRateUsed); val != "" {
|
||||
meta["fx_rate_used"] = val
|
||||
meta[txMetaFXRateUsed] = val
|
||||
}
|
||||
if val := strings.TrimSpace(tx.FeeAmount); val != "" {
|
||||
meta["fee_amount"] = val
|
||||
meta[txMetaFeeAmount] = val
|
||||
}
|
||||
if len(meta) == 0 {
|
||||
return nil
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tech/sendico/pkg/discovery"
|
||||
accountrolev1 "github.com/tech/sendico/pkg/proto/common/account_role/v1"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
connectorv1 "github.com/tech/sendico/pkg/proto/connector/v1"
|
||||
ledgerv1 "github.com/tech/sendico/pkg/proto/ledger/v1"
|
||||
@@ -92,3 +94,65 @@ func TestTransferInternal_SubmitsTransferOperation(t *testing.T) {
|
||||
assert.Equal(t, "op-1", resp.GetJournalEntryRef())
|
||||
assert.Equal(t, ledgerv1.EntryType_ENTRY_TRANSFER, resp.GetEntryType())
|
||||
}
|
||||
|
||||
func TestPostExternalCreditWithCharges_SubmitsExternalOperation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
var captured *connectorv1.Operation
|
||||
stub := &stubConnector{
|
||||
submitFn: func(ctx context.Context, req *connectorv1.SubmitOperationRequest) (*connectorv1.SubmitOperationResponse, error) {
|
||||
captured = req.GetOperation()
|
||||
return &connectorv1.SubmitOperationResponse{Receipt: &connectorv1.OperationReceipt{OperationId: "op-ext-credit"}}, nil
|
||||
},
|
||||
}
|
||||
|
||||
client := NewWithClient(Config{}, stub)
|
||||
resp, err := client.PostExternalCreditWithCharges(ctx, &ledgerv1.PostCreditRequest{
|
||||
IdempotencyKey: "id-ext-credit",
|
||||
OrganizationRef: "org-1",
|
||||
Money: &moneyv1.Money{Currency: "USDT", Amount: "1.0"},
|
||||
Role: ledgerv1.AccountRole_ACCOUNT_ROLE_OPERATING,
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
require.NotNil(t, captured)
|
||||
|
||||
assert.Equal(t, connectorv1.OperationType_CREDIT, captured.GetType())
|
||||
assert.Equal(t, "", captured.GetTo().GetAccount().GetAccountId())
|
||||
assert.Equal(t, accountrolev1.AccountRole_OPERATING, captured.GetToRole())
|
||||
assert.Equal(t, discovery.OperationExternalCredit, captured.GetParams().AsMap()["operation"])
|
||||
assert.Equal(t, "op-ext-credit", resp.GetJournalEntryRef())
|
||||
assert.Equal(t, ledgerv1.EntryType_ENTRY_CREDIT, resp.GetEntryType())
|
||||
}
|
||||
|
||||
func TestPostExternalDebitWithCharges_SubmitsExternalOperation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
var captured *connectorv1.Operation
|
||||
stub := &stubConnector{
|
||||
submitFn: func(ctx context.Context, req *connectorv1.SubmitOperationRequest) (*connectorv1.SubmitOperationResponse, error) {
|
||||
captured = req.GetOperation()
|
||||
return &connectorv1.SubmitOperationResponse{Receipt: &connectorv1.OperationReceipt{OperationId: "op-ext-debit"}}, nil
|
||||
},
|
||||
}
|
||||
|
||||
client := NewWithClient(Config{}, stub)
|
||||
resp, err := client.PostExternalDebitWithCharges(ctx, &ledgerv1.PostDebitRequest{
|
||||
IdempotencyKey: "id-ext-debit",
|
||||
OrganizationRef: "org-1",
|
||||
Money: &moneyv1.Money{Currency: "RUB", Amount: "77.14"},
|
||||
Role: ledgerv1.AccountRole_ACCOUNT_ROLE_HOLD,
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, resp)
|
||||
require.NotNil(t, captured)
|
||||
|
||||
assert.Equal(t, connectorv1.OperationType_DEBIT, captured.GetType())
|
||||
assert.Equal(t, "", captured.GetFrom().GetAccount().GetAccountId())
|
||||
assert.Equal(t, accountrolev1.AccountRole_HOLD, captured.GetFromRole())
|
||||
assert.Equal(t, discovery.OperationExternalDebit, captured.GetParams().AsMap()["operation"])
|
||||
assert.Equal(t, "op-ext-debit", resp.GetJournalEntryRef())
|
||||
assert.Equal(t, ledgerv1.EntryType_ENTRY_DEBIT, resp.GetEntryType())
|
||||
}
|
||||
|
||||
@@ -4,29 +4,31 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/tech/sendico/pkg/payments/rail"
|
||||
connectorv1 "github.com/tech/sendico/pkg/proto/connector/v1"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
connectorv1 "github.com/tech/sendico/pkg/proto/connector/v1"
|
||||
ledgerv1 "github.com/tech/sendico/pkg/proto/ledger/v1"
|
||||
)
|
||||
|
||||
// Fake implements Client for tests.
|
||||
type Fake struct {
|
||||
ReadBalanceFn func(ctx context.Context, accountID string) (*moneyv1.Money, error)
|
||||
CreateTransactionFn func(ctx context.Context, tx rail.LedgerTx) (string, error)
|
||||
HoldBalanceFn func(ctx context.Context, accountID string, amount string) error
|
||||
CreateAccountFn func(ctx context.Context, req *ledgerv1.CreateAccountRequest) (*ledgerv1.CreateAccountResponse, error)
|
||||
ListAccountsFn func(ctx context.Context, req *ledgerv1.ListAccountsRequest) (*ledgerv1.ListAccountsResponse, error)
|
||||
ListConnectorAccountsFn func(ctx context.Context, req *connectorv1.ListAccountsRequest) (*connectorv1.ListAccountsResponse, error)
|
||||
PostCreditWithChargesFn func(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error)
|
||||
PostDebitWithChargesFn func(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error)
|
||||
TransferInternalFn func(ctx context.Context, req *ledgerv1.TransferRequest) (*ledgerv1.PostResponse, error)
|
||||
ApplyFXWithChargesFn func(ctx context.Context, req *ledgerv1.FXRequest) (*ledgerv1.PostResponse, error)
|
||||
BlockAccountFn func(ctx context.Context, req *ledgerv1.BlockAccountRequest) (*ledgerv1.BlockAccountResponse, error)
|
||||
UnblockAccountFn func(ctx context.Context, req *ledgerv1.UnblockAccountRequest) (*ledgerv1.UnblockAccountResponse, error)
|
||||
GetBalanceFn func(ctx context.Context, req *ledgerv1.GetBalanceRequest) (*ledgerv1.BalanceResponse, error)
|
||||
GetJournalEntryFn func(ctx context.Context, req *ledgerv1.GetEntryRequest) (*ledgerv1.JournalEntryResponse, error)
|
||||
GetStatementFn func(ctx context.Context, req *ledgerv1.GetStatementRequest) (*ledgerv1.StatementResponse, error)
|
||||
CloseFn func() error
|
||||
ReadBalanceFn func(ctx context.Context, accountID string) (*moneyv1.Money, error)
|
||||
CreateTransactionFn func(ctx context.Context, tx rail.LedgerTx) (string, error)
|
||||
HoldBalanceFn func(ctx context.Context, accountID string, amount string) error
|
||||
CreateAccountFn func(ctx context.Context, req *ledgerv1.CreateAccountRequest) (*ledgerv1.CreateAccountResponse, error)
|
||||
ListAccountsFn func(ctx context.Context, req *ledgerv1.ListAccountsRequest) (*ledgerv1.ListAccountsResponse, error)
|
||||
ListConnectorAccountsFn func(ctx context.Context, req *connectorv1.ListAccountsRequest) (*connectorv1.ListAccountsResponse, error)
|
||||
PostCreditWithChargesFn func(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error)
|
||||
PostDebitWithChargesFn func(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error)
|
||||
PostExternalCreditWithChargesFn func(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error)
|
||||
PostExternalDebitWithChargesFn func(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error)
|
||||
TransferInternalFn func(ctx context.Context, req *ledgerv1.TransferRequest) (*ledgerv1.PostResponse, error)
|
||||
ApplyFXWithChargesFn func(ctx context.Context, req *ledgerv1.FXRequest) (*ledgerv1.PostResponse, error)
|
||||
BlockAccountFn func(ctx context.Context, req *ledgerv1.BlockAccountRequest) (*ledgerv1.BlockAccountResponse, error)
|
||||
UnblockAccountFn func(ctx context.Context, req *ledgerv1.UnblockAccountRequest) (*ledgerv1.UnblockAccountResponse, error)
|
||||
GetBalanceFn func(ctx context.Context, req *ledgerv1.GetBalanceRequest) (*ledgerv1.BalanceResponse, error)
|
||||
GetJournalEntryFn func(ctx context.Context, req *ledgerv1.GetEntryRequest) (*ledgerv1.JournalEntryResponse, error)
|
||||
GetStatementFn func(ctx context.Context, req *ledgerv1.GetStatementRequest) (*ledgerv1.StatementResponse, error)
|
||||
CloseFn func() error
|
||||
}
|
||||
|
||||
func (f *Fake) ReadBalance(ctx context.Context, accountID string) (*moneyv1.Money, error) {
|
||||
@@ -85,6 +87,20 @@ func (f *Fake) PostDebitWithCharges(ctx context.Context, req *ledgerv1.PostDebit
|
||||
return &ledgerv1.PostResponse{}, nil
|
||||
}
|
||||
|
||||
func (f *Fake) PostExternalCreditWithCharges(ctx context.Context, req *ledgerv1.PostCreditRequest) (*ledgerv1.PostResponse, error) {
|
||||
if f.PostExternalCreditWithChargesFn != nil {
|
||||
return f.PostExternalCreditWithChargesFn(ctx, req)
|
||||
}
|
||||
return &ledgerv1.PostResponse{}, nil
|
||||
}
|
||||
|
||||
func (f *Fake) PostExternalDebitWithCharges(ctx context.Context, req *ledgerv1.PostDebitRequest) (*ledgerv1.PostResponse, error) {
|
||||
if f.PostExternalDebitWithChargesFn != nil {
|
||||
return f.PostExternalDebitWithChargesFn(ctx, req)
|
||||
}
|
||||
return &ledgerv1.PostResponse{}, nil
|
||||
}
|
||||
|
||||
func (f *Fake) TransferInternal(ctx context.Context, req *ledgerv1.TransferRequest) (*ledgerv1.PostResponse, error) {
|
||||
if f.TransferInternalFn != nil {
|
||||
return f.TransferInternalFn(ctx, req)
|
||||
|
||||
Reference in New Issue
Block a user