The original six optional finance apps were consolidated into one core Nextcloud app plus one independent NFS-e integration. These boundaries are determined by who owns financial data and by independent compliance/release requirements.
| Runtime owner | Functions | Physical data |
|---|---|---|
| LibreFinance core | Ledger, workspaces, catalog, accounts and permissions | lf_* |
| LibreFinance core | Bank CSV/OFX import, pending statements, transfers, reconciliation | lfb_* |
| LibreFinance core | Payables, receivables, partial settlements | lfob_* |
| LibreFinance core | Commercial invoices, generic tax rules and allocations | lfi_* |
| LibreFinance core | Accounting reports and saved report templates | lfr_saved_reports |
| LibreFinance core | Manager-approved import/migration, source mapping and connector read previews | lfm_* |
| Independent NFS-e app | Brazilian NFS-e preparation only, not live fiscal issuance | lfn_drafts |
The former module names remain logical feature keys used by
FinanceApi::requireModule(), the access flags in lf_module_flags and
the single canonical Vue shell. They are not required as separate
Nextcloud installations. The retired separate banking, invoicing, obligations and reporting
repositories are not runtime dependencies. Legacy Import data is covered by a pinned synthetic historical-schema fixture
in core CI; installing the old Import app is not required for new installs.
The three lfm_* tables belong to the core and remain non-destructive on upgrade. The manager-only import engine accepts explicitly supplied normalized JSON for companies, contacts, categories, accounts, pending bank movements, transfers and read-only inventory reconciliation. Existing source IDs, hashes, bank references and audit history are retained. Source balances are snapshots, not posted ledger transactions.
This normalized import engine does not accept remote credentials or API endpoints. Direct source connectors, provider discovery, pagination and complete financial mapping are not supported by this engine.
Before upgrading an installation with the independent Import app, make and verify a complete database backup. Disable but NEVER UNINSTALL the old app: uninstall hooks could delete historical data. Upgrade the core, verify record counts and references, and only then remove old app code from the runtime. Keep a verified archive for rollback. Tests cover historical table preservation on SQLite, MariaDB and PostgreSQL in disposable fixtures. Third-party data completeness and financial equivalence remain unverified.
The bounded, read-only source discovery contract is described in SOURCE-DISCOVERY.md. It is not a live source connector or a replacement for the destination inventory comparison.
Only NFS-e registers an independent ModuleDescriptor instance
through RegisterModulesEvent and OCP event listeners. Their PHP endpoints
check the current user, permissions and per-space feature flag. The five
trusted built-in domain IDs are registered by ModuleService directly and
their controller routes belong to librefinance. An external app cannot
claim a built-in feature ID, inject HTML/JavaScript into the main app, or
bypass authorization by hiding navigation links.
The banking provider contract Domain/Banking/Providers/BankProviderInterface
is experimental and independent of importing CSV/OFX statements. It receives only
a credential reference. Automatic bank synchronization, secure bank tokens
and live institution transports are NOT implemented. Historical institution-specific sample code is not loaded as a production
integration.
An internally issued commercial invoice creates one linked financial
obligation, with a unique relationship in lf_invoice_obligation_links.
A validated ledger allocation is the only permitted path to pay that
linked obligation. Updating the invoice payment projection and creating its
obligation settlement happen in the same SQL transaction. The obligation
settlement retains the journal reference. Direct settlement or cancellation
of an invoice-linked obligation returns 409, preserving the accounting audit
trail and blocking duplicate payment paths.
Invoices issued before this version are not auto-linked by number or contact: their identity and pre-existing payments need a reconciliation procedure, not a guessed data migration. A new commercial invoice is not a government-issued fiscal document.
Before upgrading an existing development installation, record the exact
revisions of every installed finance app and take a verified, restorable database snapshot.
Temporarily stop financial writes. Disable, do not uninstall, the former
Banking, Invoicing, Obligations and Reports apps; uninstall handlers may remove
historic financial tables. Upgrade core while keeping the former Import app disabled, run
occ upgrade and compare row counts, per-space balances, foreign references
and the installed route contract with the snapshot. The core retains historic
table names and does not infer or recreate old invoice payment relationships.
If an upgrade check fails, restore the matched database and original app
versions, not a partial schema. The disposable restoration rehearsal is
described in testing; it is a qualification runbook with an
disposable script in tests/ci/upgrade-import.sh: it runs explicitly with
LF_UPGRADE_SCENARIO=restore and is chained after the saas scenario (opt out
with LF_UPGRADE_RESTORE=no) on SQLite, PostgreSQL and MariaDB. An
unsupported prerequisite fails by default (exit 3); only the explicit opt-out
LF_UPGRADE_RESTORE=optional prints UNSUPPORTED and exits 0. An engine
counts as verified for restore only when its recorded run shows
RESTORE-EVIDENCE (job log and step summary); any other engine is an explicit
UNSUPPORTED combination. Import-mapping records appear only as statement
matches in the saas seed. No execution is claimed before a run exists. It is not a production backup procedure, a
certification or an activation.
An issued invoice without a verified
obligation link must be reconciled before payment allocation.
For schema ownership and testing details, see schema and testing.
Keep migration a manager-only built-in feature and fiscal integrations separately
installed, secure, reviewable and enabled deliberately by administrators. A workspace manager
may toggle availability for that workspace but cannot install arbitrary
PHP code. Data writes must use a transaction-scoped bank account reservation
FinanceApi::reserveBankAccountsForWrite(), and must not import
Nextcloud-private APIs from OC\ classes as a compatibility contract.
The UI still uses a fixed map of approved screens. Versioned safe third-party UI extension points, l10n (including English), multi-currency conversion, live banking, fiscal homologation and accounting certification are future work, not delivered by the consolidation.
Existing optional apps may continue to call FinanceApi::requireModule()
with a valid minimum role. New core operations use
requireModuleCapability(spaceId, moduleId, capability), which checks
financial authority, installed module minimum, per-space enablement and
effective policy. Report and import operations additionally require their
own canonical domain to be enabled, independently of the caller module.
No unknown role or capability is implicitly a viewer.
The existing constructor of ModuleDescriptor defaults to contract version 1. An extension may pass an explicit contractVersion as the final constructor argument. Versions must be positive integers within the supported descriptor range (1–65535). A descriptor targeting a newer contract can be registered, but is excluded from discovery and all module authorization until the core supports that contract. The core currently supports version 1 only.
The authorized module list includes contractVersion. This additive field does not change module roles, workspace flags, restrictive policies or native route ownership. Incompatible extensions cannot provide navigation URLs or gain authorization. Existing NFS-e draft registrations remain compatible. This is the module descriptor negotiation boundary, not a promise of compatibility for future public service or event versions.
A registered descriptor is usable only when all of the following hold, checked
server-side by ModuleService on every request:
| State | Behavior |
|---|---|
| Compatible and app enabled for the user | Discovered; still subject to role floor, per-space flag and policy. |
| Disabled in the workspace | Listed with enabled: false; data requests return module_disabled (403). |
| App unavailable (not installed or not enabled for the user) | Not discovered; requireEnabled, requireEnabledForCapability and toggle return module_not_found, even for a finance owner. |
Incompatible contractVersion |
Not discovered; same module_not_found result. |
| Built-in ID claimed by an extension | Ignored; the built-in role floor and version stay. |
Tests added in tests/integration/modules.php (synthetic descriptors
registered through the real OCP event dispatcher; the listener is deactivated
afterwards and the session is restored) cover the unavailable-app, future-version
and built-in-shadowing rows. The existing NFS-e cases cover the real enabled,
disabled and policy-blocked paths. Unit tests for version rules live in
tests/php/Unit/PublicAPI/ModuleDescriptorTest.php. Run the
installed-Nextcloud integration suite and PHPUnit to verify them.
Known limits: the integration fixture cannot register an enabled app with a
future version without installing an app, so the incompatible case there also
has an unavailable app; the version-only rule is covered by the unit test and
by the isCompatible() filter in discovery.
Delivered, as test source (execution is done by CI, not claimed here):
- Reusable conformance closures in
tests/integration/modules.php($assertModuleConformance,$assertWorkspaceDisabled) that take a module ID and check: not-enabled and incompatible descriptors are not discovered and answermodule_not_found; a built-in ID claimed by an extension is ignored; a workspace-disabled module answersmodule_disabled; an app-owned route outside the app namespace is rejected at construction. Listeners are always removed infinally. - Scoped denial and revocation in the same file: a synthetic Nextcloud group
administrator without financial capability is denied by listing,
requireEnabled,requireEnabledForCapabilityandtoggle; disabling the module or revoking a member denies later requests; re-enabling restores access; ledger and audit row IDs are identical before and after. - Descriptor version boundaries (0, 1, 2, 65535, 65536), route ownership and
injection cases in
tests/php/Unit/PublicAPI/ModuleDescriptorTest.php. - Real-browser navigation in
tests/e2e/saas-module-policy.spec.mjs: the link stays inside/apps/librefinance, no script or inline handler is rendered, disabled or policy-blocked modules have no link, and incompatible or absent descriptors are never listed.
- Declare
contractVersion1 (the default). Only version 1 is supported; a newer descriptor is registrable but never discovered or authorized. - Keep
appIdandrouteNamestable across releases.routeNamemust belong to the app (<appId>.…, lowercase[a-z0-9_.]); only the five built-in domains may uselibrefinance.page.index. - Core builds the navigation URL with
IURLGenerator::linkToRoute(); an app cannot supply a URL, script or HTML. - Authorize every endpoint through the documented
FinanceApiandModuleServicegates (requireEnabled,requireEnabledForCapability). Never write corelf_*,lfb_*,lfob_*,lfi_*orlfm_*tables. - Raise
contractVersiononly together with a core release that supports it; until then the app is invisible and denied, and its history is preserved.
Assumption: these rules describe current AccessService semantics and must be
requalified against the final integrated governance contract before publication.
The Playwright check uses a mocked module list for presentation states; real
discovery and authorization are covered by the integration suite.