Skip to content

feat: cascade deletes remove the account's counterparties and stay within the account's bank - #2953

Open
hongwei1 wants to merge 7 commits into
OpenBankProject:developfrom
hongwei1:fix/cascade-delete-counterparties
Open

hongwei1 wants to merge 7 commits into
OpenBankProject:developfrom
hongwei1:fix/cascade-delete-counterparties

Conversation

@hongwei1

@hongwei1 hongwei1 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Cascade-deleting an account (DELETE /obp/v4.0.0/management/cascading/banks/BANK_ID/accounts/ACCOUNT_ID, and through it the bank and product cascades) now also removes the counterparties the account created, together with their bespoke fields, counterparty attributes and counterparty limits, and the account's counterparty metadata with its physical and corporate locations. Every step now selects the account by both BANK_ID and ACCOUNT_ID, including the card step and the step that picks the users whose entitlements are removed, so an account with the same ACCOUNT_ID at another bank keeps its counterparties and cards, and its users keep their entitlements. Counterparties of other accounts that point at the deleted account are left untouched.

DeleteCascadeCounterpartiesTest covers the account and bank cascades, asserting that every counterparty table is emptied for the deleted account while a same-ACCOUNT_ID account at another bank and a sibling account at the same bank keep all their rows; DeleteAccountCascadeTest gains scenarios for cards and entitlements across banks. The existing cascade, counterparty, counterparty limit, counterparty attribute and card suites pass. Not covered yet: transaction requests and direct debits that reference a deleted counterparty, and the bank-wide scope of the entitlement step, which is raised in #2954.

Cascade-deleting an account or a bank must remove the account's own
counterparties with their bespoke fields, metadata, attributes and
limits, and must not touch counterparties of an account with the same
ACCOUNT_ID at another bank or of another account at the same bank.
DeleteAccountCascade now removes the counterparties the account created,
with their bespoke fields, attributes and limits, and the account's
counterparty metadata with its locations. Rows are selected by both
BANK_ID and ACCOUNT_ID, so another bank's account with the same
ACCOUNT_ID keeps its counterparties. Bank and product cascades use the
same code and get the same behaviour.
deleteCards looked the account up by ACCOUNT_ID alone, so deleting an
account also deleted the cards of an account with the same ACCOUNT_ID at
another bank. It now selects the account by BANK_ID and ACCOUNT_ID.
… BANK_ID too

deleteEntitlements found the account's users by ACCOUNT_ID alone, so the
users of an account with the same ACCOUNT_ID at another bank lost their
entitlements at the deleted account's bank. It now selects the account
access by BANK_ID and ACCOUNT_ID.
@hongwei1 hongwei1 changed the title feat: cascade deletes remove the account's counterparties and keep other banks' cards feat: cascade deletes remove the account's counterparties and stay within the account's bank Nov 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

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.

1 participant