Stop multiplying colleague prices by weight and fee from unit price.

Colleague quotes are per piece, and the settings service charge is a percent of that price times count.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-14 22:21:08 +03:30
co-authored by Cursor
parent 71da064cab
commit 7ab78bd550
4 changed files with 51 additions and 9 deletions
@@ -276,6 +276,7 @@ import { useWalletAssets } from '@/composables/useWalletAssets'
import { useCartStore } from '@/store/cartStore'
import { getStoreClosedMessage, isStoreClosed } from '@/utils/storeHours'
import { isProductTradingHoursOpen, productHoursClosedMessage } from '@/utils/productTradeOpen'
import { loadServiceFeeFromSettings, serviceFeePercentage } from '@/utils/serviceFee'
const typeDeal: SelectItem[] = [
{
@@ -313,8 +314,14 @@ interface Prop {
const props = withDefaults(defineProps<Prop>(), {})
const isBuy = ref<boolean>(true)
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 نسبت به قیمت واحد × تعداد — نه وزن گرم */
function countDealFeeRial(unitPrice?: number | null, count = Number(form.value?.goldValue ?? 0)) {
return count * Number(unitPrice ?? 0) * Number(serviceFeePercentage.value)
}
const buyFee = computed(() => countDealFeeRial(props?.ProductItem?.price).toFixed(0))
const sellFee = computed(() => countDealFeeRial(props?.ProductItem?.sellPrice).toFixed(0))
const sellFeeGeram = computed(() => {
if (form.value.goldVazn)
return (form.value.goldVazn * props.ProductItem?.percent_fee_sell).toFixed(3)
@@ -344,8 +351,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 + finalPrice.value * 0.007)
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 disableTransaction = computed(() => {
if (isStoreClosed() || !isProductTradingHoursOpen(props.ProductItem)) {
@@ -466,6 +475,7 @@ async function initSellTable() {
// }
onMounted(async () => {
await loadServiceFeeFromSettings()
switch (router.currentRoute.value.query.state) {
case 'sell':
isBuy.value = false
@@ -570,7 +580,10 @@ function calculateCash(val: number) {
console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastPrice.value?.buy)
if (isBuy.value) {
if (val){
form.value.goldCash = parseFloat(val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy))).toFixed(0)
const base = Number(props?.ProductItem?.price ?? 0)
const goods = val * (base + Number(props?.ProductItem?.cash_fee_buy ?? 0))
const fee = countDealFeeRial(base, val)
form.value.goldCash = parseFloat(String(goods + fee)).toFixed(0)
}
else {
form.value.goldCash = 0
@@ -578,8 +591,12 @@ console.log(val,props?.ProductItem?.price,props?.ProductItem?.cash_fee_buy,lastP
}
}
else {
if (val)
form.value.goldCash = parseFloat((val * props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_sell)).toFixed(0)
if (val) {
const base = Number(props?.ProductItem?.price ?? 0)
const goods = val * base + Number(props?.ProductItem?.cash_fee_sell ?? 0)
const fee = countDealFeeRial(base, val)
form.value.goldCash = parseFloat(String(Math.max(0, goods - fee))).toFixed(0)
}
else{
form.value.goldCash = 0
form.value.goldVazn = 0