added pdf in withdraw and deposit and fix bug
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/** دستهبندی یکسان محصول در همه اپهای ماژولار */
|
||||
export const PRODUCT_CATEGORY_ABSHODE = 'آبشده'
|
||||
|
||||
export const UNIFIED_PRODUCT_CATEGORIES = [
|
||||
PRODUCT_CATEGORY_ABSHODE,
|
||||
'مکعب',
|
||||
'گوی',
|
||||
'سکه',
|
||||
'سکه پارسیان',
|
||||
'مس',
|
||||
'نقره',
|
||||
] as const
|
||||
|
||||
export const LEGACY_GROUP_KATOD = 'کاتد مس'
|
||||
export const LEGACY_GROUP_MAFTOL = 'مفتول مس'
|
||||
export const LEGACY_GROUP_GOLD = 'طلا'
|
||||
|
||||
export function normalizeProductGroupType(groupType?: string | null) {
|
||||
return (groupType ?? '').trim()
|
||||
}
|
||||
|
||||
export function isMeltedTradeGroup(groupType?: string | null) {
|
||||
const group = normalizeProductGroupType(groupType)
|
||||
return group === PRODUCT_CATEGORY_ABSHODE || group === LEGACY_GROUP_KATOD
|
||||
}
|
||||
|
||||
export type MeltedPriceSource = 'app' | 'fixed' | 'reference'
|
||||
|
||||
export function resolveMeltedPriceSource(product?: {
|
||||
reading_method?: string | null
|
||||
direct_price?: number | null
|
||||
} | null): MeltedPriceSource {
|
||||
if (product?.reading_method) {
|
||||
return 'reference'
|
||||
}
|
||||
if (Number(product?.direct_price) === 1) {
|
||||
return 'fixed'
|
||||
}
|
||||
return 'app'
|
||||
}
|
||||
|
||||
export function buildCategorySelectItems(metalItems: Array<{ key: number; value: string }>) {
|
||||
const metalHint = metalItems.map((item) => item.value).join('، ')
|
||||
|
||||
return UNIFIED_PRODUCT_CATEGORIES.map((category) => ({
|
||||
key: category,
|
||||
value: category === PRODUCT_CATEGORY_ABSHODE ? `${category} (${metalHint})` : category,
|
||||
}))
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export const TRADE_WEIGHT_UNIT_GRAM = 'گرم'
|
||||
export const TRADE_WEIGHT_UNIT_KILOGRAM = 'کیلوگرم'
|
||||
|
||||
export function isKilogramUnit(unit?: string | null) {
|
||||
const value = (unit ?? '').trim()
|
||||
return value === TRADE_WEIGHT_UNIT_KILOGRAM || value === 'kilogram' || value === 'kg'
|
||||
}
|
||||
|
||||
export function resolveTradeWeightUnit(settingValue?: string | number | null) {
|
||||
return isKilogramUnit(settingValue?.toString()) ? TRADE_WEIGHT_UNIT_KILOGRAM : TRADE_WEIGHT_UNIT_GRAM
|
||||
}
|
||||
|
||||
export function weightFieldLabelForUnit(unit?: string | null) {
|
||||
return isKilogramUnit(unit) ? 'وزن به کیلوگرم' : 'وزن به گرم'
|
||||
}
|
||||
Reference in New Issue
Block a user