fix borcecu edits 2

This commit is contained in:
2026-07-23 12:27:24 +03:30
parent bc642e91ed
commit 149f82edd4
2 changed files with 26 additions and 7 deletions
+3 -4
View File
@@ -439,7 +439,7 @@ export function formatMainMetalReceiveText(weight?: number | null) {
export function calcSellReceivedMetalWeight(
count?: number | null,
product?: ProductUnitSource & { percent_fee_sell?: number | null } | null,
product?: ProductUnitSource | null,
) {
const quantity = Number(count ?? 0)
const unitAmount = Number(product?.amount ?? 0)
@@ -447,9 +447,8 @@ export function calcSellReceivedMetalWeight(
return 0
}
const grossAmount = quantity * unitAmount
const feeRate = Number(product?.percent_fee_sell ?? 0)
return grossAmount - feeRate * grossAmount
// کارمزد محصول تعدادی از ریال است — وزن دریافتی فلز کم نمی‌شود
return quantity * unitAmount
}
export function isCashLikeDealMethod(method?: string | null) {
@@ -332,6 +332,7 @@ import { useWalletAssets } from '@/composables/useWalletAssets'
import { formatProductWalletBalanceText, formatInventoryCardValue, getCashWalletBalance, getProductInventoryQuantity } from '@/utils/productAssets'
import { resolvePhysicalDeliveryState } from '@/utils/physicalDelivery'
import { isStoreClosed, resolveStoreClosedNotice } from '@/utils/storeHours'
import { serviceFeePercentage } from '@/utils/serviceFee'
const catalogProducts = getProductsCatalogRef()
@@ -434,8 +435,24 @@ const isBuy = ref<boolean>(true)
const buyTotalPrice = computed(() => resolveProductTradeBuyUnitPrice(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>({
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 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 maxOrderCash = computed(() => productMaxOrderCash(props.ProductItem))