fix: Use typeFacture instead of type and add required Facture fields (dateCreation, dateModification, client)

This commit is contained in:
dahoud
2025-10-13 19:42:45 +00:00
parent 2b6fb084d3
commit b0049c8d88

View File

@@ -17,7 +17,7 @@ import { InputNumber } from 'primereact/inputnumber';
import { factureService, clientService } from '../../../services/api'; import { factureService, clientService } from '../../../services/api';
import { formatDate, formatCurrency } from '../../../utils/formatters'; import { formatDate, formatCurrency } from '../../../utils/formatters';
import { ErrorHandler } from '../../../services/errorHandler'; import { ErrorHandler } from '../../../services/errorHandler';
import type { Facture } from '../../../types/btp'; import type { Facture, Client } from '../../../types/btp';
import { StatutFacture, TypeFacture } from '../../../types/btp'; import { StatutFacture, TypeFacture } from '../../../types/btp';
import { import {
ActionButtonGroup, ActionButtonGroup,
@@ -41,18 +41,20 @@ const FacturesPage = () => {
numero: '', numero: '',
dateEmission: new Date().toISOString(), dateEmission: new Date().toISOString(),
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
datePaiement: null, datePaiement: undefined,
objet: '', objet: '',
description: '', description: '',
montantHT: 0, montantHT: 0,
montantTTC: 0, montantTTC: 0,
tauxTVA: 20, tauxTVA: 20,
statut: StatutFacture.BROUILLON, statut: StatutFacture.BROUILLON,
type: TypeFacture.FACTURE, typeFacture: TypeFacture.FACTURE,
dateCreation: new Date().toISOString(),
dateModification: new Date().toISOString(),
actif: true, actif: true,
client: null, client: {} as Client,
chantier: null, chantier: undefined,
devis: null devis: undefined
}); });
const [submitted, setSubmitted] = useState(false); const [submitted, setSubmitted] = useState(false);
const toast = useRef<Toast>(null); const toast = useRef<Toast>(null);
@@ -116,18 +118,20 @@ const FacturesPage = () => {
numero: '', numero: '',
dateEmission: new Date().toISOString(), dateEmission: new Date().toISOString(),
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
datePaiement: null, datePaiement: undefined,
objet: '', objet: '',
description: '', description: '',
montantHT: 0, montantHT: 0,
montantTTC: 0, montantTTC: 0,
tauxTVA: 20, tauxTVA: 20,
statut: StatutFacture.BROUILLON, statut: StatutFacture.BROUILLON,
type: TypeFacture.FACTURE, typeFacture: TypeFacture.FACTURE,
dateCreation: new Date().toISOString(),
dateModification: new Date().toISOString(),
actif: true, actif: true,
client: null, client: {} as Client,
chantier: null, chantier: undefined,
devis: null devis: undefined
}); });
setSubmitted(false); setSubmitted(false);
setFactureDialog(true); setFactureDialog(true);
@@ -223,18 +227,20 @@ const FacturesPage = () => {
numero: '', numero: '',
dateEmission: new Date().toISOString(), dateEmission: new Date().toISOString(),
dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), dateEcheance: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
datePaiement: null, datePaiement: undefined,
objet: '', objet: '',
description: '', description: '',
montantHT: 0, montantHT: 0,
montantTTC: 0, montantTTC: 0,
tauxTVA: 20, tauxTVA: 20,
statut: StatutFacture.BROUILLON, statut: StatutFacture.BROUILLON,
type: TypeFacture.FACTURE, typeFacture: TypeFacture.FACTURE,
dateCreation: new Date().toISOString(),
dateModification: new Date().toISOString(),
actif: true, actif: true,
client: null, client: {} as Client,
chantier: null, chantier: undefined,
devis: null devis: undefined
}); });
} catch (error) { } catch (error) {
console.error('Erreur lors de la sauvegarde:', error); console.error('Erreur lors de la sauvegarde:', error);