mirror of
https://github.com/valitydev/fistful-server.git
synced 2024-11-06 02:35:18 +00:00
DC-111: Add subagent account (#56)
This commit is contained in:
parent
8ef6c2449e
commit
487cfaf843
@ -144,7 +144,8 @@ proxy(Ref, Name, Opts) ->
|
||||
object().
|
||||
|
||||
system_account_set(Ref, Name, ?cur(SymCode), C) ->
|
||||
AccountID = account(SymCode, C),
|
||||
AccountID1 = account(SymCode, C),
|
||||
AccountID2 = account(SymCode, C),
|
||||
{system_account_set, #domain_SystemAccountSetObject{
|
||||
ref = Ref,
|
||||
data = #domain_SystemAccountSet{
|
||||
@ -152,7 +153,8 @@ system_account_set(Ref, Name, ?cur(SymCode), C) ->
|
||||
description = <<>>,
|
||||
accounts = #{
|
||||
?cur(SymCode) => #domain_SystemAccount{
|
||||
settlement = AccountID
|
||||
settlement = AccountID1,
|
||||
subagent = AccountID2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,11 @@ setup_dominant(Options, C) ->
|
||||
|
||||
configure_processing_apps(_Options) ->
|
||||
ok = set_app_env(
|
||||
[ff_transfer, withdrawal, system, accounts, <<"RUB">>],
|
||||
[ff_transfer, withdrawal, system, accounts, settlement, <<"RUB">>],
|
||||
create_company_account()
|
||||
),
|
||||
ok = set_app_env(
|
||||
[ff_transfer, withdrawal, system, accounts, subagent, <<"RUB">>],
|
||||
create_company_account()
|
||||
),
|
||||
ok = set_app_env(
|
||||
@ -454,6 +458,11 @@ default_termset(Options) ->
|
||||
{wallet, receiver_destination},
|
||||
{system, settlement},
|
||||
?share(10, 100, operation_amount)
|
||||
),
|
||||
?cfpost(
|
||||
{wallet, receiver_destination},
|
||||
{system, subagent},
|
||||
?share(10, 100, operation_amount)
|
||||
)
|
||||
]}
|
||||
}
|
||||
|
@ -253,10 +253,19 @@ create_p_transfer(Withdrawal) ->
|
||||
ProviderAccount = maps:get(CurrencyID, ProviderAccounts, undefined),
|
||||
ProviderFee = ff_withdrawal_provider:fee(Provider, CurrencyID),
|
||||
SystemAccounts = unwrap(system, get_system_accounts()),
|
||||
SystemAccount = maps:get(CurrencyID, SystemAccounts, undefined),
|
||||
SettlementAccountMap = maps:get(settlement, SystemAccounts, #{}),
|
||||
SettlementAccount = maps:get(CurrencyID, SettlementAccountMap, undefined),
|
||||
SubagentAccountMap = maps:get(subagent, SystemAccounts, #{}),
|
||||
SubagentAccount = maps:get(CurrencyID, SubagentAccountMap, undefined),
|
||||
CashFlowPlan = unwrap(provider_fee, ff_cash_flow:add_fee(WalletCashFlowPlan, ProviderFee)),
|
||||
FinalCashFlow = unwrap(cash_flow, finalize_cash_flow(
|
||||
CashFlowPlan, WalletAccount, DestinationAccount, SystemAccount, ProviderAccount, body(Withdrawal)
|
||||
CashFlowPlan,
|
||||
WalletAccount,
|
||||
DestinationAccount,
|
||||
SettlementAccount,
|
||||
SubagentAccount,
|
||||
ProviderAccount,
|
||||
body(Withdrawal)
|
||||
)),
|
||||
PTransferID = construct_p_transfer_id(id(Withdrawal)),
|
||||
PostingsTransferEvents = unwrap(p_transfer, ff_postings_transfer:create(PTransferID, FinalCashFlow)),
|
||||
@ -331,16 +340,18 @@ get_system_accounts() ->
|
||||
SystemAccounts = maps:get(accounts, SystemConfig, undefined),
|
||||
{ok, SystemAccounts}.
|
||||
|
||||
-spec finalize_cash_flow(cash_flow_plan(), account(), account(), account(), account(), body()) ->
|
||||
-spec finalize_cash_flow(cash_flow_plan(), account(), account(), account(), account(), account(), body()) ->
|
||||
{ok, final_cash_flow()} | {error, _Error}.
|
||||
finalize_cash_flow(CashFlowPlan, WalletAccount, DestinationAccount, SystemAccount, ProviderAccount, Body) ->
|
||||
finalize_cash_flow(CashFlowPlan, WalletAccount, DestinationAccount,
|
||||
SettlementAccount, SubagentAccount, ProviderAccount, Body) ->
|
||||
Constants = #{
|
||||
operation_amount => Body
|
||||
},
|
||||
Accounts = genlib_map:compact(#{
|
||||
{wallet, sender_settlement} => WalletAccount,
|
||||
{wallet, receiver_destination} => DestinationAccount,
|
||||
{system, settlement} => SystemAccount,
|
||||
{system, settlement} => SettlementAccount,
|
||||
{system, subagent} => SubagentAccount,
|
||||
{provider, settlement} => ProviderAccount
|
||||
}),
|
||||
ff_cash_flow:finalize(CashFlowPlan, Accounts, Constants).
|
||||
|
@ -456,5 +456,5 @@ process_withdrawal(WalID, DestID) ->
|
||||
genlib_retry:linear(15, 1000)
|
||||
),
|
||||
ok = await_wallet_balance({10000 - 4240, <<"RUB">>}, WalID),
|
||||
ok = await_destination_balance({4240 - 424, <<"RUB">>}, DestID),
|
||||
ok = await_destination_balance({4240 - 848, <<"RUB">>}, DestID),
|
||||
WdrID.
|
||||
|
@ -59,6 +59,7 @@
|
||||
{wallet, receiver_settlement} |
|
||||
{wallet, receiver_destination} |
|
||||
{system, settlement} |
|
||||
{system, subagent} |
|
||||
{provider, settlement}.
|
||||
-type final_account() :: #{
|
||||
account := account(),
|
||||
|
@ -91,11 +91,21 @@
|
||||
},
|
||||
system => #{
|
||||
accounts => #{
|
||||
<<"RUB">> => #{
|
||||
id => <<"system_some_id">>,
|
||||
identity => <<"system_some_other_id">>,
|
||||
currency => <<"RUB">>,
|
||||
accounter_account_id => <<"system_some_third_id">>
|
||||
settlement => #{
|
||||
<<"RUB">> => #{
|
||||
id => <<"system_some_id">>,
|
||||
identity => <<"system_some_other_id">>,
|
||||
currency => <<"RUB">>,
|
||||
accounter_account_id => <<"system_some_third_id">>
|
||||
}
|
||||
},
|
||||
subagent => #{
|
||||
<<"RUB">> => #{
|
||||
id => <<"system_some_id">>,
|
||||
identity => <<"system_some_other_id">>,
|
||||
currency => <<"RUB">>,
|
||||
accounter_account_id => <<"system_some_third_id">>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ services:
|
||||
retries: 10
|
||||
|
||||
hellgate:
|
||||
image: dr.rbkmoney.com/rbkmoney/hellgate:998985ade2bb8d8b7882e8d09a036414e91e25b4
|
||||
image: dr.rbkmoney.com/rbkmoney/hellgate:8d7f618f6f2e1d8410384797b8f9a76150580f46
|
||||
command: /opt/hellgate/bin/hellgate foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
@ -86,7 +86,7 @@ services:
|
||||
retries: 20
|
||||
|
||||
dominant:
|
||||
image: dr.rbkmoney.com/rbkmoney/dominant:7eda4ecade678a7a2dd25795c214ab8be93e8cd4
|
||||
image: dr.rbkmoney.com/rbkmoney/dominant:3cf6c46d482f0057d117209170c831f5a238d95a
|
||||
command: /opt/dominant/bin/dominant foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
@ -117,7 +117,7 @@ services:
|
||||
test: "curl http://localhost:8022/"
|
||||
interval: 5s
|
||||
timeout: 1s
|
||||
retries: 10
|
||||
retries: 30
|
||||
|
||||
identification:
|
||||
image: dr.rbkmoney.com/rbkmoney/identification:ff4ef447327d81882c0ee618b622e5e04e771881
|
||||
|
@ -18,7 +18,7 @@
|
||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"1.0.2">>},1},
|
||||
{<<"dmsl">>,
|
||||
{git,"git@github.com:rbkmoney/damsel.git",
|
||||
{ref,"8cfdc074bf39ae966c286796d25f94c1e95d5b47"}},
|
||||
{ref,"37f417a48c19675478058733fa753dbe70babf58"}},
|
||||
0},
|
||||
{<<"dmt_client">>,
|
||||
{git,"git@github.com:rbkmoney/dmt_client.git",
|
||||
@ -42,7 +42,7 @@
|
||||
0},
|
||||
{<<"fistful_proto">>,
|
||||
{git,"git@github.com:rbkmoney/fistful-proto.git",
|
||||
{ref,"56a39762845bf8eb299ae0ba4d0bf21ae0fa4620"}},
|
||||
{ref,"6977cd82d85282277a2d371edca647ce9cdfcf70"}},
|
||||
0},
|
||||
{<<"fistful_reporter_proto">>,
|
||||
{git,"git@github.com:rbkmoney/fistful-reporter-proto.git",
|
||||
|
Loading…
Reference in New Issue
Block a user