@measurequick/measurequick-report-generator 1.5.67 → 1.5.70

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.67",
3
+ "version": "1.5.70",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -184,17 +184,25 @@ export async function getReport(payload) {
184
184
  /************* DUCT SCREENING SHEET ***********/
185
185
  try {
186
186
  if (payload.project.duct_screening && payload.project.duct_screening.length > 0) {
187
- let payload = {
188
- test: payload.project.duct_screening[payload.project.duct_screening.length-1]
187
+ let ductPayload = {
188
+ test: payload.project.duct_screening[payload.project.duct_screening.length - 1]
189
189
  };
190
- let nciReport = await nciReport.getReport(payload);
191
- const nciReportDoc = nciReport&&nciReport.status===200 ? await PDFDocument.load(util._base64ToArrayBuffer(nciReport.data)) : false;
192
190
 
193
- const [_nciReportDoc] = nciReportDoc ? await coreDoc.copyPages(nciReportDoc, [0]) : false;
194
- if (_nciReportDoc) coreDoc.insertPage(coreDoc.getPages().length, _nciReportDoc);
191
+ let nciReport = await nciReport.getReport(ductPayload);
192
+
193
+ // Ensure that nciReport is defined and has the expected structure
194
+ const nciReportDoc = nciReport && nciReport.status === 200
195
+ ? await PDFDocument.load(util._base64ToArrayBuffer(nciReport.data))
196
+ : null;
197
+
198
+ // Check if nciReportDoc is properly initialized before copying pages
199
+ if (nciReportDoc) {
200
+ const [_nciReportDoc] = await coreDoc.copyPages(nciReportDoc, [0]);
201
+ if (_nciReportDoc) coreDoc.insertPage(coreDoc.getPages().length, _nciReportDoc);
202
+ }
195
203
  }
196
204
  } catch (error) {
197
- errors.push(`NCI Report: ${error}`);
205
+ errors.push(`NCI Report Error: ${error.message}`);
198
206
  }
199
207
 
200
208
  /******** CORRECTIVE MEASURES (1-2 PAGES) *********/