Skip to content

feat(VSN-2809): Devis module + BDC integration

yahya.elmokhtari a demandé de fusionner VSN-2809 vers develop

Architecture & Navigation

• Add comprehensive Devis types and Zustand store for centralized quote management

• Implement routing under dashboard/facturation-paiement/devis/ with Next.js App Router

• Create modular Devis module with 2 main views (DevisListView, DevisEditView) and 8 focused components

• Update navigation wiring across paths.ts, config-navigation.tsx, and TableType enum for seamless integration

• Maintain clean folder structure with separated constants, hooks, components and store layer

• Implement code using TypeScript throughout for type safety and better development experience

Devis Management Features

• Add complete quote lifecycle with 7 statuses (draft, sent, accepted, refused, expired, bdc_generated, invoiced)

• Implement 3 tariff modes (forfait global, prix par circuit, BPU) with mode-aware UI

• Show 4 service categories (Transport scolaire, TAD, Transport privé, Navette privée) with dropdown selection

• Update Devis details with dynamic line items, real-time HT/VAT/TTC recalculation, and editable-only-when-draft locking

• Add status-gated lifecycle actions (Envoyer / Accepter / Refuser / Générer BDC / Générer facture)

• Create real Devis → BDC transformation through useBDCStore.createBDC() with proper field mapping and bidirectional link

• Implement automatic expiration: a sent devis with a past validity date flips to expired on read

• Add document preview section with PDF-ready layout (generation pending backend service)

Components Architecture

Main Views: DevisListView, DevisEditView

Core Components: InfoSection, LignesSection (dynamic add/remove), TotauxSection, ActionsSection, DocumentSection, DetailSection, CreateForm

Specialized Components: DevisListTable (unified pattern, pixel-perfect column alignment), DevisStatusPill, DevisObjetPill

Interactive Elements: TableControlBar integration, TabbedForm (Détail / Document), inline "Générer facture" icon-button in list rows for accepted devis

Key Features

Currency: Module ships in EUR (1 234,56 €) — other facturation modules to be migrated in a dedicated refactor MR

Unified Table Pattern: Synced horizontal scroll, fixed-px columns, filter/sort/reset/pagination

Real-time Updates: Live HT/VAT/TTC recalc on line mutations, optimistic status transitions with toast feedback

Advanced Filtering: Multi-criteria search (client, dept, objet, status, totals) with instant results

Cross-module Integration: Direct creation of BDCItem from accepted devis, persistent bdcRef/factureRef links

Data Management: Zustand store with initialized flag, pluggable mock/api data source, mutable history ledger

User Experience: Cascade selectors, mode-aware line table (circuit code shown only in prix par circuit), context-aware action buttons

Technical Implementation

State Management: Zustand store with full CRUD + lifecycle actions and stable selectors

Type Safety: Complete TypeScript implementation with explicit unions for statuses, objets, tariff modes and history actions

Pluggable Data Source: mockDataSource + apiDataSource stub abstraction toggled via NEXT_PUBLIC_USE_MOCK_DEVIS

Mock Data: 6 realistic devis covering every status, with seeded history events and BDC-YYYY-XXX/FA-DV-YYYY-XXX reference generators

Stubbed Boundaries: Facture module + PDF/email send isolated behind the data source so the backend cutover doesn't touch the UI

Closes VSN-2809

Rapports de requête de fusion