fix: Update PrimeReact to v10.8.3 and fix all compilation errors
This commit is contained in:
@@ -19,6 +19,7 @@ import { Divider } from 'primereact/divider';
|
||||
import { factureService, clientService } from '../../../../../services/api';
|
||||
import { formatCurrency } from '../../../../../utils/formatters';
|
||||
import type { Facture, LigneFacture, Client } from '../../../../../types/btp';
|
||||
import { StatutFacture, TypeFacture } from '../../../../../types/btp';
|
||||
|
||||
const FactureEditPage = () => {
|
||||
const params = useParams();
|
||||
@@ -29,10 +30,10 @@ const FactureEditPage = () => {
|
||||
numero: '',
|
||||
objet: '',
|
||||
description: '',
|
||||
type: 'FACTURE',
|
||||
statut: 'BROUILLON',
|
||||
dateEmission: new Date(),
|
||||
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // +30 jours
|
||||
typeFacture: TypeFacture.FACTURE,
|
||||
statut: StatutFacture.BROUILLON,
|
||||
dateEmission: new Date().toISOString(),
|
||||
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), // +30 jours
|
||||
tauxTVA: 20,
|
||||
lignes: []
|
||||
});
|
||||
@@ -49,7 +50,7 @@ const FactureEditPage = () => {
|
||||
quantite: 1,
|
||||
unite: 'unité',
|
||||
prixUnitaire: 0,
|
||||
montantHT: 0
|
||||
montantLigne: 0
|
||||
});
|
||||
|
||||
const factureId = params.id as string;
|
||||
@@ -96,16 +97,17 @@ const FactureEditPage = () => {
|
||||
|
||||
// Charger les clients
|
||||
const clientsResponse = await clientService.getAll();
|
||||
setClients(clientsResponse.data);
|
||||
|
||||
setClients(clientsResponse);
|
||||
|
||||
if (!isNew) {
|
||||
// Charger la facture existante
|
||||
const factureResponse = await factureService.getById(factureId);
|
||||
setFacture(factureResponse.data);
|
||||
setFacture(factureResponse);
|
||||
} else {
|
||||
// Générer un nouveau numéro
|
||||
const numeroResponse = await factureService.generateNumero();
|
||||
setFacture(prev => ({ ...prev, numero: numeroResponse.data.numero }));
|
||||
// Générer un nouveau numéro basé sur la date
|
||||
const now = new Date();
|
||||
const numero = `FAC-${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}-${String(Math.floor(Math.random() * 10000)).padStart(4, '0')}`;
|
||||
setFacture(prev => ({ ...prev, numero }));
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
@@ -122,11 +124,11 @@ const FactureEditPage = () => {
|
||||
|
||||
const calculateMontants = () => {
|
||||
if (!facture.lignes) return;
|
||||
|
||||
const montantHT = facture.lignes.reduce((total, ligne) => total + (ligne.montantHT || 0), 0);
|
||||
|
||||
const montantHT = facture.lignes.reduce((total, ligne) => total + (ligne.montantLigne || 0), 0);
|
||||
const montantTVA = montantHT * (facture.tauxTVA || 0) / 100;
|
||||
const montantTTC = montantHT + montantTVA;
|
||||
|
||||
|
||||
setFacture(prev => ({
|
||||
...prev,
|
||||
montantHT,
|
||||
@@ -185,7 +187,7 @@ const FactureEditPage = () => {
|
||||
quantite: 1,
|
||||
unite: 'unité',
|
||||
prixUnitaire: 0,
|
||||
montantHT: 0
|
||||
montantLigne: 0
|
||||
});
|
||||
setShowLigneDialog(true);
|
||||
};
|
||||
@@ -296,9 +298,9 @@ const FactureEditPage = () => {
|
||||
<label htmlFor="type" className="font-semibold">Type *</label>
|
||||
<Dropdown
|
||||
id="type"
|
||||
value={facture.type}
|
||||
value={facture.typeFacture}
|
||||
options={typeOptions}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, type: e.value }))}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, typeFacture: e.value }))}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
@@ -362,8 +364,8 @@ const FactureEditPage = () => {
|
||||
<label htmlFor="dateEmission" className="font-semibold">Date d'émission *</label>
|
||||
<Calendar
|
||||
id="dateEmission"
|
||||
value={facture.dateEmission}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEmission: e.value || new Date() }))}
|
||||
value={facture.dateEmission ? new Date(facture.dateEmission) : null}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEmission: (e.value as Date)?.toISOString() || new Date().toISOString() }))}
|
||||
className="w-full"
|
||||
dateFormat="dd/mm/yy"
|
||||
/>
|
||||
@@ -375,8 +377,8 @@ const FactureEditPage = () => {
|
||||
<label htmlFor="dateEcheance" className="font-semibold">Date d'échéance *</label>
|
||||
<Calendar
|
||||
id="dateEcheance"
|
||||
value={facture.dateEcheance}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEcheance: e.value || new Date() }))}
|
||||
value={facture.dateEcheance ? new Date(facture.dateEcheance) : null}
|
||||
onChange={(e) => setFacture(prev => ({ ...prev, dateEcheance: (e.value as Date)?.toISOString() || new Date().toISOString() }))}
|
||||
className="w-full"
|
||||
dateFormat="dd/mm/yy"
|
||||
/>
|
||||
@@ -575,7 +577,7 @@ const FactureEditPage = () => {
|
||||
<div className="field">
|
||||
<label className="font-semibold">Montant HT</label>
|
||||
<div className="text-xl font-bold text-primary">
|
||||
{formatCurrency(ligneForm.montantHT || 0)}
|
||||
{formatCurrency(ligneForm.montantLigne || 0)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user