Correction de solde

This commit is contained in:
ocroguennec committed 2026-08-16 17:48:40 +02:00
1 parent 1bab97b5b3
commit 849e16de33
3 files changed
+188 -6

No files matched your search

+44 -2
View File
@@ -16,7 +16,7 @@ import SuiviObjectifs from '../components/SuiviObjectifs.jsx';
import * as XLSX from 'xlsx';
import {
DEBIT_TYPES, signedMontant, MOUV_TYPE_LABELS, mouvToCSV, mouvToXLS, mouvToJSON,
ExportDropdown, DetailPanel, CorrectionModal, MOIS_FR, emptyMouvementForm,
ExportDropdown, AddDropdown, CorrectionPickerModal, DetailPanel, CorrectionModal, MOIS_FR, emptyMouvementForm,
timestampSuffix, dlBlob,
} from '../components/MouvementsShared.jsx';
@@ -156,6 +156,8 @@ export default function DepotsRetraits() {
open: false, plateforme_nom: '', type_operation: 'retrait',
computedBalance: 0, date: '', platId: null, investisseurId: null,
});
// État de la modale de sélection plateforme/date (correction de solde autonome, bouton "+")
const [corrPickerOpen, setCorrPickerOpen] = useState(false);
const load = async () => {
if (!activeId && activeView !== 'all') return;
@@ -705,6 +707,32 @@ export default function DepotsRetraits() {
});
};
/* Correction de solde autonome (bouton "+" du tableau Mouvements) — pas de
mouvement dépôt/retrait déclencheur, l'utilisateur choisit plateforme + date. */
const openCorrectionManual = async ({ plateforme_id, date }) => {
const plat = plats.find(p => p.id === plateforme_id);
const investId = investisseurForPlat(plateforme_id);
let computedBalance = 0;
try {
const result = await api.get('/dashboard/solde-historique', { plateforme_id, date });
computedBalance = result.solde ?? 0;
} catch (e) {
console.error('solde-historique error:', e);
}
setCorrPickerOpen(false);
setCorrModal({
open: true,
plateforme_nom: plat?.nom || '',
type_operation: null,
computedBalance,
date,
platId: plateforme_id,
investisseurId: investId ? Number(investId) : null,
});
};
const close = () => { setModalOpen(false); setEditingId(null); setForm(emptyMouvementForm); setErr(null); };
const submit = async (e) => {
@@ -766,7 +794,9 @@ export default function DepotsRetraits() {
plateforme_id: corrModal.platId,
date: corrModal.date,
montant: diff,
notes: `Correction solde porte-monnaie — ${corrModal.type_operation === 'retrait' ? 'retrait' : 'dépôt'}`,
notes: corrModal.type_operation
? `Correction solde porte-monnaie — ${corrModal.type_operation === 'retrait' ? 'retrait' : 'dépôt'}`
: 'Correction solde porte-monnaie — saisie manuelle',
});
} catch (e) {
console.error('Correction creation failed:', e);
@@ -1116,6 +1146,10 @@ export default function DepotsRetraits() {
onXLS={() => dlBlob(mouvToXLS(tableRows, multiDetenteur), `Mouvements Dépôts Retraits ${timestampSuffix()}.xlsx`, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')}
onJSON={() => dlBlob(mouvToJSON(tableRows), `Mouvements Dépôts Retraits ${timestampSuffix()}.json`, 'application/json')}
/>
<AddDropdown
disabled={plats.length === 0}
onNewCorrection={() => setCorrPickerOpen(true)}
/>
<button
type="button"
className="icon-btn"
@@ -1557,6 +1591,14 @@ export default function DepotsRetraits() {
onConfirm={handleCorrectionConfirm}
/>
<CorrectionPickerModal
open={corrPickerOpen}
onClose={() => setCorrPickerOpen(false)}
onContinue={openCorrectionManual}
plateformes={plats}
multiDetenteur={multiDetenteur}
/>
{deleteConfirm && (
<ConfirmModal
open={true}