round after ceiling

This commit is contained in:
Paul Trowbridge 2023-12-07 08:29:47 -05:00
parent eb0c969ec7
commit 885a2982ee
3 changed files with 9 additions and 9 deletions

2
api.ts
View File

@ -60,7 +60,7 @@ router.get('/dseg_reason/:billcode/:shipcode/:stlc/:dseg/:qty', async (ctx) => {
const { billcode, shipcode, stlc, dseg, qty } = ctx.params; const { billcode, shipcode, stlc, dseg, qty } = ctx.params;
const result = await client.queryObject({args: [billcode, shipcode, stlc, dseg, qty], text: query_dseg} ); const result = await client.queryObject({args: [billcode, shipcode, stlc, dseg, qty], text: query_dseg} );
const ag = apply_guidance(result.rows[0]["doc"]); 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()); app.use(router.routes());

View File

@ -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 listReason = fxrate === 1 ? `list ${pp(list)}` : `list ${pp(list)} CAD ${pp(listUSD)} USD`;
let prices = { let prices = {
cust: [custPrice, custReason, "cust", ceiling(custPrice,snap)], cust: [custPrice, custReason, "cust", r5(ceiling(custPrice,snap))],
mark: [markPrice, markReason, "mark", ceiling(markPrice,snap)], mark: [markPrice, markReason, "mark", r5(ceiling(markPrice,snap))],
targ: [targPrice, targReason, "targ", ceiling(targPrice,snap)], targ: [targPrice, targReason, "targ", r5(ceiling(targPrice,snap))],
list: [listPrice, listReason, "list", ceiling(listPrice,snap)] list: [listPrice, listReason, "list", r5(ceiling(listPrice,snap))]
} }
let finalPrice = lowestPrice(prices); let finalPrice = lowestPrice(prices);

View File

@ -110,10 +110,10 @@ AS $function$
let listReason = fxrate === 1 ? `list ${pp(list)}` : `list ${pp(list)} CAD ${pp(listUSD)} USD`; let listReason = fxrate === 1 ? `list ${pp(list)}` : `list ${pp(list)} CAD ${pp(listUSD)} USD`;
let prices = { let prices = {
cust: [custPrice, custReason, "cust", ceiling(custPrice,snap)], cust: [custPrice, custReason, "cust", r5(ceiling(custPrice,snap))],
mark: [markPrice, markReason, "mark", ceiling(markPrice,snap)], mark: [markPrice, markReason, "mark", r5(ceiling(markPrice,snap))],
targ: [targPrice, targReason, "targ", ceiling(targPrice,snap)], targ: [targPrice, targReason, "targ", r5(ceiling(targPrice,snap))],
list: [listPrice, listReason, "list", ceiling(listPrice,snap)] list: [listPrice, listReason, "list", r5(ceiling(listPrice,snap))]
} }
let finalPrice = lowestPrice(prices); let finalPrice = lowestPrice(prices);