Skip to content

feat: link transactions to Mros via many-to-many (PR 1.3)#3624

Merged
TaprootFreak merged 3 commits intodevelopfrom
feat/mros-transactions-relation
Apr 28, 2026
Merged

feat: link transactions to Mros via many-to-many (PR 1.3)#3624
TaprootFreak merged 3 commits intodevelopfrom
feat/mros-transactions-relation

Conversation

@TaprootFreak
Copy link
Copy Markdown
Collaborator

Summary

Third of four small API PRs preparing Mros for goAML SAR export. Adds a many-to-many relation between Mros and Transaction so a compliance officer can select which transactions belong in a report.

At XML export time (Phase 2) these become the structured transaction nodes (t_from_my_client / t_to_my_client) of the goAML schema.

Changes

  • Mros.transactions ManyToMany (owning side, generates a join table)
  • transactionIds: number[] on both create and update DTO
  • TransactionService.getTransactionsByIds for bulk resolution
  • Import TransactionModule into MrosModule
  • MrosService:
    • create resolves transactionIds → Transaction[] and attaches
    • update loads the existing transactions relation so replacing the selection works
    • resolveTransactions throws NotFoundException if any id is invalid

Migration

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

```bash
cd ~/Documents/GitHub/dfx/api
git pull
git checkout feat/mros-transactions-relation
npm run migration AddMrosTransactionsRelation
git add migration/*-AddMrosTransactionsRelation.js
git commit -m "feat: add migration for mros transactions many-to-many"
git push
```

Roadmap

Test plan

  • Migration generated locally, applies cleanly (up + down)
  • POST /mros with transactionIds → join rows created
  • PUT /mros/:id with different transactionIds → join rows replaced
  • PUT /mros/:id without transactionIds → existing links preserved
  • PUT /mros/:id with [] → join rows cleared
  • Invalid transactionId → 404

A compliance officer selects which transactions are relevant to an MROS
report — goAML XML needs these as structured transaction nodes
(t_from_my_client / t_to_my_client) at export time.

- Many-to-many relation on Mros.transactions (new join table generated
  by typeorm via migration)
- transactionIds: number[] on create/update DTO; service resolves to
  Transaction entities via the new TransactionService.getTransactionsByIds
- Update loads the existing transactions relation so replacing the
  selection works cleanly

Migration to be generated locally via
  npm run migration AddMrosTransactionsRelation
(per CONTRIBUTING.md).
Comment on lines +45 to +47
@ManyToMany(() => Transaction)
@JoinTable()
transactions: Transaction[];
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.

Migration committed in 60c2690 (join table mros_transactions_transaction with composite PK + indices + cascading FKs, all constraint names via TypeORM hash formula).

Join table mros_transactions_transaction with composite PK +
indices + cascading FKs on both sides.

All constraint names computed via TypeORM's DefaultNamingStrategy
(sha1(table_name + '_' + column).substring(0, N)) so future
'npm run migration' won't see drift.
Copy link
Copy Markdown
Member

@davidleomay davidleomay left a comment

Choose a reason for hiding this comment

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

  • Fix merge conflicts

@TaprootFreak TaprootFreak merged commit ab1c140 into develop Apr 28, 2026
8 checks passed
@TaprootFreak TaprootFreak deleted the feat/mros-transactions-relation branch April 28, 2026 06:51
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