Skip to content

Commit

Permalink
IMP-278: Retires payouts (#48)
Browse files Browse the repository at this point in the history
* IMP-278: Retires payouts

* Refactors fixture for `pm_party_tests_SUITE:check_all_payment_methods/1` testcase

* Fixes dialyzer warns and updates woody metrics publishing

* Bumps CI cache

* Fixes deps order in main application

* Bumps damsel

* Reverts removed fields

* Bumps damsel

* Bumps CI

* Bumps damsel
  • Loading branch information
nanodirijabl authored Aug 28, 2024
1 parent 9af7d71 commit e16301b
Show file tree
Hide file tree
Showing 33 changed files with 223 additions and 1,150 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/erlang-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
run:
name: Run checks
needs: setup
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.14
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.15
with:
otp-version: ${{ needs.setup.outputs.otp-version }}
rebar-version: ${{ needs.setup.outputs.rebar-version }}
use-thrift: true
thrift-version: ${{ needs.setup.outputs.thrift-version }}
run-ct-with-compose: true
cache-version: v3
cache-version: v4
upload-coverage: false
60 changes: 2 additions & 58 deletions apps/party_management/include/claim_management.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,6 @@
{termination, #claimmgmt_ContractTermination{reason = Reason}}
).

-define(cm_payout_tool_modification(PayoutToolID, Mod),
{payout_tool_modification, #claimmgmt_PayoutToolModificationUnit{
payout_tool_id = PayoutToolID,
modification = Mod
}}
).

-define(cm_payout_tool_creation(PayoutToolID, PayoutToolParams),
?cm_payout_tool_modification(PayoutToolID, {creation, PayoutToolParams})
).

-define(cm_payout_tool_info_modification(PayoutToolID, Info),
?cm_payout_tool_modification(PayoutToolID, {info_modification, Info})
).

-define(cm_payout_schedule_modification(BusinessScheduleRef),
{payout_schedule_modification, #claimmgmt_ScheduleModification{
schedule = BusinessScheduleRef
}}
).

-define(cm_cash_register_unit_creation(ID, Params),
{creation, #claimmgmt_CashRegisterParams{
cash_register_provider_id = ID,
Expand Down Expand Up @@ -115,10 +94,9 @@
}}
).

-define(cm_shop_contract_modification(ContractID, PayoutToolID),
-define(cm_shop_contract_modification(ContractID),
{contract_modification, #claimmgmt_ShopContractModification{
contract_id = ContractID,
payout_tool_id = PayoutToolID
contract_id = ContractID
}}
).

Expand Down Expand Up @@ -223,40 +201,6 @@
)
).

-define(cm_invalid_shop_payout_tool(ID, Reason),
?cm_invalid_shop(ID, {payout_tool_invalid, Reason})
).

-define(cm_invalid_shop_payout_tool_not_set_for_payouts(ID, Schedule),
?cm_invalid_shop_payout_tool(
ID,
{not_set_for_payouts, #claimmgmt_PayoutToolNotSetForPayouts{
payout_schedule = Schedule
}}
)
).

-define(cm_invalid_shop_payout_tool_currency_mismatch(ID, PayoutToolID, ShopAccountCurrency, PayoutToolCurrency),
?cm_invalid_shop_payout_tool(
ID,
{currency_mismatch, #claimmgmt_PayoutToolCurrencyMismatch{
shop_account_currency = ShopAccountCurrency,
payout_tool_id = PayoutToolID,
payout_tool_currency = PayoutToolCurrency
}}
)
).

-define(cm_invalid_shop_payout_tool_not_in_contract(ID, ContractID, PayoutToolID),
?cm_invalid_shop_payout_tool(
ID,
{not_in_contract, #claimmgmt_PayoutToolNotInContract{
contract_id = ContractID,
payout_tool_id = PayoutToolID
}}
)
).

-define(cm_invalid_contract(ID, Reason),
{invalid_contract, #claimmgmt_InvalidContract{id = ID, reason = Reason}}
).
Expand Down
29 changes: 0 additions & 29 deletions apps/party_management/include/legacy_party_structures.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
{payproc_ContractParams, Contractor, TemplateRef, PaymentInstitutionRef}
).

-define(legacy_payout_tool_creation(ID, Params),
{payout_tool_modification, {payproc_PayoutToolModificationUnit, ID, {creation, Params}}}
).

-define(legacy_payout_tool_params(Currency, PayoutToolInfo),
{payproc_PayoutToolParams, Currency, PayoutToolInfo}
).

-define(legacy_russian_legal_entity(
RegisteredName,
RegisteredNumber,
Expand Down Expand Up @@ -89,10 +81,6 @@
{shop_modification, {payproc_ShopModificationUnit, ID, Modification}}
).

-define(legacy_schedule_modification(PayoutScheduleRef),
{payproc_ScheduleModification, PayoutScheduleRef}
).

-define(legacy_shop_effect(ID, Effect),
{shop_effect, {payproc_ShopEffectUnit, ID, Effect}}
).
Expand Down Expand Up @@ -129,14 +117,6 @@
PayoutScheduleRef}
).

-define(legacy_payout_schedule_ref(ID),
{domain_PayoutScheduleRef, ID}
).

-define(legacy_schedule_changed(PayoutScheduleRef),
{payproc_ScheduleChanged, PayoutScheduleRef}
).

-define(legacy_contract_effect(ID, Effect),
{contract_effect, {payproc_ContractEffectUnit, ID, Effect}}
).
Expand Down Expand Up @@ -192,15 +172,6 @@
Adjustments, PayoutTools, LegalAgreement, ReportPreferences}
).

-define(legacy_payout_tool(
ID,
CreatedAt,
Currency,
PayoutToolInfo
),
{domain_PayoutTool, ID, CreatedAt, Currency, PayoutToolInfo}
).

-define(legacy_legal_agreement(
SignedAt,
LegalAgreementID
Expand Down
26 changes: 2 additions & 24 deletions apps/party_management/include/party_events.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,12 @@
}}
).

-define(payout_tool_creation(ID, Params),
{payout_tool_modification, #payproc_PayoutToolModificationUnit{
payout_tool_id = ID,
modification = {creation, Params}
}}
).

-define(payout_tool_info_modification(ID, Info),
{payout_tool_modification, #payproc_PayoutToolModificationUnit{
payout_tool_id = ID,
modification = {info_modification, Info}
}}
).

-define(shop_modification(ID, Modification),
{shop_modification, #payproc_ShopModificationUnit{id = ID, modification = Modification}}
).

-define(shop_contract_modification(ContractID, PayoutToolID),
{contract_modification, #payproc_ShopContractModification{contract_id = ContractID, payout_tool_id = PayoutToolID}}
-define(shop_contract_modification(ContractID),
{contract_modification, #payproc_ShopContractModification{contract_id = ContractID}}
).

-define(shop_account_creation_params(CurrencyRef),
Expand All @@ -114,10 +100,6 @@
{proxy_modification, #payproc_ProxyModification{proxy = Proxy}}
).

-define(payout_schedule_modification(BusinessScheduleRef),
{payout_schedule_modification, #payproc_ScheduleModification{schedule = BusinessScheduleRef}}
).

-define(contract_effect(ID, Effect),
{contract_effect, #payproc_ContractEffectUnit{contract_id = ID, effect = Effect}}
).
Expand All @@ -126,10 +108,6 @@
{shop_effect, #payproc_ShopEffectUnit{shop_id = ID, effect = Effect}}
).

-define(payout_schedule_changed(BusinessScheduleRef),
{payout_schedule_changed, #payproc_ScheduleChanged{schedule = BusinessScheduleRef}}
).

-define(wallet_modification(ID, Modification),
{wallet_modification, #payproc_WalletModificationUnit{id = ID, modification = Modification}}
).
Expand Down
2 changes: 2 additions & 0 deletions apps/party_management/src/party_management.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
genlib,
pm_proto,
cowboy,
prometheus,
prometheus_cowboy,
woody,
scoper, % should be before any scoper event handler usage
gproc,
Expand Down
7 changes: 7 additions & 0 deletions apps/party_management/src/party_management.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@ get_prometheus_route() ->

-spec start(normal, any()) -> {ok, pid()} | {error, any()}.
start(_StartType, _StartArgs) ->
ok = setup_metrics(),
supervisor:start_link(?MODULE, []).

-spec stop(any()) -> ok.
stop(_State) ->
ok.

%%

setup_metrics() ->
ok = woody_ranch_prometheus_collector:setup(),
ok = woody_hackney_prometheus_collector:setup().
31 changes: 2 additions & 29 deletions apps/party_management/src/pm_claim.erl
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,6 @@ update_contract({status_changed, Status}, Contract) ->
update_contract({adjustment_created, Adjustment}, Contract) ->
Adjustments = Contract#domain_Contract.adjustments ++ [Adjustment],
Contract#domain_Contract{adjustments = Adjustments};
update_contract({payout_tool_created, PayoutTool}, Contract) ->
PayoutTools = Contract#domain_Contract.payout_tools ++ [PayoutTool],
Contract#domain_Contract{payout_tools = PayoutTools};
update_contract(
{payout_tool_info_changed, #payproc_PayoutToolInfoChanged{payout_tool_id = PayoutToolID, info = Info}},
Contract
) ->
PayoutTool = pm_contract:get_payout_tool(PayoutToolID, Contract),
pm_contract:set_payout_tool(PayoutTool#domain_PayoutTool{payout_tool_info = Info}, Contract);
update_contract({legal_agreement_bound, LegalAgreement}, Contract) ->
Contract#domain_Contract{legal_agreement = LegalAgreement};
update_contract({report_preferences_changed, ReportPreferences}, Contract) ->
Expand All @@ -416,19 +407,15 @@ update_shop({category_changed, Category}, Shop) ->
update_shop({details_changed, Details}, Shop) ->
Shop#domain_Shop{details = Details};
update_shop(
{contract_changed, #payproc_ShopContractChanged{contract_id = ContractID, payout_tool_id = PayoutToolID}},
{contract_changed, #payproc_ShopContractChanged{contract_id = ContractID}},
Shop
) ->
Shop#domain_Shop{contract_id = ContractID, payout_tool_id = PayoutToolID};
update_shop({payout_tool_changed, PayoutToolID}, Shop) ->
Shop#domain_Shop{payout_tool_id = PayoutToolID};
Shop#domain_Shop{contract_id = ContractID};
update_shop({location_changed, Location}, Shop) ->
Shop#domain_Shop{location = Location};
update_shop({proxy_changed, _}, Shop) ->
% deprecated
Shop;
update_shop(?payout_schedule_changed(BusinessScheduleRef), Shop) ->
Shop#domain_Shop{payout_schedule = BusinessScheduleRef};
update_shop({account_created, Account}, Shop) ->
Shop#domain_Shop{account = Account};
update_shop({turnover_limits_changed, TurnoverLimits}, Shop) ->
Expand Down Expand Up @@ -524,20 +511,6 @@ assert_contract_change_applicable(ID, ?adjustment_creation(AdjustmentID, _), Con
_ ->
raise_invalid_changeset(?invalid_contract(ID, {contract_adjustment_already_exists, AdjustmentID}))
end;
assert_contract_change_applicable(ID, ?payout_tool_creation(PayoutToolID, _), Contract) ->
case pm_contract:get_payout_tool(PayoutToolID, Contract) of
undefined ->
ok;
_ ->
raise_invalid_changeset(?invalid_contract(ID, {payout_tool_already_exists, PayoutToolID}))
end;
assert_contract_change_applicable(ID, ?payout_tool_info_modification(PayoutToolID, _), Contract) ->
case pm_contract:get_payout_tool(PayoutToolID, Contract) of
undefined ->
raise_invalid_changeset(?invalid_contract(ID, {payout_tool_not_exists, PayoutToolID}));
_ ->
ok
end;
assert_contract_change_applicable(_, _, _) ->
ok.

Expand Down
19 changes: 0 additions & 19 deletions apps/party_management/src/pm_claim_committer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,6 @@ assert_contract_modification_applicable(ID, ?cm_adjustment_creation(AdjustmentID
PartyChange
])
end;
assert_contract_modification_applicable(ID, ?cm_payout_tool_creation(PayoutToolID, _), Contract, PartyChange) ->
case pm_contract:get_payout_tool(PayoutToolID, Contract) of
undefined ->
ok;
_ ->
raise_invalid_changeset(?cm_invalid_contract(ID, {payout_tool_already_exists, PayoutToolID}), [PartyChange])
end;
assert_contract_modification_applicable(
ID,
?cm_payout_tool_info_modification(PayoutToolID, _),
Contract,
PartyChange
) ->
case pm_contract:get_payout_tool(PayoutToolID, Contract) of
undefined ->
raise_invalid_changeset(?cm_invalid_contract(ID, {payout_tool_not_exists, PayoutToolID}), [PartyChange]);
_ ->
ok
end;
assert_contract_modification_applicable(_, _, _, _) ->
ok.

Expand Down
Loading

0 comments on commit e16301b

Please sign in to comment.