Implementation de la notion d'espace d'investissement
This commit is contained in:
1 parent
6b6cad7cd6
commit
4b7df66862
54 files changed
+6782
-288
No files matched your search
@@ -125,6 +125,19 @@ router.get('/', (req, res) => {
|
||||
GROUP BY i.plateforme_id
|
||||
`).all(...(asOf ? [asOf] : []), ...invParams, ...(asOf ? [asOf] : []));
|
||||
|
||||
// Capital investi Private Equity (investissements_pe.montant_investi) — une
|
||||
// plateforme peut être partagée entre le workspace crowdlending et le
|
||||
// workspace Private Equity (ex. Fundora) : le porte-monnaie réel chez le
|
||||
// courtier est UNIQUE, donc le capital englouti dans un deal PE doit aussi
|
||||
// réduire le porte-monnaie affiché ici, même si cette page est celle du
|
||||
// workspace crowdlending (17/09/26).
|
||||
const capitalInvestiPePerPlat = db.prepare(`
|
||||
SELECT plateforme_id, COALESCE(SUM(montant_investi), 0) AS capital_investi
|
||||
FROM investissements_pe
|
||||
WHERE ${invWhere}${asOf ? ' AND date_souscription <= ?' : ''}
|
||||
GROUP BY plateforme_id
|
||||
`).all(...invParams, ...(asOf ? [asOf] : []));
|
||||
|
||||
// Frais d'opération (Étape 3, 31/08/26) : un frais réglé 'source' ou 'portefeuille'
|
||||
// réduit le solde du porte-monnaie. 'source' s'ajoute à la réduction déjà appliquée via
|
||||
// capitalInvestiPerPlat (qui soustrait montant_investi déjà net) — cas confirmé par Olivier
|
||||
@@ -158,6 +171,7 @@ router.get('/', (req, res) => {
|
||||
for (const r of bonusWalletPerPlat) walletMap[r.plateforme_id] = (walletMap[r.plateforme_id] || 0) + r.bonus_wallet;
|
||||
for (const r of interetsPlateformeWalletPerPlat) walletMap[r.plateforme_id] = (walletMap[r.plateforme_id] || 0) + r.interets_plateforme_wallet;
|
||||
for (const r of capitalInvestiPerPlat) walletMap[r.plateforme_id] = (walletMap[r.plateforme_id] || 0) - r.capital_investi;
|
||||
for (const r of capitalInvestiPePerPlat) walletMap[r.plateforme_id] = (walletMap[r.plateforme_id] || 0) - r.capital_investi;
|
||||
for (const r of fraisPerPlat) walletMap[r.plateforme_id] = (walletMap[r.plateforme_id] || 0) - r.total_frais;
|
||||
for (const r of correctionsPerPlat) walletMap[r.plateforme_id] = (walletMap[r.plateforme_id] || 0) + r.total_correction;
|
||||
|
||||
@@ -358,6 +372,14 @@ router.get('/solde-historique', (req, res) => {
|
||||
AND i.date_souscription <= ?
|
||||
`).get(date, platId, ...invParams, date);
|
||||
|
||||
// Capital investi Private Equity sur cette même plateforme (cf. GET / —
|
||||
// capitalInvestiPePerPlat) : même porte-monnaie physique, même correction.
|
||||
const capitalPe = db.prepare(`
|
||||
SELECT COALESCE(SUM(montant_investi), 0) AS capital_investi
|
||||
FROM investissements_pe
|
||||
WHERE plateforme_id = ? AND ${invWhere} AND date_souscription <= ?
|
||||
`).get(platId, ...invParams, date);
|
||||
|
||||
/* ── 5. Frais d'opération 'source'/'portefeuille' (jusqu'à :date) ─── */
|
||||
// Cf. GET / ci-dessus (fraisPerPlat) — même logique, même exclusion de compte_courant.
|
||||
const frais = db.prepare(`
|
||||
@@ -382,6 +404,7 @@ router.get('/solde-historique', (req, res) => {
|
||||
+ remb.remb_wallet
|
||||
+ bonus.bonus_wallet
|
||||
- capital.capital_investi
|
||||
- capitalPe.capital_investi
|
||||
- frais.total_frais
|
||||
+ corrections.total_correction
|
||||
) * 100) / 100;
|
||||
|
||||
Reference in new issue
Block a user