diff --git a/api.ts b/api.ts index 1435701..c5f0311 100644 --- a/api.ts +++ b/api.ts @@ -125,10 +125,10 @@ function apply_guidance(doc: any) { // Determine the anchor price and source if (doc.targetPrice !== undefined && (mostRelevantCustomerPrice === undefined || doc.targetPrice < mostRelevantCustomerPrice)) { doc.anchorPrice = doc.targetPrice; - doc.anchorSource = 'targetPrice'; + doc.anchorSource = 'Target Price'; } else if (mostRelevantCustomerPrice !== undefined) { doc.anchorPrice = mostRelevantCustomerPrice; - doc.anchorSource = 'customerPrice'; + doc.anchorSource = doc.mostRelevantCustomerSeason + ' Customer Price'; } else { doc.anchorPrice = null; doc.anchorSource = 'none'; // or any other default value you wish to indicate no anchor price was found @@ -137,21 +137,6 @@ function apply_guidance(doc: any) { return doc; } - -// Function to update each item with the most recent price -function updateWithMostRecentPrice(items) { - for (let item of items) { - // Find the most recent price - //const lastPrice = findMostRecentPrice(item.season); - const years = Object.keys(item.season); - const recentYear = Math.max(...years); - const lastPrice = item.season[recentYear].price_usd; - // Append the last_price to the item - item.last_price = lastPrice; - item.last_year = recentYear; - } -} - // Define a route to retrieve values from the database using parameters router.get('/code_price/:billcode/:shipcode/:partcode/:qty', async (ctx) => {