@measurequick/measurequick-report-generator 1.5.158 → 1.5.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measurequick/measurequick-report-generator",
3
- "version": "1.5.158",
3
+ "version": "1.5.160",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -197,8 +197,7 @@ export async function getReport(payload, _test) {
197
197
  );
198
198
 
199
199
  // CO warning based on ambient CO only
200
- var data =
201
- test && test.testInfo && test.testInfo.data ? test.testInfo.data : {};
200
+ var data = t && t.data ? t.data : {};
202
201
  function toNum(v) {
203
202
  var n = Number(v);
204
203
  return isFinite(n) ? n : NaN;
@@ -2,8 +2,21 @@ import { PDFDocument } from "pdf-lib";
2
2
  import * as base64 from "../base-64/icons.js";
3
3
  import * as pdf from "../base-64/mq-vitals-heating.js";
4
4
  import * as systemInfoPage from "./system-info-page.js";
5
+
5
6
  import * as util from "../util.js";
6
7
 
8
+ // Lightweight debug logger for this module
9
+ const __DEBUG_VITALS_HEATING__ = true;
10
+ function VH_LOG(...args) {
11
+ try {
12
+ if (__DEBUG_VITALS_HEATING__) {
13
+ console.log("[VitalsHeatingReport]", ...args);
14
+ }
15
+ } catch (e) {
16
+ // no-op
17
+ }
18
+ }
19
+
7
20
  function safeSetText(form, name, value) {
8
21
  try {
9
22
  if (value === undefined || value === null) value = "";
@@ -197,8 +210,7 @@ export async function getReport(payload, _test) {
197
210
  );
198
211
 
199
212
  // Show CO warnings based on raw values (avoid false negatives from rounded display strings)
200
- var data =
201
- test && test.testInfo && test.testInfo.data ? test.testInfo.data : {};
213
+ var data = t && t.data ? t.data : {};
202
214
  function toNum(v) {
203
215
  var n = Number(v);
204
216
  return isFinite(n) ? n : NaN;
@@ -207,12 +219,28 @@ export async function getReport(payload, _test) {
207
219
  var coRetRaw = toNum(data && data.co_return);
208
220
  var coSupRaw = toNum(data && data.co_supply);
209
221
 
210
- var coHigh =
211
- (isFinite(coAmbRaw) && coAmbRaw > 9) ||
212
- (isFinite(coRetRaw) && coRetRaw > 9) ||
213
- (isFinite(coSupRaw) && coSupRaw > 9);
222
+ // Debug: log CO inputs and parsed numbers
223
+ VH_LOG("t present:", !!t, "t.data present:", !!(t && t.data));
224
+ VH_LOG("CO (raw values)", {
225
+ co_ambient: data ? data.co_ambient : undefined,
226
+ co_return: data ? data.co_return : undefined,
227
+ co_supply: data ? data.co_supply : undefined,
228
+ });
229
+ VH_LOG("CO (parsed numbers)", {
230
+ coAmbRaw,
231
+ coRetRaw,
232
+ coSupRaw,
233
+ });
234
+
235
+ var reasons = [];
236
+ if (isFinite(coAmbRaw) && coAmbRaw > 9) reasons.push("ambient=" + coAmbRaw);
237
+ if (isFinite(coRetRaw) && coRetRaw > 9) reasons.push("return=" + coRetRaw);
238
+ if (isFinite(coSupRaw) && coSupRaw > 9) reasons.push("supply=" + coSupRaw);
239
+ var coHigh = reasons.length > 0;
240
+ VH_LOG("CO threshold check > 9 ppm:", { coHigh, reasons });
214
241
 
215
242
  if (coHigh) {
243
+ VH_LOG("Setting CO warnings in form fields: COWarning / COWarning2");
216
244
  safeSetText(
217
245
  form,
218
246
  "COWarning",
@@ -224,6 +252,7 @@ export async function getReport(payload, _test) {
224
252
  "WARNING: Elevated CO above 9 ppm Detected! Ventilate the area and investigate the source."
225
253
  );
226
254
  } else {
255
+ VH_LOG("Clearing CO warnings (values within threshold)");
227
256
  // clear warnings if not applicable
228
257
  safeSetText(form, "COWarning", "");
229
258
  safeSetText(form, "COWarning2", "");
@@ -578,7 +607,7 @@ function getTextFields(payload, test) {
578
607
  test.data.pressure_manifold_before
579
608
  );
580
609
 
581
- return {
610
+ const __textFields = {
582
611
  cName:
583
612
  payload.site.customer.first_name && payload.site.customer.last_name
584
613
  ? `${payload.site.customer.first_name} ${payload.site.customer.last_name}`
@@ -612,4 +641,6 @@ function getTextFields(payload, test) {
612
641
  co_return: fmt(test.data.co_return, 0),
613
642
  co_supply: fmt(test.data.co_supply, 0),
614
643
  };
644
+ VH_LOG("Computed textFields", __textFields);
645
+ return __textFields;
615
646
  }