====== Sprint 6 — Paiements & Facturation ======
===== Objectif du Sprint =====
Mettre en œuvre l'ensemble du cycle financier de la plateforme.
À l'issue du Sprint 6 :
* Un client peut régler un acompte
* Un client peut régler le solde d'une réservation
* Les paiements sont sécurisés
* Les factures sont générées automatiquement
* Les avoirs sont gérés
* Les remboursements sont possibles
* L'historique financier est disponible
* Les exports comptables sont générés
Ce sprint clôture le cycle commercial complet :
Recherche
↓
Réservation
↓
Contrat
↓
Paiement
↓
Facturation
----
====== Périmètre ======
===== Modules concernés =====
PaymentsModule
InvoicesModule
RefundsModule
PaymentGatewayModule
AccountingModule
FinancialReportingModule
----
====== Workflow métier ======
Réservation
↓
Contrat signé
↓
Paiement acompte
↓
Facture acompte
↓
Paiement solde
↓
Facture finale
↓
Réservation payée
----
====== User Stories ======
===== US-601 : Créer une demande de paiement =====
**En tant que système**
Je souhaite créer automatiquement un paiement
Afin de permettre au client de régler sa réservation.
----
===== Endpoint =====
POST /payments
----
===== Données =====
Réservation
Montant
Échéance
Type paiement
----
===== Types =====
DEPOSIT
BALANCE
FULL_PAYMENT
ADDITIONAL_CHARGE
----
====== US-602 : Payer une réservation ======
===== Endpoint =====
POST /payments/{id}/checkout
----
===== Fournisseurs =====
Stripe
MangoPay
PayPal (optionnel)
----
===== Modes =====
Carte bancaire
Apple Pay
Google Pay
----
====== US-603 : Consulter un paiement ======
===== Endpoint =====
GET /payments/{id}
----
===== Informations =====
Référence
Montant
Date
Statut
Transaction
----
====== US-604 : Historique des paiements ======
===== Endpoint =====
GET /payments
----
===== Filtres =====
Client
Réservation
Date
Statut
Montant
----
====== Gestion des acomptes ======
===== US-605 : Paiement d'acompte =====
===== Exemple =====
Réservation : 1 000 €
Acompte : 30 %
↓
300 €
----
===== Paramétrage =====
Agence
Bien
Type contrat
----
====== US-606 : Paiement du solde =====
===== Calcul =====
Montant réservation
-
Acompte payé
=
Solde restant
----
===== Déclenchement =====
X jours avant arrivée
----
====== Facturation ======
===== US-607 : Génération facture =====
===== Déclencheurs =====
Paiement reçu
↓
Facture générée
----
===== Endpoint =====
POST /invoices/generate
----
===== Numérotation =====
FAC-2027-000001
----
====== US-608 : Télécharger une facture =====
===== Endpoint =====
GET /invoices/{id}/download
----
===== Format =====
PDF
----
====== US-609 : Historique factures =====
===== Endpoint =====
GET /invoices
----
====== Avoirs ======
===== US-610 : Générer un avoir =====
===== Endpoint =====
POST /credit-notes
----
===== Cas d'usage =====
Annulation
Réduction commerciale
Erreur facturation
----
===== Numérotation =====
AV-2027-000001
----
====== Remboursements ======
===== US-611 : Rembourser un paiement =====
===== Endpoint =====
POST /payments/{id}/refund
----
===== Types =====
Partiel
Total
----
===== Workflow =====
Paiement
↓
Demande remboursement
↓
Stripe Refund
↓
Historisation
↓
Avoir
----
====== Export comptable ======
===== US-612 : Export comptable =====
===== Endpoint =====
GET /accounting/export
----
===== Formats =====
CSV
Excel
PDF
----
===== Données =====
Paiements
Factures
Avoirs
Taxes
----
====== Historique financier ======
===== US-613 : Tableau financier =====
===== KPIs =====
CA
Montant encaissé
Montant remboursé
Factures émises
Avoirs émis
----
====== Cycle de vie paiement ======
PENDING
↓
AUTHORIZED
↓
PAID
└── FAILED
└── REFUNDED
----
====== Cycle de vie facture ======
DRAFT
↓
ISSUED
↓
PAID
└── CANCELLED
----
====== Modèle Prisma ======
===== Payment =====
model Payment {
id String @id @default(uuid())
reservationId String
amount Decimal
paymentType String
status String
paymentDate DateTime?
transactionReference String?
}
----
===== PaymentTransaction =====
model PaymentTransaction {
id String @id @default(uuid())
paymentId String
provider String
externalId String
status String
payload Json
}
----
===== Invoice =====
model Invoice {
id String @id @default(uuid())
invoiceNumber String @unique
reservationId String
totalHt Decimal
totalVat Decimal
totalTtc Decimal
issuedAt DateTime
}
----
===== InvoiceLine =====
model InvoiceLine {
id String @id @default(uuid())
invoiceId String
description String
quantity Decimal
unitPrice Decimal
total Decimal
}
----
===== CreditNote =====
model CreditNote {
id String @id @default(uuid())
creditNoteNumber String @unique
invoiceId String
amount Decimal
reason String
}
----
====== Architecture Backend ======
src/modules/payments
├── payments
│
├── transactions
│
├── invoices
│
├── credit-notes
│
├── refunds
│
├── accounting
│
└── gateways
----
====== Domain Services ======
PaymentService
InvoiceService
RefundService
AccountingService
PaymentGatewayService
----
====== Événements métier ======
===== PaymentAuthorized =====
PaymentAuthorized
----
===== PaymentSucceeded =====
PaymentSucceeded
----
===== PaymentFailed =====
PaymentFailed
----
===== PaymentRefunded =====
PaymentRefunded
----
===== InvoiceGenerated =====
InvoiceGenerated
----
====== Intégrations externes ======
===== Paiement =====
Stripe (prioritaire)
MangoPay
PayPal
----
===== Comptabilité =====
Préparation future :
Sage
Cegid
EBP
Pennylane
----
====== Swagger ======
===== Tags =====
Payments
Invoices
Refunds
Accounting
----
===== Volume API =====
Environ :
30 endpoints
----
====== Frontend ======
===== Client =====
Pages :
/payments
/payments/[id]
/invoices
/invoices/[id]
----
===== Back Office =====
Pages :
/payments
/invoices
/credit-notes
/accounting
----
===== Composants =====
PaymentCheckout
PaymentHistory
InvoiceViewer
InvoiceTable
RefundModal
AccountingDashboard
----
====== Tests ======
===== Unitaires =====
PaymentService
InvoiceService
RefundService
AccountingService
----
===== Intégration =====
Reservation
↓
Contract Signed
↓
Payment
↓
Invoice
↓
Accounting
----
===== E2E =====
Réservation
↓
Contrat signé
↓
Paiement acompte
↓
Facture
↓
Paiement solde
↓
Facture finale
----
====== Définition de terminé ======
Le Sprint 6 est terminé lorsque :
* Paiement CB fonctionnel
* Acompte fonctionnel
* Solde fonctionnel
* Facturation automatique fonctionnelle
* Avoirs fonctionnels
* Remboursements fonctionnels
* Exports comptables fonctionnels
* Swagger à jour
* Tests verts
* CI verte
----
====== Livrables ======
* PaymentsModule
* InvoicesModule
* RefundsModule
* PaymentGatewayModule
* AccountingModule
* DTO
* Swagger
* Tests
* Migrations Prisma
----
====== Démonstration Sprint ======
Scénario métier :
1. Réservation créée
2. Contrat signé
3. Paiement acompte
4. Facture acompte
5. Paiement solde
6. Facture finale
7. Consultation historique
8. Export comptable
----
====== Bilan Phase MVP ======
À l'issue du Sprint 6, la plateforme dispose :
* Authentification
* Gestion utilisateurs
* Catalogue immobilier
* Réservation
* Contrats
* Paiements
* Facturation
Le MVP commercial est désormais opérationnel.
----
====== Sprint suivant ======
===== Sprint 7 — Extranet Propriétaire =====
Objectif :
Offrir aux propriétaires un espace dédié de suivi.
Modules concernés :
OwnersModule
OwnerPropertiesModule
OwnerReservationsModule
OwnerRevenueModule
OwnerDocumentsModule
Fonctionnalités :
* Tableau de bord propriétaire
* Consultation des biens
* Consultation des réservations
* Revenus
* Contrats
* Factures
* Export financier
À l'issue du Sprint 7, les propriétaires pourront suivre en autonomie l'activité de leurs biens.