From 970968f98080e53748787a151024cd25beb9ff08 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Fri, 26 Jan 2024 12:42:00 -0500 Subject: [PATCH] set cap dish prices --- sql/apply_guidance.pg.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sql/apply_guidance.pg.sql b/sql/apply_guidance.pg.sql index 228146e..a8a8055 100644 --- a/sql/apply_guidance.pg.sql +++ b/sql/apply_guidance.pg.sql @@ -17,6 +17,20 @@ AS $function$ return match ? match.adj : null; } + //-------------------------------set flor prices------------------------------- + function getFloor(stlc) { + switch (stlc) { + case "SDD10000": + return 0.045; + case "SDD10001": + return 0.045; + case "SDD12000": + return 0.065; + default: + return null; + } + } + function lowestPrice(priceObject) { let Price = Infinity; let Reason = ''; @@ -92,6 +106,7 @@ AS $function$ let optReason = (optimization ?? 0) !== 0 ? ` + ${(optimization * 100).toFixed(1)}% opt`: ""; let custAddReason = `${inflReason}${ltpReason}${optReason}`; let markAddReason = `${inflReason}${ltpReason}`; + let floor = getFloor(stlc); // ------------------start building price options------------------------------------------------ @@ -117,6 +132,11 @@ AS $function$ } let finalPrice = lowestPrice(prices); + if (floor && floor > finalPrice.Price) { + finalPrice.Price = floor; + finalPrice.Snapped = floor; + finalPrice.Reason = `${finalPrice.Reason} floor at ${floor}`; + } let guidance = { prices ,finalPrice