diff --git a/backend/index.js b/backend/index.js index 324ba0c..2de1afb 100644 --- a/backend/index.js +++ b/backend/index.js @@ -174,7 +174,9 @@ app.post('/api/data', authenticateAPIKey, async (req, res) => { for (const item of payload) { // Handle potential missing fields gracefully - const orderId = item.id || item.ID_Pedido || (item.json && item.json.body && item.json.body.id) || ''; + // If there is no explicit ID, create a composite ID using Name + Date + Value to prevent squashing historical data + const fallbackId = `${item.Nome_Cliente}_${item.Data_Pedido}_${item.Valor_Pedido}`; + const orderId = item.id || item.ID_Pedido || (item.json && item.json.body && item.json.body.id) || fallbackId; const values = [ item.Nome_Cliente || 'Unknown',