Fix anchor price selection - prioritize anchor over method

The previous logic checked preferred method first, which could select
a wrong price even when anchor price was available. Now:

1. PRIORITY 1: Anchor price - if user confirmed a price, find closest
   match (within 10% tolerance) across ALL candidates
2. PRIORITY 2: Preferred method - only used if no anchor match found
3. PRIORITY 3: Consensus voting

Also added debug logging to trace anchor price saving and retrieval.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
clucraft 2026-01-24 19:01:15 -05:00
parent 389915a6ec
commit 8131017f3a
3 changed files with 31 additions and 29 deletions

View file

@ -59,6 +59,7 @@ router.post('/', async (req: AuthRequest, res: Response) => {
// Store the anchor price - used on refresh to select the correct variant
await productQueries.updateAnchorPrice(product.id, selectedPrice);
console.log(`[Products] Saved anchor price ${selectedPrice} for product ${product.id} (method: ${selectedMethod})`);
// Record the user-selected price
await priceHistoryQueries.create(