@actual-app/api 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/bundle.api.js +16317 -24484
- package/dist/app/query.js +67 -81
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -73
- package/dist/methods.js +48 -125
- package/dist/migrations/1632571489012_remove_cache.js +93 -119
- package/dist/migrations/1685007876842_add_category_hidden.sql +6 -0
- package/dist/test.js +4 -52
- package/package.json +5 -5
- package/migrations/1632571489012_remove_cache.js +0 -135
- /package/{default-db.sqlite → dist/default-db.sqlite} +0 -0
- /package/{migrations → dist/migrations}/1548957970627_remove-db-version.sql +0 -0
- /package/{migrations → dist/migrations}/1550601598648_payees.sql +0 -0
- /package/{migrations → dist/migrations}/1555786194328_remove_category_group_unique.sql +0 -0
- /package/{migrations → dist/migrations}/1561751833510_indexes.sql +0 -0
- /package/{migrations → dist/migrations}/1567699552727_budget.sql +0 -0
- /package/{migrations → dist/migrations}/1582384163573_cleared.sql +0 -0
- /package/{migrations → dist/migrations}/1597756566448_rules.sql +0 -0
- /package/{migrations → dist/migrations}/1608652596043_parent_field.sql +0 -0
- /package/{migrations → dist/migrations}/1608652596044_trans_views.sql +0 -0
- /package/{migrations → dist/migrations}/1612625548236_optimize.sql +0 -0
- /package/{migrations → dist/migrations}/1614782639336_trans_views2.sql +0 -0
- /package/{migrations → dist/migrations}/1615745967948_meta.sql +0 -0
- /package/{migrations → dist/migrations}/1616167010796_accounts_order.sql +0 -0
- /package/{migrations → dist/migrations}/1618975177358_schedules.sql +0 -0
- /package/{migrations → dist/migrations}/1679728867040_rules_conditions.sql +0 -0
- /package/{migrations → dist/migrations}/1681115033845_add_schedule_name.sql +0 -0
- /package/{migrations → dist/migrations}/1682974838138_remove_payee_rules.sql +0 -0
|
@@ -1,129 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
async function runMigration(db, uuid) {
|
|
4
|
+
function getValue(node) {
|
|
5
|
+
return node.expr != null ? node.expr : node.cachedValue;
|
|
6
|
+
}
|
|
7
|
+
db.execQuery(`
|
|
8
|
+
CREATE TABLE zero_budget_months
|
|
9
|
+
(id TEXT PRIMARY KEY,
|
|
10
|
+
buffered INTEGER DEFAULT 0);
|
|
11
|
+
|
|
12
|
+
CREATE TABLE zero_budgets
|
|
13
|
+
(id TEXT PRIMARY KEY,
|
|
14
|
+
month INTEGER,
|
|
15
|
+
category TEXT,
|
|
16
|
+
amount INTEGER DEFAULT 0,
|
|
17
|
+
carryover INTEGER DEFAULT 0);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE reflect_budgets
|
|
20
|
+
(id TEXT PRIMARY KEY,
|
|
21
|
+
month INTEGER,
|
|
22
|
+
category TEXT,
|
|
23
|
+
amount INTEGER DEFAULT 0,
|
|
24
|
+
carryover INTEGER DEFAULT 0);
|
|
25
|
+
|
|
26
|
+
CREATE TABLE notes
|
|
27
|
+
(id TEXT PRIMARY KEY,
|
|
28
|
+
note TEXT);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE kvcache (key TEXT PRIMARY KEY, value TEXT);
|
|
31
|
+
CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
32
|
+
`);
|
|
33
|
+
// Migrate budget amounts and carryover
|
|
34
|
+
let budget = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!budget-%'`, [], true);
|
|
35
|
+
db.transaction(() => {
|
|
36
|
+
budget.forEach(monthBudget => {
|
|
37
|
+
let match = monthBudget.name.match(/^(budget-report|budget)(\d+)!budget-(.+)$/);
|
|
38
|
+
if (match == null) {
|
|
39
|
+
console.log('Warning: invalid budget month name', monthBudget.name);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let type = match[1];
|
|
43
|
+
let month = match[2].slice(0, 4) + '-' + match[2].slice(4);
|
|
44
|
+
let dbmonth = parseInt(match[2]);
|
|
45
|
+
let cat = match[3];
|
|
46
|
+
let amount = parseInt(getValue(monthBudget));
|
|
47
|
+
if (isNaN(amount)) {
|
|
48
|
+
amount = 0;
|
|
49
|
+
}
|
|
50
|
+
let sheetName = monthBudget.name.split('!')[0];
|
|
51
|
+
let carryover = db.runQuery('SELECT * FROM spreadsheet_cells WHERE name = ?', [`${sheetName}!carryover-${cat}`], true);
|
|
52
|
+
let table = type === 'budget-report' ? 'reflect_budgets' : 'zero_budgets';
|
|
53
|
+
db.runQuery(`INSERT INTO ${table} (id, month, category, amount, carryover) VALUES (?, ?, ?, ?, ?)`, [
|
|
54
|
+
`${month}-${cat}`,
|
|
55
|
+
dbmonth,
|
|
56
|
+
cat,
|
|
57
|
+
amount,
|
|
58
|
+
carryover.length > 0 && getValue(carryover[0]) === 'true' ? 1 : 0,
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
9
61
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
62
|
+
// Migrate buffers
|
|
63
|
+
let buffers = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!buffered'`, [], true);
|
|
64
|
+
db.transaction(() => {
|
|
65
|
+
buffers.forEach(buffer => {
|
|
66
|
+
let match = buffer.name.match(/^budget(\d+)!buffered$/);
|
|
67
|
+
if (match) {
|
|
68
|
+
let month = match[1].slice(0, 4) + '-' + match[1].slice(4);
|
|
69
|
+
let amount = parseInt(getValue(buffer));
|
|
70
|
+
if (isNaN(amount)) {
|
|
71
|
+
amount = 0;
|
|
72
|
+
}
|
|
73
|
+
db.runQuery(`INSERT INTO zero_budget_months (id, buffered) VALUES (?, ?)`, [month, amount]);
|
|
32
74
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
// Migrate notes
|
|
78
|
+
let notes = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'`, [], true);
|
|
79
|
+
let parseNote = str => {
|
|
47
80
|
try {
|
|
48
|
-
|
|
81
|
+
let value = JSON.parse(str);
|
|
82
|
+
return value && value !== '' ? value : null;
|
|
49
83
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
function runMigration(db, uuid) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
function getValue(node) {
|
|
58
|
-
return node.expr != null ? node.expr : node.cachedValue;
|
|
84
|
+
catch (e) {
|
|
85
|
+
return null;
|
|
59
86
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
console.log('Warning: invalid budget month name', monthBudget.name);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
var type = match[1];
|
|
72
|
-
var month = match[2].slice(0, 4) + '-' + match[2].slice(4);
|
|
73
|
-
var dbmonth = parseInt(match[2]);
|
|
74
|
-
var cat = match[3];
|
|
75
|
-
var amount = parseInt(getValue(monthBudget));
|
|
76
|
-
if (isNaN(amount)) {
|
|
77
|
-
amount = 0;
|
|
78
|
-
}
|
|
79
|
-
var sheetName = monthBudget.name.split('!')[0];
|
|
80
|
-
var carryover = db.runQuery('SELECT * FROM spreadsheet_cells WHERE name = ?', ["".concat(sheetName, "!carryover-").concat(cat)], true);
|
|
81
|
-
var table = type === 'budget-report' ? 'reflect_budgets' : 'zero_budgets';
|
|
82
|
-
db.runQuery("INSERT INTO ".concat(table, " (id, month, category, amount, carryover) VALUES (?, ?, ?, ?, ?)"), [
|
|
83
|
-
"".concat(month, "-").concat(cat),
|
|
84
|
-
dbmonth,
|
|
85
|
-
cat,
|
|
86
|
-
amount,
|
|
87
|
-
carryover.length > 0 && getValue(carryover[0]) === 'true' ? 1 : 0,
|
|
88
|
-
]);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
buffers = db.runQuery("SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!buffered'", [], true);
|
|
92
|
-
db.transaction(function () {
|
|
93
|
-
buffers.forEach(function (buffer) {
|
|
94
|
-
var match = buffer.name.match(/^budget(\d+)!buffered$/);
|
|
95
|
-
if (match) {
|
|
96
|
-
var month = match[1].slice(0, 4) + '-' + match[1].slice(4);
|
|
97
|
-
var amount = parseInt(getValue(buffer));
|
|
98
|
-
if (isNaN(amount)) {
|
|
99
|
-
amount = 0;
|
|
100
|
-
}
|
|
101
|
-
db.runQuery("INSERT INTO zero_budget_months (id, buffered) VALUES (?, ?)", [month, amount]);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
notes = db.runQuery("SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'", [], true);
|
|
106
|
-
parseNote = function (str) {
|
|
107
|
-
try {
|
|
108
|
-
var value = JSON.parse(str);
|
|
109
|
-
return value && value !== '' ? value : null;
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
db.transaction(function () {
|
|
116
|
-
notes.forEach(function (note) {
|
|
117
|
-
var parsed = parseNote(getValue(note));
|
|
118
|
-
if (parsed) {
|
|
119
|
-
var _a = __read(note.name.split('!'), 2), id = _a[1];
|
|
120
|
-
db.runQuery("INSERT INTO notes (id, note) VALUES (?, ?)", [id, parsed]);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
db.execQuery("\n DROP TABLE spreadsheet_cells;\n ANALYZE;\n VACUUM;\n ");
|
|
125
|
-
return [2 /*return*/];
|
|
87
|
+
};
|
|
88
|
+
db.transaction(() => {
|
|
89
|
+
notes.forEach(note => {
|
|
90
|
+
let parsed = parseNote(getValue(note));
|
|
91
|
+
if (parsed) {
|
|
92
|
+
let [, id] = note.name.split('!');
|
|
93
|
+
db.runQuery(`INSERT INTO notes (id, note) VALUES (?, ?)`, [id, parsed]);
|
|
94
|
+
}
|
|
126
95
|
});
|
|
127
96
|
});
|
|
97
|
+
db.execQuery(`
|
|
98
|
+
DROP TABLE spreadsheet_cells;
|
|
99
|
+
ANALYZE;
|
|
100
|
+
VACUUM;
|
|
101
|
+
`);
|
|
128
102
|
}
|
|
129
103
|
exports.default = runMigration;
|
package/dist/test.js
CHANGED
|
@@ -22,58 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
|
|
63
|
-
function run() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, api.init({ config: { dataDir: '/tmp' } })];
|
|
69
|
-
case 1:
|
|
70
|
-
app = _a.sent();
|
|
71
|
-
return [4 /*yield*/, app.send('create-budget', { testMode: true })];
|
|
72
|
-
case 2:
|
|
73
|
-
_a.sent();
|
|
74
|
-
return [2 /*return*/];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
26
|
+
const api = __importStar(require("./index"));
|
|
27
|
+
async function run() {
|
|
28
|
+
let app = await api.init({ config: { dataDir: '/tmp' } });
|
|
29
|
+
await app.send('create-budget', { testMode: true });
|
|
78
30
|
}
|
|
79
31
|
run();
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actual-app/api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "An API for Actual",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
"default-db.sqlite",
|
|
11
|
-
"migrations"
|
|
9
|
+
"dist"
|
|
12
10
|
],
|
|
13
11
|
"scripts": {
|
|
14
12
|
"lint": "eslint .",
|
|
15
13
|
"build:app": "yarn workspace loot-core build:api",
|
|
16
14
|
"build:node": "tsc --p tsconfig.dist.json",
|
|
17
|
-
"build": "
|
|
15
|
+
"build:migrations": "cp migrations/*.sql dist/migrations",
|
|
16
|
+
"build:default-db": "cp default-db.sqlite dist/",
|
|
17
|
+
"build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"better-sqlite3": "^8.2.0",
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
export default async function runMigration(db, uuid) {
|
|
2
|
-
function getValue(node) {
|
|
3
|
-
return node.expr != null ? node.expr : node.cachedValue;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
db.execQuery(`
|
|
7
|
-
CREATE TABLE zero_budget_months
|
|
8
|
-
(id TEXT PRIMARY KEY,
|
|
9
|
-
buffered INTEGER DEFAULT 0);
|
|
10
|
-
|
|
11
|
-
CREATE TABLE zero_budgets
|
|
12
|
-
(id TEXT PRIMARY KEY,
|
|
13
|
-
month INTEGER,
|
|
14
|
-
category TEXT,
|
|
15
|
-
amount INTEGER DEFAULT 0,
|
|
16
|
-
carryover INTEGER DEFAULT 0);
|
|
17
|
-
|
|
18
|
-
CREATE TABLE reflect_budgets
|
|
19
|
-
(id TEXT PRIMARY KEY,
|
|
20
|
-
month INTEGER,
|
|
21
|
-
category TEXT,
|
|
22
|
-
amount INTEGER DEFAULT 0,
|
|
23
|
-
carryover INTEGER DEFAULT 0);
|
|
24
|
-
|
|
25
|
-
CREATE TABLE notes
|
|
26
|
-
(id TEXT PRIMARY KEY,
|
|
27
|
-
note TEXT);
|
|
28
|
-
|
|
29
|
-
CREATE TABLE kvcache (key TEXT PRIMARY KEY, value TEXT);
|
|
30
|
-
CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
31
|
-
`);
|
|
32
|
-
|
|
33
|
-
// Migrate budget amounts and carryover
|
|
34
|
-
let budget = db.runQuery(
|
|
35
|
-
`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!budget-%'`,
|
|
36
|
-
[],
|
|
37
|
-
true,
|
|
38
|
-
);
|
|
39
|
-
db.transaction(() => {
|
|
40
|
-
budget.forEach(monthBudget => {
|
|
41
|
-
let match = monthBudget.name.match(
|
|
42
|
-
/^(budget-report|budget)(\d+)!budget-(.+)$/,
|
|
43
|
-
);
|
|
44
|
-
if (match == null) {
|
|
45
|
-
console.log('Warning: invalid budget month name', monthBudget.name);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let type = match[1];
|
|
50
|
-
let month = match[2].slice(0, 4) + '-' + match[2].slice(4);
|
|
51
|
-
let dbmonth = parseInt(match[2]);
|
|
52
|
-
let cat = match[3];
|
|
53
|
-
|
|
54
|
-
let amount = parseInt(getValue(monthBudget));
|
|
55
|
-
if (isNaN(amount)) {
|
|
56
|
-
amount = 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let sheetName = monthBudget.name.split('!')[0];
|
|
60
|
-
let carryover = db.runQuery(
|
|
61
|
-
'SELECT * FROM spreadsheet_cells WHERE name = ?',
|
|
62
|
-
[`${sheetName}!carryover-${cat}`],
|
|
63
|
-
true,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
let table = type === 'budget-report' ? 'reflect_budgets' : 'zero_budgets';
|
|
67
|
-
db.runQuery(
|
|
68
|
-
`INSERT INTO ${table} (id, month, category, amount, carryover) VALUES (?, ?, ?, ?, ?)`,
|
|
69
|
-
[
|
|
70
|
-
`${month}-${cat}`,
|
|
71
|
-
dbmonth,
|
|
72
|
-
cat,
|
|
73
|
-
amount,
|
|
74
|
-
carryover.length > 0 && getValue(carryover[0]) === 'true' ? 1 : 0,
|
|
75
|
-
],
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// Migrate buffers
|
|
81
|
-
let buffers = db.runQuery(
|
|
82
|
-
`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!buffered'`,
|
|
83
|
-
[],
|
|
84
|
-
true,
|
|
85
|
-
);
|
|
86
|
-
db.transaction(() => {
|
|
87
|
-
buffers.forEach(buffer => {
|
|
88
|
-
let match = buffer.name.match(/^budget(\d+)!buffered$/);
|
|
89
|
-
if (match) {
|
|
90
|
-
let month = match[1].slice(0, 4) + '-' + match[1].slice(4);
|
|
91
|
-
let amount = parseInt(getValue(buffer));
|
|
92
|
-
if (isNaN(amount)) {
|
|
93
|
-
amount = 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
db.runQuery(
|
|
97
|
-
`INSERT INTO zero_budget_months (id, buffered) VALUES (?, ?)`,
|
|
98
|
-
[month, amount],
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Migrate notes
|
|
105
|
-
let notes = db.runQuery(
|
|
106
|
-
`SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'`,
|
|
107
|
-
[],
|
|
108
|
-
true,
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
let parseNote = str => {
|
|
112
|
-
try {
|
|
113
|
-
let value = JSON.parse(str);
|
|
114
|
-
return value && value !== '' ? value : null;
|
|
115
|
-
} catch (e) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
db.transaction(() => {
|
|
121
|
-
notes.forEach(note => {
|
|
122
|
-
let parsed = parseNote(getValue(note));
|
|
123
|
-
if (parsed) {
|
|
124
|
-
let [, id] = note.name.split('!');
|
|
125
|
-
db.runQuery(`INSERT INTO notes (id, note) VALUES (?, ?)`, [id, parsed]);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
db.execQuery(`
|
|
131
|
-
DROP TABLE spreadsheet_cells;
|
|
132
|
-
ANALYZE;
|
|
133
|
-
VACUUM;
|
|
134
|
-
`);
|
|
135
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|