fix(tv): show board prices from tv_price instead of list price
The monitor uses the TV formula field so the catalog list price stays unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,6 +40,7 @@ export interface Product {
|
|||||||
similar?:Product[]
|
similar?:Product[]
|
||||||
inventory:number
|
inventory:number
|
||||||
app_price?: boolean | number | null
|
app_price?: boolean | number | null
|
||||||
|
tv_price?: number | null
|
||||||
direct_price?: number | null
|
direct_price?: number | null
|
||||||
trade_by_quantity?: boolean | number | null
|
trade_by_quantity?: boolean | number | null
|
||||||
use_last_price_if_zero?: boolean | null
|
use_last_price_if_zero?: boolean | null
|
||||||
|
|||||||
@@ -249,6 +249,42 @@ export function isProductPriceInactive(product?: Product | null): boolean {
|
|||||||
return getProductBaseBuyPrice(product) <= 0
|
return getProductBaseBuyPrice(product) <= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tvUnitPrice(product: Product): number {
|
||||||
|
return Number(product.tv_price ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTvProductBuyPrice(product?: Product | null): number {
|
||||||
|
if (!product) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
const unit = tvUnitPrice(product)
|
||||||
|
if (unit > 0) {
|
||||||
|
return unit + resolveProductCashFeeBuyRial(product, unit)
|
||||||
|
}
|
||||||
|
return getProductBuyPrice(product)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTvProductSellPrice(product?: Product | null): number {
|
||||||
|
if (!product) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
const unit = tvUnitPrice(product)
|
||||||
|
if (unit > 0) {
|
||||||
|
return unit - resolveProductCashFeeSellRial(product, unit)
|
||||||
|
}
|
||||||
|
return getProductSellPrice(product)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isTvProductPriceInactive(product?: Product | null): boolean {
|
||||||
|
if (!product) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (tvUnitPrice(product) > 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return isProductPriceInactive(product)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* نمایش محصول در فروشگاه — اولویت با `show` سرور.
|
* نمایش محصول در فروشگاه — اولویت با `show` سرور.
|
||||||
* آبشدهٔ قیمتاپ با مظنه زنده حتی اگر show هنوز false باشد.
|
* آبشدهٔ قیمتاپ با مظنه زنده حتی اگر show هنوز false باشد.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|||||||
import { getTvProducts } from '@/api/products'
|
import { getTvProducts } from '@/api/products'
|
||||||
import type { Product } from '@/models/products'
|
import type { Product } from '@/models/products'
|
||||||
import { getConfigApp } from '@/utils/config'
|
import { getConfigApp } from '@/utils/config'
|
||||||
import { getProductBuyPrice, getProductSellPrice, isProductPriceInactive } from '@/utils/productPrice'
|
import { getTvProductBuyPrice, getTvProductSellPrice, isTvProductPriceInactive } from '@/utils/productPrice'
|
||||||
import { lastPrice, getLastPrices, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
import { lastPrice, getLastPrices, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||||
import { getPriceDisplayMessage, getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
import { getPriceDisplayMessage, getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
||||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||||
@@ -81,7 +81,7 @@ const rows = computed(() => {
|
|||||||
const marked = list.filter(isShowOnTv)
|
const marked = list.filter(isShowOnTv)
|
||||||
const source = marked.length ? marked : list
|
const source = marked.length ? marked : list
|
||||||
return source.map((product) => {
|
return source.map((product) => {
|
||||||
if (isProductPriceInactive(product)) {
|
if (isTvProductPriceInactive(product)) {
|
||||||
return {
|
return {
|
||||||
id: product.id,
|
id: product.id,
|
||||||
title: product.title,
|
title: product.title,
|
||||||
@@ -93,8 +93,8 @@ const rows = computed(() => {
|
|||||||
return {
|
return {
|
||||||
id: product.id,
|
id: product.id,
|
||||||
title: product.title,
|
title: product.title,
|
||||||
buyText: usePriceWithoutType(getProductBuyPrice(product)),
|
buyText: usePriceWithoutType(getTvProductBuyPrice(product)),
|
||||||
sellText: usePriceWithoutType(getProductSellPrice(product)),
|
sellText: usePriceWithoutType(getTvProductSellPrice(product)),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useFullscreen } from '@vueuse/core'
|
|||||||
import type { Product } from '@/models/products'
|
import type { Product } from '@/models/products'
|
||||||
import { getTvProducts } from '@/api/products'
|
import { getTvProducts } from '@/api/products'
|
||||||
import { getConfigApp } from '@/utils/config'
|
import { getConfigApp } from '@/utils/config'
|
||||||
import { getProductBuyPrice, getProductSellPrice, isProductPriceInactive } from '@/utils/productPrice'
|
import { getTvProductBuyPrice, getTvProductSellPrice, isTvProductPriceInactive } from '@/utils/productPrice'
|
||||||
import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||||
import { getPriceDisplayMessage, getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
import { getPriceDisplayMessage, getPriceDisplayState, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
||||||
import { isMeltedTradeGroup } from '@/utils/productCategories'
|
import { isMeltedTradeGroup } from '@/utils/productCategories'
|
||||||
@@ -239,14 +239,14 @@ export function useTvMonitorPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function productBuyLabel(product: Product) {
|
function productBuyLabel(product: Product) {
|
||||||
if (isProductPriceInactive(product)) return NO_QUOTE_MESSAGE
|
if (isTvProductPriceInactive(product)) return NO_QUOTE_MESSAGE
|
||||||
const value = getProductBuyPrice(product)
|
const value = getTvProductBuyPrice(product)
|
||||||
return value > 0 ? usePrice(value) : '—'
|
return value > 0 ? usePrice(value) : '—'
|
||||||
}
|
}
|
||||||
|
|
||||||
function productSellLabel(product: Product) {
|
function productSellLabel(product: Product) {
|
||||||
if (isProductPriceInactive(product)) return NO_QUOTE_MESSAGE
|
if (isTvProductPriceInactive(product)) return NO_QUOTE_MESSAGE
|
||||||
const value = getProductSellPrice(product)
|
const value = getTvProductSellPrice(product)
|
||||||
return value > 0 ? usePrice(value) : '—'
|
return value > 0 ? usePrice(value) : '—'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user