vault backup: 2023-11-06 15:34:50

This commit is contained in:
Paul Trowbridge 2023-11-06 15:34:50 -05:00
parent ca730bb9bd
commit ba44e463d2

19
api.ts
View File

@ -125,10 +125,10 @@ function apply_guidance(doc: any) {
// Determine the anchor price and source // Determine the anchor price and source
if (doc.targetPrice !== undefined && (mostRelevantCustomerPrice === undefined || doc.targetPrice < mostRelevantCustomerPrice)) { if (doc.targetPrice !== undefined && (mostRelevantCustomerPrice === undefined || doc.targetPrice < mostRelevantCustomerPrice)) {
doc.anchorPrice = doc.targetPrice; doc.anchorPrice = doc.targetPrice;
doc.anchorSource = 'targetPrice'; doc.anchorSource = 'Target Price';
} else if (mostRelevantCustomerPrice !== undefined) { } else if (mostRelevantCustomerPrice !== undefined) {
doc.anchorPrice = mostRelevantCustomerPrice; doc.anchorPrice = mostRelevantCustomerPrice;
doc.anchorSource = 'customerPrice'; doc.anchorSource = doc.mostRelevantCustomerSeason + ' Customer Price';
} else { } else {
doc.anchorPrice = null; doc.anchorPrice = null;
doc.anchorSource = 'none'; // or any other default value you wish to indicate no anchor price was found 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; 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 // Define a route to retrieve values from the database using parameters
router.get('/code_price/:billcode/:shipcode/:partcode/:qty', async (ctx) => { router.get('/code_price/:billcode/:shipcode/:partcode/:qty', async (ctx) => {