From 37ef179288bac364cf74039f2d676b742ee26d03 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Tue, 17 Feb 2026 17:01:45 +0330 Subject: [PATCH] change copper&silver prices --- src/models/products.ts | 1 + src/views/base/copper&silver/index.vue | 41 ++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/models/products.ts b/src/models/products.ts index 603a2b0..e92b736 100644 --- a/src/models/products.ts +++ b/src/models/products.ts @@ -26,6 +26,7 @@ export interface Product { wallet: Wallet auto_close_at: string auto_open_at: string + price_profit: number } export interface PInventory { diff --git a/src/views/base/copper&silver/index.vue b/src/views/base/copper&silver/index.vue index 818d73b..62faaa1 100644 --- a/src/views/base/copper&silver/index.vue +++ b/src/views/base/copper&silver/index.vue @@ -27,7 +27,7 @@
{{ !isBuy ? 'قیمت فروش' : 'قیمت خرید' }}
- {{ usePriceWithoutType(isBuy ? ((props?.ProductItem?.price ?? 0) + (props?.ProductItem?.cash_fee_buy ?? 0)) : ((props?.ProductItem?.price ?? 0) - (props?.ProductItem?.cash_fee_sell ?? 0))) }} + {{ usePriceWithoutType(basePriceValue) }}
ریال
@@ -164,7 +164,7 @@
مظنه:
-
{{ usePriceWithoutType(isBuy ? price.buy ?? 0 : price.sell ?? 0) }}
+
{{ usePriceWithoutType(((props?.ProductItem?.price_profit) + (props?.ProductItem?.price))) }}
ریال
@@ -277,8 +277,37 @@ const sellPagination = ref({ }], limit: 6, page: 0 }) -const finalPrice = computed(() => (form.value?.goldValue * (isBuy.value ? price.value?.buy ?? 0 : price.value?.sell ?? 0))) -// const payablePrice = computed(() => finalPrice.value + finalPrice.value * 0.007) +const basePriceValue = computed(() => { + const product = props?.ProductItem + if (!product) return undefined + + const { price_profit = 0, price = 0, cash_fee_buy = 0, cash_fee_sell = 0 } = product + const base = price_profit + price + + const rawPrice = isBuy.value + ? base + cash_fee_buy + : base - cash_fee_sell + return rawPrice +}) + +const finalPrice = computed(() => { + + const gold = form.value?.goldValue ?? 0 + + const product = props?.ProductItem + if (!product) return 0 + + const { price_profit = 0, price = 0, cash_fee_buy = 0, cash_fee_sell = 0 } = product + + const base = price_profit + price + + if (isBuy.value) { + return gold * (base + cash_fee_buy) + } else { + return gold * (base - cash_fee_sell) + } +}) + const payablePrice = computed(() => finalPrice.value) const equivalentPrice = computed(() => usePriceWithoutType(((isBuy ? price.value?.buy ?? 0 : price.value?.sell ?? 0) * (parseFloat(((form.value?.goldValue ?? 0) * 0.01).toFixed(4))) ).toFixed(0)) ) @@ -506,7 +535,7 @@ function calculateGold(val: number) { if (price.value) { if (isBuy.value) { if (val) { - form.value.goldValue = toFixedDownThreeChar(parseFloat(val / price?.value?.buy)) + form.value.goldValue = toFixedDownThreeChar(parseFloat(val / (((props?.ProductItem?.price_profit) + (props?.ProductItem?.price)) + (props?.ProductItem?.cash_fee_buy)))) if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false } @@ -521,7 +550,7 @@ function calculateGold(val: number) { } else { if (val) { - form.value.goldValue = toFixedDownThreeChar(parseFloat((val / price?.value?.sell))) + form.value.goldValue = toFixedDownThreeChar(parseFloat(val / (((props?.ProductItem?.price_profit) + (props?.ProductItem?.price)) + (props?.ProductItem?.cash_fee_sell)))) if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false } else if (val.toString() === '') {