From 2c49e05d56697a15f98c59336143ea10407917b1 Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Wed, 31 Mar 2021 12:05:17 +0300 Subject: [PATCH] ED-100: Use domain revision to while compute system account (#384) --- apps/ff_transfer/src/ff_withdrawal.erl | 6 +++++- apps/fistful/src/ff_payment_institution.erl | 9 +++++---- apps/p2p/src/p2p_transfer.erl | 6 +++++- apps/w2w/src/w2w_transfer.erl | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/ff_transfer/src/ff_withdrawal.erl b/apps/ff_transfer/src/ff_withdrawal.erl index c57cb89..912a6bd 100644 --- a/apps/ff_transfer/src/ff_withdrawal.erl +++ b/apps/ff_transfer/src/ff_withdrawal.erl @@ -980,7 +980,11 @@ make_final_cash_flow(Withdrawal) -> {ok, PaymentInstitutionID} = ff_party:get_identity_payment_institution_id(Identity), {ok, PaymentInstitution} = ff_payment_institution:get(PaymentInstitutionID, DomainRevision), - {ok, SystemAccounts} = ff_payment_institution:compute_system_accounts(PaymentInstitution, PartyVarset), + {ok, SystemAccounts} = ff_payment_institution:compute_system_accounts( + PaymentInstitution, + PartyVarset, + DomainRevision + ), SystemAccount = maps:get(CurrencyID, SystemAccounts, #{}), SettlementAccount = maps:get(settlement, SystemAccount, undefined), SubagentAccount = maps:get(subagent, SystemAccount, undefined), diff --git a/apps/fistful/src/ff_payment_institution.erl b/apps/fistful/src/ff_payment_institution.erl index bc7dad9..74f1901 100644 --- a/apps/fistful/src/ff_payment_institution.erl +++ b/apps/fistful/src/ff_payment_institution.erl @@ -35,7 +35,7 @@ -export([compute_withdrawal_providers/2]). -export([compute_p2p_transfer_providers/2]). -export([compute_p2p_inspector/2]). --export([compute_system_accounts/2]). +-export([compute_system_accounts/3]). %% Pipeline @@ -93,15 +93,16 @@ compute_p2p_inspector(#{p2p_inspector := InspectorSelector}, VS) -> Error end. --spec compute_system_accounts(payment_institution(), hg_selector:varset()) -> {ok, system_accounts()} | {error, term()}. -compute_system_accounts(PaymentInstitution, VS) -> +-spec compute_system_accounts(payment_institution(), hg_selector:varset(), ff_domain_config:revision()) -> + {ok, system_accounts()} | {error, term()}. +compute_system_accounts(PaymentInstitution, VS, DomainRevision) -> #{ identity := Identity, system_accounts := SystemAccountsSelector } = PaymentInstitution, do(fun() -> SystemAccountSetRef = unwrap(hg_selector:reduce_to_value(SystemAccountsSelector, VS)), - SystemAccountSet = unwrap(ff_domain_config:object({system_account_set, SystemAccountSetRef})), + SystemAccountSet = unwrap(ff_domain_config:object(DomainRevision, {system_account_set, SystemAccountSetRef})), decode_system_account_set(Identity, SystemAccountSet) end). diff --git a/apps/p2p/src/p2p_transfer.erl b/apps/p2p/src/p2p_transfer.erl index dd6ec0b..c2ec09f 100644 --- a/apps/p2p/src/p2p_transfer.erl +++ b/apps/p2p/src/p2p_transfer.erl @@ -942,7 +942,11 @@ make_final_cash_flow(P2PTransferState) -> {ok, PaymentInstitutionID} = ff_party:get_identity_payment_institution_id(Identity), {ok, PaymentInstitution} = ff_payment_institution:get(PaymentInstitutionID, DomainRevision), - {ok, SystemAccounts} = ff_payment_institution:compute_system_accounts(PaymentInstitution, PartyVarset), + {ok, SystemAccounts} = ff_payment_institution:compute_system_accounts( + PaymentInstitution, + PartyVarset, + DomainRevision + ), SystemAccount = maps:get(CurrencyID, SystemAccounts, #{}), SettlementAccount = maps:get(settlement, SystemAccount, undefined), SubagentAccount = maps:get(subagent, SystemAccount, undefined), diff --git a/apps/w2w/src/w2w_transfer.erl b/apps/w2w/src/w2w_transfer.erl index f38b9a3..d4b6cd7 100644 --- a/apps/w2w/src/w2w_transfer.erl +++ b/apps/w2w/src/w2w_transfer.erl @@ -476,7 +476,7 @@ make_final_cash_flow(W2WTransferState) -> }), {ok, PaymentInstitutionID} = ff_party:get_identity_payment_institution_id(Identity), {ok, PaymentInstitution} = ff_payment_institution:get(PaymentInstitutionID, DomainRevision), - {ok, SystemAccounts} = ff_payment_institution:compute_system_accounts(PaymentInstitution, Varset), + {ok, SystemAccounts} = ff_payment_institution:compute_system_accounts(PaymentInstitution, Varset, DomainRevision), SystemAccount = maps:get(CurrencyID, SystemAccounts, #{}), SettlementAccount = maps:get(settlement, SystemAccount, undefined), SubagentAccount = maps:get(subagent, SystemAccount, undefined),