Correction de solde
This commit is contained in:
1 parent
1bab97b5b3
commit
849e16de33
3 files changed
+188
-6
No files matched your search
@@ -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}
|
||||
|
||||
@@ -19,7 +19,7 @@ import Modal from '../components/Modal.jsx';
|
||||
import ConfirmModal from '../components/ConfirmModal.jsx';
|
||||
import {
|
||||
mouvToCSV, mouvToXLS, mouvToJSON,
|
||||
ExportDropdown, DetailPanel, CorrectionModal, MOIS_FR, emptyMouvementForm,
|
||||
ExportDropdown, AddDropdown, CorrectionPickerModal, DetailPanel, CorrectionModal, MOIS_FR, emptyMouvementForm,
|
||||
timestampSuffix, dlBlob,
|
||||
} from '../components/MouvementsShared.jsx';
|
||||
|
||||
@@ -897,6 +897,8 @@ export default function Plateformes() {
|
||||
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 [mvCorrPickerOpen, setMvCorrPickerOpen] = useState(false);
|
||||
|
||||
// Le périmètre plateforme de cet onglet est strictement verrouillé sur la sélection
|
||||
// "Plateforme" de la page (filteredPlatIds) — aucun contrôle interne ne permet de
|
||||
@@ -1187,6 +1189,33 @@ export default function Plateformes() {
|
||||
});
|
||||
};
|
||||
|
||||
/* Correction de solde autonome (bouton "+" du tableau Mouvements Porte-monnaie) —
|
||||
pas de mouvement dépôt/retrait déclencheur, l'utilisateur choisit plateforme + date
|
||||
parmi les plateformes du périmètre de la page (filteredPlatIds). */
|
||||
const mvOpenCorrectionManual = async ({ plateforme_id, date }) => {
|
||||
const plat = plats.find(p => p.id === plateforme_id);
|
||||
const investId = mvInvestisseurForPlat(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);
|
||||
}
|
||||
|
||||
setMvCorrPickerOpen(false);
|
||||
setMvCorrModal({
|
||||
open: true,
|
||||
plateforme_nom: plat?.nom || '',
|
||||
type_operation: null,
|
||||
computedBalance,
|
||||
date,
|
||||
platId: plateforme_id,
|
||||
investisseurId: investId ? Number(investId) : null,
|
||||
});
|
||||
};
|
||||
|
||||
const mvSubmit = async (e) => {
|
||||
e?.preventDefault?.(); setMvErr(null);
|
||||
try {
|
||||
@@ -1220,7 +1249,9 @@ export default function Plateformes() {
|
||||
plateforme_id: mvCorrModal.platId,
|
||||
date: mvCorrModal.date,
|
||||
montant: diff,
|
||||
notes: `Correction solde porte-monnaie — ${mvCorrModal.type_operation === 'retrait' ? 'retrait' : 'dépôt'}`,
|
||||
notes: mvCorrModal.type_operation
|
||||
? `Correction solde porte-monnaie — ${mvCorrModal.type_operation === 'retrait' ? 'retrait' : 'dépôt'}`
|
||||
: 'Correction solde porte-monnaie — saisie manuelle',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Correction creation failed:', e);
|
||||
@@ -2394,6 +2425,10 @@ export default function Plateformes() {
|
||||
onXLS={() => dlBlob(mouvToXLS(mvTableRows, multiDetenteur), `Mouvements Porte-monnaie ${timestampSuffix()}.xlsx`, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')}
|
||||
onJSON={() => dlBlob(mouvToJSON(mvTableRows), `Mouvements Porte-monnaie ${timestampSuffix()}.json`, 'application/json')}
|
||||
/>
|
||||
<AddDropdown
|
||||
disabled={filteredPlatIds.size === 0}
|
||||
onNewCorrection={() => setMvCorrPickerOpen(true)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2801,6 +2836,15 @@ export default function Plateformes() {
|
||||
onConfirm={mvHandleCorrectionConfirm}
|
||||
/>
|
||||
|
||||
<CorrectionPickerModal
|
||||
open={mvCorrPickerOpen}
|
||||
onClose={() => setMvCorrPickerOpen(false)}
|
||||
onContinue={mvOpenCorrectionManual}
|
||||
plateformes={plats.filter(p => filteredPlatIds.has(p.id))}
|
||||
multiDetenteur={multiDetenteur}
|
||||
defaultPlateformeId={filteredPlatIds.size === 1 ? [...filteredPlatIds][0] : undefined}
|
||||
/>
|
||||
|
||||
{mvDeleteConfirm && (
|
||||
<ConfirmModal
|
||||
open={true}
|
||||
|
||||
Reference in new issue
Block a user