fix some bug

This commit is contained in:
2026-06-06 15:48:27 +03:30
parent f82a0c3873
commit 4c707849ef
5 changed files with 29 additions and 27 deletions
+10 -2
View File
@@ -1,10 +1,10 @@
import type { Product } from '@/models/products'
import { getTradeBuyPrice, lastPrice } from '@/utils/price'
import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
/** قیمت خرید نمایشی محصول (همان مقداری که در لیست و اکشن‌شیت نشان داده می‌شود) */
export function getProductBuyPrice(product: Product): number {
if (product.group_type === 'آبشده') {
return getTradeBuyPrice(lastPrice.value)
return getTradeBuyPrice(lastPrice.value) + (product.cash_fee_buy ?? 0)
}
if (['مس', 'نقره'].includes(product.group_type)) {
@@ -18,6 +18,14 @@ export function getProductBuyPrice(product: Product): number {
: basePrice
}
/** قیمت فروش نمایشی آبشده — فقط 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)
}
export function isProductPriceInactive(product: Product): boolean {
return getProductBuyPrice(product) <= 0
}