Repository navigation
feat(bank-accounts): self-serve add/update/delete/set-default for ERPNext bank accounts - #513
Merged
Merged
Conversation
…Next bank accounts Customers can now manage their ERPNext (Jamaican) cashout bank accounts instantly, with no admin review: - ErpNext service: createBankAccount / updateBankAccount / deleteBankAccount / setDefaultBankAccount over the admin_panel.api.banking endpoints, with duplicate-number, not-owned and validation refusals told apart from generic failures. Full account numbers are never logged. - getBankAccountsByCustomer filters disabled=0, so a soft-deleted account vanishes from the app and from the cashout ownership checks. - App layer: erpParty only from the authenticated account, ownership verified before every write, currency locked on update, bank must be a supported bank, open update requests closed after an instant edit, shared per-account rate limit. - GraphQL: bankAccountAdd / bankAccountUpdate / bankAccountSetDefault / bankAccountDelete (blocked for API keys); bankAccountUpdateRequest deprecated. - error-map: all new errors plus the previously unmapped bank account errors. Co-Authored-By: Claude Fable 5.1 <[email protected]>
bankAccountAdd/Update validate bankName against listBanks, so a truncated list would reject valid banks once ERPNext has more than 20. Co-Authored-By: Claude Fable 5.1 <[email protected]>
- getBankAccountsByCustomer asks for every row (limit_page_length=0) and addBankAccount caps a customer at 10 enabled accounts, so an account can no longer land past Frappe's default page of 20 and become invisible. - ERPNext refusals are allowlisted: only the banking.py refusals map to BankAccountValidationError, with flash-owned text; "Unknown ERP customer" maps to BankAccountUpgradeRequiredError; any other 417 (missing method, Frappe-internal checks) is a generic failure. The error map only shows allowlisted BANK_ACCOUNT_INVALID messages. - validateDetails enforces an account-number format, length limits on branch and account name, and rejects control characters and <>. - BANK_ACCOUNT_DUPLICATE_NUMBER is only returned for a number on the customer's own visible accounts (checked locally). An ERPNext duplicate refusal for a number the customer cannot see becomes the generic BANK_ACCOUNT_INVALID, removing the cross-customer probe. Decision recorded in the module header. - A failed re-read after a committed add/update/set-default logs and returns the written values instead of failing the mutation. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…d account name UNSAFE_TEXT_REGEX only covered C0 controls, DEL and angle brackets, so zero-width, bidi-override, line-separator, BOM and C1 code points passed validation. A holder name could display reordered in the ERPNext desk, where ops compares it against KYC on payout. Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.
What
Customers manage their own Jamaican (ERPNext) bank accounts: add, edit, delete, set default. All changes apply instantly (product decision; ops still reviews every Cashout before paying it). Bridge external accounts already had this and are untouched.
Depends on lnflash/frappe-flash-admin#78, which adds the
delete_bank_accountendpoint. Deploy that first.GraphQL
bankAccountUpdateRequestis marked@deprecatedand keeps working for older app versions. New error codes:BANK_ACCOUNT_UPGRADE_REQUIRED,BANK_ACCOUNT_NOT_FOUND,BANK_ACCOUNT_DUPLICATE_NUMBER,BANK_ACCOUNT_INVALID.schema.graphqlanddev/apollo-federation/supergraph.graphqlare both regenerated and both carry the new fields (the router rejectedpendingUpdatein the past because only the subgraph SDL was updated).Behavior
erpPartycomes only from the authenticated account, never from input. Update, delete and set-default also check the id is in the caller's own account list before calling ERPNext (the Frappe side checks again)./api/method/admin_panel.api.banking.{add,update,set_default,delete}_bank_account.getBankAccountsByCustomerfiltersdisabled=0and no longer stops at Frappe's default 20 rows. Cashout ownership checks use the same method, so a removed account cannot be cashed out to.listBanks()(the Frappe endpoint would otherwise create a Bank master from free text), account type Chequing or Savings, currency JMD or USD on add and immutable after, length limits, control / zero-width / bidi characters rejected in text ops reads off a Cashout. At most 10 accounts per customer.Bank Account Update Requestfor that account so a stale approval cannot overwrite it (best effort, logged on failure).bankAccountManage: 20 writes per hour. New mutations are blocked for API keys, like their sibling.listBanksnow requests every bank instead of the first 20.Not verified
Nothing here has run against a live ERPNext. The 417 /
_server_messageserror shape is from Frappe conventions and the sibling branch's source, and needs confirming on TEST.Tests
4 new spec files plus updates (service methods with mocked axios, app layer, error map, rate limit config).
yarn tsc-check,yarn eslint-check,yarn madge-check,yarn check-yaml,yarn check:sdl,typosand lockfile prettier all pass. Full unit suite was green on the feature commit (3241 passed); after the review fixes the touched specs, lint and typecheck were re-run and pass.🤖 Generated with Claude Code