Ajout du type Intérêt plateforme pour les remboursements
This commit is contained in:
1 parent
37f9f8b8a7
commit
1bab97b5b3
9 files changed
+248
-66
No files matched your search
@@ -268,6 +268,7 @@ export default function DepotsRetraits() {
|
||||
const out = [];
|
||||
for (const r of allRemb) {
|
||||
const isBonus = r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme';
|
||||
const isInteretsPlateforme = r.type === 'interets_plateforme';
|
||||
const plat = plats.find(p => p.id === r.plateforme_id);
|
||||
const base = {
|
||||
_rembId: r.id,
|
||||
@@ -305,7 +306,7 @@ export default function DepotsRetraits() {
|
||||
out.push({
|
||||
...base,
|
||||
id: `remb_${r.id}`,
|
||||
type: 'remboursement',
|
||||
type: isInteretsPlateforme ? 'interets_plateforme' : 'remboursement',
|
||||
montant: grossMontant,
|
||||
_isFlatTax: isFlatTax,
|
||||
_isAutoSweep: r.methode_remboursement === 'compte_courant',
|
||||
@@ -1140,6 +1141,7 @@ export default function DepotsRetraits() {
|
||||
<option value="remboursement">Remboursements</option>
|
||||
<option value="bonus">Bonus</option>
|
||||
<option value="cashback">Cashback</option>
|
||||
<option value="interets_plateforme">Intérêts plateforme</option>
|
||||
<option value="souscription">Souscriptions</option>
|
||||
<option value="prelevement_ir">Prélèvements IR</option>
|
||||
<option value="prelevement_csg">Prélèvements CSG</option>
|
||||
@@ -1251,9 +1253,10 @@ export default function DepotsRetraits() {
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
if (r.type === 'remboursement' || r.type === 'bonus' || r.type === 'cashback') {
|
||||
if (r.type === 'remboursement' || r.type === 'bonus' || r.type === 'cashback' || r.type === 'interets_plateforme') {
|
||||
const isBonus = r.type === 'bonus';
|
||||
const isCashback = r.type === 'cashback';
|
||||
const isInteretsPlateforme = r.type === 'interets_plateforme';
|
||||
return (
|
||||
<tr key={r.id}
|
||||
className={`dr-row${selectedRow?.id === r.id ? ' dr-row-selected' : ''}`}
|
||||
@@ -1269,9 +1272,11 @@ export default function DepotsRetraits() {
|
||||
padding: '2px 7px', borderRadius: 4,
|
||||
background: (isBonus || isCashback)
|
||||
? 'color-mix(in srgb, var(--warning) 18%, transparent)'
|
||||
: 'color-mix(in srgb, var(--success) 15%, transparent)',
|
||||
color: (isBonus || isCashback) ? 'var(--warning)' : 'var(--success)',
|
||||
}}>{isBonus ? 'bonus' : isCashback ? 'cashback' : 'remboursement'}</span>
|
||||
: isInteretsPlateforme
|
||||
? 'color-mix(in srgb, var(--primary) 18%, transparent)'
|
||||
: 'color-mix(in srgb, var(--success) 15%, transparent)',
|
||||
color: (isBonus || isCashback) ? 'var(--warning)' : isInteretsPlateforme ? 'var(--primary)' : 'var(--success)',
|
||||
}}>{isBonus ? 'bonus' : isCashback ? 'cashback' : isInteretsPlateforme ? 'intérêts plateforme' : 'remboursement'}</span>
|
||||
</td>
|
||||
<td className="text-muted">{r._projet || '—'}</td>
|
||||
<td className="num success">
|
||||
|
||||
@@ -850,6 +850,8 @@ export default function Plateformes() {
|
||||
: (r.capital || 0) + (r.cashback || 0) + (r.interets_bruts || 0);
|
||||
} else if (r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme') {
|
||||
balance += r.cashback || 0;
|
||||
} else if (r.type === 'interets_plateforme') {
|
||||
balance += r.net_recu || 0;
|
||||
}
|
||||
}
|
||||
for (const inv of allRows) {
|
||||
@@ -964,6 +966,7 @@ export default function Plateformes() {
|
||||
const out = [];
|
||||
for (const r of allRembs) {
|
||||
const isBonus = r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme';
|
||||
const isInteretsPlateforme = r.type === 'interets_plateforme';
|
||||
const plat = plats.find(p => p.id === r.plateforme_id);
|
||||
const base = {
|
||||
_rembId: r.id,
|
||||
@@ -999,7 +1002,7 @@ export default function Plateformes() {
|
||||
out.push({
|
||||
...base,
|
||||
id: `remb_${r.id}`,
|
||||
type: 'remboursement',
|
||||
type: isInteretsPlateforme ? 'interets_plateforme' : 'remboursement',
|
||||
montant: grossMontant,
|
||||
_isFlatTax: isFlatTax,
|
||||
_isAutoSweep: r.methode_remboursement === 'compte_courant',
|
||||
@@ -2406,6 +2409,7 @@ export default function Plateformes() {
|
||||
<option value="remboursement">Remboursements</option>
|
||||
<option value="bonus">Bonus</option>
|
||||
<option value="cashback">Cashback</option>
|
||||
<option value="interets_plateforme">Intérêts plateforme</option>
|
||||
<option value="souscription">Souscriptions</option>
|
||||
<option value="prelevement_ir">Prélèvements IR</option>
|
||||
<option value="prelevement_csg">Prélèvements CSG</option>
|
||||
@@ -2493,9 +2497,10 @@ export default function Plateformes() {
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
if (r.type === 'remboursement' || r.type === 'bonus' || r.type === 'cashback') {
|
||||
if (r.type === 'remboursement' || r.type === 'bonus' || r.type === 'cashback' || r.type === 'interets_plateforme') {
|
||||
const isBonus = r.type === 'bonus';
|
||||
const isCashback = r.type === 'cashback';
|
||||
const isInteretsPlateforme = r.type === 'interets_plateforme';
|
||||
return (
|
||||
<tr key={r.id}
|
||||
className={`dr-row${mvSelectedRow?.id === r.id ? ' dr-row-selected' : ''}`}
|
||||
@@ -2511,9 +2516,11 @@ export default function Plateformes() {
|
||||
padding: '2px 7px', borderRadius: 4,
|
||||
background: (isBonus || isCashback)
|
||||
? 'color-mix(in srgb, var(--warning) 18%, transparent)'
|
||||
: 'color-mix(in srgb, var(--success) 15%, transparent)',
|
||||
color: (isBonus || isCashback) ? 'var(--warning)' : 'var(--success)',
|
||||
}}>{isBonus ? 'bonus' : isCashback ? 'cashback' : 'remboursement'}</span>
|
||||
: isInteretsPlateforme
|
||||
? 'color-mix(in srgb, var(--primary) 18%, transparent)'
|
||||
: 'color-mix(in srgb, var(--success) 15%, transparent)',
|
||||
color: (isBonus || isCashback) ? 'var(--warning)' : isInteretsPlateforme ? 'var(--primary)' : 'var(--success)',
|
||||
}}>{isBonus ? 'bonus' : isCashback ? 'cashback' : isInteretsPlateforme ? 'intérêts plateforme' : 'remboursement'}</span>
|
||||
</td>
|
||||
<td className="text-muted">{r._projet || '—'}</td>
|
||||
<td className="num success">
|
||||
|
||||
@@ -48,6 +48,7 @@ function TrendBadge({ current, prev, invert = false }) {
|
||||
|
||||
|
||||
const BONUS_VALUES = ['BONUS_PARRAINAGE', 'BONUS_PLATEFORME'];
|
||||
const INTERETS_PLATEFORME_VALUE = 'INTERETS_PLATEFORME';
|
||||
const ICONS_BASE = '/api/icons-files/';
|
||||
const BONUS_TYPE_MAP = { BONUS_PARRAINAGE: 'bonus_parrainage', BONUS_PLATEFORME: 'bonus_plateforme' };
|
||||
|
||||
@@ -424,9 +425,9 @@ export default function Remboursements() {
|
||||
if (tableFilter.type && tableFilter.type !== 'correction_solde' && r.type !== tableFilter.type) return false;
|
||||
if (tableFilter.type === 'correction_solde') return false; // géré séparément
|
||||
// Filtre projet
|
||||
const isBonusTypeFilter = tableFilter.type === 'bonus_parrainage' || tableFilter.type === 'bonus_plateforme';
|
||||
const isBonusTypeFilter = tableFilter.type === 'bonus_parrainage' || tableFilter.type === 'bonus_plateforme' || tableFilter.type === 'interets_plateforme';
|
||||
if (!isBonusTypeFilter && tableFilter.investissement_id) {
|
||||
const isBonus = r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme';
|
||||
const isBonus = r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme' || r.type === 'interets_plateforme';
|
||||
if (isBonus) return false;
|
||||
if (String(r.investissement_id) !== String(tableFilter.investissement_id)) return false;
|
||||
}
|
||||
@@ -535,9 +536,13 @@ export default function Remboursements() {
|
||||
const openEdit = (r) => {
|
||||
setEditingId(r.id);
|
||||
const isBonus = r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme';
|
||||
const sentinelle = r.type === 'bonus_parrainage' ? 'BONUS_PARRAINAGE' : r.type === 'bonus_plateforme' ? 'BONUS_PLATEFORME' : '';
|
||||
const isInteretsPlateforme = r.type === 'interets_plateforme';
|
||||
const sentinelle = r.type === 'bonus_parrainage' ? 'BONUS_PARRAINAGE'
|
||||
: r.type === 'bonus_plateforme' ? 'BONUS_PLATEFORME'
|
||||
: isInteretsPlateforme ? INTERETS_PLATEFORME_VALUE
|
||||
: '';
|
||||
setForm({
|
||||
investissement_id: isBonus ? sentinelle : r.investissement_id,
|
||||
investissement_id: (isBonus || isInteretsPlateforme) ? sentinelle : r.investissement_id,
|
||||
date_remb: r.date_remb,
|
||||
capital: r.capital, cashback: r.cashback || 0,
|
||||
interets_bruts_avant_local: r.interets_bruts_avant_local || 0,
|
||||
@@ -552,7 +557,7 @@ export default function Remboursements() {
|
||||
});
|
||||
setErr(null); setModalOpen(true);
|
||||
// Charge les comptes du détenteur pour le dropdown Compte de réception
|
||||
if (!isBonus) {
|
||||
if (!isBonus && !isInteretsPlateforme) {
|
||||
const invForEdit = investissements.find(i => i.id === r.investissement_id);
|
||||
if (invForEdit?.investisseur_id) {
|
||||
api.get(`/investissements/comptes-par-investisseur/${invForEdit.investisseur_id}`)
|
||||
@@ -654,8 +659,12 @@ export default function Remboursements() {
|
||||
|
||||
// Fiscalité locale : calcule taxe_locale et interets_bruts à partir du brut avant retenue
|
||||
if (k === 'interets_bruts_avant_local') {
|
||||
const inv = investissements.find(i => i.id === Number(next.investissement_id));
|
||||
const plat = plateformes.find(p => p.id === inv?.plateforme_id);
|
||||
const plat = next.investissement_id === INTERETS_PLATEFORME_VALUE
|
||||
? plateformes.find(p => String(p.id) === String(next.bonus_plateforme_id))
|
||||
: (() => {
|
||||
const inv = investissements.find(i => i.id === Number(next.investissement_id));
|
||||
return plateformes.find(p => p.id === inv?.plateforme_id);
|
||||
})();
|
||||
const taux = plat?.fiscalite === 'avec_fiscalite_locale' ? (plat?.taux_fiscalite_locale || 0) : 0;
|
||||
next.taxe_locale = round2(Number(v) * taux / 100);
|
||||
next.interets_bruts = round2(Number(v) - next.taxe_locale);
|
||||
@@ -676,7 +685,7 @@ export default function Remboursements() {
|
||||
}
|
||||
// Quand l'investissement change, on hérite silencieusement de la méthode de la plateforme
|
||||
// (si fermée) ou on remet le défaut (si ouverte, l'utilisateur choisira dans le formulaire)
|
||||
if (k === 'investissement_id' && !BONUS_VALUES.includes(v)) {
|
||||
if (k === 'investissement_id' && !BONUS_VALUES.includes(v) && v !== INTERETS_PLATEFORME_VALUE) {
|
||||
const inv = investissements.find(i => i.id === Number(v));
|
||||
const plat = plateformes.find(p => p.id === inv?.plateforme_id);
|
||||
if (plat && plat.methode_remboursement !== 'choix_investisseur') {
|
||||
@@ -708,6 +717,7 @@ export default function Remboursements() {
|
||||
};
|
||||
|
||||
const isBonus = BONUS_VALUES.includes(form.investissement_id);
|
||||
const isInteretsPlateforme = form.investissement_id === INTERETS_PLATEFORME_VALUE;
|
||||
|
||||
const submit = async (e) => {
|
||||
e?.preventDefault?.();
|
||||
@@ -724,6 +734,20 @@ export default function Remboursements() {
|
||||
statut: form.statut,
|
||||
notes: form.notes || undefined,
|
||||
};
|
||||
} else if (isInteretsPlateforme) {
|
||||
payload = {
|
||||
type: 'interets_plateforme',
|
||||
bonus_plateforme_id: Number(form.bonus_plateforme_id),
|
||||
bonus_investisseur_id: form.bonus_investisseur_id ? Number(form.bonus_investisseur_id) : undefined,
|
||||
date_remb: form.date_remb,
|
||||
interets_bruts_avant_local: Number(form.interets_bruts_avant_local || 0),
|
||||
taxe_locale: Number(form.taxe_locale || 0),
|
||||
interets_bruts: Number(form.interets_bruts || 0),
|
||||
prelev_sociaux: Number(form.prelev_sociaux || 0),
|
||||
prelev_forfaitaire: Number(form.prelev_forfaitaire || 0),
|
||||
statut: form.statut,
|
||||
notes: form.notes || undefined,
|
||||
};
|
||||
} else {
|
||||
payload = {
|
||||
type: 'normal',
|
||||
@@ -1136,6 +1160,7 @@ export default function Remboursements() {
|
||||
<option value="normal">Remboursements</option>
|
||||
<option value="bonus_parrainage">Bonus Parrainage</option>
|
||||
<option value="bonus_plateforme">Bonus Plateforme</option>
|
||||
<option value="interets_plateforme">Intérêts plateforme</option>
|
||||
<option value="correction_solde">Corrections de solde</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -1186,6 +1211,8 @@ export default function Remboursements() {
|
||||
)}
|
||||
{pagedTableRows.map(r => {
|
||||
const isBonus = r.type === 'bonus_parrainage' || r.type === 'bonus_plateforme';
|
||||
const isInteretsPlateforme = r.type === 'interets_plateforme';
|
||||
const isBonusLike = isBonus || isInteretsPlateforme;
|
||||
const isCorrection = r._is_correction === true;
|
||||
const rowKey = isCorrection ? `corr-${r.id}` : `remb-${r.id}`;
|
||||
return (
|
||||
@@ -1214,7 +1241,7 @@ export default function Remboursements() {
|
||||
<td>
|
||||
{isCorrection
|
||||
? <span style={{ color: 'var(--text-muted)', fontStyle: 'italic' }}>{r.nom_projet}</span>
|
||||
: isBonus
|
||||
: isBonusLike
|
||||
? <span style={{ color: 'var(--text-muted)', fontStyle: 'italic' }}>{r.nom_projet}</span>
|
||||
: r.nom_projet}
|
||||
</td>
|
||||
@@ -1233,9 +1260,9 @@ export default function Remboursements() {
|
||||
<span className="text-muted">Porte-monnaie</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="num">{(isBonus || isCorrection) ? '—' : fmtEUR(r.capital)}</td>
|
||||
<td className="num" style={{ color: !isBonus && !isCorrection && r.capital_restant_du <= 0 ? 'var(--success)' : undefined }}>
|
||||
{(isBonus || isCorrection) ? '—' : fmtEUR(Math.max(0, r.capital_restant_du ?? 0))}
|
||||
<td className="num">{(isBonusLike || isCorrection) ? '—' : fmtEUR(r.capital)}</td>
|
||||
<td className="num" style={{ color: !isBonusLike && !isCorrection && r.capital_restant_du <= 0 ? 'var(--success)' : undefined }}>
|
||||
{(isBonusLike || isCorrection) ? '—' : fmtEUR(Math.max(0, r.capital_restant_du ?? 0))}
|
||||
</td>
|
||||
<td className="num">{r.cashback ? fmtEUR(r.cashback) : '—'}</td>
|
||||
<td className="num">{(isBonus || isCorrection) ? '—' : fmtEUR(r.interets_bruts)}</td>
|
||||
|
||||
Reference in new issue
Block a user