Aller au contenu

investor-freeze

Append-only history of investor freezes and unfreezes.

The table is investor_freeze_history. A row is one action, a freeze or an unfreeze. A freeze on an account that is already frozen does not change customers.transactionRights (cashin_fundraise = frozen, all = not). It is recorded when its reason differs from the latest freeze row. The same reason writes nothing. No earlier freeze row writes a line.

Single write point

CustomerFreezeService.freezeCustomer and safeUnfreeze insert the entry in the same transaction as the transactionRights update. No other application path writes that table. A manual freeze goes through CustomerFreezeService, never raw SQL: the database does not validate the cause.

When safeUnfreeze owns the transaction and the P2P replay returns an error, that transaction rolls the entry back with the unfreeze. A caller that passes parent owns the rollback: the error does not roll the entry back by itself.

Entry

  • kind — freeze or unfreeze. The cause does not encode the direction.
  • cause — jsonb, validated by InvestorFreezeModel.cause in investor-freeze.model.ts. The database only checks that it is an object.
  • reason — InvestorFreezeModel.Reason, the union of AdminReason and AutomaticReason. The cause of the action, on a freeze and on an unfreeze. An unfreeze names the cause being lifted: automatic callers reuse the freeze reason, an admin picks death, fraud_victim or other. The BO contract declares only the admin reasons, with their French labels. It does not import this file. The automatic reasons keep their French labels here, for the Slack message.
  • detail — optional text, trimmed, at least 1 character. Required when reason is other. No maximum length: a long detail must not block the freeze. CustomerFreezeService parses InvestorFreezeModel.cause before writing, so every caller is checked. The chargeback webhook cuts the Lemonway comment to 500 characters before that parse. Automatic callers otherwise write a short sentence: the KYC transition, the file name, or the balance sentence.
  • adminId — session admin. Required for death, fraud_victim and other. Absent for an automatic action. The Excel upload passes the session admin. The waiting-purchases script does not.
  • adminId_view — generated from cause->>'adminId'. Holds the foreign key to better_auth_user for the admin email join. The repository does not return it.

Entries are never rewritten. Removing or renaming a reason, or tightening a cause rule, breaks the parse of past entries.

Slack

A freeze that changes transactionRights, and a successful unfreeze, post to #suivi-investor-freeze in production. The message names the investor, the reason, and links to the BO Invest profile (/customers/:id/profile). The origin is BO_INVEST_URL. No stack trace. Other environments stay on their dev alert channel.