fix: pass erpParty when changing account level to Pro/Merchant#53
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After #52 surfaced real backend errors, Change Level in Account Hub fails with:
...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
accountUpdateLevelmutation requires anerpPartywhenever 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.admin_api.update_account_level(uid, level)didn't take or forward it, and thechange_leveldialog 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 inapprove_upgrade_request(admin_api.py), which supplieserp_partyfor TWO/THREE.Fix
admin_api.update_account_level— accepterp_party=Noneand forward it to the client.change_level(JS) — when the target level is TWO/THREE, pass the account's existingerpParty. 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 --checkon the page JS andpy_compileonadmin_api.pyboth pass.uidalready resolves anderpPartywas the only missing input.🤖 Generated with Claude Code