minor changes

This commit is contained in:
2026-07-29 15:10:25 +02:00
parent 22005d464d
commit 884d8bd1fe
+5 -29
View File
@@ -6,8 +6,6 @@ const os = require('os');
const path = require('path');
const sfdc = require('./sfdc2');
require('dotenv').config();
let excelFile = process.argv[2];
let pdfFile = process.argv[3];
// excel1 => /Users/ddatinguinoo/Downloads/Estratto IPP 5 Sic.xlsx
// excel2 => /Users/ddatinguinoo/Downloads/Estratto Haccp IPP 5 (1).xlsx
// excel3 di prova => /Users/ddatinguinoo/Downloads/File di prova.xlsx
@@ -165,7 +163,6 @@ async function processPage(pdfDoc, pageIndex, tempFiles) {
async function splitExcelFile(inputFile) {
let numRows; // this parameter is needed when we need to analyze the pdf file in case it has duplicate pages
const columnNames = []; // contains the names of the columns (header names)
const data = []; // contains the info of all the clients
try {
console.log(`Loading excel file: ${ inputFile }\n`);
@@ -207,9 +204,8 @@ async function splitExcelFile(inputFile) {
dataUser[cleanKey] = cell.value;
})
data.push(dataUser);
}
return { numRows, data };
return numRows;
}
catch (error) {
console.error('Error processing the excel file: ', error);
@@ -288,9 +284,10 @@ async function main() {
if (isMyFlag) {
console.log(`--- Test di attachPdfToAccount ${isDryRun ? '(MODALITÀ DRY RUN)' : ''} --- \n`);
const testPdfFile = pdfFile || process.argv[2];
let excelFile = process.argv[2];
let pdfFile = process.argv[3];
if (!testPdfFile) {
if (!pdfFile || !excelFile) {
console.error('Errore: Fornisci il percorso di un file PDF per il test.');
process.exit(1);
}
@@ -299,11 +296,9 @@ async function main() {
try {
let resultExcel = await splitExcelFile(excelFile);
let resultPdf = await splitPDF(resultExcel.numRows, pdfFile, tempFilePath);
let resultPdf = await splitPDF(resultExcel, pdfFile, tempFilePath);
await initializeSalesforceConnection();
// Passiamo isDryRun come terzo parametro!
await attachPdfToAccount(sfdc, resultPdf, isDryRun);
} catch (err) {
@@ -313,25 +308,6 @@ async function main() {
}
return;
}
/*if (!excelFile || !pdfFile) {
console.error('Error: Please provide both Excel and PDF paths.\nUsage: node script.js <path-to-excel> <path-to-pdf>');
process.exit(1);
}
const tempFilePath = []; // contains the temporary files
let resultExcel, resultPdf;
try {
resultExcel = await splitExcelFile(excelFile);
resultPdf = await splitPDF(resultExcel.numRows, pdfFile, tempFilePath);
await initializeSalesforceConnection();
await attachPdfToAccount(sfdc, resultPdf);
}
catch (err) {
console.error('An error occurred in main: ', err);
}
finally {
cleanUp(tempFilePath);
}*/
}
main();