@measurequick/measurequick-report-generator 1.0.99 → 1.1.0
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/index.js +7 -9
- package/mq-standard-report-generator.js +1 -1
- package/package.json +1 -1
- package/scripts/fill-signature.js +5 -6
- package/scripts/mq-standard.js +53 -20
package/index.js
CHANGED
|
@@ -6,14 +6,12 @@ import * as fillSignature from "./scripts/fill-signature.js";
|
|
|
6
6
|
|
|
7
7
|
export function generateReport(reportType, payload) {
|
|
8
8
|
switch (reportType) {
|
|
9
|
-
case "mqStandard":
|
|
10
|
-
case "mqVitalsCooling":
|
|
11
|
-
case "mqVitalsHeating":
|
|
12
|
-
case "ptcsHeatPump":
|
|
13
|
-
|
|
9
|
+
case "mqStandard": return mqStandard.generateReport(payload);
|
|
10
|
+
case "mqVitalsCooling": return mqVitalsCooling.generateReport(payload);
|
|
11
|
+
case "mqVitalsHeating": return mqVitalsHeating.generateReport(payload);
|
|
12
|
+
case "ptcsHeatPump": return ptcsHeatPump.generateReport(payload);
|
|
13
|
+
case "bgeFillSignature":
|
|
14
|
+
case "smecoFillSignature": return fillSignature.generateReport(payload);
|
|
15
|
+
default: return false;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
export async function signReport(fillableReportFileName, fillableFieldName, signatureBase64) {
|
|
18
|
-
return await fillSignature.signReport(fillableReportFileName, fillableFieldName, signatureBase64);
|
|
19
|
-
}
|
|
@@ -52,7 +52,7 @@ export async function generateReport(payload) {
|
|
|
52
52
|
form.getTextField("Date of Service Cover").setText();
|
|
53
53
|
form.getTextField("Time of Service Cover").setText();
|
|
54
54
|
|
|
55
|
-
//
|
|
55
|
+
// vitals report
|
|
56
56
|
let scoreDeduction = 0;
|
|
57
57
|
if (payload.test.diagnostics.multi_point_analysis && payload.test.diagnostics.multi_point_analysis.length > 0) {
|
|
58
58
|
for (let i = 0; i < 9; i++) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { PDFDocument } from 'pdf-lib';
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as bgePdf from '../templates/base-64/bge-fill-signature.js';
|
|
3
|
+
import * as smecoPdf from '../templates/base-64/smeco-fill-signature.js';
|
|
4
4
|
|
|
5
|
-
export async function
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
const formPdfBytes = _base64ToArrayBuffer(fillablePdfTemplateFile);
|
|
5
|
+
export async function generateReport(payload) {
|
|
6
|
+
let base64 = payload.reportType == "bge" ? bgePdf.base64 : smecoPdf.base64;
|
|
7
|
+
const formPdfBytes = _base64ToArrayBuffer(base64);
|
|
9
8
|
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
10
9
|
const signatureBytes = _base64ToArrayBuffer(signatureBase64);
|
|
11
10
|
const signature = await pdfDoc.embedPng(signatureBytes);
|
package/scripts/mq-standard.js
CHANGED
|
@@ -6,6 +6,8 @@ export async function generateReport(payload) {
|
|
|
6
6
|
|
|
7
7
|
const pdfDoc = await PDFDocument.load(_base64ToArrayBuffer(pdf.base64));
|
|
8
8
|
|
|
9
|
+
console.log(payload);
|
|
10
|
+
|
|
9
11
|
let numCols = payload.project.numReportColumns;
|
|
10
12
|
|
|
11
13
|
// pages[1, 2, 3, 12]: Cooling Specific Pages
|
|
@@ -56,11 +58,13 @@ export async function generateReport(payload) {
|
|
|
56
58
|
form.getTextField("Date of Service Cover").setText();
|
|
57
59
|
form.getTextField("Time of Service Cover").setText();
|
|
58
60
|
|
|
61
|
+
let test = payload.project.tests[0];
|
|
62
|
+
|
|
59
63
|
// vitals report
|
|
60
64
|
let scoreDeduction = 0;
|
|
61
|
-
if (
|
|
65
|
+
if (test.testInfo.diagnostics.multi_point_analysis && test.testInfo.diagnostics.multi_point_analysis.length > 0) {
|
|
62
66
|
for (let i = 0; i < 9; i++) {
|
|
63
|
-
let d =
|
|
67
|
+
let d = test.testInfo.diagnostics.multi_point_analysis[i];
|
|
64
68
|
if (d) {
|
|
65
69
|
let diagnosticIcon = iconFlagBlack;
|
|
66
70
|
if (d.type === 'stability')
|
|
@@ -79,8 +83,8 @@ export async function generateReport(payload) {
|
|
|
79
83
|
form.getButton("ImageDiagnostics1_af_image").setImage(iconFlagGreen);
|
|
80
84
|
form.getTextField("SystemDiagnostics1").setText("No system-wide issues were detected.");
|
|
81
85
|
}
|
|
82
|
-
if (
|
|
83
|
-
scoreDeduction =
|
|
86
|
+
if (test.testInfo.score_deduction) {
|
|
87
|
+
scoreDeduction = test.testInfo.score_deduction;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
let systemScorePercentage = +(100 - +(scoreDeduction.toFixed(0)));
|
|
@@ -147,10 +151,10 @@ export async function generateReport(payload) {
|
|
|
147
151
|
for (let i = 0; i < measureLabels.length; i++) {
|
|
148
152
|
let iconPlacement = "Mid";
|
|
149
153
|
let icon = iconRangeRed;
|
|
150
|
-
let actual = +
|
|
151
|
-
let mid = +
|
|
152
|
-
let low = +
|
|
153
|
-
let high = +
|
|
154
|
+
let actual = +test.testInfo.data[targetKeys[i]];
|
|
155
|
+
let mid = +test.testInfo.targets[targetKeys[i]];
|
|
156
|
+
let low = +test.testInfo.targets[`${targetKeys[i]}_ideal_low`];
|
|
157
|
+
let high = +test.testInfo.targets[`${targetKeys[i]}_ideal_high`];
|
|
154
158
|
low = mid - low;
|
|
155
159
|
high = mid + high;
|
|
156
160
|
if (targetKeys[i] == "pressure_static_total_external") high = mid * 1.4;
|
|
@@ -168,7 +172,7 @@ export async function generateReport(payload) {
|
|
|
168
172
|
// print pass fail measures
|
|
169
173
|
let passFails = ["electrical_system_pass_fail", "air_distribution_system_pass_fail", "air_filtration_system_pass_fail", "condensate_drain_system_pass_fail", "refrigerant_charge_pass_fail", "outdoor_equipment_pass_fail", "indoor_equipment_pass_fail", "cooling_capacity_pass_fail", "cooling_electrical_efficiency_pass_fail"];
|
|
170
174
|
for (let i = 1; i <= passFails.length; i++) {
|
|
171
|
-
let meas =
|
|
175
|
+
let meas = test.testInfo[passFails[i - 1]];
|
|
172
176
|
let icon = meas == "Pass" || meas == "High" || meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
173
177
|
form.getButton(`ImageSubsystem${i}_af_image`).setImage(icon);
|
|
174
178
|
}
|
|
@@ -191,6 +195,14 @@ export async function generateReport(payload) {
|
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
194
206
|
// measurement details page
|
|
195
207
|
for (let rowNum = 1; rowNum <= 35; rowNum++) {
|
|
196
208
|
for (let colNum = 1; colNum <= numCols; colNum++) {
|
|
@@ -198,6 +210,14 @@ export async function generateReport(payload) {
|
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
201
221
|
// photos page: take code from standard report
|
|
202
222
|
|
|
203
223
|
|
|
@@ -232,6 +252,7 @@ function getColorFromGrade(grade) {
|
|
|
232
252
|
}
|
|
233
253
|
|
|
234
254
|
function getTextFields(payload) {
|
|
255
|
+
let test = payload.project.tests[0];
|
|
235
256
|
return {
|
|
236
257
|
"cName": payload.site.customer.first_name && payload.site.customer.last_name ? `${payload.site.customer.first_name} ${payload.site.customer.last_name}` : "",
|
|
237
258
|
"address": payload.site.location.address ? payload.site.location.address : "",
|
|
@@ -239,17 +260,17 @@ function getTextFields(payload) {
|
|
|
239
260
|
"city": payload.site.location.city ? payload.site.location.city : "",
|
|
240
261
|
"state": payload.site.location.state ? `, ${payload.site.location.state}` : "",
|
|
241
262
|
"zip": payload.site.location.zip ? ` ${payload.site.location.zip}` : "",
|
|
242
|
-
"superheat":
|
|
243
|
-
"subcooling":
|
|
244
|
-
"approach":
|
|
245
|
-
"tempSplit":
|
|
246
|
-
"tesp":
|
|
247
|
-
"fltrFace":
|
|
248
|
-
"ageLosses":
|
|
249
|
-
"tempSplitLosses":
|
|
250
|
-
"staticLosses":
|
|
251
|
-
"approachLosses":
|
|
252
|
-
"refChargeLosses":
|
|
263
|
+
"superheat": test.testInfo.data.superheat ? (+test.testInfo.data.superheat).toFixed(1) : "--",
|
|
264
|
+
"subcooling": test.testInfo.data.subcooling ? (+test.testInfo.data.subcooling).toFixed(1) : "--",
|
|
265
|
+
"approach": test.testInfo.data.approach ? (+test.testInfo.data.approach).toFixed(1) : "--",
|
|
266
|
+
"tempSplit": test.testInfo.data.temperature_split ? (+test.testInfo.data.temperature_split).toFixed(1) : "--",
|
|
267
|
+
"tesp": test.testInfo.data.pressure_static_total_external ? (+test.testInfo.data.pressure_static_total_external).toFixed(2) : "--",
|
|
268
|
+
"fltrFace": test.testInfo.data.velocity_face_filter1 ? (+test.testInfo.data.velocity_face_filter1).toFixed(1) : "--",
|
|
269
|
+
"ageLosses": test.testInfo.data.age_loss ? (+test.testInfo.data.age_loss).toFixed(0) : 0,
|
|
270
|
+
"tempSplitLosses": test.testInfo.data.temp_split_loss ? (+test.testInfo.data.temp_split_loss).toFixed(0) : 0,
|
|
271
|
+
"staticLosses": test.testInfo.data.static_loss ? (+test.testInfo.data.static_loss).toFixed(0) : 0,
|
|
272
|
+
"approachLosses": test.testInfo.data.approach_loss ? (+test.testInfo.data.approach_loss).toFixed(0) : 0,
|
|
273
|
+
"refChargeLosses": test.testInfo.data.refrigerant_charge_loss ? (+test.testInfo.data.refrigerant_charge_loss).toFixed(0) : 0
|
|
253
274
|
}
|
|
254
275
|
}
|
|
255
276
|
|
|
@@ -272,3 +293,15 @@ async function formPdfBytes() {
|
|
|
272
293
|
};
|
|
273
294
|
|
|
274
295
|
}
|
|
296
|
+
|
|
297
|
+
function _base64ToArrayBuffer(base64) {
|
|
298
|
+
if (!base64) return "";
|
|
299
|
+
base64 = base64.replace(/^[^,]+,/, '').replace(/\s/g, '');
|
|
300
|
+
var binary_string = window.atob(base64);
|
|
301
|
+
var len = binary_string.length;
|
|
302
|
+
var bytes = new Uint8Array(len);
|
|
303
|
+
for (var i = 0; i < len; i++) {
|
|
304
|
+
bytes[i] = binary_string.charCodeAt(i);
|
|
305
|
+
}
|
|
306
|
+
return bytes.buffer;
|
|
307
|
+
}
|