minor changes
This commit is contained in:
@@ -65,7 +65,7 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) {
|
|||||||
const userID = result.text.match(/Codice fiscale:\s*([A-Za-z0-9]+)/i);
|
const userID = result.text.match(/Codice fiscale:\s*([A-Za-z0-9]+)/i);
|
||||||
const codiceFiscale = userID ? userID[1].trim() : null;
|
const codiceFiscale = userID ? userID[1].trim() : null;
|
||||||
if (codiceFiscale) {
|
if (codiceFiscale) {
|
||||||
const cfSoql = `SELECT Id, Name, CF__c FROM Account WHERE CF__c='${codiceFiscale }' ORDER BY CreatedDate ASC LIMIT 1`;
|
const cfSoql = `SELECT Id, Name, CF__c FROM Account WHERE CF__c='${ codiceFiscale }' ORDER BY CreatedDate ASC LIMIT 1`;
|
||||||
const cfResult = await sfdc.query(cfSoql);
|
const cfResult = await sfdc.query(cfSoql);
|
||||||
|
|
||||||
if (cfResult && cfResult.records && cfResult.records.length > 0) {
|
if (cfResult && cfResult.records && cfResult.records.length > 0) {
|
||||||
@@ -95,7 +95,7 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) {
|
|||||||
|
|
||||||
// in this query, we prioritize the accounts that have the CF (e.g. if a client has two accounts and in one of them
|
// in this query, we prioritize the accounts that have the CF (e.g. if a client has two accounts and in one of them
|
||||||
// they don't have the CF but on the other one they do, we consider the latter)
|
// they don't have the CF but on the other one they do, we consider the latter)
|
||||||
const nameSoql = `SELECT Id, Name, CF__c FROM Account WHERE (${conditions.join(' OR ')}) ORDER BY CF__c DESC NULLS LAST, CreatedDate ASC LIMIT 1`;
|
const nameSoql = `SELECT Id, Name, CF__c FROM Account WHERE (${ conditions.join(' OR ') }) ORDER BY CF__c DESC NULLS LAST, CreatedDate ASC LIMIT 1`;
|
||||||
const nameResult = await sfdc.query(nameSoql);
|
const nameResult = await sfdc.query(nameSoql);
|
||||||
|
|
||||||
if (nameResult && nameResult.records && nameResult.records.length > 0) {
|
if (nameResult && nameResult.records && nameResult.records.length > 0) {
|
||||||
@@ -153,7 +153,7 @@ async function processPage(pdfDoc, pageIndex, tempFiles) {
|
|||||||
newDoc.addPage(copiedPage);
|
newDoc.addPage(copiedPage);
|
||||||
const pdfBytes = await newDoc.save();
|
const pdfBytes = await newDoc.save();
|
||||||
|
|
||||||
const filepath = path.join(os.tmpdir(), `fileTemp_page_${pageIndex}.pdf`);
|
const filepath = path.join(os.tmpdir(), `fileTemp_page_${ pageIndex }.pdf`);
|
||||||
fs.writeFileSync(filepath, pdfBytes);
|
fs.writeFileSync(filepath, pdfBytes);
|
||||||
tempFiles.push(filepath);
|
tempFiles.push(filepath);
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,6 @@ async function splitExcelFile(inputFile) {
|
|||||||
await workbook.xlsx.readFile(inputFile);
|
await workbook.xlsx.readFile(inputFile);
|
||||||
const worksheet = workbook.getWorksheet(1);
|
const worksheet = workbook.getWorksheet(1);
|
||||||
|
|
||||||
const headerRow = worksheet.getRow(1).actualCellCount; //number of columns of the table
|
|
||||||
numRows = (worksheet.actualRowCount) - 1; // since it counts the row that represents the header, I need to subtract -1
|
numRows = (worksheet.actualRowCount) - 1; // since it counts the row that represents the header, I need to subtract -1
|
||||||
// to get the actual number of rows that contains the data
|
// to get the actual number of rows that contains the data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user