Skip to content

fix: pass erpParty when changing account level to Pro/Merchant#53

Merged
islandbitcoin merged 1 commit into
mainfrom
fix/account-hub-change-level-erpparty
Jul 13, 2026
Merged

fix: pass erpParty when changing account level to Pro/Merchant#53
islandbitcoin merged 1 commit into
mainfrom
fix/account-hub-change-level-erpparty

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

Problem

After #52 surfaced real backend errors, Change Level in Account Hub fails with:

erpParty is required for level 2 and 3 accounts

...even for a THREE → TWO downgrade of an account that already has an ERP party (e.g. the account's ERP Party is shown right there in the Overview). So Pro/Merchant re-leveling is currently impossible from this button.

Root cause

Flash's accountUpdateLevel mutation requires an erpParty whenever the resulting level is TWO (Pro) or THREE (Merchant). The plumbing was half-built:

  • GraphQLClient.update_account_level(uid, level, erp_party=None) already accepts it.
  • But admin_api.update_account_level(uid, level) didn't take or forward it, and the change_level dialog sent only {uid, level}.

The account object already carries erpParty (rendered in the Overview) — it just wasn't passed back into the mutation. The correct precedent already exists in approve_upgrade_request (admin_api.py), which supplies erp_party for TWO/THREE.

Fix

  • admin_api.update_account_level — accept erp_party=None and forward it to the client.
  • change_level (JS) — when the target level is TWO/THREE, pass the account's existing erpParty. If such an account has no party, block with an actionable message pointing to the upgrade-request approval flow (the only path that mints the ERP Customer/Address/Bank records) instead of fabricating a dangling party.

Downgrades to ZERO/ONE and re-leveling of accounts that already have a party work; the mint-a-new-party case is intentionally still routed through upgrade-request approval.

Verification

  • node --check on the page JS and py_compile on admin_api.py both pass.
  • The prior error was "erpParty is required" (not "account not found"), which confirms uid already resolves and erpParty was the only missing input.
  • End-to-end check on TEST: select a Merchant (level THREE) account with an ERP party → Change Level → Pro → expect success, and the level badge updates.

🤖 Generated with Claude Code

Flash requires an erpParty for level TWO/THREE accounts, so the Account
Hub "Change Level" action failed with "erpParty is required for level 2
and 3 accounts" — even for a THREE->TWO downgrade of an account that
already has a party. The GraphQL client already accepted erp_party; the
update_account_level endpoint and the change_level dialog just never
forwarded it.

- update_account_level(uid, level, erp_party=None): forward to the client.
- change_level: send the account's existing erpParty when the target level
  is TWO or THREE. If such an account has no party, block with a message
  pointing to the upgrade-request approval flow (the only path that mints
  ERP Customer/Address/Bank records) rather than fabricating one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@islandbitcoin
islandbitcoin merged commit a2d2294 into main Jul 13, 2026
1 check passed
@islandbitcoin
islandbitcoin deleted the fix/account-hub-change-level-erpparty branch July 13, 2026 07:48
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