diff --git a/api.ts b/api.ts index 3c79a8b..4ffc0a7 100644 --- a/api.ts +++ b/api.ts @@ -60,7 +60,7 @@ router.get('/dseg_reason/:billcode/:shipcode/:stlc/:dseg/:qty', async (ctx) => { const { billcode, shipcode, stlc, dseg, qty } = ctx.params; const result = await client.queryObject({args: [billcode, shipcode, stlc, dseg, qty], text: query_dseg} ); const ag = apply_guidance(result.rows[0]["doc"]); - ctx.response.body = ag.guidance.finalPrice.Reason; + ctx.response.body = ag.guidance.finalPrice.Snapped + ' (' + ag.guidance.finalPrice.Reason + ')'; }); app.use(router.routes()); diff --git a/apply_guidance.ts b/apply_guidance.ts index f6be241..1bd97e5 100644 --- a/apply_guidance.ts +++ b/apply_guidance.ts @@ -123,10 +123,10 @@ export function apply_guidance(doc: any) { let listReason = fxrate === 1 ? `list ${pp(list)}` : `list ${pp(list)} CAD ${pp(listUSD)} USD`; let prices = { - cust: [custPrice, custReason, "cust", ceiling(custPrice,snap)], - mark: [markPrice, markReason, "mark", ceiling(markPrice,snap)], - targ: [targPrice, targReason, "targ", ceiling(targPrice,snap)], - list: [listPrice, listReason, "list", ceiling(listPrice,snap)] + cust: [custPrice, custReason, "cust", r5(ceiling(custPrice,snap))], + mark: [markPrice, markReason, "mark", r5(ceiling(markPrice,snap))], + targ: [targPrice, targReason, "targ", r5(ceiling(targPrice,snap))], + list: [listPrice, listReason, "list", r5(ceiling(listPrice,snap))] } let finalPrice = lowestPrice(prices); diff --git a/sql/apply_guidance.pg.sql b/sql/apply_guidance.pg.sql index 6b6ed6f..228146e 100644 --- a/sql/apply_guidance.pg.sql +++ b/sql/apply_guidance.pg.sql @@ -110,10 +110,10 @@ AS $function$ let listReason = fxrate === 1 ? `list ${pp(list)}` : `list ${pp(list)} CAD ${pp(listUSD)} USD`; let prices = { - cust: [custPrice, custReason, "cust", ceiling(custPrice,snap)], - mark: [markPrice, markReason, "mark", ceiling(markPrice,snap)], - targ: [targPrice, targReason, "targ", ceiling(targPrice,snap)], - list: [listPrice, listReason, "list", ceiling(listPrice,snap)] + cust: [custPrice, custReason, "cust", r5(ceiling(custPrice,snap))], + mark: [markPrice, markReason, "mark", r5(ceiling(markPrice,snap))], + targ: [targPrice, targReason, "targ", r5(ceiling(targPrice,snap))], + list: [listPrice, listReason, "list", r5(ceiling(listPrice,snap))] } let finalPrice = lowestPrice(prices);