Let melted products trade without store inventory, and split TV sell prices with extra tickers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-10 15:10:10 +03:30
co-authored by Cursor
parent c2f6f9d226
commit d4e3a99e61
12 changed files with 379 additions and 155 deletions
+16
View File
@@ -85,3 +85,19 @@ export function isMeltedProductUsingAppPrice(product?: {
return Number(product.price ?? 0) <= 0
}
/** آبشده موجودی انبار فروشگاهی ندارد */
export function productTracksStoreInventory(product?: { group_type?: string | null } | null) {
return !isMeltedTradeGroup(product?.group_type)
}
export function isProductOutOfStock(product?: {
group_type?: string | null
inventory?: number | null
} | null) {
if (!product || !productTracksStoreInventory(product)) {
return false
}
return Number(product.inventory ?? 0) <= 0
}
+12 -4
View File
@@ -249,15 +249,23 @@ export function isProductPriceInactive(product?: Product | null): boolean {
return getProductBaseBuyPrice(product) <= 0
}
function tvUnitPrice(product: Product): number {
function tvBuyUnitPrice(product: Product): number {
return Number(product.tv_price ?? 0)
}
function tvSellUnitPrice(product: Product): number {
const sell = Number(product.tv_sell_price ?? 0)
if (sell > 0) {
return sell
}
return tvBuyUnitPrice(product)
}
export function getTvProductBuyPrice(product?: Product | null): number {
if (!product) {
return 0
}
const unit = tvUnitPrice(product)
const unit = tvBuyUnitPrice(product)
if (unit > 0) {
return unit + resolveProductCashFeeBuyRial(product, unit)
}
@@ -268,7 +276,7 @@ export function getTvProductSellPrice(product?: Product | null): number {
if (!product) {
return 0
}
const unit = tvUnitPrice(product)
const unit = tvSellUnitPrice(product)
if (unit > 0) {
return unit - resolveProductCashFeeSellRial(product, unit)
}
@@ -279,7 +287,7 @@ export function isTvProductPriceInactive(product?: Product | null): boolean {
if (!product) {
return true
}
if (tvUnitPrice(product) > 0) {
if (tvBuyUnitPrice(product) > 0 || tvSellUnitPrice(product) > 0) {
return false
}
return isProductPriceInactive(product)