dodil/erp-brick-gl

DODIL ERP brick: general ledger

src/brick_gl/application/use_cases.py

"""The use cases of the gl brick. Each is declared ONCE and served as an API route and as an MCP tool; this module imports
every area so that `brick_gl.application.use_cases:GL` carries them all.

  posting     post_from_source, propose_manual, approve_manual, reject_manual, reverse_journal, post_pending_reversal, journals
  masterdata  companies, ledgers, charts and accounts, the account map, dimensions, settings and controls, company access, FX rates
  periods     fiscal years, periods, close and reopen, the carry-forward
  reports     the trial balance, account lines, rollup, balances, materialised statements
"""
from contextlib import contextmanager

from brick_gl.application import (  # noqa: F401  (registering the use cases is the import)
    ai,
    allocations,
    audit,
    budgets,
    closing,
    groupdata,
    intercompany,
    masterdata,
    migration,
    periods,
    posting,
    reconcile,
    reports,
    revaluation,
    scheduled,
    statements,
)
from brick_gl.application.brick import GL  # noqa: F401


@contextmanager
def _repository_default():
    from erp_platform import db  # imported late: it needs BUCKET

    from brick_gl.infrastructure.repositories import Repository
    with db.engine.begin() as conn:
        yield Repository(conn)


repository = _repository_default                       # tests and the scenario harness swap in their own