mirror of
https://github.com/valitydev/party-management.git
synced 2024-11-06 01:05:21 +00:00
IMP-278: Retires payouts (#48)
* 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
This commit is contained in:
parent
9af7d71577
commit
e16301bd9a
4
.github/workflows/erlang-checks.yaml
vendored
4
.github/workflows/erlang-checks.yaml
vendored
@ -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
|
||||
|
@ -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,
|
||||
@ -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
|
||||
}}
|
||||
).
|
||||
|
||||
@ -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}}
|
||||
).
|
||||
|
@ -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,
|
||||
@ -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}}
|
||||
).
|
||||
@ -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}}
|
||||
).
|
||||
@ -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
|
||||
|
@ -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),
|
||||
@ -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}}
|
||||
).
|
||||
@ -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}}
|
||||
).
|
||||
|
@ -11,6 +11,8 @@
|
||||
genlib,
|
||||
pm_proto,
|
||||
cowboy,
|
||||
prometheus,
|
||||
prometheus_cowboy,
|
||||
woody,
|
||||
scoper, % should be before any scoper event handler usage
|
||||
gproc,
|
||||
|
@ -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().
|
||||
|
@ -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) ->
|
||||
@ -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) ->
|
||||
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -88,13 +88,6 @@ make_contract_effect(_, ?cm_contract_termination(_), Timestamp, _) ->
|
||||
{status_changed, {terminated, #domain_ContractTerminated{terminated_at = Timestamp}}};
|
||||
make_contract_effect(_, ?cm_adjustment_creation(AdjustmentID, Params), Timestamp, Revision) ->
|
||||
{adjustment_created, pm_contract:create_adjustment(AdjustmentID, Params, Timestamp, Revision)};
|
||||
make_contract_effect(_, ?cm_payout_tool_creation(PayoutToolID, Params), Timestamp, _) ->
|
||||
{payout_tool_created, pm_payout_tool:create(PayoutToolID, Params, Timestamp)};
|
||||
make_contract_effect(_, ?cm_payout_tool_info_modification(PayoutToolID, Info), _, _) ->
|
||||
{payout_tool_info_changed, #payproc_PayoutToolInfoChanged{
|
||||
payout_tool_id = PayoutToolID,
|
||||
info = Info
|
||||
}};
|
||||
make_contract_effect(_, {legal_agreement_binding, LegalAgreement}, _, _) ->
|
||||
{legal_agreement_bound, LegalAgreement};
|
||||
make_contract_effect(ID, {report_preferences_modification, ReportPreferences}, _, Revision) ->
|
||||
@ -109,20 +102,14 @@ make_shop_effect(_, {category_modification, Category}, _, _) ->
|
||||
{category_changed, Category};
|
||||
make_shop_effect(_, {details_modification, Details}, _, _) ->
|
||||
{details_changed, Details};
|
||||
make_shop_effect(_, ?cm_shop_contract_modification(ContractID, PayoutToolID), _, _) ->
|
||||
make_shop_effect(_, ?cm_shop_contract_modification(ContractID), _, _) ->
|
||||
{contract_changed, #payproc_ShopContractChanged{
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
}};
|
||||
make_shop_effect(_, {payout_tool_modification, PayoutToolID}, _, _) ->
|
||||
{payout_tool_changed, PayoutToolID};
|
||||
make_shop_effect(_, {location_modification, Location}, _, _) ->
|
||||
{location_changed, Location};
|
||||
make_shop_effect(_, {shop_account_creation, Params}, _, _) ->
|
||||
{account_created, create_shop_account(Params)};
|
||||
make_shop_effect(ID, ?cm_payout_schedule_modification(PayoutScheduleRef), _, Revision) ->
|
||||
_ = assert_payout_schedule_valid(ID, PayoutScheduleRef, Revision),
|
||||
?payout_schedule_changed(PayoutScheduleRef);
|
||||
make_shop_effect(_, {turnover_limits_modification, TurnoverLimits}, _, _) ->
|
||||
{turnover_limits_changed, TurnoverLimits}.
|
||||
|
||||
@ -154,11 +141,6 @@ assert_report_schedule_valid(
|
||||
) ->
|
||||
assert_valid_object_ref({contract, ID}, {business_schedule, BusinessScheduleRef}, Revision).
|
||||
|
||||
assert_payout_schedule_valid(ID, #domain_BusinessScheduleRef{} = BusinessScheduleRef, Revision) ->
|
||||
assert_valid_object_ref({shop, ID}, {business_schedule, BusinessScheduleRef}, Revision);
|
||||
assert_payout_schedule_valid(_, undefined, _) ->
|
||||
ok.
|
||||
|
||||
assert_valid_object_ref(Prefix, Ref, Revision) ->
|
||||
case pm_domain:exists(Revision, Ref) of
|
||||
true ->
|
||||
@ -176,8 +158,6 @@ raise_invalid_object_ref(Prefix, Ref) ->
|
||||
raise_invalid_object_ref_(Prefix, Ex).
|
||||
|
||||
-spec raise_invalid_object_ref_(term(), term()) -> no_return().
|
||||
raise_invalid_object_ref_({shop, ID}, Ex) ->
|
||||
pm_claim_committer:raise_invalid_changeset(?cm_invalid_shop(ID, Ex), []);
|
||||
raise_invalid_object_ref_({contract, ID}, Ex) ->
|
||||
pm_claim_committer:raise_invalid_changeset(?cm_invalid_contract(ID, Ex), []).
|
||||
|
||||
@ -186,12 +166,11 @@ create_shop_account(#claimmgmt_ShopAccountParams{currency = 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),
|
||||
#domain_ShopAccount{
|
||||
currency = CurrencyRef,
|
||||
settlement = SettlementID,
|
||||
guarantee = GuaranteeID,
|
||||
payout = PayoutID
|
||||
payout = 0
|
||||
}.
|
||||
|
||||
make_optional_domain_ref(_, undefined) ->
|
||||
@ -238,15 +217,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) ->
|
||||
@ -265,19 +235,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) ->
|
||||
|
@ -84,7 +84,6 @@ assert_shop_valid(#domain_Shop{contract_id = ContractID} = Shop, Timestamp, Revi
|
||||
case pm_party:get_contract(ContractID, Party) of
|
||||
#domain_Contract{} = Contract ->
|
||||
_ = assert_shop_contract_valid(Shop, Contract, Timestamp, Revision),
|
||||
_ = assert_shop_payout_tool_valid(Shop, Contract),
|
||||
ok;
|
||||
undefined ->
|
||||
throw({invalid_changeset, ?cm_invalid_contract_not_exists(ContractID)})
|
||||
@ -119,32 +118,6 @@ assert_shop_contract_valid(
|
||||
),
|
||||
ok.
|
||||
|
||||
assert_shop_payout_tool_valid(#domain_Shop{payout_tool_id = undefined, payout_schedule = undefined}, _) ->
|
||||
% automatic payouts disabled for this shop and it's ok
|
||||
ok;
|
||||
assert_shop_payout_tool_valid(#domain_Shop{id = ID, payout_tool_id = undefined, payout_schedule = Schedule}, _) ->
|
||||
% automatic payouts enabled for this shop but no payout tool specified
|
||||
pm_claim_committer:raise_invalid_changeset(?cm_invalid_shop_payout_tool_not_set_for_payouts(ID, Schedule), []);
|
||||
assert_shop_payout_tool_valid(#domain_Shop{id = ID, payout_tool_id = PayoutToolID} = Shop, Contract) ->
|
||||
ShopAccountCurrency = (Shop#domain_Shop.account)#domain_ShopAccount.currency,
|
||||
ContractID = Contract#domain_Contract.id,
|
||||
case pm_contract:get_payout_tool(PayoutToolID, Contract) of
|
||||
#domain_PayoutTool{currency = ShopAccountCurrency} ->
|
||||
ok;
|
||||
#domain_PayoutTool{currency = PayoutToolCurrency} ->
|
||||
throw(
|
||||
{invalid_changeset,
|
||||
?cm_invalid_shop_payout_tool_currency_mismatch(
|
||||
ID,
|
||||
PayoutToolID,
|
||||
ShopAccountCurrency,
|
||||
PayoutToolCurrency
|
||||
)}
|
||||
);
|
||||
undefined ->
|
||||
throw({invalid_changeset, ?cm_invalid_shop_payout_tool_not_in_contract(ID, ContractID, PayoutToolID)})
|
||||
end.
|
||||
|
||||
assert_wallet_valid(#domain_Wallet{contract = ContractID} = Wallet, Timestamp, Revision, Party) ->
|
||||
case pm_party:get_contract(ContractID, Party) of
|
||||
#domain_Contract{} = Contract ->
|
||||
|
@ -77,13 +77,6 @@ make_contract_effect(_, ?contract_termination(_), Timestamp, _) ->
|
||||
{status_changed, {terminated, #domain_ContractTerminated{terminated_at = Timestamp}}};
|
||||
make_contract_effect(_, ?adjustment_creation(AdjustmentID, Params), Timestamp, Revision) ->
|
||||
{adjustment_created, pm_contract:create_adjustment(AdjustmentID, Params, Timestamp, Revision)};
|
||||
make_contract_effect(_, ?payout_tool_creation(PayoutToolID, Params), Timestamp, _) ->
|
||||
{payout_tool_created, pm_payout_tool:create(PayoutToolID, Params, Timestamp)};
|
||||
make_contract_effect(_, ?payout_tool_info_modification(PayoutToolID, Info), _, _) ->
|
||||
{payout_tool_info_changed, #payproc_PayoutToolInfoChanged{
|
||||
payout_tool_id = PayoutToolID,
|
||||
info = Info
|
||||
}};
|
||||
make_contract_effect(_, {legal_agreement_binding, LegalAgreement}, _, _) ->
|
||||
{legal_agreement_bound, LegalAgreement};
|
||||
make_contract_effect(ID, {report_preferences_modification, ReportPreferences}, _, Revision) ->
|
||||
@ -98,22 +91,16 @@ make_shop_effect(_, {category_modification, Category}, _, _) ->
|
||||
{category_changed, Category};
|
||||
make_shop_effect(_, {details_modification, Details}, _, _) ->
|
||||
{details_changed, Details};
|
||||
make_shop_effect(_, ?shop_contract_modification(ContractID, PayoutToolID), _, _) ->
|
||||
make_shop_effect(_, ?shop_contract_modification(ContractID), _, _) ->
|
||||
{contract_changed, #payproc_ShopContractChanged{
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
}};
|
||||
make_shop_effect(_, {payout_tool_modification, PayoutToolID}, _, _) ->
|
||||
{payout_tool_changed, PayoutToolID};
|
||||
make_shop_effect(_, ?proxy_modification(Proxy), _, _) ->
|
||||
{proxy_changed, #payproc_ShopProxyChanged{proxy = Proxy}};
|
||||
make_shop_effect(_, {location_modification, Location}, _, _) ->
|
||||
{location_changed, Location};
|
||||
make_shop_effect(_, {shop_account_creation, Params}, _, _) ->
|
||||
{account_created, create_shop_account(Params)};
|
||||
make_shop_effect(ID, ?payout_schedule_modification(PayoutScheduleRef), _, Revision) ->
|
||||
_ = assert_payout_schedule_valid(ID, PayoutScheduleRef, Revision),
|
||||
?payout_schedule_changed(PayoutScheduleRef);
|
||||
make_shop_effect(_, {turnover_limits_modification, TurnoverLimits}, _, _) ->
|
||||
{turnover_limits_changed, TurnoverLimits}.
|
||||
|
||||
@ -145,11 +132,6 @@ assert_report_schedule_valid(
|
||||
) ->
|
||||
assert_valid_object_ref({contract, ID}, {business_schedule, BusinessScheduleRef}, Revision).
|
||||
|
||||
assert_payout_schedule_valid(ID, #domain_BusinessScheduleRef{} = BusinessScheduleRef, Revision) ->
|
||||
assert_valid_object_ref({shop, ID}, {business_schedule, BusinessScheduleRef}, Revision);
|
||||
assert_payout_schedule_valid(_, undefined, _) ->
|
||||
ok.
|
||||
|
||||
assert_valid_object_ref(Prefix, Ref, Revision) ->
|
||||
case pm_domain:exists(Revision, Ref) of
|
||||
true ->
|
||||
@ -167,8 +149,6 @@ raise_invalid_object_ref(Prefix, Ref) ->
|
||||
raise_invalid_object_ref_(Prefix, Ex).
|
||||
|
||||
-spec raise_invalid_object_ref_(term(), term()) -> no_return().
|
||||
raise_invalid_object_ref_({shop, ID}, Ex) ->
|
||||
pm_claim:raise_invalid_changeset(?invalid_shop(ID, Ex));
|
||||
raise_invalid_object_ref_({contract, ID}, Ex) ->
|
||||
pm_claim:raise_invalid_changeset(?invalid_contract(ID, Ex)).
|
||||
|
||||
@ -177,12 +157,11 @@ create_shop_account(#payproc_ShopAccountParams{currency = 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),
|
||||
#domain_ShopAccount{
|
||||
currency = CurrencyRef,
|
||||
settlement = SettlementID,
|
||||
guarantee = GuaranteeID,
|
||||
payout = PayoutID
|
||||
payout = 0
|
||||
}.
|
||||
|
||||
make_optional_domain_ref(_, undefined) ->
|
||||
|
@ -38,8 +38,6 @@ test({shop_location_is, V}, #{shop := S}, _) ->
|
||||
V =:= S#domain_Shop.location;
|
||||
test({party, V}, #{party_id := PartyID} = VS, _) ->
|
||||
test_party(V, PartyID, VS);
|
||||
test({payout_method_is, V1}, #{payout_method := V2}, _) ->
|
||||
V1 =:= V2;
|
||||
test({identification_level_is, V1}, #{identification_level := V2}, _) ->
|
||||
V1 =:= V2;
|
||||
test({bin_data, #domain_BinDataCondition{} = C}, #{bin_data := #domain_BinData{} = V}, Rev) ->
|
||||
|
@ -12,8 +12,6 @@
|
||||
|
||||
-export([get_categories/3]).
|
||||
-export([get_adjustment/2]).
|
||||
-export([get_payout_tool/2]).
|
||||
-export([set_payout_tool/2]).
|
||||
|
||||
-export([is_active/1]).
|
||||
-export([is_live/2]).
|
||||
@ -31,8 +29,6 @@
|
||||
-type adjustment_params() ::
|
||||
dmsl_payproc_thrift:'ContractAdjustmentParams'()
|
||||
| dmsl_claimmgmt_thrift:'ContractAdjustmentParams'().
|
||||
-type payout_tool() :: dmsl_domain_thrift:'PayoutTool'().
|
||||
-type payout_tool_id() :: dmsl_domain_thrift:'PayoutToolID'().
|
||||
-type category() :: dmsl_domain_thrift:'CategoryRef'().
|
||||
-type contract_template_ref() :: dmsl_domain_thrift:'ContractTemplateRef'().
|
||||
-type payment_inst_ref() :: dmsl_domain_thrift:'PaymentInstitutionRef'().
|
||||
@ -173,21 +169,6 @@ get_adjustment(AdjustmentID, #domain_Contract{adjustments = Adjustments}) ->
|
||||
undefined
|
||||
end.
|
||||
|
||||
-spec get_payout_tool(payout_tool_id(), contract()) -> payout_tool() | undefined.
|
||||
get_payout_tool(PayoutToolID, #domain_Contract{payout_tools = PayoutTools}) ->
|
||||
case lists:keysearch(PayoutToolID, #domain_PayoutTool.id, PayoutTools) of
|
||||
{value, PayoutTool} ->
|
||||
PayoutTool;
|
||||
false ->
|
||||
undefined
|
||||
end.
|
||||
|
||||
-spec set_payout_tool(payout_tool(), contract()) -> contract().
|
||||
set_payout_tool(PayoutTool, Contract = #domain_Contract{payout_tools = PayoutTools}) ->
|
||||
Contract#domain_Contract{
|
||||
payout_tools = lists:keystore(PayoutTool#domain_PayoutTool.id, #domain_PayoutTool.id, PayoutTools, PayoutTool)
|
||||
}.
|
||||
|
||||
-spec is_active(contract()) -> boolean().
|
||||
is_active(#domain_Contract{status = {active, _}}) ->
|
||||
true;
|
||||
|
@ -161,8 +161,7 @@ create_shop(ID, #payproc_ShopParams{} = ShopParams, Timestamp) ->
|
||||
category = ShopParams#payproc_ShopParams.category,
|
||||
details = ShopParams#payproc_ShopParams.details,
|
||||
location = ShopParams#payproc_ShopParams.location,
|
||||
contract_id = ShopParams#payproc_ShopParams.contract_id,
|
||||
payout_tool_id = ShopParams#payproc_ShopParams.payout_tool_id
|
||||
contract_id = ShopParams#payproc_ShopParams.contract_id
|
||||
};
|
||||
create_shop(ID, #claimmgmt_ShopParams{} = ShopParams, Timestamp) ->
|
||||
#domain_Shop{
|
||||
@ -173,8 +172,7 @@ create_shop(ID, #claimmgmt_ShopParams{} = ShopParams, Timestamp) ->
|
||||
category = ShopParams#claimmgmt_ShopParams.category,
|
||||
details = ShopParams#claimmgmt_ShopParams.details,
|
||||
location = ShopParams#claimmgmt_ShopParams.location,
|
||||
contract_id = ShopParams#claimmgmt_ShopParams.contract_id,
|
||||
payout_tool_id = ShopParams#claimmgmt_ShopParams.payout_tool_id
|
||||
contract_id = ShopParams#claimmgmt_ShopParams.contract_id
|
||||
}.
|
||||
|
||||
-spec get_shop(shop_id(), party()) -> shop() | undefined.
|
||||
@ -306,7 +304,6 @@ is_terms({struct, struct, {dmsl_domain_thrift, Struct}}, Terms) when
|
||||
Struct =:= 'PartialRefundsServiceTerms';
|
||||
Struct =:= 'PaymentChargebackServiceTerms';
|
||||
Struct =:= 'PartialCaptureServiceTerms';
|
||||
Struct =:= 'PayoutsServiceTerms';
|
||||
Struct =:= 'ReportsServiceTerms';
|
||||
Struct =:= 'ServiceAcceptanceActsTerms';
|
||||
Struct =:= 'WalletServiceTerms';
|
||||
@ -431,8 +428,6 @@ find_shop_account(ID, [{_, #domain_Shop{account = Account}} | Rest]) ->
|
||||
Account;
|
||||
#domain_ShopAccount{guarantee = ID} ->
|
||||
Account;
|
||||
#domain_ShopAccount{payout = ID} ->
|
||||
Account;
|
||||
_ ->
|
||||
find_shop_account(ID, Rest)
|
||||
end.
|
||||
@ -497,7 +492,6 @@ assert_shop_valid(#domain_Shop{contract_id = ContractID} = Shop, Timestamp, Revi
|
||||
case get_contract(ContractID, Party) of
|
||||
#domain_Contract{} = Contract ->
|
||||
_ = assert_shop_contract_valid(Shop, Contract, Timestamp, Revision),
|
||||
_ = assert_shop_payout_tool_valid(Shop, Contract),
|
||||
ok;
|
||||
undefined ->
|
||||
pm_claim:raise_invalid_changeset(?invalid_contract(ContractID, {not_exists, ContractID}))
|
||||
@ -520,34 +514,6 @@ assert_shop_contract_valid(
|
||||
_ = assert_category_valid({shop, ID}, pm_contract:get_id(Contract), CategoryRef, Terms, Revision),
|
||||
ok.
|
||||
|
||||
assert_shop_payout_tool_valid(#domain_Shop{payout_tool_id = undefined, payout_schedule = undefined}, _) ->
|
||||
% automatic payouts disabled for this shop and it's ok
|
||||
ok;
|
||||
assert_shop_payout_tool_valid(#domain_Shop{id = ID, payout_tool_id = undefined, payout_schedule = _Schedule}, _) ->
|
||||
% automatic payouts enabled for this shop but no payout tool specified
|
||||
pm_claim:raise_invalid_changeset(?invalid_shop(ID, {payout_tool_invalid, #payproc_ShopPayoutToolInvalid{}}));
|
||||
assert_shop_payout_tool_valid(#domain_Shop{id = ID, payout_tool_id = PayoutToolID} = Shop, Contract) ->
|
||||
ShopCurrency = (Shop#domain_Shop.account)#domain_ShopAccount.currency,
|
||||
case pm_contract:get_payout_tool(PayoutToolID, Contract) of
|
||||
#domain_PayoutTool{currency = ShopCurrency} ->
|
||||
ok;
|
||||
#domain_PayoutTool{} ->
|
||||
% currency missmatch
|
||||
pm_claim:raise_invalid_changeset(
|
||||
?invalid_shop(
|
||||
ID,
|
||||
{payout_tool_invalid, #payproc_ShopPayoutToolInvalid{payout_tool_id = PayoutToolID}}
|
||||
)
|
||||
);
|
||||
undefined ->
|
||||
pm_claim:raise_invalid_changeset(
|
||||
?invalid_shop(
|
||||
ID,
|
||||
{payout_tool_invalid, #payproc_ShopPayoutToolInvalid{payout_tool_id = PayoutToolID}}
|
||||
)
|
||||
)
|
||||
end.
|
||||
|
||||
assert_wallet_valid(#domain_Wallet{contract = ContractID} = Wallet, Timestamp, Revision, Party) ->
|
||||
case get_contract(ContractID, Party) of
|
||||
#domain_Contract{} = Contract ->
|
||||
|
@ -229,36 +229,7 @@ handle_function_('ComputePaymentInstitution', Args, _Opts) ->
|
||||
{PaymentInstitutionRef, DomainRevision, Varset} = Args,
|
||||
PaymentInstitution = get_payment_institution(PaymentInstitutionRef, DomainRevision),
|
||||
VS = pm_varset:decode_varset(Varset),
|
||||
pm_payment_institution:reduce_payment_institution(PaymentInstitution, VS, DomainRevision);
|
||||
%% Payouts adhocs
|
||||
|
||||
handle_function_(
|
||||
'ComputePayoutCashFlow',
|
||||
{PartyID, #payproc_PayoutParams{id = ShopID, amount = Amount, timestamp = Timestamp} = PayoutParams},
|
||||
_Opts
|
||||
) ->
|
||||
_ = set_party_mgmt_meta(PartyID),
|
||||
Party = checkout_party(PartyID, {timestamp, Timestamp}),
|
||||
Shop = ensure_shop(pm_party:get_shop(ShopID, Party)),
|
||||
Contract = pm_party:get_contract(Shop#domain_Shop.contract_id, Party),
|
||||
Currency = Amount#domain_Cash.currency,
|
||||
ok = pm_currency:validate_currency(Currency, Shop),
|
||||
PayoutTool = get_payout_tool(Shop, Contract, PayoutParams),
|
||||
VS = #{
|
||||
party_id => PartyID,
|
||||
shop_id => ShopID,
|
||||
category => Shop#domain_Shop.category,
|
||||
currency => Currency,
|
||||
cost => Amount,
|
||||
payout_method => pm_payout_tool:get_method(PayoutTool)
|
||||
},
|
||||
Revision = pm_domain:head(),
|
||||
case pm_party:get_terms(Contract, Timestamp, Revision) of
|
||||
#domain_TermSet{payouts = PayoutsTerms} when PayoutsTerms /= undefined ->
|
||||
compute_payout_cash_flow(Amount, PayoutsTerms, Shop, Contract, VS, Revision);
|
||||
#domain_TermSet{payouts = undefined} ->
|
||||
throw(#payproc_OperationNotPermitted{})
|
||||
end.
|
||||
pm_payment_institution:reduce_payment_institution(PaymentInstitution, VS, DomainRevision).
|
||||
|
||||
%%
|
||||
|
||||
@ -272,16 +243,6 @@ call(PartyID, FunctionName, Args) ->
|
||||
|
||||
%%
|
||||
|
||||
get_payout_tool(_Shop, Contract, #payproc_PayoutParams{payout_tool_id = ToolID}) when ToolID =/= undefined ->
|
||||
case pm_contract:get_payout_tool(ToolID, Contract) of
|
||||
undefined ->
|
||||
throw(#payproc_PayoutToolNotFound{});
|
||||
PayoutTool ->
|
||||
PayoutTool
|
||||
end;
|
||||
get_payout_tool(Shop, Contract, _PayoutParams) ->
|
||||
pm_contract:get_payout_tool(Shop#domain_Shop.payout_tool_id, Contract).
|
||||
|
||||
assert_provider_reduced(#domain_Provider{terms = Terms}) ->
|
||||
assert_provider_terms_reduced(Terms).
|
||||
|
||||
@ -359,37 +320,6 @@ get_default_contract_template(#domain_PaymentInstitution{default_contract_templa
|
||||
ContractTemplateRef = pm_selector:reduce_to_value(ContractSelector, VS, Revision),
|
||||
pm_domain:get(Revision, {contract_template, ContractTemplateRef}).
|
||||
|
||||
compute_payout_cash_flow(
|
||||
Amount,
|
||||
#domain_PayoutsServiceTerms{fees = CashFlowSelector},
|
||||
Shop,
|
||||
Contract,
|
||||
VS,
|
||||
Revision
|
||||
) ->
|
||||
Cashflow = pm_selector:reduce_to_value(CashFlowSelector, VS, Revision),
|
||||
CashFlowContext = #{operation_amount => Amount},
|
||||
Currency = Amount#domain_Cash.currency,
|
||||
AccountMap = collect_payout_account_map(Currency, Shop, Contract, VS, Revision),
|
||||
pm_cashflow:finalize(Cashflow, CashFlowContext, AccountMap).
|
||||
|
||||
collect_payout_account_map(
|
||||
Currency,
|
||||
#domain_Shop{account = ShopAccount},
|
||||
#domain_Contract{payment_institution = PaymentInstitutionRef},
|
||||
VS,
|
||||
Revision
|
||||
) ->
|
||||
PaymentInstitution = get_payment_institution(PaymentInstitutionRef, Revision),
|
||||
SystemAccount = pm_payment_institution:get_system_account(Currency, VS, Revision, PaymentInstitution),
|
||||
#{
|
||||
{merchant, settlement} => ShopAccount#domain_ShopAccount.settlement,
|
||||
{merchant, guarantee} => ShopAccount#domain_ShopAccount.guarantee,
|
||||
{merchant, payout} => ShopAccount#domain_ShopAccount.payout,
|
||||
{system, settlement} => SystemAccount#domain_SystemAccount.settlement,
|
||||
{system, subagent} => SystemAccount#domain_SystemAccount.subagent
|
||||
}.
|
||||
|
||||
get_identification_level(#domain_Contract{contractor_id = undefined, contractor = Contractor}, _) ->
|
||||
%% TODO legacy, remove after migration
|
||||
case Contractor of
|
||||
|
@ -1435,22 +1435,6 @@ transmute_party_modification(
|
||||
ID,
|
||||
{creation, transmute_contractor(V1, V2, Contractor)}
|
||||
);
|
||||
transmute_party_modification(
|
||||
V1,
|
||||
V2,
|
||||
?legacy_contract_modification(
|
||||
ContractID,
|
||||
?legacy_payout_tool_creation(
|
||||
ID,
|
||||
?legacy_payout_tool_params(Currency, ToolInfo)
|
||||
)
|
||||
)
|
||||
) when V1 =:= 1; V1 =:= 2; V1 =:= 5 ->
|
||||
PayoutToolParams = #payproc_PayoutToolParams{
|
||||
currency = Currency,
|
||||
tool_info = transmute_payout_tool_info(V1, V2, ToolInfo)
|
||||
},
|
||||
?contract_modification(ContractID, ?payout_tool_creation(ID, PayoutToolParams));
|
||||
transmute_party_modification(
|
||||
3,
|
||||
4,
|
||||
@ -1460,20 +1444,6 @@ transmute_party_modification(
|
||||
)
|
||||
) ->
|
||||
?contract_modification(ID, {legal_agreement_binding, transmute_legal_agreement(3, 4, LegalAgreement)});
|
||||
transmute_party_modification(
|
||||
3,
|
||||
4,
|
||||
?legacy_shop_modification(
|
||||
ID,
|
||||
{payout_schedule_modification, ?legacy_schedule_modification(PayoutScheduleRef)}
|
||||
)
|
||||
) ->
|
||||
?shop_modification(
|
||||
ID,
|
||||
{payout_schedule_modification, #payproc_ScheduleModification{
|
||||
schedule = transmute_payout_schedule_ref(3, 4, PayoutScheduleRef)
|
||||
}}
|
||||
);
|
||||
transmute_party_modification(V1, _, C) when V1 >= 1, V1 < ?TOP_VERSION ->
|
||||
C.
|
||||
|
||||
@ -1492,7 +1462,7 @@ transmute_claim_effect(
|
||||
Status,
|
||||
Terms,
|
||||
Adjustments,
|
||||
PayoutTools,
|
||||
_PayoutTools,
|
||||
LegalAgreement
|
||||
)}
|
||||
)
|
||||
@ -1507,7 +1477,7 @@ transmute_claim_effect(
|
||||
Status,
|
||||
Terms,
|
||||
Adjustments,
|
||||
[transmute_payout_tool(1, 2, P) || P <- PayoutTools],
|
||||
[],
|
||||
LegalAgreement
|
||||
),
|
||||
?legacy_contract_effect(ID, {created, Contract});
|
||||
@ -1527,7 +1497,7 @@ transmute_claim_effect(
|
||||
Status,
|
||||
Terms,
|
||||
Adjustments,
|
||||
PayoutTools,
|
||||
_PayoutTools,
|
||||
LegalAgreement
|
||||
)}
|
||||
)
|
||||
@ -1542,7 +1512,7 @@ transmute_claim_effect(
|
||||
Status,
|
||||
Terms,
|
||||
Adjustments,
|
||||
[transmute_payout_tool(2, 3, P) || P <- PayoutTools],
|
||||
[],
|
||||
LegalAgreement
|
||||
),
|
||||
?legacy_contract_effect(ID, {created, Contract});
|
||||
@ -1598,7 +1568,7 @@ transmute_claim_effect(
|
||||
Status,
|
||||
Terms,
|
||||
Adjustments,
|
||||
PayoutTools,
|
||||
_PayoutTools,
|
||||
LegalAgreement,
|
||||
ReportPreferences
|
||||
)}
|
||||
@ -1614,25 +1584,11 @@ transmute_claim_effect(
|
||||
status = Status,
|
||||
terms = Terms,
|
||||
adjustments = Adjustments,
|
||||
payout_tools = PayoutTools,
|
||||
payout_tools = [],
|
||||
legal_agreement = LegalAgreement,
|
||||
report_preferences = ReportPreferences
|
||||
},
|
||||
?contract_effect(ID, {created, Contract});
|
||||
transmute_claim_effect(
|
||||
5,
|
||||
6,
|
||||
?contract_effect(
|
||||
ID,
|
||||
{created, Contract = #domain_Contract{payout_tools = PayoutTools}}
|
||||
)
|
||||
) ->
|
||||
?contract_effect(
|
||||
ID,
|
||||
{created, Contract#domain_Contract{
|
||||
payout_tools = [transmute_payout_tool(5, 6, P) || P <- PayoutTools]
|
||||
}}
|
||||
);
|
||||
transmute_claim_effect(
|
||||
6 = V1,
|
||||
7 = V2,
|
||||
@ -1659,18 +1615,6 @@ transmute_claim_effect(
|
||||
ID,
|
||||
{created, transmute_party_contractor(V1, V2, PartyContractor)}
|
||||
);
|
||||
transmute_claim_effect(
|
||||
V1,
|
||||
V2,
|
||||
?legacy_contract_effect(
|
||||
ContractID,
|
||||
{payout_tool_created, PayoutTool}
|
||||
)
|
||||
) when V1 =:= 1; V1 =:= 2; V1 =:= 5 ->
|
||||
?contract_effect(
|
||||
ContractID,
|
||||
{payout_tool_created, transmute_payout_tool(V1, V2, PayoutTool)}
|
||||
);
|
||||
transmute_claim_effect(
|
||||
3,
|
||||
4,
|
||||
@ -1696,7 +1640,7 @@ transmute_claim_effect(
|
||||
Category,
|
||||
Account,
|
||||
ContractID,
|
||||
PayoutToolID
|
||||
_PayoutToolID
|
||||
)}
|
||||
)
|
||||
) ->
|
||||
@ -1709,8 +1653,7 @@ transmute_claim_effect(
|
||||
location = Location,
|
||||
category = Category,
|
||||
account = Account,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
},
|
||||
?shop_effect(ID, {created, Shop});
|
||||
transmute_claim_effect(
|
||||
@ -1729,8 +1672,8 @@ transmute_claim_effect(
|
||||
Category,
|
||||
Account,
|
||||
ContractID,
|
||||
PayoutToolID,
|
||||
PayoutSchedule
|
||||
_PayoutToolID,
|
||||
_PayoutSchedule
|
||||
)}
|
||||
)
|
||||
) ->
|
||||
@ -1743,25 +1686,9 @@ transmute_claim_effect(
|
||||
location = Location,
|
||||
category = Category,
|
||||
account = Account,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID,
|
||||
payout_schedule = transmute_payout_schedule_ref(3, 4, PayoutSchedule)
|
||||
contract_id = ContractID
|
||||
},
|
||||
?shop_effect(ID, {created, Shop});
|
||||
transmute_claim_effect(
|
||||
3,
|
||||
4,
|
||||
?legacy_shop_effect(
|
||||
ID,
|
||||
{payout_schedule_changed, ?legacy_schedule_changed(PayoutSchedule)}
|
||||
)
|
||||
) ->
|
||||
?shop_effect(
|
||||
ID,
|
||||
{payout_schedule_changed, #payproc_ScheduleChanged{
|
||||
schedule = transmute_payout_schedule_ref(3, 4, PayoutSchedule)
|
||||
}}
|
||||
);
|
||||
transmute_claim_effect(V1, _, C) when V1 >= 1, V1 < ?TOP_VERSION ->
|
||||
C.
|
||||
|
||||
@ -1839,75 +1766,6 @@ transmute_contractor(
|
||||
transmute_contractor(V1, _, Contractor) when V1 =:= 1; V1 =:= 2; V1 =:= 6 ->
|
||||
Contractor.
|
||||
|
||||
transmute_payout_tool(
|
||||
V1,
|
||||
V2,
|
||||
?legacy_payout_tool(
|
||||
ID,
|
||||
CreatedAt,
|
||||
Currency,
|
||||
ToolInfo
|
||||
)
|
||||
) when V1 =:= 1; V1 =:= 2 ->
|
||||
#domain_PayoutTool{
|
||||
id = ID,
|
||||
created_at = CreatedAt,
|
||||
currency = Currency,
|
||||
payout_tool_info = transmute_payout_tool_info(V1, V2, ToolInfo)
|
||||
};
|
||||
transmute_payout_tool(V1, _, PayoutTool) when V1 =:= 1; V1 =:= 2 ->
|
||||
PayoutTool;
|
||||
transmute_payout_tool(V1, V2, PayoutTool = #domain_PayoutTool{payout_tool_info = ToolInfo}) when V1 =:= 5 ->
|
||||
PayoutTool#domain_PayoutTool{payout_tool_info = transmute_payout_tool_info(V1, V2, ToolInfo)}.
|
||||
|
||||
transmute_payout_tool_info(1, 2, {bank_account, BankAccount}) ->
|
||||
{russian_bank_account, transmute_bank_account(1, 2, BankAccount)};
|
||||
transmute_payout_tool_info(
|
||||
2,
|
||||
3,
|
||||
{international_bank_account,
|
||||
?legacy_international_bank_account(
|
||||
AccountHolder,
|
||||
BankName,
|
||||
BankAddress,
|
||||
Iban,
|
||||
Bic
|
||||
)}
|
||||
) ->
|
||||
{international_bank_account,
|
||||
?legacy_international_bank_account_v3_4_5(
|
||||
AccountHolder,
|
||||
BankName,
|
||||
BankAddress,
|
||||
Iban,
|
||||
Bic,
|
||||
undefined
|
||||
)};
|
||||
transmute_payout_tool_info(
|
||||
5,
|
||||
6,
|
||||
{international_bank_account,
|
||||
?legacy_international_bank_account_v3_4_5(
|
||||
AccountHolder,
|
||||
BankName,
|
||||
BankAddress,
|
||||
Iban,
|
||||
Bic,
|
||||
_LocalBankCode
|
||||
)}
|
||||
) ->
|
||||
{international_bank_account, #domain_InternationalBankAccount{
|
||||
bank = #domain_InternationalBankDetails{
|
||||
bic = Bic,
|
||||
name = BankName,
|
||||
address = BankAddress
|
||||
},
|
||||
iban = Iban,
|
||||
account_holder = AccountHolder
|
||||
}};
|
||||
transmute_payout_tool_info(V1, _, ToolInfo) when V1 =:= 1; V1 =:= 2; V1 =:= 5 ->
|
||||
ToolInfo.
|
||||
|
||||
transmute_bank_account(1, 2, ?legacy_bank_account(Account, BankName, BankPostAccount, BankBik)) ->
|
||||
#domain_RussianBankAccount{
|
||||
account = Account,
|
||||
@ -1924,11 +1782,6 @@ transmute_legal_agreement(3, 4, ?legacy_legal_agreement(SignedAt, LegalAgreement
|
||||
transmute_legal_agreement(3, 4, undefined) ->
|
||||
undefined.
|
||||
|
||||
transmute_payout_schedule_ref(3, 4, ?legacy_payout_schedule_ref(ID)) ->
|
||||
#domain_BusinessScheduleRef{id = ID};
|
||||
transmute_payout_schedule_ref(3, 4, undefined) ->
|
||||
undefined.
|
||||
|
||||
%%
|
||||
|
||||
-ifdef(TEST).
|
||||
|
@ -1,62 +0,0 @@
|
||||
%%% Payout tools
|
||||
|
||||
-module(pm_payout_tool).
|
||||
|
||||
-include_lib("damsel/include/dmsl_claimmgmt_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
%%
|
||||
|
||||
-export([create/3]).
|
||||
-export([get_method/1]).
|
||||
|
||||
%%
|
||||
-type payout_tool() :: dmsl_domain_thrift:'PayoutTool'().
|
||||
-type payout_tool_id() :: dmsl_domain_thrift:'PayoutToolID'().
|
||||
-type payout_tool_params() ::
|
||||
dmsl_payproc_thrift:'PayoutToolParams'() | dmsl_claimmgmt_thrift:'PayoutToolParams'().
|
||||
-type method() :: dmsl_domain_thrift:'PayoutMethodRef'().
|
||||
-type timestamp() :: dmsl_base_thrift:'Timestamp'().
|
||||
|
||||
%%
|
||||
|
||||
-spec create(payout_tool_id(), payout_tool_params(), timestamp()) -> payout_tool().
|
||||
create(
|
||||
ID,
|
||||
#payproc_PayoutToolParams{
|
||||
currency = Currency,
|
||||
tool_info = ToolInfo
|
||||
},
|
||||
Timestamp
|
||||
) ->
|
||||
#domain_PayoutTool{
|
||||
id = ID,
|
||||
created_at = Timestamp,
|
||||
currency = Currency,
|
||||
payout_tool_info = ToolInfo
|
||||
};
|
||||
create(
|
||||
ID,
|
||||
#claimmgmt_PayoutToolParams{
|
||||
currency = Currency,
|
||||
tool_info = ToolInfo
|
||||
},
|
||||
Timestamp
|
||||
) ->
|
||||
#domain_PayoutTool{
|
||||
id = ID,
|
||||
created_at = Timestamp,
|
||||
currency = Currency,
|
||||
payout_tool_info = ToolInfo
|
||||
}.
|
||||
|
||||
-spec get_method(payout_tool()) -> method().
|
||||
get_method(#domain_PayoutTool{payout_tool_info = {russian_bank_account, _}}) ->
|
||||
#domain_PayoutMethodRef{id = russian_bank_account};
|
||||
get_method(#domain_PayoutTool{payout_tool_info = {international_bank_account, _}}) ->
|
||||
#domain_PayoutMethodRef{id = international_bank_account};
|
||||
get_method(#domain_PayoutTool{payout_tool_info = {wallet_info, _}}) ->
|
||||
#domain_PayoutMethodRef{id = wallet_info};
|
||||
get_method(#domain_PayoutTool{payout_tool_info = {payment_institution_account, _}}) ->
|
||||
#domain_PayoutMethodRef{id = payment_institution_account}.
|
@ -37,7 +37,6 @@ reduce_withdrawal_terms(#domain_WithdrawalProvisionTerms{} = Terms, VS, Rev) ->
|
||||
allow = reduce_predicate_if_defined(Terms#domain_WithdrawalProvisionTerms.allow, VS, Rev),
|
||||
global_allow = reduce_predicate_if_defined(Terms#domain_WithdrawalProvisionTerms.global_allow, VS, Rev),
|
||||
currencies = reduce_if_defined(Terms#domain_WithdrawalProvisionTerms.currencies, VS, Rev),
|
||||
payout_methods = reduce_if_defined(Terms#domain_WithdrawalProvisionTerms.payout_methods, VS, Rev),
|
||||
cash_limit = reduce_if_defined(Terms#domain_WithdrawalProvisionTerms.cash_limit, VS, Rev),
|
||||
cash_flow = reduce_if_defined(Terms#domain_WithdrawalProvisionTerms.cash_flow, VS, Rev),
|
||||
turnover_limit = reduce_if_defined(Terms#domain_WithdrawalProvisionTerms.turnover_limit, VS, Rev)
|
||||
@ -259,7 +258,6 @@ merge_withdrawal_terms(
|
||||
allow = PAllow,
|
||||
global_allow = PGAllow,
|
||||
currencies = PCurrencies,
|
||||
payout_methods = PMethods,
|
||||
cash_limit = PLimit,
|
||||
cash_flow = PCashflow,
|
||||
turnover_limit = PTurnoverLimit
|
||||
@ -268,7 +266,6 @@ merge_withdrawal_terms(
|
||||
allow = TAllow,
|
||||
global_allow = TGAllow,
|
||||
currencies = TCurrencies,
|
||||
payout_methods = TMethods,
|
||||
cash_limit = TLimit,
|
||||
cash_flow = TCashflow,
|
||||
turnover_limit = TTurnoverLimit
|
||||
@ -278,7 +275,6 @@ merge_withdrawal_terms(
|
||||
allow = pm_utils:select_defined(TAllow, PAllow),
|
||||
global_allow = pm_utils:select_defined(TGAllow, PGAllow),
|
||||
currencies = pm_utils:select_defined(TCurrencies, PCurrencies),
|
||||
payout_methods = pm_utils:select_defined(TMethods, PMethods),
|
||||
cash_limit = pm_utils:select_defined(TLimit, PLimit),
|
||||
cash_flow = pm_utils:select_defined(TCashflow, PCashflow),
|
||||
turnover_limit = pm_utils:select_defined(TTurnoverLimit, PTurnoverLimit)
|
||||
|
@ -42,7 +42,6 @@
|
||||
shop_id => dmsl_domain_thrift:'ShopID'(),
|
||||
risk_score => dmsl_domain_thrift:'RiskScore'(),
|
||||
flow => instant | {hold, dmsl_domain_thrift:'HoldLifetime'()},
|
||||
payout_method => dmsl_domain_thrift:'PayoutMethodRef'(),
|
||||
wallet_id => dmsl_domain_thrift:'WalletID'(),
|
||||
identification_level => dmsl_domain_thrift:'ContractorIdentificationLevel'()
|
||||
}.
|
||||
|
@ -14,7 +14,6 @@
|
||||
currency => dmsl_domain_thrift:'CurrencyRef'(),
|
||||
cost => dmsl_domain_thrift:'Cash'(),
|
||||
payment_method => dmsl_domain_thrift:'PaymentMethodRef'(),
|
||||
payout_method => dmsl_domain_thrift:'PayoutMethodRef'(),
|
||||
wallet_id => dmsl_domain_thrift:'WalletID'(),
|
||||
shop_id => dmsl_domain_thrift:'ShopID'(),
|
||||
identification_level => dmsl_domain_thrift:'ContractorIdentificationLevel'(),
|
||||
@ -34,7 +33,6 @@ encode_varset(Varset) ->
|
||||
currency = genlib_map:get(currency, Varset),
|
||||
amount = genlib_map:get(cost, Varset),
|
||||
payment_method = genlib_map:get(payment_method, Varset),
|
||||
payout_method = genlib_map:get(payout_method, Varset),
|
||||
wallet_id = genlib_map:get(wallet_id, Varset),
|
||||
shop_id = genlib_map:get(shop_id, Varset),
|
||||
identification_level = genlib_map:get(identification_level, Varset),
|
||||
@ -53,7 +51,6 @@ decode_varset(#payproc_Varset{} = Varset, VS) ->
|
||||
currency => Varset#payproc_Varset.currency,
|
||||
cost => Varset#payproc_Varset.amount,
|
||||
payment_method => Varset#payproc_Varset.payment_method,
|
||||
payout_method => Varset#payproc_Varset.payout_method,
|
||||
wallet_id => Varset#payproc_Varset.wallet_id,
|
||||
shop_id => Varset#payproc_Varset.shop_id,
|
||||
identification_level => Varset#payproc_Varset.identification_level,
|
||||
@ -67,7 +64,6 @@ decode_varset(#payproc_Varset{} = Varset, VS) ->
|
||||
decode_varset(#payproc_ComputeShopTermsVarset{} = Varset, VS) ->
|
||||
genlib_map:compact(VS#{
|
||||
cost => Varset#payproc_ComputeShopTermsVarset.amount,
|
||||
payout_method => Varset#payproc_ComputeShopTermsVarset.payout_method,
|
||||
payment_tool => Varset#payproc_ComputeShopTermsVarset.payment_tool
|
||||
});
|
||||
decode_varset(#payproc_ComputeContractTermsVarset{} = Varset, VS) ->
|
||||
@ -75,7 +71,6 @@ decode_varset(#payproc_ComputeContractTermsVarset{} = Varset, VS) ->
|
||||
currency => Varset#payproc_ComputeContractTermsVarset.currency,
|
||||
cost => Varset#payproc_ComputeContractTermsVarset.amount,
|
||||
shop_id => Varset#payproc_ComputeContractTermsVarset.shop_id,
|
||||
payout_method => Varset#payproc_ComputeContractTermsVarset.payout_method,
|
||||
payment_tool => Varset#payproc_ComputeContractTermsVarset.payment_tool,
|
||||
wallet_id => Varset#payproc_ComputeContractTermsVarset.wallet_id,
|
||||
bin_data => Varset#payproc_ComputeContractTermsVarset.bin_data
|
||||
@ -108,7 +103,6 @@ encode_decode_test() ->
|
||||
payment_system = #domain_PaymentSystemRef{id = <<"visa">>}
|
||||
}}
|
||||
},
|
||||
payout_method => #domain_PayoutMethodRef{id = russian_bank_account},
|
||||
wallet_id => <<"wallet_id">>,
|
||||
shop_id => <<"shop_id">>,
|
||||
identification_level => full,
|
||||
|
@ -60,20 +60,18 @@ create(
|
||||
create_account(#payproc_WalletAccountParams{currency = Currency}) ->
|
||||
SymbolicCode = Currency#domain_CurrencyRef.symbolic_code,
|
||||
SettlementID = pm_accounting:create_account(SymbolicCode),
|
||||
PayoutID = pm_accounting:create_account(SymbolicCode),
|
||||
#domain_WalletAccount{
|
||||
currency = Currency,
|
||||
settlement = SettlementID,
|
||||
payout = PayoutID
|
||||
payout = 0
|
||||
};
|
||||
create_account(#claimmgmt_WalletAccountParams{currency = Currency}) ->
|
||||
SymbolicCode = Currency#domain_CurrencyRef.symbolic_code,
|
||||
SettlementID = pm_accounting:create_account(SymbolicCode),
|
||||
PayoutID = pm_accounting:create_account(SymbolicCode),
|
||||
#domain_WalletAccount{
|
||||
currency = Currency,
|
||||
settlement = SettlementID,
|
||||
payout = PayoutID
|
||||
payout = 0
|
||||
}.
|
||||
|
||||
-spec create_fake_account(wallet_account_params()) -> wallet_account().
|
||||
|
@ -30,8 +30,6 @@
|
||||
-export([contract_already_exists/1]).
|
||||
-export([contract_already_terminated/1]).
|
||||
-export([shop_already_exists/1]).
|
||||
-export([invalid_shop_payout_tool_not_in_contract/1]).
|
||||
-export([invalid_shop_payout_tool_currency_mismatch/1]).
|
||||
-export([wallet_account_creation/1]).
|
||||
-export([additional_info_modification/1]).
|
||||
|
||||
@ -42,11 +40,7 @@
|
||||
-define(REAL_CONTRACTOR_ID2, <<"CONTRACTOR3">>).
|
||||
-define(REAL_CONTRACT_ID1, <<"CONTRACT2">>).
|
||||
-define(REAL_CONTRACT_ID2, <<"CONTRACT3">>).
|
||||
-define(REAL_PAYOUT_TOOL_ID1, <<"PAYOUTTOOL2">>).
|
||||
-define(REAL_PAYOUT_TOOL_ID2, <<"PAYOUTTOOL3">>).
|
||||
-define(REAL_PAYOUT_TOOL_ID4, <<"PAYOUTTOOL4">>).
|
||||
-define(REAL_SHOP_ID, <<"SHOP2">>).
|
||||
-define(REAL_SHOP_ID4, <<"SHOP4">>).
|
||||
|
||||
%%% CT
|
||||
|
||||
@ -72,8 +66,6 @@ all() ->
|
||||
contract_already_exists,
|
||||
contract_already_terminated,
|
||||
shop_already_exists,
|
||||
invalid_shop_payout_tool_not_in_contract,
|
||||
invalid_shop_payout_tool_currency_mismatch,
|
||||
wallet_account_creation,
|
||||
additional_info_modification
|
||||
].
|
||||
@ -157,45 +149,32 @@ contractor_modification(C) ->
|
||||
-spec contract_one_creation(config()) -> _.
|
||||
contract_one_creation(C) ->
|
||||
ContractParams = make_contract_params(?REAL_CONTRACTOR_ID1),
|
||||
PayoutToolParams = make_payout_tool_params(),
|
||||
ContractID = ?REAL_CONTRACT_ID1,
|
||||
PayoutToolID1 = ?REAL_PAYOUT_TOOL_ID1,
|
||||
PayoutToolID2 = ?REAL_PAYOUT_TOOL_ID2,
|
||||
Modifications = [
|
||||
?cm_contract_creation(ContractID, ContractParams),
|
||||
?cm_contract_modification(ContractID, ?cm_payout_tool_creation(PayoutToolID1, PayoutToolParams)),
|
||||
?cm_contract_modification(ContractID, ?cm_payout_tool_creation(PayoutToolID2, PayoutToolParams))
|
||||
?cm_contract_creation(ContractID, ContractParams)
|
||||
],
|
||||
PartyID = cfg(party_id, C),
|
||||
Claim = claim(Modifications, PartyID),
|
||||
ok = accept_claim(Claim, C),
|
||||
ok = commit_claim(Claim, C),
|
||||
{ok, #domain_Contract{
|
||||
id = ContractID,
|
||||
payout_tools = PayoutTools
|
||||
}} = get_contract(PartyID, ContractID, C),
|
||||
true = lists:keymember(PayoutToolID1, #domain_PayoutTool.id, PayoutTools),
|
||||
true = lists:keymember(PayoutToolID2, #domain_PayoutTool.id, PayoutTools).
|
||||
id = ContractID
|
||||
}} = get_contract(PartyID, ContractID, C).
|
||||
|
||||
-spec contract_two_creation(config()) -> _.
|
||||
contract_two_creation(C) ->
|
||||
ContractParams = make_contract_params(?REAL_CONTRACTOR_ID1),
|
||||
PayoutToolParams = make_payout_tool_params(),
|
||||
ContractID = ?REAL_CONTRACT_ID2,
|
||||
PayoutToolID1 = ?REAL_PAYOUT_TOOL_ID1,
|
||||
Modifications = [
|
||||
?cm_contract_creation(ContractID, ContractParams),
|
||||
?cm_contract_modification(ContractID, ?cm_payout_tool_creation(PayoutToolID1, PayoutToolParams))
|
||||
?cm_contract_creation(ContractID, ContractParams)
|
||||
],
|
||||
PartyID = cfg(party_id, C),
|
||||
Claim = claim(Modifications, PartyID),
|
||||
ok = accept_claim(Claim, C),
|
||||
ok = commit_claim(Claim, C),
|
||||
{ok, #domain_Contract{
|
||||
id = ContractID,
|
||||
payout_tools = PayoutTools
|
||||
}} = get_contract(PartyID, ContractID, C),
|
||||
true = lists:keymember(PayoutToolID1, #domain_PayoutTool.id, PayoutTools).
|
||||
id = ContractID
|
||||
}} = get_contract(PartyID, ContractID, C).
|
||||
|
||||
-spec contract_contractor_modification(config()) -> _.
|
||||
contract_contractor_modification(C) ->
|
||||
@ -284,20 +263,15 @@ shop_creation(C) ->
|
||||
Location = {url, <<"https://example.com">>},
|
||||
ContractID = ?REAL_CONTRACT_ID1,
|
||||
ShopID = ?REAL_SHOP_ID,
|
||||
PayoutToolID1 = ?REAL_PAYOUT_TOOL_ID1,
|
||||
ShopParams = #claimmgmt_ShopParams{
|
||||
category = Category,
|
||||
location = Location,
|
||||
details = Details,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID1
|
||||
contract_id = ContractID
|
||||
},
|
||||
Schedule = ?bussched(1),
|
||||
ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule},
|
||||
Modifications = [
|
||||
?cm_shop_creation(ShopID, ShopParams),
|
||||
?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>)),
|
||||
?cm_shop_modification(ShopID, {payout_schedule_modification, ScheduleParams})
|
||||
?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>))
|
||||
],
|
||||
Claim = claim(Modifications, PartyID),
|
||||
ok = accept_claim(Claim, C),
|
||||
@ -308,9 +282,7 @@ shop_creation(C) ->
|
||||
location = Location,
|
||||
category = Category,
|
||||
account = #domain_ShopAccount{currency = ?cur(<<"RUB">>)},
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID1,
|
||||
payout_schedule = Schedule
|
||||
contract_id = ContractID
|
||||
}} = get_shop(PartyID, ShopID, C).
|
||||
|
||||
-spec shop_complex_modification(config()) -> _.
|
||||
@ -323,9 +295,6 @@ shop_complex_modification(C) ->
|
||||
description = <<"Updated shop description.">>
|
||||
},
|
||||
NewLocation = {url, <<"http://localhost">>},
|
||||
PayoutToolID2 = ?REAL_PAYOUT_TOOL_ID2,
|
||||
Schedule = ?bussched(2),
|
||||
ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule},
|
||||
CashRegisterModificationUnit = #claimmgmt_CashRegisterModificationUnit{
|
||||
id = <<"1">>,
|
||||
modification = ?cm_cash_register_unit_creation(1, #{})
|
||||
@ -342,8 +311,6 @@ shop_complex_modification(C) ->
|
||||
?cm_shop_modification(ShopID, {category_modification, NewCategory}),
|
||||
?cm_shop_modification(ShopID, {details_modification, NewDetails}),
|
||||
?cm_shop_modification(ShopID, {location_modification, NewLocation}),
|
||||
?cm_shop_modification(ShopID, {payout_tool_modification, PayoutToolID2}),
|
||||
?cm_shop_modification(ShopID, {payout_schedule_modification, ScheduleParams}),
|
||||
?cm_shop_modification(ShopID, {cash_register_modification_unit, CashRegisterModificationUnit}),
|
||||
?cm_shop_modification(ShopID, {turnover_limits_modification, TurnoverLimits})
|
||||
],
|
||||
@ -354,8 +321,6 @@ shop_complex_modification(C) ->
|
||||
category = NewCategory,
|
||||
details = NewDetails,
|
||||
location = NewLocation,
|
||||
payout_tool_id = PayoutToolID2,
|
||||
payout_schedule = Schedule,
|
||||
turnover_limits = TurnoverLimits
|
||||
}} = get_shop(PartyID, ShopID, C).
|
||||
|
||||
@ -377,90 +342,20 @@ invalid_cash_register_modification(C) ->
|
||||
{exception, ?cm_invalid_party_changeset(?cm_invalid_shop_not_exists(AnotherShopID), [{party_modification, Mod}])} =
|
||||
accept_claim(Claim, C).
|
||||
|
||||
-spec invalid_shop_payout_tool_not_in_contract(config()) -> _.
|
||||
invalid_shop_payout_tool_not_in_contract(C) ->
|
||||
PartyID = cfg(party_id, C),
|
||||
Details = #domain_ShopDetails{
|
||||
name = <<"SOME SHOP NAME">>,
|
||||
description = <<"Very meaningfull description of the shop.">>
|
||||
},
|
||||
Category = ?cat(2),
|
||||
Location = {url, <<"https://example.com">>},
|
||||
ContractID = ?REAL_CONTRACT_ID1,
|
||||
ShopID = ?REAL_SHOP_ID4,
|
||||
ShopParams = #claimmgmt_ShopParams{
|
||||
category = Category,
|
||||
location = Location,
|
||||
details = Details,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = ?REAL_PAYOUT_TOOL_ID1
|
||||
},
|
||||
Schedule = ?bussched(1),
|
||||
ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule},
|
||||
Modifications = [
|
||||
?cm_shop_creation(ShopID, ShopParams),
|
||||
?cm_shop_account_creation(ShopID, ?cur(<<"USD">>)),
|
||||
?cm_shop_modification(ShopID, {payout_schedule_modification, ScheduleParams})
|
||||
],
|
||||
Claim = claim(Modifications, PartyID),
|
||||
{exception,
|
||||
?cm_invalid_party_changeset(
|
||||
?cm_invalid_shop_payout_tool_currency_mismatch(
|
||||
ShopID, ?REAL_PAYOUT_TOOL_ID1, ?cur(<<"USD">>), ?cur(<<"RUB">>)
|
||||
),
|
||||
_
|
||||
)} =
|
||||
accept_claim(Claim, C).
|
||||
|
||||
-spec invalid_shop_payout_tool_currency_mismatch(config()) -> _.
|
||||
invalid_shop_payout_tool_currency_mismatch(C) ->
|
||||
PartyID = cfg(party_id, C),
|
||||
Details = #domain_ShopDetails{
|
||||
name = <<"SOME SHOP NAME">>,
|
||||
description = <<"Very meaningfull description of the shop.">>
|
||||
},
|
||||
Category = ?cat(2),
|
||||
Location = {url, <<"https://example.com">>},
|
||||
ContractID = ?REAL_CONTRACT_ID1,
|
||||
ShopID = ?REAL_SHOP_ID4,
|
||||
ShopParams = #claimmgmt_ShopParams{
|
||||
category = Category,
|
||||
location = Location,
|
||||
details = Details,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = ?REAL_PAYOUT_TOOL_ID4
|
||||
},
|
||||
Schedule = ?bussched(1),
|
||||
ScheduleParams = #claimmgmt_ScheduleModification{schedule = Schedule},
|
||||
Modifications = [
|
||||
?cm_shop_creation(ShopID, ShopParams),
|
||||
?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>)),
|
||||
?cm_shop_modification(ShopID, {payout_schedule_modification, ScheduleParams})
|
||||
],
|
||||
Claim = claim(Modifications, PartyID),
|
||||
{exception,
|
||||
?cm_invalid_party_changeset(
|
||||
?cm_invalid_shop_payout_tool_not_in_contract(ShopID, ContractID, ?REAL_PAYOUT_TOOL_ID4), _
|
||||
)} =
|
||||
accept_claim(Claim, C).
|
||||
|
||||
-spec shop_contract_modification(config()) -> _.
|
||||
shop_contract_modification(C) ->
|
||||
PartyID = cfg(party_id, C),
|
||||
ShopID = ?REAL_SHOP_ID,
|
||||
ContractID = ?REAL_CONTRACT_ID2,
|
||||
PayoutToolID = ?REAL_PAYOUT_TOOL_ID1,
|
||||
ShopContractParams = #claimmgmt_ShopContractModification{
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
},
|
||||
Modifications = [?cm_shop_modification(ShopID, {contract_modification, ShopContractParams})],
|
||||
Claim = claim(Modifications, PartyID),
|
||||
ok = accept_claim(Claim, C),
|
||||
ok = commit_claim(Claim, C),
|
||||
{ok, #domain_Shop{
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
}} = get_shop(PartyID, ShopID, C).
|
||||
|
||||
-spec contract_termination(config()) -> _.
|
||||
@ -524,16 +419,13 @@ shop_already_exists(C) ->
|
||||
category = ?cat(2),
|
||||
location = {url, <<"https://example.com">>},
|
||||
details = Details,
|
||||
contract_id = ?REAL_CONTRACT_ID1,
|
||||
payout_tool_id = ?REAL_PAYOUT_TOOL_ID1
|
||||
contract_id = ?REAL_CONTRACT_ID1
|
||||
},
|
||||
ScheduleParams = #claimmgmt_ScheduleModification{schedule = ?bussched(1)},
|
||||
Mod = ?cm_shop_modification(ShopID, {creation, ShopParams}),
|
||||
|
||||
Modifications = [
|
||||
Mod,
|
||||
?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>)),
|
||||
?cm_shop_modification(ShopID, {payout_schedule_modification, ScheduleParams})
|
||||
?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>))
|
||||
],
|
||||
Claim = claim(Modifications, PartyID),
|
||||
{exception, ?cm_invalid_party_changeset(?cm_invalid_shop_already_exists(ShopID), [{party_modification, Mod}])} =
|
||||
@ -662,18 +554,6 @@ make_contract_params(ContractorID, TemplateRef, PaymentInstitutionRef) ->
|
||||
payment_institution = PaymentInstitutionRef
|
||||
}.
|
||||
|
||||
make_payout_tool_params() ->
|
||||
#claimmgmt_PayoutToolParams{
|
||||
currency = ?cur(<<"RUB">>),
|
||||
tool_info =
|
||||
{russian_bank_account, #domain_RussianBankAccount{
|
||||
account = <<"4276300010908312893">>,
|
||||
bank_name = <<"SomeBank">>,
|
||||
bank_post_account = <<"123129876">>,
|
||||
bank_bik = <<"66642666">>
|
||||
}}
|
||||
}.
|
||||
|
||||
-spec construct_domain_fixture() -> [pm_domain:object()].
|
||||
construct_domain_fixture() ->
|
||||
TestTermSet = #domain_TermSet{
|
||||
@ -719,55 +599,6 @@ construct_domain_fixture() ->
|
||||
)
|
||||
]}
|
||||
},
|
||||
payouts = #domain_PayoutsServiceTerms{
|
||||
payout_methods =
|
||||
{decisions, [
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ =
|
||||
{condition,
|
||||
{payment_tool,
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition = {issuer_bank_is, ?bank(1)}
|
||||
}}}},
|
||||
then_ =
|
||||
{value, ordsets:from_list([?pomt(russian_bank_account), ?pomt(international_bank_account)])}
|
||||
},
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ =
|
||||
{condition,
|
||||
{payment_tool,
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition = {empty_cvv_is, true}
|
||||
}}}},
|
||||
then_ = {value, ordsets:from_list([])}
|
||||
},
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ = {condition, {payment_tool, {bank_card, #domain_BankCardCondition{}}}},
|
||||
then_ = {value, ordsets:from_list([?pomt(russian_bank_account)])}
|
||||
},
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ = {condition, {payment_tool, {payment_terminal, #domain_PaymentTerminalCondition{}}}},
|
||||
then_ = {value, ordsets:from_list([?pomt(international_bank_account)])}
|
||||
},
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ = {constant, true},
|
||||
then_ = {value, ordsets:from_list([])}
|
||||
}
|
||||
]},
|
||||
fees =
|
||||
{value, [
|
||||
?cfpost(
|
||||
{merchant, settlement},
|
||||
{merchant, payout},
|
||||
?share(750, 1000, operation_amount)
|
||||
),
|
||||
?cfpost(
|
||||
{merchant, settlement},
|
||||
{system, settlement},
|
||||
?share(250, 1000, operation_amount)
|
||||
)
|
||||
]}
|
||||
},
|
||||
wallets = #domain_WalletServiceTerms{
|
||||
currencies = {value, ordsets:from_list([?cur(<<"RUB">>)])}
|
||||
}
|
||||
@ -786,9 +617,6 @@ construct_domain_fixture() ->
|
||||
pm_ct_fixture:construct_payment_method(?pmt(payment_terminal, ?pmt_srv(<<"euroset">>))),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, ?bank_card_no_cvv(<<"visa">>))),
|
||||
|
||||
pm_ct_fixture:construct_payout_method(?pomt(russian_bank_account)),
|
||||
pm_ct_fixture:construct_payout_method(?pomt(international_bank_account)),
|
||||
|
||||
pm_ct_fixture:construct_proxy(?prx(1), <<"Dummy proxy">>),
|
||||
pm_ct_fixture:construct_inspector(?insp(1), <<"Dummy Inspector">>, ?prx(1)),
|
||||
pm_ct_fixture:construct_system_account_set(?sas(1)),
|
||||
|
@ -11,7 +11,6 @@
|
||||
-define(pmt(C, T), #domain_PaymentMethodRef{id = {C, T}}).
|
||||
-define(pmt_sys(ID), #domain_PaymentSystemRef{id = ID}).
|
||||
-define(pmt_srv(ID), #domain_PaymentServiceRef{id = ID}).
|
||||
-define(pomt(M), #domain_PayoutMethodRef{id = M}).
|
||||
-define(cat(ID), #domain_CategoryRef{id = ID}).
|
||||
-define(prx(ID), #domain_ProxyRef{id = ID}).
|
||||
-define(prv(ID), #domain_ProviderRef{id = ID}).
|
||||
|
@ -12,7 +12,6 @@
|
||||
-export([construct_category/2]).
|
||||
-export([construct_category/3]).
|
||||
-export([construct_payment_method/1]).
|
||||
-export([construct_payout_method/1]).
|
||||
-export([construct_proxy/2]).
|
||||
-export([construct_proxy/4]).
|
||||
-export([construct_inspector/3]).
|
||||
@ -179,18 +178,6 @@ construct_tokenized_service(Ref, Name) ->
|
||||
}
|
||||
}}.
|
||||
|
||||
-spec construct_payout_method(dmsl_domain_thrift:'PayoutMethodRef'()) ->
|
||||
{payout_method, dmsl_domain_thrift:'PayoutMethodObject'()}.
|
||||
construct_payout_method(?pomt(M) = Ref) ->
|
||||
Def = erlang:atom_to_binary(M, unicode),
|
||||
{payout_method, #domain_PayoutMethodObject{
|
||||
ref = Ref,
|
||||
data = #domain_PayoutMethodDefinition{
|
||||
name = Def,
|
||||
description = Def
|
||||
}
|
||||
}}.
|
||||
|
||||
-spec construct_proxy(proxy(), name()) -> {proxy, dmsl_domain_thrift:'ProxyObject'()}.
|
||||
construct_proxy(Ref, Name) ->
|
||||
construct_proxy(Ref, Name, <<>>, #{}).
|
||||
|
@ -14,12 +14,10 @@
|
||||
-export([create_contract/3]).
|
||||
-export([get_first_contract_id/1]).
|
||||
-export([get_first_battle_ready_contract_id/1]).
|
||||
-export([get_first_payout_tool_id/2]).
|
||||
-export([adjust_contract/3]).
|
||||
|
||||
-export([make_battle_ready_contract_params/2]).
|
||||
-export([make_battle_ready_contractor/0]).
|
||||
-export([make_battle_ready_payout_tool_params/0]).
|
||||
|
||||
-export([make_shop_details/1]).
|
||||
-export([make_shop_details/2]).
|
||||
@ -30,7 +28,6 @@
|
||||
|
||||
-include("pm_ct_domain.hrl").
|
||||
|
||||
-include_lib("damsel/include/dmsl_base_thrift.hrl").
|
||||
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
|
||||
|
||||
-export_type([config/0]).
|
||||
@ -203,15 +200,12 @@ make_party_params() ->
|
||||
create_battle_ready_shop(Category, Currency, TemplateRef, PaymentInstitutionRef, Client) ->
|
||||
ContractID = pm_utils:unique_id(),
|
||||
ContractParams = make_battle_ready_contract_params(TemplateRef, PaymentInstitutionRef),
|
||||
PayoutToolID = pm_utils:unique_id(),
|
||||
PayoutToolParams = make_battle_ready_payout_tool_params(),
|
||||
ShopID = pm_utils:unique_id(),
|
||||
ShopParams = #payproc_ShopParams{
|
||||
category = Category,
|
||||
location = {url, <<>>},
|
||||
details = make_shop_details(<<"Battle Ready Shop">>),
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
},
|
||||
ShopAccountParams = #payproc_ShopAccountParams{currency = ?cur(Currency)},
|
||||
Changeset = [
|
||||
@ -219,14 +213,6 @@ create_battle_ready_shop(Category, Currency, TemplateRef, PaymentInstitutionRef,
|
||||
id = ContractID,
|
||||
modification = {creation, ContractParams}
|
||||
}},
|
||||
{contract_modification, #payproc_ContractModificationUnit{
|
||||
id = ContractID,
|
||||
modification =
|
||||
{payout_tool_modification, #payproc_PayoutToolModificationUnit{
|
||||
payout_tool_id = PayoutToolID,
|
||||
modification = {creation, PayoutToolParams}
|
||||
}}
|
||||
}},
|
||||
?shop_modification(ShopID, {creation, ShopParams}),
|
||||
?shop_modification(ShopID, {shop_account_creation, ShopAccountParams})
|
||||
],
|
||||
@ -259,8 +245,7 @@ get_first_battle_ready_contract_id(Client) ->
|
||||
fun({ID, Contract}, Acc) ->
|
||||
case Contract of
|
||||
#domain_Contract{
|
||||
contractor = {legal_entity, _},
|
||||
payout_tools = [#domain_PayoutTool{} | _]
|
||||
contractor = {legal_entity, _}
|
||||
} ->
|
||||
[ID | Acc];
|
||||
_ ->
|
||||
@ -307,16 +292,6 @@ ensure_claim_accepted(#payproc_Claim{id = ClaimID, revision = ClaimRevision, sta
|
||||
ok = pm_client_party:accept_claim(ClaimID, ClaimRevision, Client)
|
||||
end.
|
||||
|
||||
-spec get_first_payout_tool_id(contract_id(), Client :: pid()) -> dmsl_domain_thrift:'PayoutToolID'().
|
||||
get_first_payout_tool_id(ContractID, Client) ->
|
||||
#domain_Contract{payout_tools = PayoutTools} = pm_client_party:get_contract(ContractID, Client),
|
||||
case PayoutTools of
|
||||
[Tool | _] ->
|
||||
Tool#domain_PayoutTool.id;
|
||||
[] ->
|
||||
error(not_found)
|
||||
end.
|
||||
|
||||
-spec make_battle_ready_contract_params(
|
||||
dmsl_domain_thrift:'ContractTemplateRef'() | undefined,
|
||||
dmsl_domain_thrift:'PaymentInstitutionRef'()
|
||||
@ -349,19 +324,6 @@ make_battle_ready_contractor() ->
|
||||
russian_bank_account = BankAccount
|
||||
}}}.
|
||||
|
||||
-spec make_battle_ready_payout_tool_params() -> dmsl_payproc_thrift:'PayoutToolParams'().
|
||||
make_battle_ready_payout_tool_params() ->
|
||||
#payproc_PayoutToolParams{
|
||||
currency = ?cur(<<"RUB">>),
|
||||
tool_info =
|
||||
{russian_bank_account, #domain_RussianBankAccount{
|
||||
account = <<"4276300010908312893">>,
|
||||
bank_name = <<"SomeBank">>,
|
||||
bank_post_account = <<"123129876">>,
|
||||
bank_bik = <<"66642666">>
|
||||
}}
|
||||
}.
|
||||
|
||||
-spec make_shop_details(binary()) -> dmsl_domain_thrift:'ShopDetails'().
|
||||
make_shop_details(Name) ->
|
||||
make_shop_details(Name, undefined).
|
||||
|
@ -83,16 +83,12 @@
|
||||
-export([contract_expiration/1]).
|
||||
-export([contract_legal_agreement_binding/1]).
|
||||
-export([contract_report_preferences_modification/1]).
|
||||
-export([contract_payout_tool_creation/1]).
|
||||
-export([contract_payout_tool_modification/1]).
|
||||
-export([contract_adjustment_creation/1]).
|
||||
-export([contract_adjustment_expiration/1]).
|
||||
-export([contract_w2w_terms/1]).
|
||||
|
||||
-export([compute_payment_institution_terms/1]).
|
||||
-export([compute_payment_institution/1]).
|
||||
-export([compute_payout_cash_flow/1]).
|
||||
-export([compute_payout_cash_flow_payout_tool/1]).
|
||||
|
||||
-export([contractor_creation/1]).
|
||||
-export([contractor_modification/1]).
|
||||
@ -206,8 +202,6 @@ groups() ->
|
||||
contract_report_preferences_modification,
|
||||
contract_adjustment_creation,
|
||||
contract_adjustment_expiration,
|
||||
contract_payout_tool_creation,
|
||||
contract_payout_tool_modification,
|
||||
compute_payment_institution_terms,
|
||||
compute_payment_institution,
|
||||
contract_w2w_terms
|
||||
@ -223,8 +217,6 @@ groups() ->
|
||||
shop_terms_retrieval,
|
||||
shop_already_exists,
|
||||
shop_update,
|
||||
compute_payout_cash_flow,
|
||||
compute_payout_cash_flow_payout_tool,
|
||||
{group, shop_blocking_suspension}
|
||||
]},
|
||||
{shop_blocking_suspension, [sequence], [
|
||||
@ -492,14 +484,10 @@ end_per_testcase(_Name, _C) ->
|
||||
-spec contract_expiration(config()) -> _ | no_return().
|
||||
-spec contract_legal_agreement_binding(config()) -> _ | no_return().
|
||||
-spec contract_report_preferences_modification(config()) -> _ | no_return().
|
||||
-spec contract_payout_tool_creation(config()) -> _ | no_return().
|
||||
-spec contract_payout_tool_modification(config()) -> _ | no_return().
|
||||
-spec contract_adjustment_creation(config()) -> _ | no_return().
|
||||
-spec contract_adjustment_expiration(config()) -> _ | no_return().
|
||||
-spec compute_payment_institution_terms(config()) -> _ | no_return().
|
||||
-spec compute_payment_institution(config()) -> _ | no_return().
|
||||
-spec compute_payout_cash_flow(config()) -> _ | no_return().
|
||||
-spec compute_payout_cash_flow_payout_tool(config()) -> _ | no_return().
|
||||
-spec contract_w2w_terms(config()) -> _ | no_return().
|
||||
-spec contractor_creation(config()) -> _ | no_return().
|
||||
-spec contractor_modification(config()) -> _ | no_return().
|
||||
@ -608,13 +596,10 @@ party_get_revision(C) ->
|
||||
|
||||
create_change_set(ID) ->
|
||||
ContractParams = make_contract_params(),
|
||||
PayoutToolParams = pm_ct_helper:make_battle_ready_payout_tool_params(),
|
||||
BinaryID = erlang:integer_to_binary(ID),
|
||||
ContractID = <<?REAL_CONTRACT_ID/binary, BinaryID/binary>>,
|
||||
PayoutToolID = <<"1">>,
|
||||
[
|
||||
?contract_modification(ContractID, {creation, ContractParams}),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(PayoutToolID, PayoutToolParams))
|
||||
?contract_modification(ContractID, {creation, ContractParams})
|
||||
].
|
||||
|
||||
contract_not_found(C) ->
|
||||
@ -623,17 +608,13 @@ contract_not_found(C) ->
|
||||
contract_creation(C) ->
|
||||
Client = cfg(client, C),
|
||||
ContractParams = make_contract_params(),
|
||||
PayoutToolParams = pm_ct_helper:make_battle_ready_payout_tool_params(),
|
||||
ContractID = ?REAL_CONTRACT_ID,
|
||||
PayoutToolID = <<"1">>,
|
||||
Changeset = [
|
||||
?contract_modification(ContractID, {creation, ContractParams}),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(PayoutToolID, PayoutToolParams))
|
||||
?contract_modification(ContractID, {creation, ContractParams})
|
||||
],
|
||||
Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client),
|
||||
ok = accept_claim(Claim, Client),
|
||||
#domain_Contract{id = ContractID, payout_tools = PayoutTools} = pm_client_party:get_contract(ContractID, Client),
|
||||
true = lists:keymember(PayoutToolID, #domain_PayoutTool.id, PayoutTools).
|
||||
#domain_Contract{id = ContractID} = pm_client_party:get_contract(ContractID, Client).
|
||||
|
||||
contract_terms_retrieval(C) ->
|
||||
Client = cfg(client, C),
|
||||
@ -718,11 +699,9 @@ contract_already_terminated(C) ->
|
||||
contract_expiration(C) ->
|
||||
Client = cfg(client, C),
|
||||
ContractParams = make_contract_params(?tmpl(3)),
|
||||
PayoutToolParams = pm_ct_helper:make_battle_ready_payout_tool_params(),
|
||||
ContractID = <<"CONTRACT_EXPIRED">>,
|
||||
Changeset = [
|
||||
?contract_modification(ContractID, {creation, ContractParams}),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(<<"1">>, PayoutToolParams))
|
||||
?contract_modification(ContractID, {creation, ContractParams})
|
||||
],
|
||||
Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client),
|
||||
ok = accept_claim(Claim, Client),
|
||||
@ -772,88 +751,6 @@ contract_report_preferences_modification(C) ->
|
||||
report_preferences = Pref2
|
||||
} = pm_client_party:get_contract(ContractID, Client).
|
||||
|
||||
contract_payout_tool_creation(C) ->
|
||||
Client = cfg(client, C),
|
||||
ContractID = ?REAL_CONTRACT_ID,
|
||||
PayoutToolID1 = <<"2">>,
|
||||
PayoutToolParams1 = #payproc_PayoutToolParams{
|
||||
currency = ?cur(<<"RUB">>),
|
||||
tool_info =
|
||||
{russian_bank_account, #domain_RussianBankAccount{
|
||||
account = <<"4276300010908312893">>,
|
||||
bank_name = <<"SomeBank">>,
|
||||
bank_post_account = <<"123129876">>,
|
||||
bank_bik = <<"66642666">>
|
||||
}}
|
||||
},
|
||||
PayoutToolID2 = <<"3">>,
|
||||
PayoutToolParams2 = #payproc_PayoutToolParams{
|
||||
currency = ?cur(<<"USD">>),
|
||||
tool_info =
|
||||
{international_bank_account, #domain_InternationalBankAccount{
|
||||
bank = #domain_InternationalBankDetails{
|
||||
name = <<"SomeBank">>,
|
||||
address = <<"Bahamas">>,
|
||||
bic = <<"66642666">>
|
||||
},
|
||||
iban = <<"DC6664266612312312">>
|
||||
}}
|
||||
},
|
||||
PayoutToolID3 = <<"4">>,
|
||||
PayoutToolParams3 = #payproc_PayoutToolParams{
|
||||
currency = ?cur(<<"USD">>),
|
||||
tool_info =
|
||||
{wallet_info, #domain_WalletInfo{
|
||||
wallet_id = <<"123">>
|
||||
}}
|
||||
},
|
||||
Changeset = [
|
||||
?contract_modification(ContractID, ?payout_tool_creation(PayoutToolID1, PayoutToolParams1)),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(PayoutToolID2, PayoutToolParams2)),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(PayoutToolID3, PayoutToolParams3))
|
||||
],
|
||||
Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client),
|
||||
ok = accept_claim(Claim, Client),
|
||||
#domain_Contract{
|
||||
id = ContractID,
|
||||
payout_tools = PayoutTools
|
||||
} = pm_client_party:get_contract(ContractID, Client),
|
||||
true = lists:keymember(PayoutToolID1, #domain_PayoutTool.id, PayoutTools),
|
||||
true = lists:keymember(PayoutToolID2, #domain_PayoutTool.id, PayoutTools),
|
||||
true = lists:keymember(PayoutToolID3, #domain_PayoutTool.id, PayoutTools).
|
||||
|
||||
contract_payout_tool_modification(C) ->
|
||||
Client = cfg(client, C),
|
||||
ContractID = ?REAL_CONTRACT_ID,
|
||||
PayoutToolID = <<"3">>,
|
||||
ToolInfo =
|
||||
{international_bank_account, #domain_InternationalBankAccount{
|
||||
number = <<"123456789">>,
|
||||
bank = #domain_InternationalBankDetails{
|
||||
name = <<"ABetterBank">>,
|
||||
address = <<"Burkina Faso">>,
|
||||
bic = <<"BCAOBFBFBOB">>
|
||||
},
|
||||
correspondent_account = #domain_InternationalBankAccount{
|
||||
number = <<"1111222233334444">>
|
||||
},
|
||||
iban = <<"BF42BF0840101300463574000390">>
|
||||
}},
|
||||
Changeset = [
|
||||
?contract_modification(ContractID, ?payout_tool_info_modification(PayoutToolID, ToolInfo))
|
||||
],
|
||||
Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client),
|
||||
ok = accept_claim(Claim, Client),
|
||||
#domain_Contract{
|
||||
id = ContractID,
|
||||
payout_tools = PayoutTools
|
||||
} = pm_client_party:get_contract(ContractID, Client),
|
||||
#domain_PayoutTool{payout_tool_info = ToolInfo} = lists:keyfind(
|
||||
PayoutToolID,
|
||||
#domain_PayoutTool.id,
|
||||
PayoutTools
|
||||
).
|
||||
|
||||
contract_adjustment_creation(C) ->
|
||||
Client = cfg(client, C),
|
||||
ContractID = ?REAL_CONTRACT_ID,
|
||||
@ -953,22 +850,22 @@ check_all_payment_methods(C) ->
|
||||
TermsFun = fun(Type, Object) ->
|
||||
?assertMatch(
|
||||
#domain_TermSet{
|
||||
payouts = #domain_PayoutsServiceTerms{
|
||||
payout_methods =
|
||||
payments = #domain_PaymentsServiceTerms{
|
||||
payment_methods =
|
||||
{value, [_]}
|
||||
}
|
||||
},
|
||||
pm_client_party:compute_payment_institution_terms(
|
||||
?pinst(2),
|
||||
?pinst(5),
|
||||
#payproc_Varset{payment_method = ?pmt(Type, Object)},
|
||||
Client
|
||||
)
|
||||
),
|
||||
ok
|
||||
end,
|
||||
#domain_TermSet{payouts = #domain_PayoutsServiceTerms{payout_methods = {value, []}}} =
|
||||
#domain_TermSet{payments = #domain_PaymentsServiceTerms{payment_methods = {value, []}}} =
|
||||
pm_client_party:compute_payment_institution_terms(
|
||||
?pinst(2),
|
||||
?pinst(5),
|
||||
#payproc_Varset{payment_method = ?pmt(digital_wallet, ?pmt_srv(<<"wrong-ref">>))},
|
||||
Client
|
||||
),
|
||||
@ -982,50 +879,6 @@ check_all_payment_methods(C) ->
|
||||
TermsFun(bank_card, ?bank_card_no_cvv(<<"visa">>)),
|
||||
TermsFun(generic, ?gnrc(?pmt_srv(<<"generic">>))).
|
||||
|
||||
compute_payout_cash_flow(C) ->
|
||||
Client = cfg(client, C),
|
||||
Params = #payproc_PayoutParams{
|
||||
id = ?REAL_SHOP_ID,
|
||||
amount = #domain_Cash{amount = 10000, currency = ?cur(<<"RUB">>)},
|
||||
timestamp = pm_datetime:format_now()
|
||||
},
|
||||
[
|
||||
#domain_FinalCashFlowPosting{
|
||||
source = #domain_FinalCashFlowAccount{account_type = {merchant, settlement}},
|
||||
destination = #domain_FinalCashFlowAccount{account_type = {merchant, payout}},
|
||||
volume = #domain_Cash{amount = 7500, currency = ?cur(<<"RUB">>)}
|
||||
},
|
||||
#domain_FinalCashFlowPosting{
|
||||
source = #domain_FinalCashFlowAccount{account_type = {merchant, settlement}},
|
||||
destination = #domain_FinalCashFlowAccount{account_type = {system, settlement}},
|
||||
volume = #domain_Cash{amount = 2500, currency = ?cur(<<"RUB">>)}
|
||||
}
|
||||
] = pm_client_party:compute_payout_cash_flow(Params, Client).
|
||||
|
||||
compute_payout_cash_flow_payout_tool(C) ->
|
||||
Client = cfg(client, C),
|
||||
Params = #payproc_PayoutParams{
|
||||
id = ?REAL_SHOP_ID,
|
||||
amount = #domain_Cash{amount = 10000, currency = ?cur(<<"RUB">>)},
|
||||
timestamp = pm_datetime:format_now(),
|
||||
payout_tool_id = <<"1">>
|
||||
},
|
||||
[
|
||||
#domain_FinalCashFlowPosting{
|
||||
source = #domain_FinalCashFlowAccount{account_type = {merchant, settlement}},
|
||||
destination = #domain_FinalCashFlowAccount{account_type = {merchant, payout}},
|
||||
volume = #domain_Cash{amount = 7500, currency = ?cur(<<"RUB">>)}
|
||||
},
|
||||
#domain_FinalCashFlowPosting{
|
||||
source = #domain_FinalCashFlowAccount{account_type = {merchant, settlement}},
|
||||
destination = #domain_FinalCashFlowAccount{account_type = {system, settlement}},
|
||||
volume = #domain_Cash{amount = 2500, currency = ?cur(<<"RUB">>)}
|
||||
}
|
||||
] = pm_client_party:compute_payout_cash_flow(Params, Client),
|
||||
{exception, #payproc_PayoutToolNotFound{}} = pm_client_party:compute_payout_cash_flow(
|
||||
Params#payproc_PayoutParams{payout_tool_id = <<"Nope">>}, Client
|
||||
).
|
||||
|
||||
contract_w2w_terms(C) ->
|
||||
Client = cfg(client, C),
|
||||
ContractID = ?REAL_CONTRACT_ID,
|
||||
@ -1103,8 +956,7 @@ shop_creation(C) ->
|
||||
category = ?cat(2),
|
||||
location = {url, <<"https://somename.somedomain/p/123?redirect=1">>},
|
||||
details = Details,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = pm_ct_helper:get_first_payout_tool_id(ContractID, Client)
|
||||
contract_id = ContractID
|
||||
},
|
||||
ShopAccountParams = #payproc_ShopAccountParams{currency = ?cur(<<"RUB">>)},
|
||||
Changeset = [
|
||||
@ -1162,8 +1014,7 @@ shop_already_exists(C) ->
|
||||
category = ?cat(2),
|
||||
location = {url, <<"https://s0mename.s0med0main">>},
|
||||
details = Details,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = pm_ct_helper:get_first_payout_tool_id(ContractID, Client)
|
||||
contract_id = ContractID
|
||||
},
|
||||
Changeset = [?shop_modification(ShopID, {creation, Params})],
|
||||
?invalid_changeset(?invalid_shop(ShopID, {already_exists, _})) = pm_client_party:create_claim(Changeset, Client).
|
||||
@ -1183,21 +1034,17 @@ shop_update(C) ->
|
||||
ok = accept_claim(Claim2, Client),
|
||||
#domain_Shop{location = Location, details = Details} = pm_client_party:get_shop(ShopID, Client),
|
||||
|
||||
PayoutToolParams = pm_ct_helper:make_battle_ready_payout_tool_params(),
|
||||
ContractID = <<"CONTRACT_IN_DIFFERENT_PAYMENT_INST">>,
|
||||
PayoutToolID = <<"1">>,
|
||||
Changeset3 = [
|
||||
?contract_modification(ContractID, {creation, make_contract_params(?tmpl(2), ?pinst(3))}),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(PayoutToolID, PayoutToolParams)),
|
||||
?shop_modification(ShopID, ?shop_contract_modification(ContractID, PayoutToolID))
|
||||
?shop_modification(ShopID, ?shop_contract_modification(ContractID))
|
||||
],
|
||||
Claim3 = assert_claim_pending(pm_client_party:create_claim(Changeset3, Client), Client),
|
||||
ok = accept_claim(Claim3, Client),
|
||||
#domain_Shop{
|
||||
location = Location,
|
||||
details = Details,
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = PayoutToolID
|
||||
contract_id = ContractID
|
||||
} = pm_client_party:get_shop(ShopID, Client).
|
||||
|
||||
shop_update_before_confirm(C) ->
|
||||
@ -1207,8 +1054,7 @@ shop_update_before_confirm(C) ->
|
||||
Params = #payproc_ShopParams{
|
||||
location = {url, <<"">>},
|
||||
details = pm_ct_helper:make_shop_details(<<"THRIFT SHOP">>, <<"Hot. Fancy. Almost free.">>),
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = pm_ct_helper:get_first_payout_tool_id(ContractID, Client)
|
||||
contract_id = ContractID
|
||||
},
|
||||
Changeset1 = [?shop_modification(ShopID, {creation, Params})],
|
||||
Claim0 = assert_claim_pending(pm_client_party:create_claim(Changeset1, Client), Client),
|
||||
@ -1232,10 +1078,8 @@ shop_update_with_bad_params(C) ->
|
||||
ShopID = <<"SHOP2">>,
|
||||
ContractID = <<"CONTRACT3">>,
|
||||
ContractParams = make_contract_params(#domain_ContractTemplateRef{id = 5}),
|
||||
PayoutToolParams = pm_ct_helper:make_battle_ready_payout_tool_params(),
|
||||
Changeset = [
|
||||
?contract_modification(ContractID, {creation, ContractParams}),
|
||||
?contract_modification(ContractID, ?payout_tool_creation(<<"1">>, PayoutToolParams))
|
||||
?contract_modification(ContractID, {creation, ContractParams})
|
||||
],
|
||||
Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client),
|
||||
ok = accept_claim(Claim, Client),
|
||||
@ -1282,8 +1126,7 @@ claim_revocation(C) ->
|
||||
Params = #payproc_ShopParams{
|
||||
location = {url, <<"https://url3">>},
|
||||
details = pm_ct_helper:make_shop_details(<<"OOPS">>),
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = <<"1">>
|
||||
contract_id = ContractID
|
||||
},
|
||||
Changeset = [?shop_modification(ShopID, {creation, Params})],
|
||||
Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client),
|
||||
@ -1299,16 +1142,14 @@ complex_claim_acceptance(C) ->
|
||||
location = {url, <<"https://url4">>},
|
||||
category = ?cat(2),
|
||||
details = Details1 = pm_ct_helper:make_shop_details(<<"SHOP4">>),
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = <<"1">>
|
||||
contract_id = ContractID
|
||||
},
|
||||
ShopID2 = <<"SHOP5">>,
|
||||
Params2 = #payproc_ShopParams{
|
||||
location = {url, <<"http://url5">>},
|
||||
category = ?cat(3),
|
||||
details = Details2 = pm_ct_helper:make_shop_details(<<"SHOP5">>),
|
||||
contract_id = ContractID,
|
||||
payout_tool_id = <<"1">>
|
||||
contract_id = ContractID
|
||||
},
|
||||
PartyName = <<"PartyName">>,
|
||||
PartyComment = <<"PartyComment">>,
|
||||
@ -2284,22 +2125,76 @@ construct_domain_fixture() ->
|
||||
}
|
||||
},
|
||||
|
||||
PayoutMDFun = fun(PaymentTool, PayoutMethods) ->
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ = {condition, {payment_tool, PaymentTool}},
|
||||
then_ = {value, ordsets:from_list(PayoutMethods)}
|
||||
}
|
||||
end,
|
||||
|
||||
PaymentMDFun = fun(PaymentTool, PaymentMethods) ->
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {condition, {payment_tool, PaymentTool}},
|
||||
then_ = {value, ordsets:from_list(PaymentMethods)}
|
||||
}
|
||||
end,
|
||||
|
||||
TermSet = #domain_TermSet{
|
||||
AllMethodsTermSet = #domain_TermSet{
|
||||
payments = #domain_PaymentsServiceTerms{
|
||||
payment_methods =
|
||||
{decisions, [
|
||||
%% For check_all_payment_methods
|
||||
mk_payment_decision(
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition = {
|
||||
payment_system,
|
||||
#domain_PaymentSystemCondition{
|
||||
payment_system_is = ?pmt_sys(<<"visa">>)
|
||||
}
|
||||
}
|
||||
}},
|
||||
[?pmt(bank_card, ?bank_card(<<"visa">>))]
|
||||
),
|
||||
mk_payment_decision(
|
||||
{payment_terminal, #domain_PaymentTerminalCondition{
|
||||
definition = {
|
||||
payment_service_is,
|
||||
?pmt_srv(<<"alipay">>)
|
||||
}
|
||||
}},
|
||||
[?pmt(payment_terminal, ?pmt_srv(<<"alipay">>))]
|
||||
),
|
||||
mk_payment_decision(
|
||||
{digital_wallet, #domain_DigitalWalletCondition{
|
||||
definition =
|
||||
{payment_service_is, ?pmt_srv(<<"qiwi">>)}
|
||||
}},
|
||||
[?pmt(digital_wallet, ?pmt_srv(<<"qiwi">>))]
|
||||
),
|
||||
mk_payment_decision(
|
||||
{mobile_commerce, #domain_MobileCommerceCondition{
|
||||
definition = {operator_is, ?mob(<<"mts">>)}
|
||||
}},
|
||||
[?pmt(mobile, ?mob(<<"mts">>))]
|
||||
),
|
||||
mk_payment_decision(
|
||||
{crypto_currency, #domain_CryptoCurrencyCondition{
|
||||
definition = {crypto_currency_is, ?crypta(<<"bitcoin">>)}
|
||||
}},
|
||||
[?pmt(crypto_currency, ?crypta(<<"bitcoin">>))]
|
||||
),
|
||||
mk_payment_decision(
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition =
|
||||
{payment_system, #domain_PaymentSystemCondition{
|
||||
token_service_is = ?token_srv(<<"applepay">>)
|
||||
}}
|
||||
}},
|
||||
[?pmt(bank_card, ?token_bank_card(<<"visa">>, <<"applepay">>))]
|
||||
),
|
||||
mk_payment_decision(
|
||||
{generic, {payment_service_is, ?pmt_srv(<<"generic">>)}},
|
||||
[?pmt(generic, ?gnrc(?pmt_srv(<<"generic">>)))]
|
||||
),
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {condition, {payment_tool, {bank_card, #domain_BankCardCondition{}}}},
|
||||
then_ = {value, ordsets:from_list([?pmt(bank_card, ?bank_card(<<"mastercard">>))])}
|
||||
},
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {condition, {payment_tool, {payment_terminal, #domain_PaymentTerminalCondition{}}}},
|
||||
then_ = {value, ordsets:from_list([?pmt(payment_terminal, ?pmt_srv(<<"euroset">>))])}
|
||||
},
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {constant, true},
|
||||
then_ = {value, ordsets:from_list([])}
|
||||
}
|
||||
]},
|
||||
cash_limit =
|
||||
{value, #domain_CashRange{
|
||||
lower = {inclusive, #domain_Cash{amount = 1000, currency = ?cur(<<"RUB">>)}},
|
||||
@ -2313,96 +2208,44 @@ construct_domain_fixture() ->
|
||||
?share(45, 1000, operation_amount)
|
||||
)
|
||||
]}
|
||||
}
|
||||
},
|
||||
payouts = #domain_PayoutsServiceTerms{
|
||||
payout_methods =
|
||||
{decisions, [
|
||||
PayoutMDFun(
|
||||
{bank_card, #domain_BankCardCondition{definition = {issuer_bank_is, ?bank(1)}}},
|
||||
[?pomt(russian_bank_account), ?pomt(international_bank_account)]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{bank_card, #domain_BankCardCondition{definition = {empty_cvv_is, true}}},
|
||||
[?pomt(wallet_info)]
|
||||
),
|
||||
|
||||
%% For check_all_payment_methods
|
||||
PayoutMDFun(
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition = {
|
||||
payment_system,
|
||||
#domain_PaymentSystemCondition{
|
||||
payment_system_is = ?pmt_sys(<<"visa">>)
|
||||
}
|
||||
}
|
||||
}},
|
||||
[?pomt(international_bank_account)]
|
||||
TermSet = #domain_TermSet{
|
||||
recurrent_paytools = #domain_RecurrentPaytoolsServiceTerms{
|
||||
payment_methods =
|
||||
{decisions, [
|
||||
mk_payment_decision(
|
||||
{bank_card, #domain_BankCardCondition{definition = {issuer_bank_is, ?bank(1)}}},
|
||||
[?pmt(bank_card, ?bank_card(<<"visa">>)), ?pmt(crypto_currency, ?crypta(<<"bitcoin">>))]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{payment_terminal, #domain_PaymentTerminalCondition{
|
||||
definition = {
|
||||
payment_service_is,
|
||||
?pmt_srv(<<"alipay">>)
|
||||
}
|
||||
}},
|
||||
[?pomt(wallet_info)]
|
||||
mk_payment_decision({bank_card, #domain_BankCardCondition{definition = {empty_cvv_is, true}}}, []),
|
||||
mk_payment_decision(
|
||||
{bank_card, #domain_BankCardCondition{}},
|
||||
[?pmt(bank_card, ?bank_card(<<"visa">>))]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{digital_wallet, #domain_DigitalWalletCondition{
|
||||
definition =
|
||||
{payment_service_is, ?pmt_srv(<<"qiwi">>)}
|
||||
}},
|
||||
[?pomt(wallet_info)]
|
||||
mk_payment_decision(
|
||||
{payment_terminal, #domain_PaymentTerminalCondition{}},
|
||||
[?pmt(crypto_currency, ?crypta(<<"bitcoin">>))]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{mobile_commerce, #domain_MobileCommerceCondition{
|
||||
definition = {operator_is, ?mob(<<"mts">>)}
|
||||
}},
|
||||
[?pomt(wallet_info)]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{crypto_currency, #domain_CryptoCurrencyCondition{
|
||||
definition = {crypto_currency_is, ?crypta(<<"bitcoin">>)}
|
||||
}},
|
||||
[?pomt(wallet_info)]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition =
|
||||
{payment_system, #domain_PaymentSystemCondition{
|
||||
token_service_is = ?token_srv(<<"applepay">>)
|
||||
}}
|
||||
}},
|
||||
[?pomt(wallet_info)]
|
||||
),
|
||||
PayoutMDFun(
|
||||
{generic, {payment_service_is, ?pmt_srv(<<"generic">>)}},
|
||||
[?pomt(wallet_info)]
|
||||
),
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ = {condition, {payment_tool, {bank_card, #domain_BankCardCondition{}}}},
|
||||
then_ = {value, ordsets:from_list([?pomt(russian_bank_account)])}
|
||||
},
|
||||
#domain_PayoutMethodDecision{
|
||||
if_ = {condition, {payment_tool, {payment_terminal, #domain_PaymentTerminalCondition{}}}},
|
||||
then_ = {value, ordsets:from_list([?pomt(international_bank_account)])}
|
||||
},
|
||||
#domain_PayoutMethodDecision{
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {constant, true},
|
||||
then_ = {value, ordsets:from_list([])}
|
||||
}
|
||||
]},
|
||||
]}
|
||||
},
|
||||
payments = #domain_PaymentsServiceTerms{
|
||||
cash_limit =
|
||||
{value, #domain_CashRange{
|
||||
lower = {inclusive, #domain_Cash{amount = 1000, currency = ?cur(<<"RUB">>)}},
|
||||
upper = {exclusive, #domain_Cash{amount = 4200000, currency = ?cur(<<"RUB">>)}}
|
||||
}},
|
||||
fees =
|
||||
{value, [
|
||||
?cfpost(
|
||||
{merchant, settlement},
|
||||
{merchant, payout},
|
||||
?share(750, 1000, operation_amount)
|
||||
),
|
||||
?cfpost(
|
||||
{merchant, settlement},
|
||||
{system, settlement},
|
||||
?share(250, 1000, operation_amount)
|
||||
?share(45, 1000, operation_amount)
|
||||
)
|
||||
]}
|
||||
},
|
||||
@ -2432,7 +2275,7 @@ construct_domain_fixture() ->
|
||||
withdrawals = #domain_WithdrawalServiceTerms{
|
||||
methods =
|
||||
{decisions, [
|
||||
PaymentMDFun(
|
||||
mk_payment_decision(
|
||||
{bank_card, #domain_BankCardCondition{
|
||||
definition = {
|
||||
payment_system,
|
||||
@ -2443,20 +2286,20 @@ construct_domain_fixture() ->
|
||||
}},
|
||||
[?pmt(bank_card, ?bank_card(<<"visa">>))]
|
||||
),
|
||||
PaymentMDFun(
|
||||
mk_payment_decision(
|
||||
{digital_wallet, #domain_DigitalWalletCondition{
|
||||
definition =
|
||||
{payment_service_is, ?pmt_srv(<<"qiwi">>)}
|
||||
}},
|
||||
[?pmt(bank_card, ?bank_card(<<"visa">>))]
|
||||
),
|
||||
PaymentMDFun(
|
||||
mk_payment_decision(
|
||||
{mobile_commerce, #domain_MobileCommerceCondition{
|
||||
definition = {operator_is, ?mob(<<"mts">>)}
|
||||
}},
|
||||
[?pmt(bank_card, ?bank_card(<<"visa">>))]
|
||||
),
|
||||
PaymentMDFun(
|
||||
mk_payment_decision(
|
||||
{crypto_currency, #domain_CryptoCurrencyCondition{
|
||||
definition = {crypto_currency_is, ?crypta(<<"bitcoin">>)}
|
||||
}},
|
||||
@ -2662,10 +2505,6 @@ construct_domain_fixture() ->
|
||||
pm_ct_fixture:construct_payment_method(?pmt(payment_terminal, ?pmt_srv(<<"euroset">>))),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, ?bank_card_no_cvv(<<"visa">>))),
|
||||
|
||||
pm_ct_fixture:construct_payout_method(?pomt(russian_bank_account)),
|
||||
pm_ct_fixture:construct_payout_method(?pomt(international_bank_account)),
|
||||
pm_ct_fixture:construct_payout_method(?pomt(wallet_info)),
|
||||
|
||||
pm_ct_fixture:construct_proxy(
|
||||
?prx(1),
|
||||
<<"Dummy proxy">>,
|
||||
@ -2754,6 +2593,20 @@ construct_domain_fixture() ->
|
||||
}
|
||||
}},
|
||||
|
||||
%% For check_all_payment_methods
|
||||
{payment_institution, #domain_PaymentInstitutionObject{
|
||||
ref = ?pinst(5),
|
||||
data = #domain_PaymentInstitution{
|
||||
name = <<"All Payments GmbH">>,
|
||||
system_account_set = {value, ?sas(2)},
|
||||
default_contract_template = {value, ?tmpl(6)},
|
||||
providers = {value, ?ordset([])},
|
||||
inspector = {value, ?insp(1)},
|
||||
residences = [],
|
||||
realm = live
|
||||
}
|
||||
}},
|
||||
|
||||
{globals, #domain_GlobalsObject{
|
||||
ref = #domain_GlobalsRef{},
|
||||
data = #domain_Globals{
|
||||
@ -2764,7 +2617,7 @@ construct_domain_fixture() ->
|
||||
then_ = {value, ?eas(1)}
|
||||
}
|
||||
]},
|
||||
payment_institutions = ?ordset([?pinst(1), ?pinst(2)])
|
||||
payment_institutions = ?ordset([?pinst(1), ?pinst(2), ?pinst(5)])
|
||||
}
|
||||
}},
|
||||
pm_ct_fixture:construct_contract_template(
|
||||
@ -2791,6 +2644,11 @@ construct_domain_fixture() ->
|
||||
?tmpl(5),
|
||||
?trms(4)
|
||||
),
|
||||
%% For check_all_payment_methods
|
||||
pm_ct_fixture:construct_contract_template(
|
||||
?tmpl(6),
|
||||
?trms(5)
|
||||
),
|
||||
pm_ct_fixture:construct_term_set_hierarchy(?trms(1), undefined, TestTermSet),
|
||||
pm_ct_fixture:construct_term_set_hierarchy(?trms(2), undefined, DefaultTermSet),
|
||||
pm_ct_fixture:construct_term_set_hierarchy(?trms(3), ?trms(2), TermSet),
|
||||
@ -2817,6 +2675,8 @@ construct_domain_fixture() ->
|
||||
}
|
||||
}
|
||||
),
|
||||
%% For check_all_payment_methods
|
||||
pm_ct_fixture:construct_term_set_hierarchy(?trms(5), ?trms(2), AllMethodsTermSet),
|
||||
{bank, #domain_BankObject{
|
||||
ref = ?bank(1),
|
||||
data = #domain_Bank{
|
||||
@ -3124,3 +2984,9 @@ construct_domain_fixture() ->
|
||||
}
|
||||
}}
|
||||
].
|
||||
|
||||
mk_payment_decision(PaymentTool, PaymentMethods) ->
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {condition, {payment_tool, PaymentTool}},
|
||||
then_ = {value, ordsets:from_list(PaymentMethods)}
|
||||
}.
|
||||
|
@ -27,7 +27,6 @@
|
||||
-export([compute_shop_terms/5]).
|
||||
-export([compute_payment_institution_terms/3]).
|
||||
-export([compute_payment_institution/4]).
|
||||
-export([compute_payout_cash_flow/2]).
|
||||
|
||||
-export([block_shop/3]).
|
||||
-export([unblock_shop/3]).
|
||||
@ -179,11 +178,6 @@ compute_payment_institution_terms(Ref, Varset, Client) ->
|
||||
compute_payment_institution(Ref, DomainRevision, Varset, Client) ->
|
||||
call(Client, 'ComputePaymentInstitution', [Ref, DomainRevision, Varset]).
|
||||
|
||||
-spec compute_payout_cash_flow(dmsl_payproc_thrift:'PayoutParams'(), pid()) ->
|
||||
dmsl_domain_thrift:'FinalCashFlow'() | woody_error:business_error().
|
||||
compute_payout_cash_flow(Params, Client) ->
|
||||
call(Client, 'ComputePayoutCashFlow', with_party_id([Params])).
|
||||
|
||||
-spec get_shop(shop_id(), pid()) -> dmsl_domain_thrift:'Shop'() | woody_error:business_error().
|
||||
get_shop(ID, Client) ->
|
||||
call(Client, 'GetShop', with_party_id([ID])).
|
||||
|
@ -1,5 +1,20 @@
|
||||
services:
|
||||
|
||||
dominant:
|
||||
environment: &otlp_enabled
|
||||
OTEL_TRACES_EXPORTER: otlp
|
||||
OTEL_TRACES_SAMPLER: parentbased_always_off
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http_protobuf
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://jaeger:4318
|
||||
|
||||
machinegun:
|
||||
environment: *otlp_enabled
|
||||
|
||||
testrunner:
|
||||
environment:
|
||||
<<: *otlp_enabled
|
||||
OTEL_SERVICE_NAME: party-management_testrunner
|
||||
OTEL_TRACES_SAMPLER: parentbased_always_on
|
||||
depends_on:
|
||||
jaeger:
|
||||
condition: service_healthy
|
||||
|
@ -24,7 +24,7 @@ services:
|
||||
command: /sbin/init
|
||||
|
||||
dominant:
|
||||
image: ghcr.io/valitydev/dominant:sha-2150eea
|
||||
image: ghcr.io/valitydev/dominant:sha-1c283be-epic-IMP-278-fx-retire-payouts
|
||||
depends_on:
|
||||
- machinegun
|
||||
ports:
|
||||
@ -39,15 +39,15 @@ services:
|
||||
retries: 20
|
||||
|
||||
machinegun:
|
||||
image: ghcr.io/valitydev/machinegun:sha-5c0db56
|
||||
image: ghcr.io/valitydev/mg2:sha-8bbcd29
|
||||
command: /opt/machinegun/bin/machinegun foreground
|
||||
volumes:
|
||||
- ./test/machinegun/config.yaml:/opt/machinegun/etc/config.yaml
|
||||
- ./test/machinegun/cookie:/opt/machinegun/etc/cookie
|
||||
healthcheck:
|
||||
test: "/opt/machinegun/bin/machinegun ping"
|
||||
interval: 5s
|
||||
timeout: 1s
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
shumway:
|
||||
|
@ -69,16 +69,6 @@
|
||||
}}
|
||||
]},
|
||||
|
||||
{how_are_you, [
|
||||
{metrics_publishers, [
|
||||
% {hay_statsd_publisher, #{
|
||||
% key_prefix => <<"hellgate.">>,
|
||||
% host => "localhost",
|
||||
% port => 8125
|
||||
% }}
|
||||
]}
|
||||
]},
|
||||
|
||||
{snowflake, [
|
||||
{max_backward_clock_moving, 1000}, % 1 second
|
||||
{machine_id, hostname_hash}
|
||||
@ -86,5 +76,9 @@
|
||||
|
||||
{prometheus, [
|
||||
{collectors, [default]}
|
||||
]},
|
||||
|
||||
{hackney, [
|
||||
{mod_metrics, woody_hackney_prometheus}
|
||||
]}
|
||||
].
|
||||
|
18
rebar.config
18
rebar.config
@ -29,6 +29,8 @@
|
||||
{cache, "2.3.3"},
|
||||
{gproc, "0.9.0"},
|
||||
{genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}},
|
||||
{prometheus, "4.8.1"},
|
||||
{prometheus_cowboy, "0.1.8"},
|
||||
{woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, "master"}}},
|
||||
{damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}},
|
||||
{payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}},
|
||||
@ -68,12 +70,6 @@
|
||||
{profiles, [
|
||||
{prod, [
|
||||
{deps, [
|
||||
% Because of a dependency conflict, prometheus libs are only included in the prod profile for now
|
||||
% https://github.com/valitydev/hellgate/pull/2/commits/884724c1799703cee4d1033850fe32c17f986d9e
|
||||
{prometheus, "4.8.1"},
|
||||
{prometheus_cowboy, "0.1.8"},
|
||||
{how_are_you, {git, "https://github.com/valitydev/how_are_you.git", {ref, "2fd80134"}}},
|
||||
{woody_api_hay, {git, "https://github.com/valitydev/woody_api_hay.git", {ref, "4c39134cd"}}},
|
||||
% for introspection on production
|
||||
{recon, "2.5.2"},
|
||||
{logger_logstash_formatter,
|
||||
@ -88,8 +84,6 @@
|
||||
{tools, load},
|
||||
{opentelemetry, temporary},
|
||||
{logger_logstash_formatter, load},
|
||||
woody_api_hay,
|
||||
how_are_you,
|
||||
prometheus,
|
||||
prometheus_cowboy,
|
||||
sasl,
|
||||
@ -118,3 +112,11 @@
|
||||
{files, ["apps/*/{src,include,test}/*.{hrl,erl}", "rebar.config", "elvis.config"]},
|
||||
{exclude_files, ["apps/pm_proto/{src,include}/*_thrift.*rl"]}
|
||||
]}.
|
||||
|
||||
%% NOTE
|
||||
%% It is needed to use rebar3 lint plugin
|
||||
{overrides, [
|
||||
{del, accept, [{plugins, [{rebar3_archive_plugin, "0.0.2"}]}]},
|
||||
{del, prometheus_cowboy, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]},
|
||||
{del, prometheus_httpd, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]}
|
||||
]}.
|
||||
|
31
rebar.lock
31
rebar.lock
@ -1,5 +1,6 @@
|
||||
{"1.2.0",
|
||||
[{<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},2},
|
||||
[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.5">>},2},
|
||||
{<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},2},
|
||||
{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},0},
|
||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.8.0">>},2},
|
||||
{<<"cg_mon">>,
|
||||
@ -12,15 +13,15 @@
|
||||
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
|
||||
{<<"damsel">>,
|
||||
{git,"https://github.com/valitydev/damsel.git",
|
||||
{ref,"02e0ec0db6fc70c30a97d61af3729c4e09df4a88"}},
|
||||
{ref,"8e034bc74b1f4ed0e00dd63d0c3ca9c922be1c47"}},
|
||||
0},
|
||||
{<<"dmt_client">>,
|
||||
{git,"https://github.com/valitydev/dmt_client.git",
|
||||
{ref,"b8bc0281dbf1e55a1a67ef6da861e0353ff14913"}},
|
||||
{ref,"d8a4f490d49c038d96f1cbc2a279164c6f4039f9"}},
|
||||
0},
|
||||
{<<"dmt_core">>,
|
||||
{git,"https://github.com/valitydev/dmt-core.git",
|
||||
{ref,"75841332fe0b40a77da0c12ea8d5dbb994da8e82"}},
|
||||
{ref,"19d8f57198f2cbe5b64aa4a923ba32774e505503"}},
|
||||
1},
|
||||
{<<"erl_health">>,
|
||||
{git,"https://github.com/valitydev/erlang-health.git",
|
||||
@ -39,9 +40,9 @@
|
||||
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2},
|
||||
{<<"mg_proto">>,
|
||||
{git,"https://github.com/valitydev/machinegun-proto.git",
|
||||
{ref,"f32e92d16fdcf92a35903d267b2bfec94f64a117"}},
|
||||
{ref,"3decc8f8b13c9cd1701deab47781aacddd7dbc92"}},
|
||||
0},
|
||||
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2},
|
||||
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},2},
|
||||
{<<"opentelemetry">>,{pkg,<<"opentelemetry">>,<<"1.3.0">>},0},
|
||||
{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.2.1">>},0},
|
||||
{<<"opentelemetry_exporter">>,
|
||||
@ -55,8 +56,10 @@
|
||||
{git,"https://github.com/valitydev/payproc-errors-erlang.git",
|
||||
{ref,"8ae8586239ef68098398acf7eb8363d9ec3b3234"}},
|
||||
0},
|
||||
{<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},1},
|
||||
{<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},2},
|
||||
{<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},0},
|
||||
{<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0},
|
||||
{<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.11">>},1},
|
||||
{<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},1},
|
||||
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2},
|
||||
{<<"scoper">>,
|
||||
{git,"https://github.com/valitydev/scoper.git",
|
||||
@ -77,10 +80,11 @@
|
||||
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2},
|
||||
{<<"woody">>,
|
||||
{git,"https://github.com/valitydev/woody_erlang.git",
|
||||
{ref,"3e2337a818086f33f0a1ede5d204aee7744c7c36"}},
|
||||
{ref,"072825ee7179825a4078feb0649df71303c74157"}},
|
||||
0}]}.
|
||||
[
|
||||
{pkg_hash,[
|
||||
{<<"accept">>, <<"B33B127ABCA7CC948BBE6CAA4C263369ABF1347CFA9D8E699C6D214660F10CD1">>},
|
||||
{<<"acceptor_pool">>, <<"43C20D2ACAE35F0C2BCD64F9D2BDE267E459F0F3FD23DAB26485BF518C281B21">>},
|
||||
{<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>},
|
||||
{<<"certifi">>, <<"D4FB0A6BB20B7C9C3643E22507E42F356AC090A1DCEA9AB99E27E0376D695EBA">>},
|
||||
@ -95,19 +99,22 @@
|
||||
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
|
||||
{<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
|
||||
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
|
||||
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
|
||||
{<<"mimerl">>, <<"D0CD9FC04B9061F82490F6581E0128379830E78535E017F7780F37FEA7545726">>},
|
||||
{<<"opentelemetry">>, <<"988AC3C26ACAC9720A1D4FB8D9DC52E95B45ECFEC2D5B5583276A09E8936BC5E">>},
|
||||
{<<"opentelemetry_api">>, <<"7B69ED4F40025C005DE0B74FCE8C0549625D59CB4DF12D15C32FE6DC5076FF42">>},
|
||||
{<<"opentelemetry_exporter">>, <<"1D8809C0D4F4ACF986405F7700ED11992BCBDB6A4915DD11921E80777FFA7167">>},
|
||||
{<<"opentelemetry_semantic_conventions">>, <<"B67FE459C2938FCAB341CB0951C44860C62347C005ACE1B50F8402576F241435">>},
|
||||
{<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>},
|
||||
{<<"prometheus">>, <<"FA76B152555273739C14B06F09F485CF6D5D301FE4E9D31B7FF803D26025D7A0">>},
|
||||
{<<"prometheus_cowboy">>, <<"CFCE0BC7B668C5096639084FCD873826E6220EA714BF60A716F5BD080EF2A99C">>},
|
||||
{<<"prometheus_httpd">>, <<"F616ED9B85B536B195D94104063025A91F904A4CFC20255363F49A197D96C896">>},
|
||||
{<<"quantile_estimator">>, <<"EF50A361F11B5F26B5F16D0696E46A9E4661756492C981F7B2229EF42FF1CD15">>},
|
||||
{<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>},
|
||||
{<<"ssl_verify_fun">>, <<"354C321CF377240C7B8716899E182CE4890C5938111A1296ADD3EC74CF1715DF">>},
|
||||
{<<"tls_certificate_check">>, <<"C76C4C5D79EE79A2B11C84F910C825D6F024A78427C854F515748E9BD025E987">>},
|
||||
{<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]},
|
||||
{pkg_hash_ext,[
|
||||
{<<"accept">>, <<"11B18C220BCC2EAB63B5470C038EF10EB6783BCB1FCDB11AA4137DEFA5AC1BB8">>},
|
||||
{<<"acceptor_pool">>, <<"0CBCD83FDC8B9AD2EEE2067EF8B91A14858A5883CB7CD800E6FCD5803E158788">>},
|
||||
{<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>},
|
||||
{<<"certifi">>, <<"6AC7EFC1C6F8600B08D625292D4BBF584E14847CE1B6B5C44D983D273E1097EA">>},
|
||||
@ -122,13 +129,15 @@
|
||||
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
|
||||
{<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>},
|
||||
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
|
||||
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
|
||||
{<<"mimerl">>, <<"A1E15A50D1887217DE95F0B9B0793E32853F7C258A5CD227650889B38839FE9D">>},
|
||||
{<<"opentelemetry">>, <<"8E09EDC26AAD11161509D7ECAD854A3285D88580F93B63B0B1CF0BAC332BFCC0">>},
|
||||
{<<"opentelemetry_api">>, <<"6D7A27B7CAD2AD69A09CABF6670514CAFCEC717C8441BEB5C96322BAC3D05350">>},
|
||||
{<<"opentelemetry_exporter">>, <<"2B40007F509D38361744882FD060A8841AF772AB83BB542AA5350908B303AD65">>},
|
||||
{<<"opentelemetry_semantic_conventions">>, <<"D61FA1F5639EE8668D74B527E6806E0503EFC55A42DB7B5F39939D84C07D6895">>},
|
||||
{<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>},
|
||||
{<<"prometheus">>, <<"6EDFBE928D271C7F657A6F2C46258738086584BD6CAE4A000B8B9A6009BA23A5">>},
|
||||
{<<"prometheus_cowboy">>, <<"BA286BECA9302618418892D37BCD5DC669A6CC001F4EB6D6AF85FF81F3F4F34C">>},
|
||||
{<<"prometheus_httpd">>, <<"0BBE831452CFDF9588538EB2F570B26F30C348ADAE5E95A7D87F35A5910BCF92">>},
|
||||
{<<"quantile_estimator">>, <<"282A8A323CA2A845C9E6F787D166348F776C1D4A41EDE63046D72D422E3DA946">>},
|
||||
{<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>},
|
||||
{<<"ssl_verify_fun">>, <<"FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8">>},
|
||||
|
@ -3,10 +3,6 @@ erlang:
|
||||
secret_cookie_file: "/opt/machinegun/etc/cookie"
|
||||
namespaces:
|
||||
party:
|
||||
event_sinks:
|
||||
machine:
|
||||
type: machine
|
||||
machine_id: payproc
|
||||
processor:
|
||||
url: http://party-management:8022/v1/stateproc/party
|
||||
pool_size: 300
|
||||
@ -25,9 +21,3 @@ woody_server:
|
||||
logging:
|
||||
out_type: stdout
|
||||
level: info
|
||||
|
||||
opentelemetry:
|
||||
service_name: machinegun
|
||||
exporter:
|
||||
protocol: http/protobuf
|
||||
endpoint: http://jaeger:4318
|
||||
|
Loading…
Reference in New Issue
Block a user