adb-accounting
Rôle
Service de comptabilité complet : factures, paiements, journaux, écritures comptables, comptes auxiliaires (clients/fournisseurs), exercices fiscaux, rapports CRG (Charges Récupérables / Garanties), allocations logement.
C'est le service le plus volumineux du backend (17 controllers, 23+ collections) et l'un des plus consommateurs d'événements : il réagit aux modifications de contrats, de personnes, de paiements pour générer automatiquement les écritures correspondantes.
Stack
| Élément | Valeur |
|---|---|
| Spring Boot | 3.1.3 |
| Java | 18 |
| Port | 8089 |
| Database | MongoDB Atlas — base adb-accounting |
| Auth | Keycloak (resource server) |
| Stack réactive | Spring WebFlux + Reactive MongoDB |
| State machines | Spring Statemachine 2.2.3 (Payment + Invoice) |
| html2pdf 4.0.2 + iTextPDF | |
| Templating | FreeMarker |
| Reporting | Google Sheets v4 + Google Drive v3 (exports) |
| Detection blocking | BlockHound 1.0.9 (cloud profile) |
| Version | 0.43.0-SNAPSHOT |
| Main class | fr.lifeconnect.adb.accounting.AccountingApplication |
Architecture interne
flowchart TB
subgraph Controllers["17 Controllers"]
IC[InvoiceController]
PC[PaymentController]
IPC[InvoicePaymentController]
BC[BalanceController]
TC[TransactionController]
AEC[AccountingEntriesController]
AVC[AccountingEventController]
JC[JournalController]
LAC[LedgerAccountController]
LAUX[LedgerAuxiliaryAccountController]
FYC[FiscalYearController]
CRGC[CRGController]
DC[DocumentController]
SC[SettlementController]
RASC[RentalAllowanceStatementController]
AMI[AccountingModuleInfoController]
OIC[ObjectIdController]
end
subgraph SM[State Machines]
PSM[PaymentStateMachine]
ISM[InvoiceStateMachine]
end
subgraph Listeners[SQS Listeners]
L1[AccountingFunctions]
L2[PersonsFunctions]
L3[PaymentFunctions]
L4[ContractsFunctions]
end
subgraph External
Mongo[(adb-accounting)]
S3[(S3 templates)]
GS[Google Sheets/Drive]
SNS[SNS topics]
end
Controllers --> SM
Controllers --> Mongo
Listeners --> Mongo
Controllers --> GS
Controllers --> S3
SM -.publish.-> SNS
Endpoints (17 controllers)
| Controller | Path | Rôle |
|---|---|---|
InvoiceController | /accounting/invoices | Factures |
PaymentController | /accounting/payments | Paiements |
InvoicePaymentController | /accounting/invoice-payments | Lien factures ↔ paiements |
BalanceController | /accounting/balances | Soldes (clients, comptes) |
TransactionController | /accounting/transactions | Transactions bancaires |
AccountingEntriesController | /accounting/entries | Écritures comptables |
AccountingEventController | /accounting/events | Événements comptables |
JournalController | /accounting/journals | Journaux comptables |
LedgerAccountController | /accounting/ledger-accounts | Comptes du grand livre |
LedgerAuxiliaryAccountController | /accounting/ledger-auxiliary | Comptes auxiliaires (clients) |
FiscalYearController | /accounting/fiscal-years | Exercices fiscaux |
CRGController | /accounting/crg | Charges Récupérables (rapports) |
DocumentController | /accounting/documents | Documents comptables (PDF) |
SettlementController | – | Lettrage |
RentalAllowanceStatementController | – | Relevés d'allocations |
AccountingModuleInfoController | /accounting/info | Info module |
ObjectIdController | – | Génération IDs |
Modèle de données (extrait)
erDiagram
InvoiceEntity ||--o{ AccountingEntry : "génère"
PaymentEntity ||--o{ AccountingEntry : "génère"
JournalEntity ||--o{ AccountingEntry : "regroupe"
LedgerAccountEntity ||--o{ AccountingEntry : "imputée à"
FiscalYearEntity ||--o{ AccountingEntry : "période"
AccountingEventEntity ||--o{ InvoiceEntity : "déclenche"
AccountingEventEntity ||--o{ PaymentEntity : "déclenche"
InvoiceEntity {
string _id
string contractId
string state
number amount
date dueDate
}
PaymentEntity {
string _id
string state
number amount
date paymentDate
}
AccountingEntry {
string _id
string journalId
string ledgerAccountId
number debit
number credit
date date
}
AccountingEventEntity {
string _id
string type "call-for-rent / payment-received / ..."
date timestamp
object payload
}
23+ collections, dont les principales : invoices, payments, accounting_entries, accounting_events, journals, ledger_account, ledger_account_definition, ledger_auxiliary_accounts, fiscal_year, rental_allowance_statements, tenant_rental_allowances, serial, accounting_sequence, transaction_reads, configurations, resume_token, accounting_event_fallback.
Machines d'états
- PaymentStateMachine (
paymentStateMachineFactory) — cycle de vie d'un paiement (PENDING → PROCESSING → COMPLETED / FAILED). - InvoiceStateMachine (
invoiceStateMachineFactory) — cycle de vie d'une facture (DRAFT → ISSUED → PAID / OVERDUE / CANCELLED).
Événements
Émis (SNS)
onAccountingEntryModifiedonAccountingEventModifiedonPaymentModified
Consommés (SQS Listeners)
onPersonModified(depuisadb-persons)onOrganizationModified(depuisadb-persons)onContractModified(depuisadb-contracts) → déclenche call-for-rentonDirectDebitProcessed(depuisadb-contracts)- Auto-écoute :
onAccountingEntryModified,onAccountingEventModified,onPaymentModified
Dépendances inter-services
flowchart LR
accounting[adb-accounting]
persons[adb-persons]
parts[adb-parts]
contracts[adb-contracts]
files[adb-files]
utilities[adb-utilities]
accounting -->|GET /persons| persons
accounting -->|GET /parts| parts
accounting -->|GET /contracts<br/>(descriptors, allowances)| contracts
accounting -->|GET /files,<br/>POST /files| files
accounting -->|GET /utilities/i18n| utilities
contracts2[adb-contracts] -->|POST /accounting/entries| accounting
aggregates[adb-aggregates] -.indirect.-> accounting
views[adb-views] -.SQS events.-> accounting
Intégrations externes
- Google Sheets v4 + Drive v3 : exports comptables, rapports CRG. Service account configuré via
GOOGLE_SHEETS_CLIENT_CREDENTIALS(JSON). - AWS S3 (
BUCKET_TEMPLATES) : templates PDF. - AWS SQS/SNS : event-driven (cf. listeners ci-dessus).
- BlockHound : activé en environnement cloud pour détecter du code bloquant (
BLOCKHOUND_ENABLED).
Configuration & déploiement
Variables d'environnement clés
| Variable | Rôle |
|---|---|
MONGO_DB_URI | Connection string MongoDB |
SECURITY_ISSUER_URI / SECURITY_TOKEN_URI | Keycloak |
CLIENT_ID / CLIENT_SECRET | OAuth2 |
AWS_REGION / AWS_ACCESS_KEY / AWS_SECRET_KEY | AWS |
BUCKET_TEMPLATES | Bucket S3 templates |
ACCOUNTING_*_QUEUE | URLs queues SQS |
GOOGLE_SHEETS_CLIENT_CREDENTIALS | JSON service account Google |
BLOCKHOUND_ENABLED | true/false |
Profils spéciaux
cloud: production / dev cloud (BlockHound activé).maven-build: profil pour le build CI.filatov: profil de développement local nommé.
Chart Helm
adb-charts/charts/services/templates/adb-accounting.yaml. Image : lifeconnect/adb-accounting.
Liens
- Code :
adb-accounting/ - Doc fonctionnelle :
technical-epics/accounting/ - Doc CRG :
functional-epics/reporting/