Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-12: Adds support for 'currency_conversion' config option #28

Merged
merged 6 commits into from
May 29, 2024

Conversation

nanodirijabl
Copy link
Contributor

No description provided.

@nanodirijabl nanodirijabl changed the title CP-12: Adds support for 'currency_conversin' config option CP-12: Adds support for 'currency_conversion' config option May 28, 2024
@nanodirijabl nanodirijabl requested a review from WWWcool May 28, 2024 09:33
@nanodirijabl
Copy link
Contributor Author

Ждёт апрува и влива valitydev/limiter-proto#44 и valitydev/damsel#129

Copy link
Contributor

@WWWcool WWWcool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а тесты с работающей конвертацией работают?

@nanodirijabl
Copy link
Contributor Author

nanodirijabl commented May 28, 2024

а тесты с работающей конвертацией работают?

Прежние тесты остались. Это те что были на моке ещё до добавления общего флага в env.

-spec commit_with_default_exchange(config()) -> _.
commit_with_default_exchange(C) ->
ok = application:set_env(limiter, currency_conversion, enabled),
Rational = #base_Rational{p = 1000000, q = 100},
_ = mock_exchange(Rational, C),
{ID, Version} = configure_limit(
?time_range_month(), ?global(), ?turnover_metric_amount(<<"RUB">>), ?currency_conversion(), C
),
Cost = ?cash(10000, <<"SOME_CURRENCY">>),
Context = ?payproc_ctx_invoice(Cost),
{ok, {vector, _}} = hold_and_commit(?LIMIT_CHANGE(ID, ?CHANGE_ID, Version), Context, ?config(client, C)),
{ok, #limiter_Limit{amount = 10000}} = lim_client:get(ID, Version, Context, ?config(client, C)).

Там простой мок функции xrate

mock_exchange(Rational, C) ->
lim_mock:mock_services([{xrates, fun('GetConvertedAmount', _) -> {ok, Rational} end}], C).

@nanodirijabl nanodirijabl requested a review from WWWcool May 28, 2024 10:29
@nanodirijabl
Copy link
Contributor Author

Другое дело что может стоит отказаться от глобального флага currency_conversion. И всегда смотреть только на соответствующее значение из конфига лимита. По умолчанию он и так будет давать false для включения конвертации при разной валюте и кидать исключение.

@nanodirijabl nanodirijabl requested review from WWWcool and removed request for WWWcool May 29, 2024 07:09
@nanodirijabl nanodirijabl merged commit bcff0b7 into master May 29, 2024
4 checks passed
@nanodirijabl nanodirijabl deleted the CP-12/ft/limiter-denomination-opts branch May 29, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants