changes of boursecu
This commit is contained in:
@@ -2,16 +2,24 @@ import type { SelectItem } from '@/models/SelectItem'
|
||||
import { isBoursecuProject } from '@/utils/config'
|
||||
|
||||
export const BOURSECU_GROUP_MAFTOL = 'مفتول مس'
|
||||
export const BOURSECU_GROUP_KATAD = 'کاتد مس'
|
||||
export const BOURSECU_GROUP_KATOD = 'کاتد مس'
|
||||
export const BOURSECU_GROUP_ABSHODE = 'آبشده'
|
||||
|
||||
export const BOURSECU_ASSET_LABEL_KATOD = 'دارایی کاتد مس'
|
||||
export const BOURSECU_ASSET_LABEL_MAFTOL = 'دارایی مفتول مس'
|
||||
export const BOURSECU_ASSET_LABEL_GOLD = 'دارایی طلایی'
|
||||
|
||||
const DEFAULT_TYPE_DEAL: SelectItem[] = [
|
||||
{ value: 'نقدی', key: 'cash' },
|
||||
{ value: 'طلایی', key: 'gold' },
|
||||
]
|
||||
|
||||
const MAFTOL_TYPE_DEAL: SelectItem[] = [
|
||||
{ value: 'کاتد', key: 'katod' },
|
||||
{ value: BOURSECU_GROUP_KATOD, key: 'katod' },
|
||||
{ value: 'نقدی', key: 'cash' },
|
||||
]
|
||||
|
||||
const CASH_ONLY_TYPE_DEAL: SelectItem[] = [
|
||||
{ value: 'نقدی', key: 'cash' },
|
||||
]
|
||||
|
||||
@@ -30,7 +38,7 @@ export function isBoursecuDealProductGroup(groupType?: string | null) {
|
||||
|
||||
const group = normalizeProductGroupType(groupType)
|
||||
return group === BOURSECU_GROUP_MAFTOL
|
||||
|| group === BOURSECU_GROUP_KATAD
|
||||
|| group === BOURSECU_GROUP_KATOD
|
||||
|| group === BOURSECU_GROUP_ABSHODE
|
||||
}
|
||||
|
||||
@@ -38,9 +46,12 @@ export function isMaftolMesGroup(groupType?: string | null) {
|
||||
return normalizeProductGroupType(groupType) === BOURSECU_GROUP_MAFTOL
|
||||
}
|
||||
|
||||
export function isKatodMesGroup(groupType?: string | null) {
|
||||
return normalizeProductGroupType(groupType) === BOURSECU_GROUP_KATOD
|
||||
}
|
||||
|
||||
export function isGoldOnlyDealGroup(groupType?: string | null) {
|
||||
const group = normalizeProductGroupType(groupType)
|
||||
return group === BOURSECU_GROUP_KATAD || group === BOURSECU_GROUP_ABSHODE
|
||||
return normalizeProductGroupType(groupType) === BOURSECU_GROUP_ABSHODE
|
||||
}
|
||||
|
||||
export function getProductDealMethodOptions(groupType?: string | null): SelectItem[] {
|
||||
@@ -52,6 +63,10 @@ export function getProductDealMethodOptions(groupType?: string | null): SelectIt
|
||||
return MAFTOL_TYPE_DEAL
|
||||
}
|
||||
|
||||
if (isKatodMesGroup(groupType)) {
|
||||
return CASH_ONLY_TYPE_DEAL
|
||||
}
|
||||
|
||||
if (isGoldOnlyDealGroup(groupType)) {
|
||||
return GOLD_ONLY_TYPE_DEAL
|
||||
}
|
||||
@@ -66,3 +81,50 @@ export function getDefaultProductDealMethod(groupType?: string | null) {
|
||||
export function isCashLikeDealMethod(method?: string | null) {
|
||||
return method === 'cash' || method === 'katod'
|
||||
}
|
||||
|
||||
export const BOURSECU_WALLET_LABEL_GENERIC = 'موجودی کیف'
|
||||
|
||||
export function getGoldWalletLabel(groupType?: string | null) {
|
||||
if (!isBoursecuProject()) return 'موجودی کیف طلا'
|
||||
|
||||
const group = normalizeProductGroupType(groupType)
|
||||
if (group === BOURSECU_GROUP_KATOD) return `موجودی کیف ${BOURSECU_GROUP_KATOD}`
|
||||
if (group === BOURSECU_GROUP_MAFTOL) return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}`
|
||||
if (group === BOURSECU_GROUP_ABSHODE) return 'موجودی کیف طلا'
|
||||
|
||||
return BOURSECU_WALLET_LABEL_GENERIC
|
||||
}
|
||||
|
||||
export function getCashWalletLabel(groupType?: string | null) {
|
||||
if (!isBoursecuProject()) return 'موجودی کیف پول'
|
||||
|
||||
const group = normalizeProductGroupType(groupType)
|
||||
if (group === BOURSECU_GROUP_KATOD) return `موجودی کیف ${BOURSECU_GROUP_KATOD}`
|
||||
if (group === BOURSECU_GROUP_MAFTOL) return `موجودی کیف ${BOURSECU_GROUP_MAFTOL}`
|
||||
|
||||
return BOURSECU_WALLET_LABEL_GENERIC
|
||||
}
|
||||
|
||||
export function getWeightUnit() {
|
||||
return isBoursecuProject() ? 'کیلوگرم' : 'گرم'
|
||||
}
|
||||
|
||||
export function formatBoursecuAssetAmount(amount?: number | null) {
|
||||
return `${amount ?? 0}${getWeightUnit()}`
|
||||
}
|
||||
|
||||
export function formatGoldWalletBalanceText(gold: number, groupType?: string | null) {
|
||||
return `${getGoldWalletLabel(groupType)}: ${gold} ${getWeightUnit()}`
|
||||
}
|
||||
|
||||
export function formatCashWalletBalanceText(cashFormatted: string | number, groupType?: string | null) {
|
||||
return `${getCashWalletLabel(groupType)}: ${cashFormatted} ریال`
|
||||
}
|
||||
|
||||
export function getInsufficientGoldWalletMessage(groupType?: string | null) {
|
||||
return `${getGoldWalletLabel(groupType)} ناکافی است`
|
||||
}
|
||||
|
||||
export function getInsufficientCashWalletMessage(groupType?: string | null) {
|
||||
return `${getCashWalletLabel(groupType)} ناکافی است`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user