fix borcecu edits 2
This commit is contained in:
@@ -439,7 +439,7 @@ export function formatMainMetalReceiveText(weight?: number | null) {
|
|||||||
|
|
||||||
export function calcSellReceivedMetalWeight(
|
export function calcSellReceivedMetalWeight(
|
||||||
count?: number | null,
|
count?: number | null,
|
||||||
product?: ProductUnitSource & { percent_fee_sell?: number | null } | null,
|
product?: ProductUnitSource | null,
|
||||||
) {
|
) {
|
||||||
const quantity = Number(count ?? 0)
|
const quantity = Number(count ?? 0)
|
||||||
const unitAmount = Number(product?.amount ?? 0)
|
const unitAmount = Number(product?.amount ?? 0)
|
||||||
@@ -447,9 +447,8 @@ export function calcSellReceivedMetalWeight(
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const grossAmount = quantity * unitAmount
|
// کارمزد محصول تعدادی از ریال است — وزن دریافتی فلز کم نمیشود
|
||||||
const feeRate = Number(product?.percent_fee_sell ?? 0)
|
return quantity * unitAmount
|
||||||
return grossAmount - feeRate * grossAmount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCashLikeDealMethod(method?: string | null) {
|
export function isCashLikeDealMethod(method?: string | null) {
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ import { useWalletAssets } from '@/composables/useWalletAssets'
|
|||||||
import { formatProductWalletBalanceText, formatInventoryCardValue, getCashWalletBalance, getProductInventoryQuantity } from '@/utils/productAssets'
|
import { formatProductWalletBalanceText, formatInventoryCardValue, getCashWalletBalance, getProductInventoryQuantity } from '@/utils/productAssets'
|
||||||
import { resolvePhysicalDeliveryState } from '@/utils/physicalDelivery'
|
import { resolvePhysicalDeliveryState } from '@/utils/physicalDelivery'
|
||||||
import { isStoreClosed, resolveStoreClosedNotice } from '@/utils/storeHours'
|
import { isStoreClosed, resolveStoreClosedNotice } from '@/utils/storeHours'
|
||||||
|
import { serviceFeePercentage } from '@/utils/serviceFee'
|
||||||
|
|
||||||
const catalogProducts = getProductsCatalogRef()
|
const catalogProducts = getProductsCatalogRef()
|
||||||
|
|
||||||
@@ -434,8 +435,24 @@ const isBuy = ref<boolean>(true)
|
|||||||
const buyTotalPrice = computed(() => resolveProductTradeBuyUnitPrice(props?.ProductItem))
|
const buyTotalPrice = computed(() => resolveProductTradeBuyUnitPrice(props?.ProductItem))
|
||||||
|
|
||||||
const sellTotalPrice = computed(() => resolveProductTradeSellUnitPrice(props?.ProductItem))
|
const sellTotalPrice = computed(() => resolveProductTradeSellUnitPrice(props?.ProductItem))
|
||||||
const buyFee = computed(() => ((props?.ProductItem?.amount * (props?.ProductItem?.percent_fee_buy ?? 0) * (props?.ProductItem?.price ?? 0)).toFixed(0)))
|
|
||||||
const sellFee = computed(() => ((props?.ProductItem?.amount * (props?.ProductItem?.percent_fee_sell ?? 0) * (props?.ProductItem?.sellPrice ?? 0)).toFixed(0)))
|
/** کارمزد از fee_service_charge_percentage — نه percent_fee_* / اختلاف قیمت */
|
||||||
|
function countDealFeeGrams() {
|
||||||
|
const count = Number(form.value?.goldValue ?? 0)
|
||||||
|
const unitWeight = Number(props?.ProductItem?.amount ?? 0)
|
||||||
|
return count * unitWeight * Number(serviceFeePercentage.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function countDealFeeRial(piecePrice?: number | null) {
|
||||||
|
const unitWeight = Number(props?.ProductItem?.amount ?? 0)
|
||||||
|
const perGram = unitWeight > 0 ? Number(piecePrice ?? 0) / unitWeight : 0
|
||||||
|
return countDealFeeGrams() * perGram
|
||||||
|
}
|
||||||
|
|
||||||
|
const buyFee = computed(() => countDealFeeRial(props?.ProductItem?.price).toFixed(0))
|
||||||
|
const sellFee = computed(() => countDealFeeRial(props?.ProductItem?.sellPrice).toFixed(0))
|
||||||
|
const buyFeeGeram = computed(() => countDealFeeGrams().toFixed(4))
|
||||||
|
const sellFeeGeram = computed(() => countDealFeeGrams().toFixed(4))
|
||||||
|
|
||||||
const buyPagination = ref<TableEngineInput>({
|
const buyPagination = ref<TableEngineInput>({
|
||||||
filters: [{
|
filters: [{
|
||||||
@@ -458,7 +475,10 @@ const sellPagination = ref<TableEngineInput>({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const finalPrice = computed(() => (form.value?.goldValue * (isBuy.value ? props.ProductItem?.price ?? 0 : props.ProductItem?.sellPrice ?? 0)))
|
const finalPrice = computed(() => (form.value?.goldValue * (isBuy.value ? props.ProductItem?.price ?? 0 : props.ProductItem?.sellPrice ?? 0)))
|
||||||
const payablePrice = computed(() => finalPrice.value)
|
const payablePrice = computed(() => {
|
||||||
|
const fee = countDealFeeRial(isBuy.value ? props.ProductItem?.price : props.ProductItem?.sellPrice)
|
||||||
|
return isBuy.value ? finalPrice.value + fee : Math.max(0, finalPrice.value - fee)
|
||||||
|
})
|
||||||
|
|
||||||
const minOrderCash = computed(() => productMinOrderCash(props.ProductItem, isBuy.value))
|
const minOrderCash = computed(() => productMinOrderCash(props.ProductItem, isBuy.value))
|
||||||
const maxOrderCash = computed(() => productMaxOrderCash(props.ProductItem))
|
const maxOrderCash = computed(() => productMaxOrderCash(props.ProductItem))
|
||||||
|
|||||||
Reference in New Issue
Block a user