Skip to content

Commit

Permalink
fix: teiId rowStart bug in program stage sheets (#344)
Browse files Browse the repository at this point in the history
* fix: teiId rowStart bug in program stage sheets

* fix: rename rowStart variable to teiRowStart

* fix: ensure eventId exists before writing tei cell
  • Loading branch information
deeonwuli authored Feb 10, 2025
1 parent 5158366 commit fb42831
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/domain/helpers/ExcelBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,23 +333,23 @@ export class ExcelBuilder {
.uniq()
.value();

const newTEIs = _.difference(allTEIs, existingTEIs);
const newTEIs = _.difference(allTEIs, existingTEIs).reverse(); // reverse the list

for (const id of newTEIs) {
return await promiseMap(newTEIs, async (id, index) => {
const teiRowStart = dataSource.dataValues.rowStart + newTEIs.length - index - 1; // reverse tei ids
const cells = await this.excelRepository.getCellsInRange(template.id, {
...dataSource.dataValues,
rowStart,
rowEnd: rowStart,
rowStart: teiRowStart,
rowEnd: teiRowStart,
});

const eventId = payload.dataEntries[index]?.id;
const teiIdCell = await this.excelRepository.findRelativeCell(template.id, dataSource.teiId, cells[0]);

if (teiIdCell && id) {
if (eventId && teiIdCell && id) {
await this.excelRepository.writeCell(template.id, teiIdCell, id);
}

rowStart += 1;
}
});
}
}

Expand Down

0 comments on commit fb42831

Please sign in to comment.