vault backup: 2023-11-16 10:35:29
This commit is contained in:
parent
56d139c22d
commit
8a9102dbca
2
api.ts
2
api.ts
@ -52,7 +52,7 @@ router.get('/dseg_price/: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.FinalReason;
|
||||
ctx.response.body = ag.guidance.finalPrice.Snapped;
|
||||
});
|
||||
|
||||
app.use(router.routes());
|
||||
|
@ -41,7 +41,11 @@ export function apply_guidance(doc: any) {
|
||||
}
|
||||
|
||||
function pp(value) {
|
||||
return (value * 1000).toFixed(2);
|
||||
// Multiplies by 1000 and rounds to the nearest 2 decimals
|
||||
var result = Math.round(value * 1000 * 100) / 100;
|
||||
|
||||
// Converts the number to a string with commas for thousand separators
|
||||
return result.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
|
||||
}
|
||||
|
||||
// --------------------extract incoming data------------------------------------------------------
|
||||
@ -84,9 +88,9 @@ export function apply_guidance(doc: any) {
|
||||
let custSeason = earlyCustSeason;
|
||||
let custReason = bridgePremium
|
||||
? `${custSeason} (similar ${altHist} price ${pp(earlyCustPrice)} x ${bridgePremium} = ${pp(bridgedPrice)})${custAddReason}`
|
||||
: `${custSeason} + price ${pp(custPrice)}${custAddReason}`;
|
||||
: `${custSeason} price ${pp(custPrice)}${custAddReason}`;
|
||||
let markPrice = earlyMarkPrice * (1 + markAdder);
|
||||
let markReason = `${earlyMarkSeason} ASP + ${pp(earlyMarkPrice)}${markAddReason}`;
|
||||
let markReason = `${earlyMarkSeason} ASP ${pp(earlyMarkPrice)}${markAddReason}`;
|
||||
let targPrice = targetPrice * (1 + markAdder);
|
||||
let targReason = `Target price ${pp(targetPrice)}${markAddReason}`;
|
||||
let listPrice = listUSD;
|
||||
|
Loading…
Reference in New Issue
Block a user