From 7b3ce1ab821673d74117f8283905e91da691ee6d Mon Sep 17 00:00:00 2001 From: Beldor Date: Mon, 22 Jun 2026 22:53:52 -0300 Subject: [PATCH] fix: google sheets append con A1 + INSERT_ROWS para evitar desplazamiento de columna MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El rango A:N confundía a la API cuando había datos manuales en K/L (GASTOS/VARIOS), haciendo que la nueva fila empezara en columna K en vez de A. INSERT_ROWS siempre inserta fila nueva independiente del estado del sheet. Co-Authored-By: Claude Sonnet 4.6 --- src/lib/google-sheets.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/google-sheets.ts b/src/lib/google-sheets.ts index 89417a1..f1f0222 100644 --- a/src/lib/google-sheets.ts +++ b/src/lib/google-sheets.ts @@ -80,8 +80,11 @@ export async function agregarFilaSheet(fila: FilaTaller) { fila.comentario ?? "", // N: Comentarios ]; - const range = encodeURIComponent(`${SHEET_TAB}!A:N`); - const url = `https://sheets.googleapis.com/v4/spreadsheets/${SHEET_ID}/values/${range}:append?valueInputOption=USER_ENTERED`; + // Anclamos en A1 para que la API siempre busque desde el inicio de la tabla. + // INSERT_ROWS fuerza una fila nueva, evita que desplace los datos cuando hay + // celdas ocupadas en columnas manuales (GASTOS, VARIOS, etc.). + const range = encodeURIComponent(`${SHEET_TAB}!A1`); + const url = `https://sheets.googleapis.com/v4/spreadsheets/${SHEET_ID}/values/${range}:append?valueInputOption=USER_ENTERED&insertDataOption=INSERT_ROWS`; const res = await fetch(url, { method: "POST",