diff --git a/apps/party_management/test/pm_ct_domain.hrl b/apps/party_management/test/pm_ct_domain.hrl index 16c8819..972536a 100644 --- a/apps/party_management/test/pm_ct_domain.hrl +++ b/apps/party_management/test/pm_ct_domain.hrl @@ -10,6 +10,7 @@ -define(party(ID), #domain_PartyConfigRef{id = ID}). -define(shop(ID), #domain_ShopConfigRef{id = ID}). -define(wallet(ID), #domain_WalletConfigRef{id = ID}). +-define(lim(ID), #domain_LimitConfigRef{id = ID}). -define(cur(ID), #domain_CurrencyRef{symbolic_code = ID}). -define(pmt(C, T), #domain_PaymentMethodRef{id = {C, T}}). -define(pmt_sys(ID), #domain_PaymentSystemRef{id = ID}). diff --git a/apps/party_management/test/pm_ct_fixture.erl b/apps/party_management/test/pm_ct_fixture.erl index 238210e..17b03db 100644 --- a/apps/party_management/test/pm_ct_fixture.erl +++ b/apps/party_management/test/pm_ct_fixture.erl @@ -9,9 +9,9 @@ -export([construct_party/1]). -export([construct_shop_account/1]). --export([construct_shop/6]). +-export([construct_shop/7]). -export([construct_wallet_account/1]). --export([construct_wallet/4]). +-export([construct_wallet/5]). -export([construct_currency/1]). -export([construct_currency/2]). -export([construct_category/2]). @@ -98,12 +98,13 @@ construct_shop_account(CurrencyCode) -> -spec construct_shop( dmsl_domain_thrift:'ShopConfigRef'(), dmsl_domain_thrift:'PaymentInstitutionRef'(), + dmsl_domain_thrift:'TermSetHierarchyRef'(), dmsl_domain_thrift:'ShopAccount'(), dmsl_domain_thrift:'PartyConfigRef'(), binary(), dmsl_domain_thrift:'CategoryRef'() ) -> {shop_config, dmsl_domain_thrift:'ShopConfigObject'()}. -construct_shop(ShopRef, PaymentInstitutionRef, ShopAccount, PartyRef, ShopLocation, CategoryRef) -> +construct_shop(ShopRef, PaymentInstitutionRef, TermSetHierarchyRef, ShopAccount, PartyRef, ShopLocation, CategoryRef) -> {shop_config, #domain_ShopConfigObject{ ref = ShopRef, data = #domain_ShopConfig{ @@ -111,6 +112,7 @@ construct_shop(ShopRef, PaymentInstitutionRef, ShopAccount, PartyRef, ShopLocati block = make_unblocked(), suspension = make_active(), payment_institution = PaymentInstitutionRef, + terms = TermSetHierarchyRef, account = ShopAccount, party_ref = PartyRef, location = {url, ShopLocation}, @@ -131,10 +133,11 @@ construct_wallet_account(CurrencyCode) -> -spec construct_wallet( dmsl_domain_thrift:'WalletConfigRef'(), dmsl_domain_thrift:'PaymentInstitutionRef'(), + dmsl_domain_thrift:'TermSetHierarchyRef'(), dmsl_domain_thrift:'WalletAccount'(), dmsl_domain_thrift:'PartyConfigRef'() ) -> {wallet_config, dmsl_domain_thrift:'WalletConfigObject'()}. -construct_wallet(WalletRef, PaymentInstitutionRef, WalletAccount, PartyRef) -> +construct_wallet(WalletRef, PaymentInstitutionRef, TermSetHierarchyRef, WalletAccount, PartyRef) -> {wallet_config, #domain_WalletConfigObject{ ref = WalletRef, data = #domain_WalletConfig{ @@ -142,6 +145,7 @@ construct_wallet(WalletRef, PaymentInstitutionRef, WalletAccount, PartyRef) -> block = make_unblocked(), suspension = make_active(), payment_institution = PaymentInstitutionRef, + terms = TermSetHierarchyRef, account = WalletAccount, party_ref = PartyRef } diff --git a/apps/party_management/test/pm_party_tests_SUITE.erl b/apps/party_management/test/pm_party_tests_SUITE.erl index 4c8e009..55ec490 100644 --- a/apps/party_management/test/pm_party_tests_SUITE.erl +++ b/apps/party_management/test/pm_party_tests_SUITE.erl @@ -7,6 +7,7 @@ -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("damsel/include/dmsl_domain_thrift.hrl"). -include_lib("damsel/include/dmsl_base_thrift.hrl"). +-include_lib("damsel/include/dmsl_limiter_config_thrift.hrl"). -export([all/0]). -export([groups/0]). @@ -114,7 +115,8 @@ groups() -> init_per_suite(C) -> {Apps, _Ret} = pm_ct_helper:start_apps([woody, scoper, dmt_client, party_management]), PartyRef = ?party(list_to_binary(lists:concat(["party.", erlang:system_time()]))), - _Rev = pm_domain:upsert(construct_domain_fixture(PartyRef)), + LimitsRev = pm_domain:upsert(constuct_limits_domain_fixture()), + _Rev = pm_domain:upsert(construct_domain_fixture(PartyRef, LimitsRev)), [{apps, Apps}, {party_ref, PartyRef} | C]. -spec end_per_suite(config()) -> _. @@ -349,24 +351,24 @@ compute_provider_terminal_terms_ok(C) -> {value, [ %% In ordset fashion #domain_TurnoverLimit{ - id = <<"p_card_day_count">>, + ref = ?lim(<<"p_card_day_count">>), upper_boundary = 1, - domain_revision = undefined + domain_revision = _ }, #domain_TurnoverLimit{ - id = <<"payment_card_month_amount_rub">>, + ref = ?lim(<<"payment_card_month_amount_rub">>), upper_boundary = 7500000, - domain_revision = undefined + domain_revision = _ }, #domain_TurnoverLimit{ - id = <<"payment_card_month_count">>, + ref = ?lim(<<"payment_card_month_count">>), upper_boundary = 10, - domain_revision = undefined + domain_revision = _ }, #domain_TurnoverLimit{ - id = <<"payment_day_amount_rub">>, + ref = ?lim(<<"payment_day_amount_rub">>), upper_boundary = 5000000, - domain_revision = undefined + domain_revision = _ } ]} }, @@ -678,8 +680,39 @@ compute_pred_w_partially_irreducible_criterion(_) -> %% --spec construct_domain_fixture(dmsl_domain_thrift:'PartyConfigRef'()) -> [pm_domain:object()]. -construct_domain_fixture(PartyRef) -> +-spec constuct_limits_domain_fixture() -> [pm_domain:object()]. +constuct_limits_domain_fixture() -> + [ + {limit_config, #domain_LimitConfigObject{ + ref = #domain_LimitConfigRef{id = LimitID}, + data = #limiter_config_LimitConfig{ + processor_type = <<"TurnoverProcessor">>, + started_at = <<"2000-01-01T00:00:00Z">>, + shard_size = 12, + time_range_type = {calendar, {month, #limiter_config_TimeRangeTypeCalendarMonth{}}}, + context_type = {payment_processing, #limiter_config_LimitContextTypePaymentProcessing{}}, + type = + {turnover, #limiter_config_LimitTypeTurnover{ + metric = {amount, #limiter_config_LimitTurnoverAmount{currency = <<"RUB">>}} + }}, + scopes = ordsets:from_list([{shop, #limiter_config_LimitScopeEmptyDetails{}}]), + description = <<"description">>, + op_behaviour = #limiter_config_OperationLimitBehaviour{ + invoice_payment_refund = {subtraction, #limiter_config_Subtraction{}} + } + } + }} + || LimitID <- [ + <<"payment_card_month_count">>, + <<"payment_card_month_amount_rub">>, + <<"payment_day_amount_rub">>, + <<"p_card_day_count">> + ] + ]. + +-spec construct_domain_fixture(dmsl_domain_thrift:'PartyConfigRef'(), dmsl_domain_conf_v2_thrift:'Version'()) -> + [pm_domain:object()]. +construct_domain_fixture(PartyRef, PrevRev) -> TestTermSet = #domain_TermSet{ payments = #domain_PaymentsServiceTerms{ currencies = {value, ordsets:from_list([?cur(<<"RUB">>)])}, @@ -1005,6 +1038,7 @@ construct_domain_fixture(PartyRef) -> pm_ct_fixture:construct_shop( ?shop(?SHOP_ID), ?pinst(1), + ?trms(2), pm_ct_fixture:construct_shop_account(<<"RUB">>), PartyRef, <<"http://example.com">>, @@ -1013,6 +1047,7 @@ construct_domain_fixture(PartyRef) -> pm_ct_fixture:construct_wallet( ?wallet(?WALLET_ID), ?pinst(1), + ?trms(2), pm_ct_fixture:construct_wallet_account(<<"RUB">>), PartyRef ), @@ -1157,25 +1192,25 @@ construct_domain_fixture(PartyRef) -> {value, ?ordset([ #domain_TurnoverLimit{ - id = <<"payment_card_month_count">>, + ref = ?lim(<<"payment_card_month_count">>), upper_boundary = 5, - domain_revision = undefined + domain_revision = PrevRev }, %% Common limits #domain_TurnoverLimit{ - id = <<"payment_card_month_amount_rub">>, + ref = ?lim(<<"payment_card_month_amount_rub">>), upper_boundary = 7500000, - domain_revision = undefined + domain_revision = PrevRev }, #domain_TurnoverLimit{ - id = <<"payment_day_amount_rub">>, + ref = ?lim(<<"payment_day_amount_rub">>), upper_boundary = 5000000, - domain_revision = undefined + domain_revision = PrevRev }, #domain_TurnoverLimit{ - id = <<"p_card_day_count">>, + ref = ?lim(<<"p_card_day_count">>), upper_boundary = 1, - domain_revision = undefined + domain_revision = PrevRev } ])} }, @@ -1194,25 +1229,25 @@ construct_domain_fixture(PartyRef) -> {value, ?ordset([ #domain_TurnoverLimit{ - id = <<"payment_card_month_count">>, + ref = ?lim(<<"payment_card_month_count">>), upper_boundary = 10, - domain_revision = undefined + domain_revision = PrevRev }, %% Common limits #domain_TurnoverLimit{ - id = <<"payment_card_month_amount_rub">>, + ref = ?lim(<<"payment_card_month_amount_rub">>), upper_boundary = 7500000, - domain_revision = undefined + domain_revision = PrevRev }, #domain_TurnoverLimit{ - id = <<"payment_day_amount_rub">>, + ref = ?lim(<<"payment_day_amount_rub">>), upper_boundary = 5000000, - domain_revision = undefined + domain_revision = PrevRev }, #domain_TurnoverLimit{ - id = <<"p_card_day_count">>, + ref = ?lim(<<"p_card_day_count">>), upper_boundary = 1, - domain_revision = undefined + domain_revision = PrevRev } ])} } diff --git a/compose.yaml b/compose.yaml index dc08a0f..eb52b9f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -21,7 +21,7 @@ services: command: /sbin/init dmt: - image: ghcr.io/valitydev/dominant-v2:sha-bfed984 + image: ghcr.io/valitydev/dominant-v2:sha-90f5fa2 command: /opt/dmt/bin/dmt foreground healthcheck: test: "/opt/dmt/bin/dmt ping" diff --git a/rebar.config b/rebar.config index ef708de..0b8656c 100644 --- a/rebar.config +++ b/rebar.config @@ -32,11 +32,11 @@ {prometheus, "4.11.0"}, {prometheus_cowboy, "0.1.9"}, {woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.12"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.17"}}}, {payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}}, {dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {tag, "v2.0.3"}}}, {scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}}, - {erl_health, {git, "https://github.com/valitydev/erlang-health.git", {branch, "master"}}}, + {erl_health, {git, "https://github.com/valitydev/erlang-health.git", {tag, "v1.0.0"}}}, %% OpenTelemetry deps {opentelemetry_api, "1.4.0"}, diff --git a/rebar.lock b/rebar.lock index 3d2eb0c..e1da49b 100644 --- a/rebar.lock +++ b/rebar.lock @@ -13,7 +13,7 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"8cab698cd78125ac47489d0ba81169df376757a4"}}, + {ref,"f831d3aa5fdfd0338b41af44d1eeffe810ca9708"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt_client.git", @@ -21,7 +21,7 @@ 0}, {<<"erl_health">>, {git,"https://github.com/valitydev/erlang-health.git", - {ref,"49716470d0e8dab5e37db55d52dea78001735a3d"}}, + {ref,"63d34ef9fb60afea953dad9828330f4198614800"}}, 0}, {<<"genlib">>, {git,"https://github.com/valitydev/genlib.git",