diff --git a/src/controllers/syncController.ts b/src/controllers/syncController.ts index c57ea3d..44ba41a 100644 --- a/src/controllers/syncController.ts +++ b/src/controllers/syncController.ts @@ -142,12 +142,11 @@ async function processDatabaseSync(database: any) { select: { id: true, c_invoice_id: true }, }); - const existingMap = new Map( - existingRecords.map((record) => [record.c_invoice_id, record.id]) - ); - for (const op of ops) { - const existingId = existingMap.get(op.c_invoice_id); + const existData = existingRecords.find( + (record) => record.c_invoice_id === op.c_invoice_id + ); + const existingId = existData ? existData.id : null; if (existingId) { transactions.push( db.rv_openitem.update({