Skip to content

Conversation

@islandbitcoin
Copy link
Contributor

Mutation:

  • Ingest the information given from the user when filling out the business upgrade form. (regardless of Pro or Merchant)
  • create a new support issue in ERPNext using the erpnext class on the backend.
  • add user info to the issue in description field, formatted for future parsing
  • Condition: if upgrade to level TWO, this mutation should also trigger autoupgrade to level TWO without admin input. if upgrade to level THREE, manual approval required, so this mutation does nothing else.

Query:

  • Client needs to know if a request is pending, so a query is needed to look for existing open support issues connected to this user.
  • query should ingest username, and return a boolean.

@islandbitcoin
Copy link
Contributor Author

@brh28 this still needs to be wired up to the ErpNext support issue structure (WIP)

@islandbitcoin islandbitcoin assigned islandbitcoin and brh28 and unassigned brh28 Oct 17, 2025
@islandbitcoin islandbitcoin added the enhancement New feature or request label Oct 17, 2025
Copy link
Contributor

@brh28 brh28 left a comment

Choose a reason for hiding this comment

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

Have you tested this code against ErpNext? I'm wondering if the read/writes using the subject field is working correctly

if (account instanceof Error) return account

// Validate requested level
const checkedLevel = checkedToAccountLevel(level)
Copy link
Contributor

Choose a reason for hiding this comment

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

lines 43-54 could be combined into a single function. something like:

const checkedLevel = validate(level, [ isValid, isGreaterThan(account.level)] )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated


if (issueResult instanceof Error) return issueResult

// If level is 2 (Pro), auto-upgrade immediately
Copy link
Contributor

Choose a reason for hiding this comment

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

For level 2, why create an issue in ErpNext if we're already upgrading them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so we can have the update records in ErpNext, with timestamps, and saving their bank account information if they enter it, since it is optional for level 2.

/**
* Create a support Issue in ERPNext for account upgrade requests
*/
async createSupportIssue(data: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend changing the interface so that the caller doesn't need to know the implementation details. For example:

createAccountUpgradeRequest(username, details)
getAccountUpgradeRequest(username)

This way, all the logic for handling upgrade requests is contained in this file, rather than spread through the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Nodirbek75 this is where the account upgrade request is made

@islandbitcoin islandbitcoin marked this pull request as draft October 30, 2025 17:21
@islandbitcoin
Copy link
Contributor Author

doctype: Account Upgrade Request
fields:
{
current_level: "ZERO" | "ONE" | "TWO" | "THREE"
requested_level: "ZERO" | "ONE" | "TWO" | "THREE"
username: string
full_name: string
phone_number: string
email?: string
business_name?: string
business_address?: string
terminal_requested?: boolean
bank_name?: string
bank_branch?: string
account_type?: string
currency?: string
account_number?: number
id_document?: string
status: "Pending" | "Approved" | "Rejected"
}

# get from ErpNext user -> settings -> API Access
apiKey: ""
apiSecret: ""
apiKey: "293bac5aa957da3"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

helmRevision: Int
}

input BusinessAccountUpgradeRequestInput {
Copy link
Contributor

Choose a reason for hiding this comment

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

should be updated to include all required fields

if (requestResult instanceof Error) return requestResult

// Level 2 (Pro) auto-upgrades immediately
if (checkedLevel === 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps use AccountLevel enum: e.g AccountLevel.Pro

const erpUsd = (usd: USDAmount): number => Number(usd.asCents(2)) // Number(usd.asDollars(2))
const erpUsd = (usd: USDAmount): number => Number(usd.asCents(2))

type ErpLevelString = "ZERO" | "ONE" | "TWO" | "THREE"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be AccountLevels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. I had to map the numbers to Erp strings

@islandbitcoin
Copy link
Contributor Author

works™

@islandbitcoin islandbitcoin marked this pull request as ready for review December 17, 2025 20:38
@islandbitcoin islandbitcoin requested a review from brh28 December 17, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merchant Upgrade flow Step 3: Update users to Level 3 Account - Merchant

3 participants