Aller au contenu

investor-account-summary

An account summary is a PDF of one investor account over a period chosen by an admin. Calculation rules live in the Linear document « Récapitulatif de compte : méthodes de calcul des lignes » (BRI-2215).

Period

Start and end dates are calendar days, both included, read in Europe/Paris. The end date cannot be after today in Paris.

Account holder

The PDF header shows Bricks on the left and the account holder on the right.

  • Individual account: first name and last name from customer_profile, then the email.
  • Business account: the company name, customer_profile.business->>'name', its registration number, customer_profile.business->>'identificationNumber', labelled « N° d’immatriculation » (shown as stored, a SIREN or a SIRET for most French companies), then the email. The number is optional, many business profiles have none: a missing or blank one hides the line.

InvestorAccountSummary.accountHolderValidator checks the profile once it is read. A missing or blank value blocks the generation: no profile row (reported as customerType), an individual without first name or last name, a business without company name. No summary goes out without a name. The log lists the invalid field names, never their values.

A deleted account can still get a summary (BRI-2215: requests from former clients, for accounting or a succession). The email shows the original address, without the prefix added at deletion (InvestorDeletionBusiness.restoreEmailFromDeleted).

Financial movements

InvestorWalletTransactionRepository.getFinancialMovementSubtotals reads the period financial movement subtotals in the same REPEATABLE READ READ ONLY transaction as the balances: one snapshot, so the end balance check compares figures from the same instant.

  • It only sums, by kind, product, referenced kind and asset transfer origin. It never classifies.
  • Same statuses and Paris day bounds as the balances: one copy of each rule (countedInBalanceSql in InvestorWalletTransactionRepository, parisStartOfDaySql in src/__new/lib/date/paris-start-of-day-sql.ts), so a rule cannot change in one read only and break the end balance check.
  • Zod validates each row: kind against the TypeScript enum, referenced kind as free text, product in royalty | obligation | loan or none. A kind or a product outside these lists fails the parsing (500); the log names the unknown kind.

buildAccountSummarySections (business/) turns the period financial movement subtotals into the PDF lines, section totals and end balance check. It is pure: the service reads the subtotals and the balances, then maps its errors.

  • Inputs: financial movement subtotals by kind, project product, referenced kind (adjustment_neg only) and asset transfer origin; the start and end balances.
  • A subtotal from an asset transfer goes to assetTransfers, whatever its kind.
  • Any other subtotal follows walletTransactionTypeFinancialClassification, one classification per kind: a line, 'ignored', or a line by product or by referenced kind.
  • An adjustment_neg follows its referenced kind: a gift card take-back goes to giftCardCredits, a debit without reference to regularizations.
  • Every line of a section is returned, in PDF order. The PDF hides a line at 0, except:
  • start balance
  • withdraws
  • Compte client, Investissements and Remboursements totals
  • withdrawable, gift and total balances at the end date
  • portfolio value at the end date
  • Sections: nonCapitalFlows (money in and out outside the capital cycle), investments (capital placed), divestments (money back from a placement, gain or loss included). The start balance stays apart; each section total = its lines. The PDF's Total Compte client adds the start balance.

Blocking errors. The service returns them as 409 account-summary.<code> and logs investorId with the kind, product, referenced kind and transaction count, never an amount:

Code When
unexpected-product Product missing or not accepted by the line of the kind
unexpected-adjustment-neg-reference adjustment_neg referencing a kind other than gift_card_purchase
reconciliation-mismatch End balance ≠ start balance + the three totals, to the cent. An ignored kind with a non-zero amount ends here

Assets received by transfer

The end of period section shows « Actifs reçus par transfert sur la période (bricks et actions) »: the value of the bricks and company investments the account received through asset transfers during the period. The line is information only: it enters no total and no balance. It is hidden at 0.

InvestorAssetTransferRepository.getReceivedAssetsAmount reads it in the same transaction as the balances.

  • Bricks: amount of the debit_for_brick_asset_transfer, last brick price × brick count on the transfer day.
  • Company investments: amount of the company_investment created by the transfer, at purchase price.
  • Dated by the transfer (asset_transfer."createdAt"), not by the transaction: a company_investment from a transfer is backdated to the first investment of the base account.
  • Only the beneficiary gets the line. The base account has no transaction for bricks or company investments.
  • Both kinds are stored negative. The repository returns the amount received, positive.

Two lines come from an asset transfer and measure different things. assetTransfers (« Transferts de solde ») is the effect on the balance: every transaction of the transfer goes there, and the credit and debit pairs of bricks and company investments cancel out. The received assets amount is the value of those bricks and company investments, outside every total.

Portfolio value

The end-of-period section shows the portfolio value at the end date: royalties plus obligations and loans, from PortfolioWealthAtDateRepository.getComposition, the read behind the back-office Time Machine. Same read, same inclusive end date: the PDF value is the sum of the Time Machine royalties and obligations-and-loans values for the same date. Always shown, even at 0.

Auto-invest purchases not yet confirmed by the investor are not in the portfolio value. The line « Investissements en attente de confirmation », between total balance and portfolio value, shows their value from PortfolioWealthAtDateRepository.getPendingAutoInvestConfirmation. The money has left the balance: the line keeps it visible. Hidden at 0. The Time Machine does not run this read.

Read in the same REPEATABLE READ READ ONLY transaction as the balances and the financial movements.

Fundraising invested amounts

The end of period section shows « Total investi dans la levée de fonds 2022 » and « Total investi dans la levée de fonds 2026 »: the net amount invested in the company at the end date, at purchase price. Information only, outside every total and balance, each hidden at 0.

InvestorWalletTransactionRepository.getFundraisingInvestedAmountsAtStartOfDay reads both in the same transaction as the balances, with the balance statuses.

  • 2022 = −(company_investment + refund_company_investment + refund_partial_company_investment) − company investments ceded by asset transfer (asset_transfer.config.baseAccountAssets.companyInvestmentAmount).
  • A company_investment from a transfer counts from the transfer date (asset_transfer."createdAt"): its own createdAt is backdated to the first investment of the base account. The base account loses the ceded amount on the same date.
  • The ceded amount is a snapshot taken at the transfer by InvestorPortfolioRepository.getCompanyInvestmentAmount, a narrower rule (confirmed only, no gift balance, no refund_company_investment). Both rules give the same amount for every investor in prod (checked on 13/11/2026): no 2022 transaction has a gift balance part, and a total refund cancels its company_investment. Only the asset transfer still writes these kinds, confirmed without gift balance.
  • 2026 = −(company_internal_fundraise_purchase + company_internal_fundraise_refund).
  • PEA-PME and big wire investments are left out: no wallet transaction.

Storage

Generating a summary stores it: no preview is left unrecorded, and the POST returns exactly the stored PDF.

  • The PDF goes to the private investor documents bucket (INVESTOR_DOCUMENT_PRIVATE_S3_BUCKET_NAME, with its own IAM key limited to that bucket), key investor-account-summary/<uuidv7>.pdf. The key carries no personal data.
  • Then one transaction inserts the document row (bucket = 'investor-document-private', author in betterAuthUserId) and the investor_account_summary row (same admin in adminId, createdAt set by the API).
  • A failed insert deletes the S3 object. A failed generation leaves neither file nor history row.
  • A failed COMMIT keeps the object: the commit may have applied, and a history row must never point to a missing PDF. The worst case is an unreferenced object, the same as a failed delete (logged as a warning).
  • document.bucket holds a stable key, never the bucket name: InvestorDocumentPrivateS3 targets the bucket of the running environment.

History and download

  • The history lists an account's generations, newest first. The author is the admin's better_auth_user.name: Google sign-ins leave firstName and lastName empty.
  • A download reads the stored PDF back from S3, never recomputes it: it returns the bytes the POST returned. The id is always read with the account: an id from another account is not-found.
  • A history row whose S3 object cannot be read is a broken invariant: 500, never 404.