From 22b6eb2ab3aa397ebfbd6998eb786a0309a115a1 Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Fri, 17 Jul 2020 15:58:54 +0300 Subject: [PATCH 1/8] update get_account function --- apps/hellgate/src/hg_accounting.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/hellgate/src/hg_accounting.erl b/apps/hellgate/src/hg_accounting.erl index cafb275dc..fcbc3b166 100644 --- a/apps/hellgate/src/hg_accounting.erl +++ b/apps/hellgate/src/hg_accounting.erl @@ -8,6 +8,7 @@ -module(hg_accounting). -export([get_account/1]). +-export([get_account/2]). -export([get_balance/1]). -export([get_balance/2]). -export([create_account/1]). @@ -61,7 +62,13 @@ account(). get_account(AccountID) -> - case call_accounter('GetAccountByID', [AccountID]) of + get_account(AccountID, {latest, #shumpune_LatestClock{}}). + +-spec get_account(account_id(), clock()) -> + account(). + +get_account(AccountID, Clock) -> + case call_accounter('GetAccountByID', [AccountID, Clock]) of {ok, Result} -> construct_account(AccountID, Result); {exception, #shumpune_AccountNotFound{}} -> From 454201e5798ba170b55642cb5ef3e0b3d0395bf5 Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Mon, 20 Jul 2020 06:12:43 +0300 Subject: [PATCH 2/8] deprecate create_account, add clock argument --- apps/hellgate/src/hg_accounting.erl | 138 ++++++++++++++++------------ 1 file changed, 80 insertions(+), 58 deletions(-) diff --git a/apps/hellgate/src/hg_accounting.erl b/apps/hellgate/src/hg_accounting.erl index fcbc3b166..62ffebe59 100644 --- a/apps/hellgate/src/hg_accounting.erl +++ b/apps/hellgate/src/hg_accounting.erl @@ -11,8 +11,9 @@ -export([get_account/2]). -export([get_balance/1]). -export([get_balance/2]). --export([create_account/1]). --export([create_account/2]). +% creating is lazy with shumaich +% -export([create_account/1]). +% -export([create_account/2]). -export([collect_account_map/6]). -export([collect_merchant_account_map/2]). -export([collect_provider_account_map/3]). @@ -20,13 +21,20 @@ -export([collect_external_account_map/4]). -export([hold/2]). +-export([hold/3]). + -export([plan/2]). +-export([plan/3]). + -export([commit/2]). +-export([commit/3]). + -export([rollback/2]). +-export([rollback/3]). -include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("shumpune_proto/include/shumpune_shumpune_thrift.hrl"). +-include_lib("shumpune_proto/include/shumaich_shumaich_thrift.hrl"). -type amount() :: dmsl_domain_thrift:'Amount'(). -type currency_code() :: dmsl_domain_thrift:'CurrencySymbolicCode'(). @@ -35,7 +43,7 @@ -type batch_id() :: dmsl_accounter_thrift:'BatchID'(). -type final_cash_flow() :: dmsl_domain_thrift:'FinalCashFlow'(). -type batch() :: {batch_id(), final_cash_flow()}. --type clock() :: shumpune_shumpune_thrift:'Clock'(). +-type clock() :: shumaich_shumaich_thrift:'Clock'(). -type payment() :: dmsl_domain_thrift:'InvoicePayment'(). -type shop() :: dmsl_domain_thrift:'Shop'(). @@ -60,57 +68,54 @@ -spec get_account(account_id()) -> account(). - get_account(AccountID) -> - get_account(AccountID, {latest, #shumpune_LatestClock{}}). + get_account(AccountID, {latest, #shumaich_LatestClock{}}). -spec get_account(account_id(), clock()) -> account(). - get_account(AccountID, Clock) -> case call_accounter('GetAccountByID', [AccountID, Clock]) of {ok, Result} -> construct_account(AccountID, Result); - {exception, #shumpune_AccountNotFound{}} -> + {exception, #shumaich_AccountNotFound{}} -> hg_woody_wrapper:raise(#payproc_AccountNotFound{}) end. -spec get_balance(account_id()) -> balance(). - get_balance(AccountID) -> - get_balance(AccountID, {latest, #shumpune_LatestClock{}}). + get_balance(AccountID, {latest, #shumaich_LatestClock{}}). -spec get_balance(account_id(), clock()) -> balance(). - get_balance(AccountID, Clock) -> case call_accounter('GetBalanceByID', [AccountID, Clock]) of {ok, Result} -> construct_balance(AccountID, Result); - {exception, #shumpune_AccountNotFound{}} -> + {exception, #shumaich_AccountNotFound{}} -> hg_woody_wrapper:raise(#payproc_AccountNotFound{}) end. --spec create_account(currency_code()) -> - account_id(). +% DEPRECATED -create_account(CurrencyCode) -> - create_account(CurrencyCode, undefined). +% -spec create_account(currency_code()) -> +% account_id(). +% create_account(CurrencyCode) -> +% create_account(CurrencyCode, undefined). --spec create_account(currency_code(), binary() | undefined) -> - account_id(). +% -spec create_account(currency_code(), binary() | undefined) -> +% account_id(). +% create_account(CurrencyCode, Description) -> +% case call_accounter('CreateAccount', [construct_prototype(CurrencyCode, Description)]) of +% {ok, Result} -> +% Result; +% {exception, Exception} -> +% error({accounting, Exception}) % FIXME +% end. -create_account(CurrencyCode, Description) -> - case call_accounter('CreateAccount', [construct_prototype(CurrencyCode, Description)]) of - {ok, Result} -> - Result; - {exception, Exception} -> - error({accounting, Exception}) % FIXME - end. +% DEPRECATED -spec collect_account_map(payment(), shop(), payment_institution(), provider(), varset(), revision()) -> map(). - collect_account_map(Payment, Shop, PaymentInstitution, Provider, VS, Revision) -> Map0 = collect_merchant_account_map(Shop, #{}), Map1 = collect_provider_account_map(Payment, Provider, Map0), @@ -118,7 +123,6 @@ collect_account_map(Payment, Shop, PaymentInstitution, Provider, VS, Revision) - collect_external_account_map(Payment, VS, Revision, Map2). -spec collect_merchant_account_map(shop(), map()) -> map(). - collect_merchant_account_map(#domain_Shop{account = MerchantAccount}, Acc) -> Acc#{ {merchant, settlement} => MerchantAccount#domain_ShopAccount.settlement, @@ -126,7 +130,6 @@ collect_merchant_account_map(#domain_Shop{account = MerchantAccount}, Acc) -> }. -spec collect_provider_account_map(payment(), provider(), map()) -> map(). - collect_provider_account_map(Payment, #domain_Provider{accounts = ProviderAccounts}, Acc) -> Currency = get_currency(get_payment_cost(Payment)), ProviderAccount = hg_payment_institution:choose_provider_account(Currency, ProviderAccounts), @@ -135,7 +138,6 @@ collect_provider_account_map(Payment, #domain_Provider{accounts = ProviderAccoun }. -spec collect_system_account_map(payment(), payment_institution(), varset(), revision(), map()) -> map(). - collect_system_account_map(Payment, PaymentInstitution, VS, Revision, Acc) -> Currency = get_currency(get_payment_cost(Payment)), SystemAccount = hg_payment_institution:get_system_account(Currency, VS, Revision, PaymentInstitution), @@ -145,7 +147,6 @@ collect_system_account_map(Payment, PaymentInstitution, VS, Revision, Acc) -> }. -spec collect_external_account_map(payment(), varset(), revision(), map()) -> map(). - collect_external_account_map(Payment, VS, Revision, Acc) -> Currency = get_currency(get_payment_cost(Payment)), case hg_payment_institution:choose_external_account(Currency, VS, Revision) of @@ -158,47 +159,63 @@ collect_external_account_map(Payment, VS, Revision, Acc) -> Acc end. -construct_prototype(CurrencyCode, Description) -> - #shumpune_AccountPrototype{ - currency_sym_code = CurrencyCode, - description = Description - }. +% construct_prototype(CurrencyCode, Description) -> +% #shumaich_AccountPrototype{ +% currency_sym_code = CurrencyCode, +% description = Description +% }. %% -spec plan(plan_id(), [batch()]) -> clock(). +plan(PlanID, Batches) -> + plan(PlanID, Batches, {latest, #shumaich_LatestClock{}}). -plan(_PlanID, []) -> +-spec plan(plan_id(), [batch()], clock()) -> + clock(). +plan(_PlanID, [], _Clock) -> error(badarg); -plan(_PlanID, Batches) when not is_list(Batches) -> +plan(_PlanID, Batches, _Clock) when not is_list(Batches) -> error(badarg); -plan(PlanID, Batches) -> +plan(PlanID, Batches, Clock) -> lists:foldl( - fun (Batch, _) -> hold(PlanID, Batch) end, + fun (Batch, _) -> hold(PlanID, Batch, Clock) end, undefined, Batches ). -spec hold(plan_id(), batch()) -> clock(). - hold(PlanID, Batch) -> - do('Hold', construct_plan_change(PlanID, Batch)). + hold(PlanID, Batch, {latest, #shumaich_LatestClock{}}). --spec commit(plan_id(), [batch()]) -> +-spec hold(plan_id(), batch(), clock()) -> clock(). +hold(PlanID, Batch, Clock) -> + do('Hold', construct_plan_change(PlanID, Batch), Clock). +-spec commit(plan_id(), [batch()]) -> + clock(). commit(PlanID, Batches) -> - do('CommitPlan', construct_plan(PlanID, Batches)). + commit(PlanID, Batches, {latest, #shumaich_LatestClock{}}). --spec rollback(plan_id(), [batch()]) -> +-spec commit(plan_id(), [batch()], clock()) -> clock(). +commit(PlanID, Batches, Clock) -> + do('CommitPlan', construct_plan(PlanID, Batches), Clock). +-spec rollback(plan_id(), [batch()]) -> + clock(). rollback(PlanID, Batches) -> - do('RollbackPlan', construct_plan(PlanID, Batches)). + rollback(PlanID, Batches, {latest, #shumaich_LatestClock{}}). + +-spec rollback(plan_id(), [batch()], clock()) -> + clock(). +rollback(PlanID, Batches, Clock) -> + do('RollbackPlan', construct_plan(PlanID, Batches), Clock). -do(Op, Plan) -> - case call_accounter(Op, [Plan]) of +do(Op, Plan, Clock) -> + case call_accounter(Op, [Plan, Clock]) of {ok, Clock} -> Clock; {exception, Exception} -> @@ -206,19 +223,19 @@ do(Op, Plan) -> end. construct_plan_change(PlanID, {BatchID, Cashflow}) -> - #shumpune_PostingPlanChange{ + #shumaich_PostingPlanChange{ id = PlanID, - batch = #shumpune_PostingBatch{ + batch = #shumaich_PostingBatch{ id = BatchID, postings = collect_postings(Cashflow) } }. construct_plan(PlanID, Batches) -> - #shumpune_PostingPlan{ + #shumaich_PostingPlan{ id = PlanID, batch_list = [ - #shumpune_PostingBatch{ + #shumaich_PostingBatch{ id = BatchID, postings = collect_postings(Cashflow) } @@ -227,11 +244,16 @@ construct_plan(PlanID, Batches) -> collect_postings(Cashflow) -> [ - #shumpune_Posting{ - from_id = Source, - to_id = Destination, + #shumaich_Posting{ + % NEW + % TODO: change to Account + from_account = Source, + to_account = Destination, + % OLD + % from_id = Source, + % to_id = Destination, amount = Amount, - currency_sym_code = CurrencyCode, + currency_symbolic_code = CurrencyCode, description = construct_posting_description(Details) } || #domain_FinalCashFlowPosting{ @@ -254,8 +276,8 @@ construct_posting_description(undefined) -> construct_account( AccountID, - #shumpune_Account{ - currency_sym_code = CurrencyCode + #shumaich_Account{ + currency_symbolic_code = CurrencyCode } ) -> #{ @@ -265,7 +287,7 @@ construct_account( construct_balance( AccountID, - #shumpune_Balance{ + #shumaich_Balance{ own_amount = OwnAmount, min_available_amount = MinAvailableAmount, max_available_amount = MaxAvailableAmount From af00c5d769f059b49f2af463c54a9cfbbad463eb Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Mon, 20 Jul 2020 06:13:09 +0300 Subject: [PATCH 3/8] update .app.src with shumaich --- apps/hellgate/src/hellgate.app.src | 2 +- apps/party_management/src/party_management.app.src | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/hellgate/src/hellgate.app.src b/apps/hellgate/src/hellgate.app.src index b3fd7895a..3edd5e9ba 100644 --- a/apps/hellgate/src/hellgate.app.src +++ b/apps/hellgate/src/hellgate.app.src @@ -11,7 +11,7 @@ genlib, fault_detector_proto, hg_proto, - shumpune_proto, + shumaich_proto, cowboy, how_are_you, % must be after ranch and before any woody usage woody, diff --git a/apps/party_management/src/party_management.app.src b/apps/party_management/src/party_management.app.src index 348fb42fe..f9abbb4ba 100644 --- a/apps/party_management/src/party_management.app.src +++ b/apps/party_management/src/party_management.app.src @@ -10,7 +10,7 @@ stdlib, genlib, pm_proto, - shumpune_proto, + shumaich_proto, cowboy, how_are_you, % must be after ranch and before any woody usage woody, From 27c1d8db418849a56b4f7cbb760a7b8aef7043c7 Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Mon, 20 Jul 2020 06:14:41 +0300 Subject: [PATCH 4/8] add clocks to pm accounting --- apps/party_management/src/pm_accounting.erl | 68 +++++++++++---------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/apps/party_management/src/pm_accounting.erl b/apps/party_management/src/pm_accounting.erl index 887f6a97b..dab7355a5 100644 --- a/apps/party_management/src/pm_accounting.erl +++ b/apps/party_management/src/pm_accounting.erl @@ -8,11 +8,13 @@ -module(pm_accounting). -export([get_account/1]). +-export([get_account/2]). -export([get_balance/1]). --export([create_account/1]). +-export([get_balance/2]). +% -export([create_account/1]). -include_lib("damsel/include/dmsl_payment_processing_thrift.hrl"). --include_lib("shumpune_proto/include/shumpune_shumpune_thrift.hrl"). +-include_lib("shumpune_proto/include/shumaich_shumaich_thrift.hrl"). -type amount() :: dmsl_domain_thrift:'Amount'(). -type currency_code() :: dmsl_domain_thrift:'CurrencySymbolicCode'(). @@ -20,7 +22,7 @@ -type batch_id() :: dmsl_accounter_thrift:'BatchID'(). -type final_cash_flow() :: dmsl_domain_thrift:'FinalCashFlow'(). -type batch() :: {batch_id(), final_cash_flow()}. --type clock() :: shumpune_shumpune_thrift:'Clock'(). +-type clock() :: shumaich_shumaich_thrift:'Clock'(). -export_type([batch/0]). @@ -38,61 +40,65 @@ -spec get_account(account_id()) -> account(). - get_account(AccountID) -> - case call_accounter('GetAccountByID', [AccountID]) of + get_account(AccountID, {latest, #shumaich_LatestClock{}}). + +-spec get_account(account_id(), clock()) -> + account(). +get_account(AccountID, Clock) -> + case call_accounter('GetAccountByID', [AccountID, Clock]) of {ok, Result} -> construct_account(AccountID, Result); - {exception, #shumpune_AccountNotFound{}} -> + {exception, #shumaich_AccountNotFound{}} -> pm_woody_wrapper:raise(#payproc_AccountNotFound{}) end. -spec get_balance(account_id()) -> balance(). - get_balance(AccountID) -> - get_balance(AccountID, {latest, #shumpune_LatestClock{}}). + get_balance(AccountID, {latest, #shumaich_LatestClock{}}). -spec get_balance(account_id(), clock()) -> balance(). - get_balance(AccountID, Clock) -> case call_accounter('GetBalanceByID', [AccountID, Clock]) of {ok, Result} -> construct_balance(AccountID, Result); - {exception, #shumpune_AccountNotFound{}} -> + {exception, #shumaich_AccountNotFound{}} -> pm_woody_wrapper:raise(#payproc_AccountNotFound{}) end. --spec create_account(currency_code()) -> - account_id(). +% DEPRECATED -create_account(CurrencyCode) -> - create_account(CurrencyCode, undefined). +% -spec create_account(currency_code()) -> +% account_id(). +% create_account(CurrencyCode) -> +% create_account(CurrencyCode, undefined). --spec create_account(currency_code(), binary() | undefined) -> - account_id(). +% -spec create_account(currency_code(), binary() | undefined) -> +% account_id(). +% create_account(CurrencyCode, Description) -> +% case call_accounter('CreateAccount', [construct_prototype(CurrencyCode, Description)]) of +% {ok, Result} -> +% Result; +% {exception, Exception} -> +% error({accounting, Exception}) % FIXME +% end. -create_account(CurrencyCode, Description) -> - case call_accounter('CreateAccount', [construct_prototype(CurrencyCode, Description)]) of - {ok, Result} -> - Result; - {exception, Exception} -> - error({accounting, Exception}) % FIXME - end. +% DEPRECATED -construct_prototype(CurrencyCode, Description) -> - #shumpune_AccountPrototype{ - currency_sym_code = CurrencyCode, - description = Description - }. +% construct_prototype(CurrencyCode, Description) -> +% #shumaich_AccountPrototype{ +% currency_sym_code = CurrencyCode, +% description = Description +% }. %% construct_account( AccountID, - #shumpune_Account{ - currency_sym_code = CurrencyCode + #shumaich_Account{ + currency_symbolic_code = CurrencyCode } ) -> #{ @@ -102,7 +108,7 @@ construct_account( construct_balance( AccountID, - #shumpune_Balance{ + #shumaich_Balance{ own_amount = OwnAmount, min_available_amount = MinAvailableAmount, max_available_amount = MaxAvailableAmount From 0ff44ae7ef5790855535a3779a0522b27b12159a Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Mon, 20 Jul 2020 06:15:12 +0300 Subject: [PATCH 5/8] update shumpune proto --- rebar.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.lock b/rebar.lock index 3ce51b47c..2f2b194dc 100644 --- a/rebar.lock +++ b/rebar.lock @@ -70,7 +70,7 @@ 0}, {<<"shumpune_proto">>, {git,"git@github.com:rbkmoney/shumpune-proto.git", - {ref,"a0aed3bdce6aafdb832bbcde45e6278222b08c0b"}}, + {ref,"9f82af15d3c9dba4adff2f2f0e659b9821cbf773"}}, 0}, {<<"snowflake">>, {git,"https://github.com/rbkmoney/snowflake.git", From 2b31098929813e932d8c27294a0323287b34899b Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Tue, 21 Jul 2020 10:47:09 +0300 Subject: [PATCH 6/8] update service protocol --- apps/hg_proto/src/hg_proto.erl | 2 +- apps/pm_proto/src/pm_proto.erl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/hg_proto/src/hg_proto.erl b/apps/hg_proto/src/hg_proto.erl index 0067566f8..e53389022 100644 --- a/apps/hg_proto/src/hg_proto.erl +++ b/apps/hg_proto/src/hg_proto.erl @@ -40,7 +40,7 @@ get_service(proxy_inspector) -> get_service(proxy_host_provider) -> {dmsl_proxy_provider_thrift, 'ProviderProxyHost'}; get_service(accounter) -> - {shumpune_shumpune_thrift, 'Accounter'}; + {shumaich_shumaich_thrift, 'Accounter'}; get_service(automaton) -> {mg_proto_state_processing_thrift, 'Automaton'}; get_service(processor) -> diff --git a/apps/pm_proto/src/pm_proto.erl b/apps/pm_proto/src/pm_proto.erl index ff3090671..15134f602 100644 --- a/apps/pm_proto/src/pm_proto.erl +++ b/apps/pm_proto/src/pm_proto.erl @@ -22,7 +22,7 @@ get_service(claim_committer) -> get_service(party_management) -> {dmsl_payment_processing_thrift, 'PartyManagement'}; get_service(accounter) -> - {shumpune_shumpune_thrift, 'Accounter'}; + {shumaich_shumaich_thrift, 'Accounter'}; get_service(automaton) -> {mg_proto_state_processing_thrift, 'Automaton'}; get_service(processor) -> From ccae67f909f45b22683d50048d3d0b16e80a9c40 Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Tue, 21 Jul 2020 10:48:51 +0300 Subject: [PATCH 7/8] temporary adhocs around missing create account --- apps/hellgate/test/hg_ct_fixture.erl | 25 +++++++++++-------- apps/party_management/src/pm_claim_effect.erl | 9 ++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apps/hellgate/test/hg_ct_fixture.erl b/apps/hellgate/test/hg_ct_fixture.erl index b1c23b3f8..409c90faf 100644 --- a/apps/hellgate/test/hg_ct_fixture.erl +++ b/apps/hellgate/test/hg_ct_fixture.erl @@ -198,8 +198,9 @@ construct_contract_template(Ref, TermsRef, ValidSince, ValidUntil) -> construct_provider_account_set(Currencies) -> ok = hg_context:save(hg_context:create()), AccountSet = lists:foldl( - fun (Cur = ?cur(Code), Acc) -> - Acc#{Cur => ?prvacc(hg_accounting:create_account(Code))} + fun (Cur = ?cur(_Code), Acc) -> + % WARNING ADHOC FOR TESTING ONLY + Acc#{Cur => ?prvacc(rand:uniform(1000))} %?prvacc(hg_accounting:create_account(Code))} end, #{}, Currencies @@ -218,8 +219,8 @@ construct_system_account_set(Ref) -> construct_system_account_set(Ref, Name, ?cur(CurrencyCode)) -> ok = hg_context:save(hg_context:create()), - SettlementAccountID = hg_accounting:create_account(CurrencyCode), - SubagentAccountID = hg_accounting:create_account(CurrencyCode), + % SettlementAccountID = hg_accounting:create_account(CurrencyCode), + % SubagentAccountID = hg_accounting:create_account(CurrencyCode), hg_context:cleanup(), {system_account_set, #domain_SystemAccountSetObject{ ref = Ref, @@ -227,8 +228,9 @@ construct_system_account_set(Ref, Name, ?cur(CurrencyCode)) -> name = Name, description = Name, accounts = #{?cur(CurrencyCode) => #domain_SystemAccount{ - settlement = SettlementAccountID, - subagent = SubagentAccountID + % WARNING ADHOC FOR TESTING ONLY + settlement = rand:uniform(1000), + subagent = rand:uniform(1000) }} } }}. @@ -242,10 +244,10 @@ construct_external_account_set(Ref) -> -spec construct_external_account_set(external_account_set(), name(), currency()) -> {system_account_set, dmsl_domain_thrift:'ExternalAccountSetObject'()}. -construct_external_account_set(Ref, Name, ?cur(CurrencyCode)) -> +construct_external_account_set(Ref, Name, ?cur(_CurrencyCode)) -> ok = hg_context:save(hg_context:create()), - AccountID1 = hg_accounting:create_account(CurrencyCode), - AccountID2 = hg_accounting:create_account(CurrencyCode), + % AccountID1 = hg_accounting:create_account(CurrencyCode), + % AccountID2 = hg_accounting:create_account(CurrencyCode), hg_context:cleanup(), {external_account_set, #domain_ExternalAccountSetObject{ ref = Ref, @@ -253,8 +255,9 @@ construct_external_account_set(Ref, Name, ?cur(CurrencyCode)) -> name = Name, description = Name, accounts = #{?cur(<<"RUB">>) => #domain_ExternalAccount{ - income = AccountID1, - outcome = AccountID2 + % WARNING ADHOC FOR TESTING ONLY + income = rand:uniform(1000), + outcome = rand:uniform(1000) }} } }}. diff --git a/apps/party_management/src/pm_claim_effect.erl b/apps/party_management/src/pm_claim_effect.erl index 433b9bf79..0e26c7bb7 100644 --- a/apps/party_management/src/pm_claim_effect.erl +++ b/apps/party_management/src/pm_claim_effect.erl @@ -161,10 +161,11 @@ raise_invalid_object_ref_({contract, ID}, Ex) -> create_shop_account(#payproc_ShopAccountParams{currency = Currency}) -> create_shop_account(Currency); -create_shop_account(#domain_CurrencyRef{symbolic_code = SymbolicCode} = CurrencyRef) -> - GuaranteeID = pm_accounting:create_account(SymbolicCode), - SettlementID = pm_accounting:create_account(SymbolicCode), - PayoutID = pm_accounting:create_account(SymbolicCode), +create_shop_account(#domain_CurrencyRef{symbolic_code = _SymbolicCode} = CurrencyRef) -> + % WARNING ADHOC FOR TESTING ONLY + GuaranteeID = rand:uniform(1000), %pm_accounting:create_account(SymbolicCode), + SettlementID = rand:uniform(1000), %pm_accounting:create_account(SymbolicCode), + PayoutID = rand:uniform(1000), %pm_accounting:create_account(SymbolicCode), #domain_ShopAccount{ currency = CurrencyRef, settlement = SettlementID, From e5a18fd7d9dfacee1a99cdfc0a4c2d948bf2ebec Mon Sep 17 00:00:00 2001 From: Roman Pushkov Date: Tue, 21 Jul 2020 10:52:06 +0300 Subject: [PATCH 8/8] collect postings update --- apps/hellgate/src/hg_accounting.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/hellgate/src/hg_accounting.erl b/apps/hellgate/src/hg_accounting.erl index 62ffebe59..b20b477f2 100644 --- a/apps/hellgate/src/hg_accounting.erl +++ b/apps/hellgate/src/hg_accounting.erl @@ -246,9 +246,8 @@ collect_postings(Cashflow) -> [ #shumaich_Posting{ % NEW - % TODO: change to Account - from_account = Source, - to_account = Destination, + from_account = construct_posting_account(Source, CurrencyCode), + to_account = construct_posting_account(Destination, CurrencyCode), % OLD % from_id = Source, % to_id = Destination, @@ -267,6 +266,9 @@ collect_postings(Cashflow) -> } <- Cashflow ]. +construct_posting_account(ID, Currency) -> + #shumaich_Account{id = integer_to_binary(ID), currency_symbolic_code = Currency}. + construct_posting_description(Details) when is_binary(Details) -> Details; construct_posting_description(undefined) ->