-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.gs
64 lines (40 loc) · 1.48 KB
/
data.gs
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
// Accounting Generator - It's been coded with ♥ by Jeancarlo Fontalvo
var app = SpreadsheetApp.getActiveSpreadsheet();
var _ = getLodash();
var _sheetConsts = sheetConsts();
function getDebits(code) {}
function getRecords(number) {
// - - - - Obtengo la hoja de las transacciones - - - - //
var info = app.getSheetByName( _sheetConsts.RECORDS );
var range = info.getRange( _sheetConsts.RANGES.RECORDS );
// - - - - Obtengo los valores - - - - - - - - - - - - //
var rawValues = range.getValues();
var validRecords = [];
var accounts = [];
// - - - - Recorro los valores y los agrupo - - - - //
for(var i = 0; i < rawValues.length; i++) {
var row = rawValues[ i ];
if( typeof row[ _sheetConsts.INDEXES.NUMBER ] === "number" ) {
var record = {
number : row[ _sheetConsts.INDEXES.NUMBER ],
counts : []
}
do {
record.counts.push( rawValues[ i ] );
i++;
}
while( rawValues[ i ][ _sheetConsts.INDEXES.NAME ].toLowerCase() != "sumas iguales" )
validRecords.push( record );
}
}
//getPartials()
Logger.log( JSON.stringify( validRecords.slice(0, 5) ) );
// - - - - - - - - - - - - - - - - - - - - //
/*
// - - - Sorting - - - //
values.sort();
values = _.uniq(values);
_.each(values, function(value){ Logger.log( value ); });
*/
return validRecords[ (number || 1) - 1].counts;
}