Correctif redescente du référentiel
This commit is contained in:
@@ -143,7 +143,8 @@ function attachCategoriesInv(rows) {
|
||||
return rows.map(r => {
|
||||
const ownTags = map[r.id] || [];
|
||||
if (!r.referentiel_id) return { ...r, categories_inv: ownTags };
|
||||
const refTags = refCatMap[r.referentiel_id] || [];
|
||||
const excludedIds = new Set(JSON.parse(r.excluded_categories_inv_ids || '[]'));
|
||||
const refTags = (refCatMap[r.referentiel_id] || []).filter(t => !excludedIds.has(t.id));
|
||||
const refIdSet = new Set(refTags.map(t => t.id));
|
||||
const ownIds = new Set(ownTags.map(t => t.id));
|
||||
for (const tag of ownTags) tag.is_inherited = refIdSet.has(tag.id);
|
||||
@@ -192,7 +193,8 @@ function attachSecteursInv(rows) {
|
||||
return rows.map(r => {
|
||||
const ownTags = map[r.id] || [];
|
||||
if (!r.referentiel_id) return { ...r, secteurs_inv: ownTags };
|
||||
const refTags = refSectMap[r.referentiel_id] || [];
|
||||
const excludedIds = new Set(JSON.parse(r.excluded_secteurs_inv_ids || '[]'));
|
||||
const refTags = (refSectMap[r.referentiel_id] || []).filter(t => !excludedIds.has(t.id));
|
||||
const refIdSet = new Set(refTags.map(t => t.id));
|
||||
const ownIds = new Set(ownTags.map(t => t.id));
|
||||
for (const tag of ownTags) tag.is_inherited = refIdSet.has(tag.id);
|
||||
@@ -218,8 +220,9 @@ function syncCategories(platId, catIds) {
|
||||
// ── Lecture référentiel (tous users authentifiés) ─────────────────────────
|
||||
router.get('/referentiel-list', (_req, res) => {
|
||||
const rows = db.prepare(`
|
||||
SELECT pr.id, pr.nom, pr.domiciliation, pr.fiscalite,
|
||||
pr.taux_fiscalite_locale, pr.type_produit_fiscal, pr.logo_filename, pr.icone_filename
|
||||
SELECT pr.id, pr.nom, pr.url, pr.domiciliation, pr.fiscalite,
|
||||
pr.taux_fiscalite_locale, pr.type_produit_fiscal, pr.logo_filename, pr.icone_filename,
|
||||
pr.methode_remboursement, pr.type_pret_defaut, pr.freq_interets_defaut
|
||||
FROM plateformes_referentiel pr
|
||||
ORDER BY pr.nom
|
||||
`).all();
|
||||
@@ -233,6 +236,7 @@ router.get('/', (req, res) => {
|
||||
p.methode_remboursement, p.investisseur_id, p.date_ouverture, p.logo_filename, p.icone_filename, p.created_at,
|
||||
p.type_pret_defaut, p.freq_interets_defaut,
|
||||
p.referentiel_id, p.overridden_fields,
|
||||
p.excluded_categories_inv_ids, p.excluded_secteurs_inv_ids,
|
||||
pr.nom AS referentiel_nom, pr.description AS referentiel_description,
|
||||
inv.nom AS investisseur_nom, inv.prenom AS investisseur_prenom,
|
||||
inv.type AS investisseur_type, inv.type_fiscal AS investisseur_type_fiscal,
|
||||
@@ -251,7 +255,10 @@ router.get('/', (req, res) => {
|
||||
}));
|
||||
const withCats = attachCategories(req.user.id, enriched);
|
||||
const withCatsInv = attachCategoriesInv(withCats);
|
||||
const withAll = attachSecteursInv(withCatsInv);
|
||||
const withAll = attachSecteursInv(withCatsInv).map(r => {
|
||||
const { excluded_categories_inv_ids, excluded_secteurs_inv_ids, ...rest } = r;
|
||||
return rest;
|
||||
});
|
||||
res.json(withAll);
|
||||
});
|
||||
|
||||
@@ -684,12 +691,14 @@ router.post('/:id/reset', (req, res, next) => {
|
||||
|
||||
db.prepare(`
|
||||
UPDATE plateformes
|
||||
SET nom=?, domiciliation=?, fiscalite=?, taux_fiscalite_locale=?,
|
||||
type_produit_fiscal=?, logo_filename=?, overridden_fields='[]'
|
||||
SET nom=?, url=?, domiciliation=?, fiscalite=?, taux_fiscalite_locale=?,
|
||||
type_produit_fiscal=?, logo_filename=?, methode_remboursement=?,
|
||||
type_pret_defaut=?, freq_interets_defaut=?, overridden_fields='[]'
|
||||
WHERE id=? AND user_id=?
|
||||
`).run(
|
||||
ref.nom, ref.domiciliation, ref.fiscalite, ref.taux_fiscalite_locale ?? null,
|
||||
ref.type_produit_fiscal, ref.logo_filename ?? null,
|
||||
ref.nom, ref.url ?? null, ref.domiciliation, ref.fiscalite, ref.taux_fiscalite_locale ?? null,
|
||||
ref.type_produit_fiscal, ref.logo_filename ?? null, ref.methode_remboursement || 'portefeuille',
|
||||
ref.type_pret_defaut ?? null, ref.freq_interets_defaut ?? null,
|
||||
req.params.id, req.user.id
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user