diff --git a/pdf/template.js b/pdf/template.js index 7034b80..67fc5cc 100755 --- a/pdf/template.js +++ b/pdf/template.js @@ -16,10 +16,7 @@ function formatDate(d) { return dt.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', timeZone: 'America/Chicago' }); } -function formatDateTime(d, t) { - const date = formatDate(d); - return t ? `${date} at ${t}` : date; -} +function formatDateTime(d, t) { const date = formatDate(d); return t ? `${date} at ${t}` : date; } function row(label, value) { return ` @@ -30,11 +27,11 @@ function row(label, value) { } function buildHtml(v, score) { - const activePts = score.active_points || 0; - const tier = getTier(activePts); - const newTotal = activePts + v.points; - const newTier = getTier(newTotal); - const tierChange= tier.label !== newTier.label; + const priorPts = score.active_points || 0; // snapshot at time of logging + const priorTier= getTier(priorPts); + const newTotal = priorPts + v.points; // math always based on stored snapshot + const newTier = getTier(newTotal); + const tierChange = priorTier.label !== newTier.label; const generatedAt = new Date().toLocaleString('en-US', { timeZone: 'America/Chicago', dateStyle: 'full', timeStyle: 'short' }); @@ -84,10 +81,7 @@ function buildHtml(v, score) {
Message Point Media — Comprehensive Professional Accountability System
-