diff --git a/frontend/src/composables/useKitCost.js b/frontend/src/composables/useKitCost.js index c7b5af9..5134f32 100644 --- a/frontend/src/composables/useKitCost.js +++ b/frontend/src/composables/useKitCost.js @@ -37,15 +37,17 @@ export function useKitCost() { } if (totalBottlePrice === 0) return {} - // Proportional allocation — subtract accessory value, then cap at bottle price sum - const oilBudget = kit.price - (kit.accessoryValue || 0) - const effectivePrice = Math.min(oilBudget, totalBottlePrice) + // Uniform discount: kit price covers oils + accessories at the same discount rate + // discount_rate = kit_price / (oil_total + accessory_value) + // each oil's kit cost = bottle_price × discount_rate + const totalValue = totalBottlePrice + (kit.accessoryValue || 0) + const discountRate = Math.min(kit.price / totalValue, 1) // cap at 1 (no markup) const perDrop = {} for (const name of resolved) { const meta = oils.oilsMeta[name] const count = bc[name] || 1 const bp = oilBottlePrices[name] - const kitCostForOil = (bp / totalBottlePrice) * effectivePrice + const kitCostForOil = bp * discountRate const totalDrops = meta ? meta.dropCount * count : 1 perDrop[name] = totalDrops > 0 ? kitCostForOil / totalDrops : 0 }