fix bug 22/4 2

This commit is contained in:
2026-07-13 19:03:03 +03:30
parent 61235b3bf8
commit 76813df062
15 changed files with 1020 additions and 70 deletions
+7
View File
@@ -45,6 +45,13 @@ export function usesMeltedPriceEditor(input?: {
export type MeltedPriceSource = 'app' | 'fixed' | 'reference'
/** برچسب نوع معامله — فقط مقداری یا تعدادی */
export function resolveProductTradeTypeLabel(tradeByQuantity?: boolean | number | null) {
return tradeByQuantity === true || Number(tradeByQuantity) === 1
? 'معامله مقداری'
: 'معامله تعدادی'
}
export function resolveMeltedPriceSource(product?: {
reading_method?: string | null
direct_price?: number | null
+27
View File
@@ -95,6 +95,7 @@ export function computeProductEditorPricePreview(input: {
form: {
group_type?: string
price?: number | null
amount?: number | null
reading_method?: string | null
price_offset_percent?: number | null
use_last_price_if_zero?: boolean | null
@@ -168,6 +169,32 @@ export function computeProductEditorPricePreview(input: {
: { status: 'empty', message: 'قیمت وسط را وارد کنید' }
}
if (input.methodOption === '3') {
const weight = Number(input.form.amount) > 0 ? Number(input.form.amount) : 1
const base = resolveAppBasePrice(input.appLastPrice)
if (base > 0) {
const perGram = adjustedProductPrice(base, 0, offsetPercent)
return {
status: 'ready',
amount: Math.round(perGram * weight),
source: 'قیمت صفحه اصلی اپ × وزن'
}
}
const fallback = resolveStoredFallbackPrice(
input.form.price,
input.form.use_last_price_if_zero ?? false,
input.appLastPrice?.last_historical
)
if (fallback > 0) {
return {
status: 'ready',
amount: Math.round(adjustedProductPrice(fallback, 0, offsetPercent) * weight),
source: 'آخرین قیمت ذخیره‌شده × وزن'
}
}
return { status: 'empty', message: 'قیمت اپ در دسترس نیست' }
}
if (!input.form.reading_method) {
return { status: 'empty', message: 'مرجع قیمت را انتخاب کنید' }
}