2026-05-23 13:27:30 +03:30
|
|
|
import type { Product } from '@/models/products'
|
2026-06-06 15:48:27 +03:30
|
|
|
import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
|
2026-05-23 13:27:30 +03:30
|
|
|
|
|
|
|
|
/** قیمت خرید نمایشی محصول (همان مقداری که در لیست و اکشنشیت نشان داده میشود) */
|
|
|
|
|
export function getProductBuyPrice(product: Product): number {
|
|
|
|
|
if (product.group_type === 'آبشده') {
|
2026-06-06 15:48:27 +03:30
|
|
|
return getTradeBuyPrice(lastPrice.value) + (product.cash_fee_buy ?? 0)
|
2026-05-23 13:27:30 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (['مس', 'نقره'].includes(product.group_type)) {
|
|
|
|
|
const base = (product.price_profit ?? 0) + (product.price ?? 0)
|
|
|
|
|
return base + (product.cash_fee_buy ?? 0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const basePrice = (product.price ?? 0) + (product.cash_fee_buy ?? 0)
|
|
|
|
|
return product.direct_price === 0
|
|
|
|
|
? basePrice * (product.amount ?? 0)
|
|
|
|
|
: basePrice
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-06 15:48:27 +03:30
|
|
|
/** قیمت فروش نمایشی آبشده — فقط cash_fee_sell محصول اختلاف ایجاد میکند */
|
|
|
|
|
export function getProductSellPrice(product: Product): number {
|
|
|
|
|
if (product.group_type === 'آبشده') {
|
|
|
|
|
return getTradeSellPrice(lastPrice.value) - (product.cash_fee_sell ?? 0)
|
|
|
|
|
}
|
|
|
|
|
return getTradeSellPrice(lastPrice.value)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 13:27:30 +03:30
|
|
|
export function isProductPriceInactive(product: Product): boolean {
|
|
|
|
|
return getProductBuyPrice(product) <= 0
|
|
|
|
|
}
|