mirror of
https://github.com/valitydev/fistful-server.git
synced 2024-11-06 10:45:21 +00:00
FF-7 Add old cashflows decoding (#28)
This commit is contained in:
parent
f1e3355dca
commit
57fc3b7f30
@ -220,8 +220,8 @@ construct_trx_posting(Posting) ->
|
||||
%% Event migrations
|
||||
-spec maybe_migrate(any()) -> event().
|
||||
% Actual events
|
||||
maybe_migrate({created, #{final_cash_flow := _CashFlow}} = Ev) ->
|
||||
Ev;
|
||||
maybe_migrate({created, #{final_cash_flow := CashFlow} = EvBody}) ->
|
||||
{created, EvBody#{final_cash_flow => maybe_migrate_cash_flow(CashFlow)}};
|
||||
% Old events
|
||||
maybe_migrate({created, #{postings := Postings} = Transfer}) ->
|
||||
#{
|
||||
@ -238,6 +238,29 @@ maybe_migrate({created, #{postings := Postings} = Transfer}) ->
|
||||
postings => CashFlowPostings
|
||||
}
|
||||
}});
|
||||
% Other evnts
|
||||
% Other events
|
||||
maybe_migrate(Ev) ->
|
||||
Ev.
|
||||
Ev.
|
||||
|
||||
maybe_migrate_cash_flow(#{postings := CashFlowPostings} = CashFlow) ->
|
||||
CashFlow#{postings => lists:map(fun maybe_migrate_posting/1, CashFlowPostings)}.
|
||||
|
||||
% Some cashflow in early withdrawals has been created with binary accounter_account_id
|
||||
maybe_migrate_posting(#{
|
||||
sender := #{accounter_account_id := SenderAcc} = Sender
|
||||
} = Posting) when is_binary(SenderAcc) ->
|
||||
maybe_migrate_posting(Posting#{
|
||||
sender := Sender#{
|
||||
accounter_account_id := erlang:binary_to_integer(SenderAcc)
|
||||
}
|
||||
});
|
||||
maybe_migrate_posting(#{
|
||||
receiver := #{accounter_account_id := ReceiverAcc} = Receiver
|
||||
} = Posting) when is_binary(ReceiverAcc) ->
|
||||
maybe_migrate_posting(Posting#{
|
||||
receiver := Receiver#{
|
||||
accounter_account_id := erlang:binary_to_integer(ReceiverAcc)
|
||||
}
|
||||
});
|
||||
maybe_migrate_posting(Posting) ->
|
||||
Posting.
|
||||
|
Loading…
Reference in New Issue
Block a user