diff --git a/apply_guidance.ts b/apply_guidance.ts index 6a9d3fc..8393024 100644 --- a/apply_guidance.ts +++ b/apply_guidance.ts @@ -45,6 +45,10 @@ export function apply_guidance(doc: any) { return Math.ceil(value / significance) * significance; } + function r5(value) { + return Number(value.toFixed(5)); + } + function pp(value) { // Multiplies by 1000 and rounds to the nearest 2 decimals var result = Math.round(value * 1000 * 100) / 100; @@ -89,14 +93,14 @@ export function apply_guidance(doc: any) { let snap = .0005; - let custPrice = Number((bridgedPrice * (1 + custAdder)).toFixed(5)); + let custPrice = r5(bridgedPrice * (1 + custAdder)); let custSeason = earlyCustSeason; let custReason = bridgePremium ? `${custSeason} (similar ${altHist} price ${pp(earlyCustPrice)} x ${bridgePremium} = ${pp(bridgedPrice)})${custAddReason}` : `${custSeason} price ${pp(bridgedPrice)}${custAddReason}`; - let markPrice = earlyMarkPrice * (1 + markAdder); + let markPrice = r5(earlyMarkPrice * (1 + markAdder)); let markReason = `${earlyMarkSeason} ASP ${pp(earlyMarkPrice)}${markAddReason}`; - let targPrice = targetPrice ? targetPrice * (1 + markAdder) : null; + let targPrice = targetPrice ? r5(targetPrice * (1 + markAdder)) : null; let targReason = `Target price ${pp(targetPrice)}${markAddReason}`; let listPrice = listUSD; let listReason = fxrate === 1 ? "" : `list ${pp(list)} CAD ${pp(listUSD)} USD`