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:
@@ -3,6 +3,7 @@ import { getTradeBuyPrice, getTradeSellPrice, lastPrice } from '@/utils/price'
|
||||
import { resolveProductCashFeeBuyRial, resolveProductCashFeeSellRial } from '@/utils/productCashFee'
|
||||
import {
|
||||
isAppPriceProduct,
|
||||
isColleaguePriceProduct,
|
||||
isMeltedProductUsingAppPrice,
|
||||
isMeltedTradeGroup,
|
||||
isMetalCommodityGroup,
|
||||
@@ -31,7 +32,7 @@ function hasProductUnitWeight(product?: Product | null) {
|
||||
}
|
||||
|
||||
function productPriceAmountFactor(product?: Product | null) {
|
||||
if (!product || product.reading_method) {
|
||||
if (!product || product.reading_method || isColleaguePriceProduct(product)) {
|
||||
return 1
|
||||
}
|
||||
if (isAppPriceProduct(product)) {
|
||||
@@ -137,6 +138,10 @@ export function getProductBuyPrice(product?: Product | null): number {
|
||||
const fee = resolveProductCashFeeBuyRial(product, base)
|
||||
const withFee = base + fee
|
||||
|
||||
if (isColleaguePriceProduct(product)) {
|
||||
return withFee
|
||||
}
|
||||
|
||||
if (isAppPriceProduct(product)) {
|
||||
return withFee * productPriceAmountFactor(product)
|
||||
}
|
||||
@@ -194,6 +199,10 @@ export function getProductBaseSellPrice(product?: Product | null): number {
|
||||
return Number(product.sellPrice ?? product.price ?? 0)
|
||||
}
|
||||
|
||||
if (isColleaguePriceProduct(product)) {
|
||||
return Number(product.sellPrice ?? product.price ?? 0)
|
||||
}
|
||||
|
||||
const serverSell = Number(product.sellPrice ?? 0)
|
||||
if (serverSell > 0) {
|
||||
return serverSell
|
||||
@@ -213,6 +222,10 @@ export function getProductSellPrice(product?: Product | null): number {
|
||||
return 0
|
||||
}
|
||||
|
||||
if (isColleaguePriceProduct(product)) {
|
||||
return base - resolveProductCashFeeSellRial(product, base)
|
||||
}
|
||||
|
||||
if (isAppPriceProduct(product)) {
|
||||
const withFee = base - resolveProductCashFeeSellRial(product, base)
|
||||
return withFee * productPriceAmountFactor(product)
|
||||
|
||||
Reference in New Issue
Block a user