fix: withdraw flow bug (zero bal) (#5629)
This commit is contained in:
@@ -408,11 +408,11 @@ export function createWithdrawContext(
|
|||||||
const stages = computed<WithdrawStage[]>(() => {
|
const stages = computed<WithdrawStage[]>(() => {
|
||||||
const dynamicStages: WithdrawStage[] = []
|
const dynamicStages: WithdrawStage[] = []
|
||||||
|
|
||||||
const usedLimit = balance?.withdrawn_ytd ?? 0
|
const usedLimit = balanceRef.value?.withdrawn_ytd ?? 0
|
||||||
const available = balance?.available ?? 0
|
const available = balanceRef.value?.available ?? 0
|
||||||
|
|
||||||
const needsTaxForm =
|
const needsTaxForm =
|
||||||
balance?.form_completion_status !== 'complete' &&
|
balanceRef.value?.form_completion_status !== 'complete' &&
|
||||||
usedLimit + available >= getTaxThreshold(taxComplianceThresholds)
|
usedLimit + available >= getTaxThreshold(taxComplianceThresholds)
|
||||||
|
|
||||||
const threshold = getTaxThreshold(taxComplianceThresholds)
|
const threshold = getTaxThreshold(taxComplianceThresholds)
|
||||||
@@ -420,7 +420,7 @@ export function createWithdrawContext(
|
|||||||
usedLimit,
|
usedLimit,
|
||||||
available,
|
available,
|
||||||
total: usedLimit + available,
|
total: usedLimit + available,
|
||||||
status: balance?.form_completion_status,
|
status: balanceRef.value?.form_completion_status,
|
||||||
needsTaxForm,
|
needsTaxForm,
|
||||||
taxThreshold: threshold,
|
taxThreshold: threshold,
|
||||||
taxComplianceFilled: `${((usedLimit / threshold) * 100).toFixed(1)}%`,
|
taxComplianceFilled: `${((usedLimit / threshold) * 100).toFixed(1)}%`,
|
||||||
@@ -448,14 +448,14 @@ export function createWithdrawContext(
|
|||||||
})
|
})
|
||||||
|
|
||||||
const maxWithdrawAmount = computed(() => {
|
const maxWithdrawAmount = computed(() => {
|
||||||
const availableBalance = balance?.available ?? 0
|
const availableBalance = balanceRef.value?.available ?? 0
|
||||||
const formCompleted = balance?.form_completion_status === 'complete'
|
const formCompleted = balanceRef.value?.form_completion_status === 'complete'
|
||||||
|
|
||||||
if (formCompleted) {
|
if (formCompleted) {
|
||||||
return Math.max(0, availableBalance)
|
return Math.max(0, availableBalance)
|
||||||
}
|
}
|
||||||
|
|
||||||
const usedLimit = balance?.withdrawn_ytd ?? 0
|
const usedLimit = balanceRef.value?.withdrawn_ytd ?? 0
|
||||||
const remainingLimit = Math.max(0, getTaxThresholdActual(taxComplianceThresholds) - usedLimit)
|
const remainingLimit = Math.max(0, getTaxThresholdActual(taxComplianceThresholds) - usedLimit)
|
||||||
return Math.max(0, Math.min(remainingLimit, availableBalance))
|
return Math.max(0, Math.min(remainingLimit, availableBalance))
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user