fixed amount 2
This commit is contained in:
@@ -232,6 +232,7 @@ import type { Product } from '@/models/products'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import {useConfigStore} from "@/store/configStore";
|
||||
import { calcFeeInGrams, calcPayablePriceRial, calcSellGoldDebit, feeDeductFromGold, loadServiceFeeFromSettings } from '@/utils/serviceFee'
|
||||
import { resolveProductCashFeeBuyRial, resolveProductCashFeeSellRial } from '@/utils/productCashFee'
|
||||
import { formatCashWalletBalanceText, formatGoldWalletBalanceText } from '@/utils/productDealMethod'
|
||||
import { getCashWalletBalance } from '@/utils/productAssets'
|
||||
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
|
||||
@@ -283,13 +284,12 @@ 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 { price_profit = 0, price = 0 } = product
|
||||
const base = price_profit + price
|
||||
const buyFee = resolveProductCashFeeBuyRial(product, base)
|
||||
const sellFee = resolveProductCashFeeSellRial(product, base)
|
||||
|
||||
const rawPrice = isBuy.value
|
||||
? base + cash_fee_buy
|
||||
: base - cash_fee_sell
|
||||
return rawPrice
|
||||
return isBuy.value ? base + buyFee : base - sellFee
|
||||
})
|
||||
|
||||
const finalPrice = computed(() => {
|
||||
@@ -299,15 +299,17 @@ const finalPrice = computed(() => {
|
||||
const product = props?.ProductItem
|
||||
if (!product) return 0
|
||||
|
||||
const { price_profit = 0, price = 0, cash_fee_buy = 0, cash_fee_sell = 0 } = product
|
||||
const { price_profit = 0, price = 0 } = product
|
||||
|
||||
const base = price_profit + price
|
||||
const buyFee = resolveProductCashFeeBuyRial(product, base)
|
||||
const sellFee = resolveProductCashFeeSellRial(product, base)
|
||||
|
||||
if (isBuy.value) {
|
||||
return gold * (base + cash_fee_buy)
|
||||
} else {
|
||||
return gold * (base - cash_fee_sell)
|
||||
return gold * (base + buyFee)
|
||||
}
|
||||
|
||||
return gold * (base - sellFee)
|
||||
})
|
||||
|
||||
const payablePrice = computed(() =>
|
||||
@@ -533,20 +535,30 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
function productFeeBase(product?: Product) {
|
||||
return (product?.price_profit ?? 0) + (product?.price ?? 0)
|
||||
}
|
||||
|
||||
function calculateCash(val: number) {
|
||||
priceErrorVisible.value = false
|
||||
if (!lastPrice.value) return
|
||||
|
||||
const product = props?.ProductItem
|
||||
if (!product) return
|
||||
|
||||
const base = productFeeBase(product)
|
||||
const buyFee = resolveProductCashFeeBuyRial(product, base)
|
||||
const sellFee = resolveProductCashFeeSellRial(product, base)
|
||||
const tradeBuy = getTradeBuyPrice(lastPrice.value)
|
||||
form.value.goldVazn = parseFloat((val * ((props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy))) / tradeBuy).toFixed(1)
|
||||
form.value.goldVazn = parseFloat(String((val * (base + buyFee)) / tradeBuy)).toFixed(1)
|
||||
if (isBuy.value) {
|
||||
form.value.goldCash = val
|
||||
? parseFloat(String(val * ((props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy))))
|
||||
? parseFloat(String(val * (base + buyFee)))
|
||||
: 0
|
||||
if (!val) form.value.goldVazn = 0
|
||||
} else {
|
||||
form.value.goldCash = val
|
||||
? parseFloat(String((val * props?.ProductItem?.price) - (props?.ProductItem?.cash_fee_sell)))
|
||||
? parseFloat(String(val * base - sellFee))
|
||||
: 0
|
||||
if (!val) form.value.goldVazn = 0
|
||||
}
|
||||
@@ -554,9 +566,16 @@ function calculateCash(val: number) {
|
||||
|
||||
function calculateGold(val: number) {
|
||||
if (price.value) {
|
||||
const product = props?.ProductItem
|
||||
if (!product) return
|
||||
|
||||
const base = productFeeBase(product)
|
||||
const buyFee = resolveProductCashFeeBuyRial(product, base)
|
||||
const sellFee = resolveProductCashFeeSellRial(product, base)
|
||||
|
||||
if (isBuy.value) {
|
||||
if (val) {
|
||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(val / (((props?.ProductItem?.price_profit) + (props?.ProductItem?.price)) + (props?.ProductItem?.cash_fee_buy))))
|
||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(String(val / (base + buyFee))))
|
||||
if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true
|
||||
if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false
|
||||
}
|
||||
@@ -571,7 +590,7 @@ function calculateGold(val: number) {
|
||||
}
|
||||
else {
|
||||
if (val) {
|
||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(val / (((props?.ProductItem?.price_profit) + (props?.ProductItem?.price)) + (props?.ProductItem?.cash_fee_sell))))
|
||||
form.value.goldValue = toFixedDownThreeChar(parseFloat(String(val / (base - sellFee))))
|
||||
if (parseInt(finalPrice.value) > 0) priceErrorVisible.value = true
|
||||
if (parseInt(finalPrice.value) === 0) priceErrorVisible.value = false
|
||||
} else if (val.toString() === '') {
|
||||
|
||||
Reference in New Issue
Block a user