Skip to content

feat: add personOverrides JSON column to Mros (PR 1.2)#3623

Merged
TaprootFreak merged 4 commits intodevelopfrom
feat/mros-person-overrides
Apr 27, 2026
Merged

feat: add personOverrides JSON column to Mros (PR 1.2)#3623
TaprootFreak merged 4 commits intodevelopfrom
feat/mros-person-overrides

Conversation

@TaprootFreak
Copy link
Copy Markdown
Collaborator

Summary

Second of four small API PRs preparing Mros for goAML SAR export. Adds an optional personOverrides JSON column so compliance officers can supply goAML-required person data that's not available on UserData:

  • gender
  • middleName
  • birthPlace
  • profession
  • sourceOfWealth
  • canton
  • idDocIssueDate
  • idDocValidUntil
  • idDocIssuingCountryCode

All fields are optional — an override is only stored when the officer actively enters it; otherwise the goAML XML falls back to UserData at export time (Phase 2).

Pattern

Stored as a single nvarchar(MAX) JSON string with a typed getter/setter personOverridesObject, following the canonical priceStepsObject / creditorData patterns from buy-crypto.entity.ts.

Migration

Per CONTRIBUTING.md, the schema migration must be generated locally:

```bash
cd ~/Documents/GitHub/dfx/api
git pull
git checkout feat/mros-person-overrides
npm run migration AddMrosPersonOverrides
git add migration/*-AddMrosPersonOverrides.js
git commit -m "feat: add migration for mros personOverrides"
git push
```

Roadmap

  • PR 1.1 (merged): core report fields
  • PR 1.2 (this one): personOverrides JSON column
  • PR 1.3: Mros ↔ Transaction many-to-many
  • PR 1.4: frontend edit page
  • Phase 2: XML export + XSD validation + download endpoint

Test plan

  • Migration generated locally, applies cleanly (up + down)
  • POST /mros with personOverrides object → stored as JSON, readable via personOverridesObject
  • PUT /mros/:id with personOverrides → updates; absent → existing preserved
  • Nested DTO validation rejects wrong types (e.g. gender: 123)

Adds an optional personOverrides field on Mros that lets a compliance
officer supply goAML-required person data that is not captured on
UserData (gender, middle name, birth place, profession, source of
wealth, canton, ID document issue/expiry/country).

Stored as a single JSON-serialised MAX-length column with a typed
getter/setter (personOverridesObject) following the canonical
priceStepsObject pattern from buy-crypto.entity.ts.

Nested DTO validated via class-transformer @type and @ValidateNested.

Migration to be generated locally via npm run migration
AddMrosPersonOverrides (per CONTRIBUTING.md).
Comment on lines +56 to +60
// JSON-serialized MrosPersonOverrides — fields that override UserData
// when the compliance officer needs to supply goAML-required data that
// is not captured on UserData (e.g. gender, middle name, profession).
@Column({ length: 'MAX', nullable: true })
personOverrides?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use simple-json type here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generate migration

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0c409ad — converted personOverrides to simple-json. Column SQL stays nvarchar(MAX) so the migration is unchanged.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration committed in c5cf818.

Single nullable nvarchar(MAX) column — no DEFAULT constraint, so no
hash-naming concern.
Per @davidleomay's review on #3623 — TypeORM's simple-json type
serializes/deserializes JSON automatically, no need for the
JSON.parse getter/setter dance. Column SQL stays nvarchar(MAX)
on MSSQL so the migration is unchanged.
TypeORM's MSSQL driver maps simple-json columns to ntext (verified in
node_modules/typeorm/driver/sqlserver/SqlServerDriver.js — see normalizeType).
Previous nvarchar(MAX) would have created drift between entity and DB on the
next 'npm run migration' run.
@TaprootFreak TaprootFreak merged commit db0f8a9 into develop Apr 27, 2026
8 checks passed
@TaprootFreak TaprootFreak deleted the feat/mros-person-overrides branch April 27, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants