Life ConnectLife Connect
Table of contents
Architecture
Services
Swagger Docs
GitHub
Table of contents
Architecture
Services
Swagger Docs
GitHub
  • Backend (Java / Spring Boot)

    • adb (parent Maven + proxy)
    • adb-persons
    • adb-parts
    • adb-contracts
    • adb-accounting
    • adb-files
    • adb-utilities
    • adb-aggregates
    • adb-views
    • adb-reports
  • Frontend

    • adb-ui
    • adb-web
  • Infrastructure & Outillage

    • adb-charts
    • adb-infrastructure
    • adb-tests-artillery
    • adb-doc
  • Services externes (hors monorepo)

    • adb-tickets (externe)
    • adb-notes (déprécié)
    • adb-graph (externe, statut incomplet)

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émentValeur
Spring Boot3.1.3
Java18
Port8089
DatabaseMongoDB Atlas — base adb-accounting
AuthKeycloak (resource server)
Stack réactiveSpring WebFlux + Reactive MongoDB
State machinesSpring Statemachine 2.2.3 (Payment + Invoice)
PDFhtml2pdf 4.0.2 + iTextPDF
TemplatingFreeMarker
ReportingGoogle Sheets v4 + Google Drive v3 (exports)
Detection blockingBlockHound 1.0.9 (cloud profile)
Version0.43.0-SNAPSHOT
Main classfr.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)

ControllerPathRôle
InvoiceController/accounting/invoicesFactures
PaymentController/accounting/paymentsPaiements
InvoicePaymentController/accounting/invoice-paymentsLien factures ↔ paiements
BalanceController/accounting/balancesSoldes (clients, comptes)
TransactionController/accounting/transactionsTransactions bancaires
AccountingEntriesController/accounting/entriesÉcritures comptables
AccountingEventController/accounting/eventsÉvénements comptables
JournalController/accounting/journalsJournaux comptables
LedgerAccountController/accounting/ledger-accountsComptes du grand livre
LedgerAuxiliaryAccountController/accounting/ledger-auxiliaryComptes auxiliaires (clients)
FiscalYearController/accounting/fiscal-yearsExercices fiscaux
CRGController/accounting/crgCharges Récupérables (rapports)
DocumentController/accounting/documentsDocuments comptables (PDF)
SettlementController–Lettrage
RentalAllowanceStatementController–Relevés d'allocations
AccountingModuleInfoController/accounting/infoInfo 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)

  • onAccountingEntryModified
  • onAccountingEventModified
  • onPaymentModified

Consommés (SQS Listeners)

  • onPersonModified (depuis adb-persons)
  • onOrganizationModified (depuis adb-persons)
  • onContractModified (depuis adb-contracts) → déclenche call-for-rent
  • onDirectDebitProcessed (depuis adb-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

VariableRôle
MONGO_DB_URIConnection string MongoDB
SECURITY_ISSUER_URI / SECURITY_TOKEN_URIKeycloak
CLIENT_ID / CLIENT_SECRETOAuth2
AWS_REGION / AWS_ACCESS_KEY / AWS_SECRET_KEYAWS
BUCKET_TEMPLATESBucket S3 templates
ACCOUNTING_*_QUEUEURLs queues SQS
GOOGLE_SHEETS_CLIENT_CREDENTIALSJSON service account Google
BLOCKHOUND_ENABLEDtrue/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/
Edit this page
Last Updated:
Contributors: gregory
Prev
adb-contracts
Next
adb-files