Backdated funds in BOS statements

This is the continuation of the old RFC - Backdated funds - BOS Statements which was rejected due to other projects having more priority. Now that these projects have been finished, we would like to revisit the RFC to update the statements. We need to fix the statements generated by BOS, used by EBO also, to show the backdated funds according to their creation time, not to their original value date.

Problem Description

Statements give clients visibility of their transactions and account movements (including funds in and out) at aggregate and individual currency level related to its client currency account. At this moment, we are generating the statements taking into account the original value date of a backdated fund, so if a client/BOS-user generates a statement file before and after receiving a backdated fund, the results may vary.

For example, on May'21 a client:
- generates statements for Apr'21 and May'21
- receives a backdated fund with original value date on Apr'21
- generates statements for Apr'21 and May'21 again

The new incoming is included in the Apr'21 statement. So a statement file for a past month is not static because it may vary along the time.

Background

Common background

A backdated fund usually happens when we receive funds to be matched against a client balance and for any reason, like the AML or any other screening reason, the fund is held for some days. After all checks are OK, the fund is fully authorised and the entry is created in the client balance, but with the original value date of the physical entry (Bank Account Entry).

At this moment, we have in BOS two database fields for the Currency Account Entries:
- date: Mostly used along BOS and it stores the original value date of the related entry (the Bank Account Entry or the original balance entry if we are doing a reversal).
- value_datetime: Newer field added -that actually has the logic we are looking for in this epic- but only exposed in the BOS API (get_client_transaction and get_client_transactions endpoints).

Specific background

The current statements are filtering by the CurrencyAccountEntry.date field, which stores the original value date.

Solution

Filter by CurrencyAccountEntry.value_datetime field, actually, this is already prepared in the code, we just need to use a flag. In settlements.controllers.statements.prepare_movements.get_movements, use using_value_datetime=True in AccountsFacade.get_client_currency_accounts_movements.

Alternatives

Just for the record, but we don't encourage going with this alternative in this RFC.
Change the creation of Currency Account Entries to store the proper value in the date field.

Caveats

In the code there are several functions where the balance is calculated based on dates, it seems to not affect to the statements, but we need to be aware.

Operation

If this is released not at the same time as the BOS interface fixes, there may be a discrepancy between them.

Security Impact

N/A

Performance Impact

N/A

Developer Impact

N/A

Data Consumer Impact

N/A

Deployment

Current BOS releases process.

Dependencies

References