Skip to content

Commit ac16b07

Browse files
ndiezel0WWWcool
andauthored
BG-360: Bump damsel (#166)
* BG-360: Bump damsel * Bump erlfmt * Revert "BG-360: Bump damsel" This reverts commit ed2b268. * Revert some format * Revert some more format * Revert even more format * Some more * Some debug info * Bump progressor * Fix limit tests --------- Co-authored-by: Артем <WWW_cool@inbox.ru>
1 parent 84d103f commit ac16b07

35 files changed

Lines changed: 1334 additions & 1048 deletions

apps/hellgate/include/allocation.hrl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
body = Body
7474
}).
7575

76-
-define(allocation_trx_target_shop(OwnerID, ShopID),
76+
-define(allocation_trx_target_shop(PartyConfigRef, ShopConfigRef),
7777
{shop, #domain_AllocationTransactionTargetShop{
78-
owner_id = OwnerID,
79-
shop_id = ShopID
78+
party_ref = PartyConfigRef,
79+
shop_ref = ShopConfigRef
8080
}}
8181
).
8282

apps/hellgate/include/hg_invoice.hrl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
invoice :: undefined | hg_invoice:invoice(),
77
payments = [] :: [{hg_invoice:payment_id(), hg_invoice:payment_st()}],
88
party :: undefined | hg_invoice:party(),
9-
party_id :: undefined | hg_invoice:party_id()
9+
party_config_ref :: undefined | hg_invoice:party_config_ref()
1010
}).
1111

1212
-endif.

apps/hellgate/src/hg_accounting.erl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
-type thrift_account() :: dmsl_accounter_thrift:'Account'().
3838

3939
-type payment() :: dmsl_domain_thrift:'InvoicePayment'().
40-
-type party_id() :: dmsl_domain_thrift:'PartyID'().
40+
-type party_config_ref() :: dmsl_domain_thrift:'PartyConfigRef'().
4141
-type shop() :: dmsl_domain_thrift:'ShopConfig'().
42-
-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'().
42+
-type shop_config_ref() :: dmsl_domain_thrift:'ShopConfigRef'().
4343
-type route() :: hg_route:payment_route().
4444
-type payment_institution() :: dmsl_domain_thrift:'PaymentInstitution'().
4545
-type provider() :: dmsl_domain_thrift:'Provider'().
@@ -48,8 +48,8 @@
4848

4949
-type collect_account_context() :: #{
5050
payment := payment(),
51-
party_id := party_id(),
52-
shop := {shop_id(), shop()},
51+
party_config_ref := party_config_ref(),
52+
shop := {shop_config_ref(), shop()},
5353
route := route(),
5454
payment_institution := payment_institution(),
5555
provider := provider(),
@@ -101,23 +101,23 @@ create_account(CurrencyCode, Description) ->
101101
-spec collect_account_map(collect_account_context()) -> map().
102102
collect_account_map(#{
103103
payment := Payment,
104-
party_id := PartyID,
104+
party_config_ref := PartyConfigRef,
105105
shop := ShopObj,
106106
route := Route,
107107
payment_institution := PaymentInstitution,
108108
provider := Provider,
109109
varset := VS,
110110
revision := Revision
111111
}) ->
112-
Map0 = collect_merchant_account_map(PartyID, ShopObj, #{}),
112+
Map0 = collect_merchant_account_map(PartyConfigRef, ShopObj, #{}),
113113
Map1 = collect_provider_account_map(Payment, Provider, Route, Map0),
114114
Map2 = collect_system_account_map(Payment, PaymentInstitution, Revision, Map1),
115115
collect_external_account_map(Payment, VS, Revision, Map2).
116116

117-
-spec collect_merchant_account_map(party_id(), {shop_id(), shop()}, map()) -> map().
118-
collect_merchant_account_map(PartyID, {ShopID, #domain_ShopConfig{account = Account}}, Acc) ->
117+
-spec collect_merchant_account_map(party_config_ref(), {shop_config_ref(), shop()}, map()) -> map().
118+
collect_merchant_account_map(PartyConfigRef, {ShopConfigRef, #domain_ShopConfig{account = Account}}, Acc) ->
119119
Acc#{
120-
merchant => {PartyID, ShopID},
120+
merchant => {PartyConfigRef, ShopConfigRef},
121121
{merchant, settlement} => Account#domain_ShopAccount.settlement,
122122
{merchant, guarantee} => Account#domain_ShopAccount.guarantee
123123
}.

apps/hellgate/src/hg_allocation.erl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
-type party() :: dmsl_domain_thrift:'PartyConfig'().
2424
-type shop() :: dmsl_domain_thrift:'ShopConfig'().
25-
-type party_id() :: dmsl_payproc_thrift:'PartyID'().
26-
-type shop_id() :: dmsl_payproc_thrift:'ShopID'().
25+
-type party_config_ref() :: dmsl_domain_thrift:'PartyConfigRef'().
26+
-type shop_config_ref() :: dmsl_domain_thrift:'ShopConfigRef'().
2727
-type target_map() :: #{
28-
party_id => party_id(),
29-
shop_id => shop_id()
28+
party_config_ref => party_config_ref(),
29+
shop_config_ref => shop_config_ref()
3030
}.
3131

3232
-type sub_errors() ::
@@ -85,14 +85,14 @@ assert_allocatable(_Allocation, _PaymentAllocationServiceTerms, _Party, _Shop, _
8585
{error, allocation_not_allowed}.
8686

8787
-spec construct_target(target_map()) -> target().
88-
construct_target(#{party_id := PartyID, shop_id := ShopID}) ->
89-
?allocation_trx_target_shop(PartyID, ShopID).
88+
construct_target(#{party_config_ref := PartyConfigRef, shop_config_ref := ShopConfigRef}) ->
89+
?allocation_trx_target_shop(PartyConfigRef, ShopConfigRef).
9090

91-
-spec calculate(allocation_prototype(), party_id(), shop_id(), cash()) -> allocation().
92-
calculate(AllocationPrototype, PartyID, ShopID, Cost) ->
91+
-spec calculate(allocation_prototype(), party_config_ref(), shop_config_ref(), cash()) -> allocation().
92+
calculate(AllocationPrototype, PartyConfigRef, ShopConfigRef, Cost) ->
9393
FeeTarget = construct_target(#{
94-
party_id => PartyID,
95-
shop_id => ShopID
94+
party_config_ref => PartyConfigRef,
95+
shop_config_ref => ShopConfigRef
9696
}),
9797
calculate(AllocationPrototype, FeeTarget, Cost).
9898

apps/hellgate/src/hg_cashflow.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
-type account_id() :: dmsl_domain_thrift:'AccountID'().
1818
-type account_map() :: #{
1919
account() => account_id(),
20-
merchant := {party_id(), shop_id()},
20+
merchant := {party_config_ref(), shop_config_ref()},
2121
provider := route()
2222
}.
2323
-type context() :: dmsl_domain_thrift:'CashFlowContext'().
@@ -27,8 +27,8 @@
2727
-type cash_volume() :: dmsl_domain_thrift:'CashVolume'().
2828
-type final_cash_flow_account() :: dmsl_domain_thrift:'FinalCashFlowAccount'().
2929

30-
-type shop_id() :: dmsl_domain_thrift:'ShopID'().
31-
-type party_id() :: dmsl_domain_thrift:'PartyID'().
30+
-type shop_config_ref() :: dmsl_domain_thrift:'ShopConfigRef'().
31+
-type party_config_ref() :: dmsl_domain_thrift:'PartyConfigRef'().
3232
-type route() :: hg_route:payment_route().
3333

3434
%%
@@ -80,10 +80,10 @@ construct_final_account(AccountType, AccountMap) ->
8080
transaction_account = construct_transaction_account(AccountType, AccountMap)
8181
}.
8282

83-
construct_transaction_account({merchant, MerchantFlowAccount}, #{merchant := {PartyID, ShopID}}) ->
83+
construct_transaction_account({merchant, MerchantFlowAccount}, #{merchant := {PartyConfigRef, ShopConfigRef}}) ->
8484
AccountOwner = #domain_MerchantTransactionAccountOwner{
85-
party_id = PartyID,
86-
shop_id = ShopID
85+
party_ref = PartyConfigRef,
86+
shop_ref = ShopConfigRef
8787
},
8888
{merchant, #domain_MerchantTransactionAccount{
8989
type = MerchantFlowAccount,

apps/hellgate/src/hg_cashflow_utils.erl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
-type cash_flow_context() :: #{
1111
operation := refund | payment,
1212
provision_terms := dmsl_domain_thrift:'PaymentsProvisionTerms'(),
13-
party := {party_id(), party()},
14-
shop := {shop_id(), shop()},
13+
party := {party_config_ref(), party()},
14+
shop := {shop_config_ref(), shop()},
1515
route := route(),
1616
payment := payment(),
1717
provider := provider(),
@@ -29,9 +29,9 @@
2929
-export([collect_cashflow/2]).
3030

3131
-type party() :: dmsl_domain_thrift:'PartyConfig'().
32-
-type party_id() :: dmsl_domain_thrift:'PartyID'().
32+
-type party_config_ref() :: dmsl_domain_thrift:'PartyConfigRef'().
3333
-type shop() :: dmsl_domain_thrift:'ShopConfig'().
34-
-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'().
34+
-type shop_config_ref() :: dmsl_domain_thrift:'ShopConfigRef'().
3535
-type route() :: dmsl_domain_thrift:'PaymentRoute'().
3636
-type payment() :: dmsl_domain_thrift:'InvoicePayment'().
3737
-type refund() :: dmsl_domain_thrift:'InvoicePaymentRefund'().
@@ -70,20 +70,21 @@ collect_allocation_cash_flow(
7070
) ->
7171
lists:foldl(
7272
fun(?allocation_trx(_ID, Target, Amount), Acc) ->
73-
?allocation_trx_target_shop(PartyID, ShopID) = Target,
74-
{PartyID, TargetParty} = hg_party:get_party(PartyID),
75-
{ShopID, TargetShop} = hg_party:get_shop(ShopID, TargetParty, Revision),
73+
?allocation_trx_target_shop(PartyConfigRef, ShopConfigRef) = Target,
74+
{PartyConfigRef, TargetParty} = hg_party:get_party(PartyConfigRef),
75+
{#domain_ShopConfigRef{id = ShopConfigID} = ShopConfigRef, TargetShop} =
76+
hg_party:get_shop(ShopConfigRef, PartyConfigRef, Revision),
7677
VS1 = VS0#{
77-
party_id => PartyID,
78-
shop_id => ShopID,
78+
party_config_ref => PartyConfigRef,
79+
shop_id => ShopConfigID,
7980
cost => Amount
8081
},
8182
AllocationPaymentInstitution =
8283
get_cashflow_payment_institution(Shop, VS1, Revision),
8384
construct_transaction_cashflow(
8485
Amount,
8586
AllocationPaymentInstitution,
86-
Context#{party => {PartyID, TargetParty}, shop => {ShopID, TargetShop}}
87+
Context#{party => {PartyConfigRef, TargetParty}, shop => {ShopConfigRef, TargetShop}}
8788
) ++ Acc
8889
end,
8990
[],
@@ -161,7 +162,7 @@ get_selector_value(Name, Selector) ->
161162
hg_accounting:collect_account_context().
162163
make_collect_account_context(PaymentInstitution, #{
163164
payment := Payment,
164-
party := {PartyID, _},
165+
party := {PartyConfigRef, _},
165166
shop := Shop,
166167
route := Route,
167168
provider := Provider,
@@ -170,7 +171,7 @@ make_collect_account_context(PaymentInstitution, #{
170171
}) ->
171172
#{
172173
payment => Payment,
173-
party_id => PartyID,
174+
party_config_ref => PartyConfigRef,
174175
shop => Shop,
175176
route => Route,
176177
payment_institution => PaymentInstitution,

apps/hellgate/src/hg_inspector.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ get_payment_info(
105105
location = Location
106106
},
107107
#domain_Invoice{
108-
owner_id = PartyID,
109-
shop_id = ShopID,
108+
party_ref = PartyConfigRef,
109+
shop_ref = ShopConfigRef,
110110
id = InvoiceID,
111111
created_at = InvoiceCreatedAt,
112112
due = InvoiceDue,
@@ -123,14 +123,14 @@ get_payment_info(
123123
}
124124
) ->
125125
Party = #proxy_inspector_Party{
126-
party_id = PartyID
126+
party_ref = PartyConfigRef
127127
},
128128
ShopCategory = hg_domain:get(
129129
Revision,
130130
{category, CategoryRef}
131131
),
132132
ProxyShop = #proxy_inspector_Shop{
133-
id = ShopID,
133+
shop_ref = ShopConfigRef,
134134
category = ShopCategory,
135135
name = Shop#domain_ShopConfig.name,
136136
description = Shop#domain_ShopConfig.description,

apps/hellgate/src/hg_invoice.erl

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
-export_type([payment_id/0]).
3232
-export_type([payment_st/0]).
3333
-export_type([party/0]).
34-
-export_type([party_id/0]).
34+
-export_type([party_config_ref/0]).
3535

3636
%% Public interface
3737

@@ -77,7 +77,7 @@
7777
-type invoice() :: dmsl_domain_thrift:'Invoice'().
7878
-type allocation() :: dmsl_domain_thrift:'Allocation'().
7979
-type party() :: dmsl_domain_thrift:'PartyConfig'().
80-
-type party_id() :: dmsl_domain_thrift:'PartyID'().
80+
-type party_config_ref() :: dmsl_domain_thrift:'PartyConfigRef'().
8181
-type revision() :: dmt_client:vsn().
8282

8383
-type payment_id() :: dmsl_domain_thrift:'InvoicePaymentID'().
@@ -109,28 +109,28 @@ get_payment(PaymentID, St) ->
109109

110110
-spec get_payment_opts(st()) -> hg_invoice_payment:opts().
111111
get_payment_opts(St = #st{invoice = Invoice, party = undefined}) ->
112-
{PartyID, Party} = hg_party:get_party(get_party_id(St)),
112+
{PartyConfigRef, Party} = hg_party:get_party(get_party_config_ref(St)),
113113
#{
114114
party => Party,
115-
party_id => PartyID,
115+
party_config_ref => PartyConfigRef,
116116
invoice => Invoice,
117117
timestamp => hg_datetime:format_now()
118118
};
119-
get_payment_opts(#st{invoice = Invoice, party = Party, party_id = PartyID}) ->
119+
get_payment_opts(#st{invoice = Invoice, party = Party, party_config_ref = PartyConfigRef}) ->
120120
#{
121121
party => Party,
122-
party_id => PartyID,
122+
party_config_ref => PartyConfigRef,
123123
invoice => Invoice,
124124
timestamp => hg_datetime:format_now()
125125
}.
126126

127127
-spec get_payment_opts(hg_domain:revision(), st()) ->
128128
hg_invoice_payment:opts().
129129
get_payment_opts(Revision, St = #st{invoice = Invoice}) ->
130-
{PartyID, Party} = hg_party:checkout(get_party_id(St), Revision),
130+
{PartyConfigRef, Party} = hg_party:checkout(get_party_config_ref(St), Revision),
131131
#{
132132
party => Party,
133-
party_id => PartyID,
133+
party_config_ref => PartyConfigRef,
134134
invoice => Invoice,
135135
timestamp => hg_datetime:format_now()
136136
}.
@@ -145,13 +145,13 @@ get_payment_opts(Revision, St = #st{invoice = Invoice}) ->
145145
) ->
146146
invoice().
147147
create(ID, InvoiceTplID, V = #payproc_InvoiceParams{}, _Allocation, Mutations, DomainRevision) ->
148-
OwnerID = V#payproc_InvoiceParams.party_id,
149-
ShopID = V#payproc_InvoiceParams.shop_id,
148+
PartyConfigRef = V#payproc_InvoiceParams.party_id,
149+
ShopConfigRef = V#payproc_InvoiceParams.shop_id,
150150
Cost = V#payproc_InvoiceParams.cost,
151151
hg_invoice_mutation:apply_mutations(Mutations, #domain_Invoice{
152152
id = ID,
153-
shop_id = ShopID,
154-
owner_id = OwnerID,
153+
party_ref = PartyConfigRef,
154+
shop_ref = ShopConfigRef,
155155
created_at = hg_datetime:format_now(),
156156
status = ?invoice_unpaid(),
157157
cost = Cost,
@@ -169,13 +169,13 @@ assert_invoice(Checks, #st{} = St) when is_list(Checks) ->
169169
lists:foldl(fun assert_invoice/2, St, Checks);
170170
assert_invoice(operable, #st{party = Party} = St) when Party =/= undefined ->
171171
assert_party_shop_operable(
172-
hg_party:get_shop(get_shop_id(St), Party, hg_party:get_party_revision()),
172+
hg_party:get_shop(get_shop_config_ref(St), get_party_config_ref(St), hg_party:get_party_revision()),
173173
Party
174174
),
175175
St;
176176
assert_invoice(unblocked, #st{party = Party} = St) when Party =/= undefined ->
177177
assert_party_shop_unblocked(
178-
hg_party:get_shop(get_shop_id(St), Party, hg_party:get_party_revision()),
178+
hg_party:get_shop(get_shop_config_ref(St), get_party_config_ref(St), hg_party:get_party_revision()),
179179
Party
180180
),
181181
St;
@@ -898,14 +898,14 @@ check_non_idle_payments_([{PaymentID, PaymentSession} | Rest], St) ->
898898
end.
899899

900900
add_party_to_st(St) ->
901-
{PartyID, Party} = hg_party:get_party(get_party_id(St)),
902-
St#st{party = Party, party_id = PartyID}.
901+
{PartyConfigRef, Party} = hg_party:get_party(get_party_config_ref(St)),
902+
St#st{party = Party, party_config_ref = PartyConfigRef}.
903903

904-
get_party_id(#st{invoice = #domain_Invoice{owner_id = PartyID}}) ->
905-
PartyID.
904+
get_party_config_ref(#st{invoice = #domain_Invoice{party_ref = PartyConfigRef}}) ->
905+
PartyConfigRef.
906906

907-
get_shop_id(#st{invoice = #domain_Invoice{shop_id = ShopID}}) ->
908-
ShopID.
907+
get_shop_config_ref(#st{invoice = #domain_Invoice{shop_ref = ShopConfigRef}}) ->
908+
ShopConfigRef.
909909

910910
get_payment_session(PaymentID, St) ->
911911
case try_get_payment_session(PaymentID, St) of
@@ -970,11 +970,16 @@ get_invoice_event_log(EventType, StatusName, Invoice) ->
970970
get_invoice_params(Invoice) ->
971971
#domain_Invoice{
972972
id = ID,
973-
owner_id = PartyID,
974973
cost = ?cash(Amount, Currency),
975-
shop_id = ShopID
974+
party_ref = PartyConfigRef,
975+
shop_ref = ShopConfigRef
976976
} = Invoice,
977-
[{id, ID}, {owner_id, PartyID}, {cost, [{amount, Amount}, {currency, Currency}]}, {shop_id, ShopID}].
977+
[
978+
{id, ID},
979+
{party_ref, PartyConfigRef},
980+
{shop_ref, ShopConfigRef},
981+
{cost, [{amount, Amount}, {currency, Currency}]}
982+
].
978983

979984
get_message(invoice_created) ->
980985
"Invoice is created";

0 commit comments

Comments
 (0)