You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

9.2 KiB

Upstream Directa import validation

Validated locally on the dedicated feat/broker-import-directa worktree, based on official main 23312d192. The NG integration branch is preserved. Its earlier success is not counted as upstream validation.

Real source qualification

Two private samples were evaluated separately. The currently supplied CSV has 239 movements after the owner intentionally removed rows for a reimport test. The original XLSX retains 356 movements; those twelve source columns were normalized to a private temporary CSV solely for the adapter qualification. No source amounts were rounded or adjusted. This does not add an XLSX upload feature.

Both runs used the actual upstream-adapted parser, planner, verified listing resolver, Yahoo quote service, upstream data-provider validation method, Prisma transaction and PostgreSQL schema. The qualification harness supplies direct transport and free-Yahoo configuration, without seed mappings or mocked market responses. Production provider configuration and activity limits are separately exercised by the application and tests. Tests run against disposable broker_test_directa PostgreSQL on a separate local port and an isolated temporary Redis instance for application-module checks.

Check Reduced CSV Complete source
Source movements recognized 239 356
Distinct instruments automatically resolved 6 7
Verified instrument choices requiring confirmation 2 4
Instruments lacking reliable evidence after confirmation 0 0
Activities persisted 88 136
Whole unsupported groups explicitly excluded 111 162
Source provenance records persisted 111 166
Reimported rows recognized as duplicates 111 166

Confirmation choices are explicitly simulated by the qualification harness selecting the sole verified EUR candidate on Borsa Italiana. They are not automatic resolutions or actual end-user GUI confirmations. The fresh-catalog complete run does not rely on an existing portfolio mapping. Additional valid alternatives remain available in the preview.

The complete-source import persists the tax-free BUY/SELL activity groups. All 24 dividend-withholding relationships can be identified, but their complete dividend groups remain unsupported upstream. Two taxed sale groups, standalone taxes, cash transfers and stamp duties are also excluded explicitly. The 162 excluded groups contain 190 source rows. No unsupported tax is converted to a fee and no gross amount or balancing entry is invented. These results do not claim NG's 162 activities/298 cash movements/356 provenance parity.

Source amount coverage balances after attribution to imported and explicitly omitted movements; there is no upstream cash-ledger reconciliation or cash update. A synthetic existing balance checkpoint remains unchanged. Preview writes no profiles, activities, provenance, account settings or balances. A failure injected on the final provenance write rolls back the entire batch, including newly created profiles. A subsequent confirmed import succeeds, and reimport writes nothing.

Overlapping real files

The reduced CSV was also imported first, followed by the complete source in the same disposable account. The second preview recognizes 111 source rows already imported and adds only 48 activities, resulting in 136 activities total. Reimport of the complete file recognizes all 166 supported source rows and adds none. The excluded movements remain explicitly omitted rather than being falsely marked imported.

Original financial files, source-account identifiers, personal names, transaction references and portfolio-specific ISIN mappings are absent from this repository. The private temporary CSV is not committed. Only anonymous fixtures are versioned.

Automated checks

The relevant backend regression assertions passed: 10 suites, 120 tests and the route-security snapshot. They cover parsing, decimal/date/header validation, symbol proof and alternatives, provider failures, cost families, unsupported accounting, explicit partial consent, preview purity, atomic rollback, corrected/deleted output, repeated references, overlapping imports, concurrent confirmations, late costs, ownership and configured limits, plus existing Ghostfolio import regressions. The final run used the repository Nx test runner and exited successfully. The original upstream application-module test remains unchanged; its route-security snapshot adds only the two authenticated broker endpoints. A direct Jest CLI invocation retained a cache connection after assertions, so that invocation is not used as process-exit evidence.

All 9 client tests pass, covering final confirmation, partial consent, bulk exclusions, invalidation, restricted error display, UTF-8 input, real Material-dialog rendering and all new message targets. There are 74 source messages with translations in every one of the 13 supported non-English locales; all 14 XLF catalogs are XML-validated. API and client TypeScript checks pass. Final checks passed:

Check Result
API regression suite 10 suites, 120 tests, 1 security snapshot; successful exit
PostgreSQL integration in Europe/Rome 12 tests passed
Client dialog 9 tests passed
API and client TypeScript Passed
Affected quiet lint All 4 projects passed
Formatting / whitespace Passed
English and Italian frontend builds Passed sequentially
Prisma schema drift against the migrated disposable database No difference
Fresh complete-source qualification and reduced-to-complete overlap Passed again after final implementation changes

Git hooks remain enabled and run on each commit. Existing Sass deprecation warnings are outside this change. Counts overlap across suites and are not additive coverage.

No manual browser acceptance, full repository-wide test run, hosted CI result or performance SLA is claimed. Provider availability and public listing tables can change. The PR is proposed as a draft for review of scope, accounting exclusions and generic provenance design.

Reproduce

Use the documented Node version and npm ci, then migrate only a disposable local database named broker_test_*. Set DATABASE_URL/DIRECT_URL for Prisma, and BROKER_TEST_DATABASE_URL for the integration suite. Load .env.example for configuration-dependent tests and use a temporary Redis host/port; never point integration checks at production.

NODE_OPTIONS='--max-old-space-size=3072 -r dotenv/config' \
DOTENV_CONFIG_PATH=.env.example npx nx test api --runInBand \
  --testFile=broker-import.integration.spec.ts --skip-nx-cache

tools/qualify-broker-import.ts is an opt-in private-source check. Set BROKER_TEST_CSV_PATH, BROKER_TEST_REPORT_PATH (outside the repository) and the disposable database URL, then bundle it with esbuild using apps/api/tsconfig.app.json. Set NODE_PATH to this worktree's node_modules when running an output bundle in /tmp. Default behavior is read-only preview. BROKER_TEST_PARTIAL=true explicitly enables test exclusions, partial consent, injected rollback, persistence and reimport; BROKER_TEST_CONFIRM_MARKET='Borsa Italiana' simulates the qualified market choices. BROKER_TEST_OVERLAP_CSV_PATH optionally exercises the subsequent complete-file import. The runner removes its own test user and newly created profiles.

Migration and remaining limits

The single additive migration creates generic BrokerImportRecord; all upstream migrations were applied successfully to the temporary PostgreSQL database. No existing data is rewritten and no NG migrations or cash services are included. Activity deletion retains a provenance tombstone; account deletion removes its records. Standard JSON export/restore does not transport this provenance across installations, so restored similar activities require manual review. EUR monetary legs and the documented twelve-column layout are the supported initial scope. Taxes and transfers require separate upstream accounting work.