-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path25dic.js
More file actions
68 lines (61 loc) · 2.25 KB
/
25dic.js
File metadata and controls
68 lines (61 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function testExtraerTabla() {
try {
// 1) ID del Documento de Google (NO el PDF)
// Ajusta a tu docFile.id resultante de la conversión
var docId = "1oa2UIah3NAWQ9IUpqTGgBqSHCXExewXxpxUsSmWuLCU";
// 2) Abre el Doc y obtiene el texto
var doc = DocumentApp.openById(docId);
var textoCompleto = doc.getBody().getText();
// 3) Parsear con la función anterior
var datos = parsearLineasSeparadas(textoCompleto);
// 4) Revisar en logs
Logger.log("Item: " + datos.item);
Logger.log("Servicio: " + datos.servicio);
Logger.log("Descripción: " + datos.descripcion);
Logger.log("Fecha entrega: " + datos.fechaEntrega);
Logger.log("Oferta No.: " + datos.ofertaNo);
Logger.log("CTD: " + datos.ctd);
Logger.log("UM: " + datos.um);
Logger.log("% Iva: " + datos.porcIva);
Logger.log("Val DTO: " + datos.valDto);
Logger.log("Valor unitario: " + datos.valorUnit);
Logger.log("Valor total: " + datos.valorTotal);
Logger.log("Subtotal: " + datos.subtotal);
Logger.log("Subtotal con descuento: " + datos.subtotalConDesc);
Logger.log("IVA: " + datos.iva);
Logger.log("Total con IVA: " + datos.totalConIva);
// 5) (Opcional) Guardar en una hoja "Procesados" de un Spreadsheet
// Ajusta sheetId a tu hoja y crea encabezados si quieres.
/*
var sheetId = "TU_SPREADSHEET_ID";
var ss = SpreadsheetApp.openById(sheetId);
var hoja = ss.getSheetByName("Procesados") || ss.insertSheet("Procesados");
// Si quieres, crea encabezados si están vacíos
var headers = ["Item","Servicio","Descripción","Fecha entrega","Oferta No.","CTD","UM","% Iva","Val DTO","Valor unit","Valor total","Subtotal","Subtotal c/ desc","IVA","Total c/ IVA"];
if (hoja.getLastRow() === 0) {
hoja.appendRow(headers);
}
// Prepara la fila
var fila = [
datos.item,
datos.servicio,
datos.descripcion,
datos.fechaEntrega,
datos.ofertaNo,
datos.ctd,
datos.um,
datos.porcIva,
datos.valDto,
datos.valorUnit,
datos.valorTotal,
datos.subtotal,
datos.subtotalConDesc,
datos.iva,
datos.totalConIva
];
hoja.appendRow(fila);
*/
} catch (err) {
Logger.log("Error en testExtraerTabla: " + err);
}
}