@tasenor/common-node 1.9.32 → 1.9.34
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/migrations/01_init.js +60 -0
- package/dist/src/cli.d.ts +81 -0
- package/dist/src/cli.js +242 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/account.d.ts +12 -0
- package/dist/src/commands/account.js +58 -0
- package/dist/src/commands/account.js.map +1 -0
- package/dist/src/commands/balance.d.ts +11 -0
- package/dist/src/commands/balance.js +117 -0
- package/dist/src/commands/balance.js.map +1 -0
- package/dist/src/commands/db.d.ts +14 -0
- package/dist/src/commands/db.js +69 -0
- package/dist/src/commands/db.js.map +1 -0
- package/dist/src/commands/entry.d.ts +13 -0
- package/dist/src/commands/entry.js +106 -0
- package/dist/src/commands/entry.js.map +1 -0
- package/dist/src/commands/import.d.ts +17 -0
- package/dist/src/commands/import.js +140 -0
- package/dist/src/commands/import.js.map +1 -0
- package/dist/src/commands/importer.d.ts +13 -0
- package/dist/src/commands/importer.js +71 -0
- package/dist/src/commands/importer.js.map +1 -0
- package/dist/src/commands/index.d.ts +191 -0
- package/dist/src/commands/index.js +482 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/period.d.ts +12 -0
- package/dist/src/commands/period.js +48 -0
- package/dist/src/commands/period.js.map +1 -0
- package/dist/src/commands/plugin.d.ts +15 -0
- package/dist/src/commands/plugin.js +78 -0
- package/dist/src/commands/plugin.js.map +1 -0
- package/dist/src/commands/report.d.ts +11 -0
- package/dist/src/commands/report.js +96 -0
- package/dist/src/commands/report.js.map +1 -0
- package/dist/src/commands/settings.d.ts +10 -0
- package/dist/src/commands/settings.js +64 -0
- package/dist/src/commands/settings.js.map +1 -0
- package/dist/src/commands/stock.d.ts +8 -0
- package/dist/src/commands/stock.js +73 -0
- package/dist/src/commands/stock.js.map +1 -0
- package/dist/src/commands/tag.d.ts +13 -0
- package/dist/src/commands/tag.js +89 -0
- package/dist/src/commands/tag.js.map +1 -0
- package/dist/src/commands/tx.d.ts +12 -0
- package/dist/src/commands/tx.js +81 -0
- package/dist/src/commands/tx.js.map +1 -0
- package/dist/src/commands/user.d.ts +12 -0
- package/dist/src/commands/user.js +52 -0
- package/dist/src/commands/user.js.map +1 -0
- package/dist/src/database/BookkeeperImporter.d.ts +77 -0
- package/dist/src/database/BookkeeperImporter.js +343 -0
- package/dist/src/database/BookkeeperImporter.js.map +1 -0
- package/dist/src/database/DB.d.ts +51 -0
- package/dist/src/database/DB.js +354 -0
- package/dist/src/database/DB.js.map +1 -0
- package/dist/src/database/index.d.ts +7 -0
- package/dist/src/database/index.js +8 -0
- package/dist/src/database/index.js.map +1 -0
- package/dist/src/doccer.d.ts +29 -0
- package/dist/src/doccer.js +30 -0
- package/dist/src/doccer.js.map +1 -0
- package/dist/src/error.d.ts +30 -0
- package/dist/src/error.js +35 -0
- package/dist/src/error.js.map +1 -0
- package/dist/src/export/Exporter.d.ts +69 -0
- package/dist/src/export/Exporter.js +123 -0
- package/dist/src/export/Exporter.js.map +1 -0
- package/dist/src/export/TasenorExporter.d.ts +55 -0
- package/dist/src/export/TasenorExporter.js +135 -0
- package/dist/src/export/TasenorExporter.js.map +1 -0
- package/dist/src/export/TilitinExporter.d.ts +71 -0
- package/dist/src/export/TilitinExporter.js +290 -0
- package/dist/src/export/TilitinExporter.js.map +1 -0
- package/dist/src/export/index.d.ts +8 -0
- package/dist/src/export/index.js +9 -0
- package/dist/src/export/index.js.map +1 -0
- package/dist/src/import/TextFileProcessHandler.d.ts +104 -0
- package/dist/src/import/TextFileProcessHandler.js +354 -0
- package/dist/src/import/TextFileProcessHandler.js.map +1 -0
- package/dist/src/import/TransactionImportConnector.d.ts +38 -0
- package/dist/src/import/TransactionImportConnector.js +27 -0
- package/dist/src/import/TransactionImportConnector.js.map +1 -0
- package/dist/src/import/TransactionImportHandler.d.ts +174 -0
- package/dist/src/import/TransactionImportHandler.js +736 -0
- package/dist/src/import/TransactionImportHandler.js.map +1 -0
- package/dist/src/import/TransactionRules.d.ts +238 -0
- package/dist/src/import/TransactionRules.js +522 -0
- package/dist/src/import/TransactionRules.js.map +1 -0
- package/dist/src/import/TransactionUI.d.ts +181 -0
- package/dist/src/import/TransactionUI.js +482 -0
- package/dist/src/import/TransactionUI.js.map +1 -0
- package/dist/src/import/TransferAnalyzer.d.ts +324 -0
- package/dist/src/import/TransferAnalyzer.js +1379 -0
- package/dist/src/import/TransferAnalyzer.js.map +1 -0
- package/dist/src/import/index.d.ts +11 -0
- package/dist/src/import/index.js +12 -0
- package/dist/src/import/index.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/net/crypto.d.ts +33 -0
- package/dist/src/net/crypto.js +63 -0
- package/dist/src/net/crypto.js.map +1 -0
- package/dist/src/net/git.d.ts +49 -0
- package/dist/src/net/git.js +137 -0
- package/dist/src/net/git.js.map +1 -0
- package/dist/src/net/index.d.ts +10 -0
- package/dist/src/net/index.js +11 -0
- package/dist/src/net/index.js.map +1 -0
- package/dist/src/net/middleware.d.ts +61 -0
- package/dist/src/net/middleware.js +220 -0
- package/dist/src/net/middleware.js.map +1 -0
- package/dist/src/net/tokens.d.ts +50 -0
- package/dist/src/net/tokens.js +141 -0
- package/dist/src/net/tokens.js.map +1 -0
- package/dist/src/net/vault.d.ts +67 -0
- package/dist/src/net/vault.js +145 -0
- package/dist/src/net/vault.js.map +1 -0
- package/dist/src/plugins/BackendPlugin.d.ts +91 -0
- package/dist/src/plugins/BackendPlugin.js +165 -0
- package/dist/src/plugins/BackendPlugin.js.map +1 -0
- package/dist/src/plugins/DataPlugin.d.ts +13 -0
- package/dist/src/plugins/DataPlugin.js +26 -0
- package/dist/src/plugins/DataPlugin.js.map +1 -0
- package/dist/src/plugins/ImportPlugin.d.ts +188 -0
- package/dist/src/plugins/ImportPlugin.js +204 -0
- package/dist/src/plugins/ImportPlugin.js.map +1 -0
- package/dist/src/plugins/ReportPlugin.d.ts +132 -0
- package/dist/src/plugins/ReportPlugin.js +393 -0
- package/dist/src/plugins/ReportPlugin.js.map +1 -0
- package/dist/src/plugins/SchemePlugin.d.ts +34 -0
- package/dist/src/plugins/SchemePlugin.js +47 -0
- package/dist/src/plugins/SchemePlugin.js.map +1 -0
- package/dist/src/plugins/ServicePlugin.d.ts +80 -0
- package/dist/src/plugins/ServicePlugin.js +168 -0
- package/dist/src/plugins/ServicePlugin.js.map +1 -0
- package/dist/src/plugins/ToolPlugin.d.ts +27 -0
- package/dist/src/plugins/ToolPlugin.js +37 -0
- package/dist/src/plugins/ToolPlugin.js.map +1 -0
- package/dist/src/plugins/index.d.ts +13 -0
- package/dist/src/plugins/index.js +14 -0
- package/dist/src/plugins/index.js.map +1 -0
- package/dist/src/plugins/plugins.d.ts +101 -0
- package/dist/src/plugins/plugins.js +292 -0
- package/dist/src/plugins/plugins.js.map +1 -0
- package/dist/src/process/Process.d.ts +108 -0
- package/dist/src/process/Process.js +335 -0
- package/dist/src/process/Process.js.map +1 -0
- package/dist/src/process/ProcessConnector.d.ts +24 -0
- package/dist/src/process/ProcessConnector.js +28 -0
- package/dist/src/process/ProcessConnector.js.map +1 -0
- package/dist/src/process/ProcessFile.d.ts +69 -0
- package/dist/src/process/ProcessFile.js +145 -0
- package/dist/src/process/ProcessFile.js.map +1 -0
- package/dist/src/process/ProcessHandler.d.ts +60 -0
- package/dist/src/process/ProcessHandler.js +73 -0
- package/dist/src/process/ProcessHandler.js.map +1 -0
- package/dist/src/process/ProcessStep.d.ts +52 -0
- package/dist/src/process/ProcessStep.js +78 -0
- package/dist/src/process/ProcessStep.js.map +1 -0
- package/dist/src/process/ProcessingSystem.d.ts +60 -0
- package/dist/src/process/ProcessingSystem.js +182 -0
- package/dist/src/process/ProcessingSystem.js.map +1 -0
- package/dist/src/process/index.d.ts +11 -0
- package/dist/src/process/index.js +12 -0
- package/dist/src/process/index.js.map +1 -0
- package/dist/src/reports/conversions.d.ts +8 -0
- package/dist/src/reports/conversions.js +47 -0
- package/dist/src/reports/conversions.js.map +1 -0
- package/dist/src/reports/index.d.ts +6 -0
- package/dist/src/reports/index.js +7 -0
- package/dist/src/reports/index.js.map +1 -0
- package/dist/src/server/ISPDemoServer.d.ts +43 -0
- package/dist/src/server/ISPDemoServer.js +112 -0
- package/dist/src/server/ISPDemoServer.js.map +1 -0
- package/dist/src/server/api.d.ts +15 -0
- package/dist/src/server/api.js +27 -0
- package/dist/src/server/api.js.map +1 -0
- package/dist/src/server/index.d.ts +7 -0
- package/dist/src/server/index.js +8 -0
- package/dist/src/server/index.js.map +1 -0
- package/dist/src/server/router.d.ts +5 -0
- package/dist/src/server/router.js +37 -0
- package/dist/src/server/router.js.map +1 -0
- package/dist/src/system.d.ts +27 -0
- package/dist/src/system.js +95 -0
- package/dist/src/system.js.map +1 -0
- package/dist/tests/TransactionRules.spec.d.ts +1 -0
- package/dist/tests/TransactionRules.spec.js +64 -0
- package/dist/tests/TransactionRules.spec.js.map +1 -0
- package/dist/tests/password.spec.d.ts +1 -0
- package/dist/tests/password.spec.js +8 -0
- package/dist/tests/password.spec.js.map +1 -0
- package/dist/tests/tokens.spec.d.ts +1 -0
- package/dist/tests/tokens.spec.js +49 -0
- package/dist/tests/tokens.spec.js.map +1 -0
- package/dist/tests/vault.spec.d.ts +1 -0
- package/dist/tests/vault.spec.js +19 -0
- package/dist/tests/vault.spec.js.map +1 -0
- package/package.json +3 -3
- package/src/import/TransactionImportHandler.ts +5 -1
- package/src/index.ts +0 -1
- package/src/testing/ProcessingSystemMock.ts +0 -45
- package/src/testing/UnitTestImportConnector.ts +0 -86
- package/src/testing/UnitTester.ts +0 -231
- package/src/testing/index.ts +0 -4
- package/src/testing/test-handlers.ts +0 -47
- package/tests/TransferAnalyzer-account-address.spec.ts +0 -87
- package/tests/TransferAnalyzer-buying-and-selling.spec.ts +0 -354
- package/tests/TransferAnalyzer-loans.spec.ts +0 -197
- package/tests/TransferAnalyzer-multiple-null-amounts.spec.ts +0 -181
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { log } from '@tasenor/common';
|
|
5
|
+
import { create } from 'ts-opaque';
|
|
6
|
+
import { system } from '../system';
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
/**
|
|
9
|
+
* Common functionality for exporters.
|
|
10
|
+
*/
|
|
11
|
+
export class Exporter {
|
|
12
|
+
/**
|
|
13
|
+
* Version number of the file format produced by this exporter.
|
|
14
|
+
*/
|
|
15
|
+
VERSION = 2;
|
|
16
|
+
/**
|
|
17
|
+
* Read all accounts from the database and generate TSV-data.
|
|
18
|
+
* @param db Knex connection to use.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
async getAccounts(db) {
|
|
22
|
+
throw new Error(`Exporter ${this.constructor.name} does not implement getAccounts().`);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Read all periods from the database and generate TSV-data.
|
|
26
|
+
* @param db Knex connection to use.
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
async getPeriods(db) {
|
|
30
|
+
throw new Error(`Exporter ${this.constructor.name} does not implement getPeriods().`);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read all entries and documents from the database and generate TSV-data.
|
|
34
|
+
* @param db Knex connection to use.
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
async getEntries(db) {
|
|
38
|
+
throw new Error(`Exporter ${this.constructor.name} does not implement getEntries().`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Read configuration information from database and construct compiled configuration.
|
|
42
|
+
* @param db Knex connection to use.
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
async getConfig(db) {
|
|
46
|
+
throw new Error(`Exporter ${this.constructor.name} does not implement getConfig().`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read all tags from the database and generate TSV-data.
|
|
50
|
+
* @param db Knex connection to use.
|
|
51
|
+
* @param out Directory to write image files.
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
async getTags(db, out) {
|
|
55
|
+
throw new Error(`Exporter ${this.constructor.name} does not implement getTags().`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Write prepared data to TSV file.
|
|
59
|
+
* @param path Output file path.
|
|
60
|
+
* @param lines Data content.
|
|
61
|
+
*/
|
|
62
|
+
writeTsv(path, lines) {
|
|
63
|
+
log(`Writing ${path}`);
|
|
64
|
+
fs.writeFileSync(path, lines.map(l => l.join('\t')).join('\n') + '\n');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Write prepared data to JSON file.
|
|
68
|
+
* @param path Output file path.
|
|
69
|
+
* @param lines Data content.
|
|
70
|
+
*/
|
|
71
|
+
writeJson(path, data) {
|
|
72
|
+
log(`Writing ${path}`);
|
|
73
|
+
fs.writeFileSync(path, JSON.stringify(data, null, 4) + '\n');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Save complete backup of the Sqlite database to the given directory.
|
|
77
|
+
* @param db Database connection.
|
|
78
|
+
* @param out Directory to store all files.
|
|
79
|
+
* @returns Configuration constructed from the database.
|
|
80
|
+
*/
|
|
81
|
+
async dump(db, out) {
|
|
82
|
+
const accountDir = path.join(out, 'accounts');
|
|
83
|
+
if (!fs.existsSync(accountDir)) {
|
|
84
|
+
fs.mkdirSync(accountDir);
|
|
85
|
+
}
|
|
86
|
+
log(`Saving file format version ${this.VERSION}.`);
|
|
87
|
+
this.writeJson(create(path.join(out, 'VERSION')), this.VERSION);
|
|
88
|
+
const conf = await this.getConfig(db);
|
|
89
|
+
this.writeJson(create(path.join(out, 'settings.json')), conf);
|
|
90
|
+
const accounts = await this.getAccounts(db);
|
|
91
|
+
this.writeTsv(create(path.join(accountDir, 'fi-EUR.tsv')), accounts);
|
|
92
|
+
const periods = await this.getPeriods(db);
|
|
93
|
+
this.writeTsv(create(path.join(out, 'periods.tsv')), periods);
|
|
94
|
+
const entries = await this.getEntries(db);
|
|
95
|
+
this.writeTsv(create(path.join(out, 'entries.tsv')), entries);
|
|
96
|
+
const tags = await this.getTags(db, out);
|
|
97
|
+
this.writeTsv(create(path.join(out, 'tags.tsv')), tags);
|
|
98
|
+
return conf;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Construct a tar-package for the given configuration from the source directory.
|
|
102
|
+
* @param conf Configuration found from the database.
|
|
103
|
+
* @param out Directory containing files extracted as a backup.
|
|
104
|
+
* @param destPath Destionation file name if given.
|
|
105
|
+
* @returns Path to the tar-package.
|
|
106
|
+
*/
|
|
107
|
+
async makeTar(conf, out, destPath) {
|
|
108
|
+
const name = conf.companyName || 'unknown';
|
|
109
|
+
const tar = `${name.replace(/[^-a-zA-Z0-9]/, '_')}-${dayjs().format('YYYY-MM-DD')}.tasenor`;
|
|
110
|
+
const tarPath = `${out}/../${tar}`;
|
|
111
|
+
const dest = process.cwd();
|
|
112
|
+
if (!destPath) {
|
|
113
|
+
destPath = create(path.join(dest, tar));
|
|
114
|
+
}
|
|
115
|
+
if (path.dirname(destPath) === '.') {
|
|
116
|
+
destPath = create(path.join(dest, path.basename(destPath)));
|
|
117
|
+
}
|
|
118
|
+
await system(`cd "${out}" && tar cjf "${tarPath}" . && mv "${tarPath}" "${destPath}" && rm -fr ${out}`);
|
|
119
|
+
log(`Package ready ${destPath}`);
|
|
120
|
+
return destPath;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=Exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exporter.js","sourceRoot":"","sources":["../../../src/export/Exporter.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,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,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;SAC3E;QACD,MAAM,MAAM,CAAC,OAAO,GAAG,iBAAiB,OAAO,cAAc,OAAO,MAAM,QAAQ,eAAe,GAAG,EAAE,CAAC,CAAA;QACvG,GAAG,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAA;QAChC,OAAO,QAAkC,CAAA;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BookkeeperConfig, DirectoryPath, ParsedTsvFileData, TarFilePath, Url } from '@tasenor/common';
|
|
2
|
+
import { KnexDatabase } from '../database';
|
|
3
|
+
import { Exporter } from './Exporter';
|
|
4
|
+
/**
|
|
5
|
+
* Export Tasenor database.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TasenorExporter extends Exporter {
|
|
8
|
+
/**
|
|
9
|
+
* Read configuration information from database and construct compiled configuration.
|
|
10
|
+
* @param db Knex connection to use.
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
getConfig(db: KnexDatabase): Promise<BookkeeperConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* Read all accounts from the database and generate TSV-data.
|
|
16
|
+
* @param db Knex connection to use.
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getAccounts(db: KnexDatabase): Promise<ParsedTsvFileData>;
|
|
20
|
+
/**
|
|
21
|
+
* Read all periods from the database and generate TSV-data.
|
|
22
|
+
* @param db Knex connection to use.
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
getPeriods(db: KnexDatabase): Promise<ParsedTsvFileData>;
|
|
26
|
+
/**
|
|
27
|
+
* Read all entries and documents from the database and generate TSV-data.
|
|
28
|
+
* @param db Knex connection to use.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
getEntries(db: KnexDatabase): Promise<ParsedTsvFileData>;
|
|
32
|
+
/**
|
|
33
|
+
* Read all tags from the database and generate TSV-data.
|
|
34
|
+
* @param db Knex connection to use.
|
|
35
|
+
* @param out Directory to write image files.
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
getTags(db: KnexDatabase, out: DirectoryPath): Promise<ParsedTsvFileData>;
|
|
39
|
+
/**
|
|
40
|
+
* Run the full backup for the given database.
|
|
41
|
+
* @param dbUrl Database URL.
|
|
42
|
+
* @param out Directory to save backup.
|
|
43
|
+
* @param destPath Destionation file name if given.
|
|
44
|
+
* @returns Path to the tar-package.
|
|
45
|
+
*/
|
|
46
|
+
run(dbUrl: Url, out: DirectoryPath, destPath?: DirectoryPath | undefined): Promise<TarFilePath>;
|
|
47
|
+
/**
|
|
48
|
+
* Run the full backup for the given database.
|
|
49
|
+
* @param db Knex database.
|
|
50
|
+
* @param out Directory to save backup.
|
|
51
|
+
* @param destPath Destionation file name if given.
|
|
52
|
+
* @returns Path to the tar-package.
|
|
53
|
+
*/
|
|
54
|
+
runDb(db: KnexDatabase, out: DirectoryPath, destPath?: DirectoryPath | undefined): Promise<TarFilePath>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Bookkeeper, log } from '@tasenor/common';
|
|
2
|
+
import { DB } from '../database';
|
|
3
|
+
import { Exporter } from './Exporter';
|
|
4
|
+
import knex from 'knex';
|
|
5
|
+
import dot from 'dot-object';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
/**
|
|
9
|
+
* Export Tasenor database.
|
|
10
|
+
*/
|
|
11
|
+
export class TasenorExporter extends Exporter {
|
|
12
|
+
/**
|
|
13
|
+
* Read configuration information from database and construct compiled configuration.
|
|
14
|
+
* @param db Knex connection to use.
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
async getConfig(db) {
|
|
18
|
+
const conf = Bookkeeper.createConfig();
|
|
19
|
+
const settings = {};
|
|
20
|
+
for (const setting of await db('settings').select('*')) {
|
|
21
|
+
settings[setting.name] = setting.value;
|
|
22
|
+
}
|
|
23
|
+
Object.assign(conf, dot.object(settings));
|
|
24
|
+
return conf;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read all accounts from the database and generate TSV-data.
|
|
28
|
+
* @param db Knex connection to use.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
async getAccounts(db) {
|
|
32
|
+
const headings = {};
|
|
33
|
+
for (const heading of await db('heading').select('*').orderBy('level')) {
|
|
34
|
+
headings[heading.number] = headings[heading.number] || [];
|
|
35
|
+
let tab = '';
|
|
36
|
+
for (let i = 0; i < heading.level; i++) {
|
|
37
|
+
tab += '_';
|
|
38
|
+
}
|
|
39
|
+
heading.text = tab + heading.text;
|
|
40
|
+
headings[heading.number].push(heading);
|
|
41
|
+
}
|
|
42
|
+
const lines = [['# number / title', 'text', 'type', 'code', 'data']];
|
|
43
|
+
for (const account of await db('account').select('*').orderBy('number')) {
|
|
44
|
+
if (headings[account.number]) {
|
|
45
|
+
for (const heading of headings[account.number]) {
|
|
46
|
+
lines.push([heading.text, '', '', '', '', '']);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const code = account.data.code || '';
|
|
50
|
+
delete account.data.code;
|
|
51
|
+
lines.push([account.number, account.name, account.type, code, JSON.stringify(account.data)]);
|
|
52
|
+
}
|
|
53
|
+
log(`Found ${lines.length} lines of data for headings and accounts.`);
|
|
54
|
+
return lines;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read all periods from the database and generate TSV-data.
|
|
58
|
+
* @param db Knex connection to use.
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
async getPeriods(db) {
|
|
62
|
+
const lines = [['# start', 'end', 'flags']];
|
|
63
|
+
for (const period of await db('period').select('*').orderBy('start_date')) {
|
|
64
|
+
lines.push([period.start_date, period.end_date, period.locked ? 'LOCKED' : '']);
|
|
65
|
+
}
|
|
66
|
+
log(`Found ${lines.length} lines of data for periods.`);
|
|
67
|
+
return lines;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Read all entries and documents from the database and generate TSV-data.
|
|
71
|
+
* @param db Knex connection to use.
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
async getEntries(db) {
|
|
75
|
+
const lines = [['# number', 'date / account', 'amount', 'text', 'data']];
|
|
76
|
+
let n = 1;
|
|
77
|
+
for (const period of await db('period').select('*').orderBy('start_date')) {
|
|
78
|
+
lines.push([`Period ${n}`, '', '', '', '']);
|
|
79
|
+
for (const doc of await db('document').select('*').where({ period_id: period.id }).orderBy('period_id', 'number')) {
|
|
80
|
+
lines.push([doc.number, doc.date, '', '', '']);
|
|
81
|
+
for (const entry of await db('entry').join('account', 'entry.account_id', 'account.id').select('entry.*', 'account.number').where({ document_id: doc.id }).orderBy('row_number')) {
|
|
82
|
+
lines.push(['', entry.number, entry.debit ? entry.amount : -entry.amount, entry.description, JSON.stringify(entry.data)]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
n++;
|
|
86
|
+
}
|
|
87
|
+
log(`Found ${lines.length} lines of data for documents and entries.`);
|
|
88
|
+
return lines;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read all tags from the database and generate TSV-data.
|
|
92
|
+
* @param db Knex connection to use.
|
|
93
|
+
* @param out Directory to write image files.
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
async getTags(db, out) {
|
|
97
|
+
const lines = [['# tag', 'name', 'mime', 'picture', 'type', 'order']];
|
|
98
|
+
const picDir = path.join(out, 'pictures');
|
|
99
|
+
if (!fs.existsSync(picDir)) {
|
|
100
|
+
fs.mkdirSync(picDir);
|
|
101
|
+
}
|
|
102
|
+
for (const tag of await db('tags').select('*').orderBy('order')) {
|
|
103
|
+
const ext = tag.mime.split('/')[1];
|
|
104
|
+
const file = `${tag.type}-${tag.order}.${ext}`;
|
|
105
|
+
fs.writeFileSync(path.join(picDir, file), tag.picture);
|
|
106
|
+
lines.push([tag.tag, tag.name, tag.mime, path.join('pictures', file), tag.type, tag.order]);
|
|
107
|
+
}
|
|
108
|
+
log(`Found ${lines.length} lines of data for tags.`);
|
|
109
|
+
return lines;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Run the full backup for the given database.
|
|
113
|
+
* @param dbUrl Database URL.
|
|
114
|
+
* @param out Directory to save backup.
|
|
115
|
+
* @param destPath Destionation file name if given.
|
|
116
|
+
* @returns Path to the tar-package.
|
|
117
|
+
*/
|
|
118
|
+
async run(dbUrl, out, destPath = undefined) {
|
|
119
|
+
const db = DB.getKnexConfig(dbUrl);
|
|
120
|
+
const conf = await this.dump(knex(db), out);
|
|
121
|
+
return this.makeTar(conf, out, destPath);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Run the full backup for the given database.
|
|
125
|
+
* @param db Knex database.
|
|
126
|
+
* @param out Directory to save backup.
|
|
127
|
+
* @param destPath Destionation file name if given.
|
|
128
|
+
* @returns Path to the tar-package.
|
|
129
|
+
*/
|
|
130
|
+
async runDb(db, out, destPath = undefined) {
|
|
131
|
+
const conf = await this.dump(db, out);
|
|
132
|
+
return this.makeTar(conf, out, destPath);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=TasenorExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TasenorExporter.js","sourceRoot":"","sources":["../../../src/export/TasenorExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmC,GAAG,EAAuC,MAAM,iBAAiB,CAAA;AACvH,OAAO,EAAE,EAAE,EAAgB,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,GAAG,MAAM,YAAY,CAAA;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB;;GAE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AC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;SAC5F;QACD,GAAG,CAAC,SAAS,KAAK,CAAC,MAAM,0BAA0B,CAAC,CAAA;QACpD,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,KAAU,EAAE,GAAkB,EAAE,WAAsC,SAAS;QACvF,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAClC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,EAAgB,EAAE,GAAkB,EAAE,WAAsC,SAAS;QAC/F,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { KnexDatabase } from '..';
|
|
2
|
+
import { ParsedTsvFileData, BookkeeperConfig, DirectoryPath, ReportFormat, TarFilePath, SqliteDbPath } from '@tasenor/common';
|
|
3
|
+
import { Exporter } from './Exporter';
|
|
4
|
+
/**
|
|
5
|
+
* A class implementing conversion from old legacy Tilitin Sqlite-format to Tasenor format.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TilitinExporter extends Exporter {
|
|
8
|
+
/**
|
|
9
|
+
* Construct Knex configuration for the given file.
|
|
10
|
+
* @param path Path to the Sqlite-file.
|
|
11
|
+
* @returns Instantiated Knex database connection.
|
|
12
|
+
*/
|
|
13
|
+
database(path: any): KnexDatabase;
|
|
14
|
+
/**
|
|
15
|
+
* Read all accounts from the database and generate TSV-data.
|
|
16
|
+
* @param db Knex connection to use.
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getAccounts(db: KnexDatabase): Promise<ParsedTsvFileData>;
|
|
20
|
+
/**
|
|
21
|
+
* Read all periods from the database and generate TSV-data.
|
|
22
|
+
* @param db Knex connection to use.
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
getPeriods(db: KnexDatabase): Promise<ParsedTsvFileData>;
|
|
26
|
+
/**
|
|
27
|
+
* Read all entries and documents from the database and generate TSV-data.
|
|
28
|
+
* @param db Knex connection to use.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
getEntries(db: KnexDatabase): Promise<ParsedTsvFileData>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if the given table exist.
|
|
34
|
+
* @param db
|
|
35
|
+
*/
|
|
36
|
+
hasTable(db: KnexDatabase, table: string): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Read configuration information from database and construct compiled configuration.
|
|
39
|
+
* @param db Knex connection to use.
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
getConfig(db: KnexDatabase): Promise<BookkeeperConfig>;
|
|
43
|
+
/**
|
|
44
|
+
* Read all tags from the database and generate TSV-data.
|
|
45
|
+
* @param db Knex connection to use.
|
|
46
|
+
* @param out Directory to write image files.
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
getTags(db: KnexDatabase, out: DirectoryPath): Promise<ParsedTsvFileData>;
|
|
50
|
+
/**
|
|
51
|
+
* Read all report formats from the database and generate mapping from report IDs to report format.
|
|
52
|
+
* @param db Knex connection to use.
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
getReports(db: KnexDatabase): Promise<{
|
|
56
|
+
[key: string]: ReportFormat;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Convert old report format to new.
|
|
60
|
+
* @param report
|
|
61
|
+
*/
|
|
62
|
+
convertReport(report: ReportFormat): ParsedTsvFileData;
|
|
63
|
+
/**
|
|
64
|
+
* Run the full backup for the given legacy database.
|
|
65
|
+
* @param sqlite Path to the Sqlite database to create backup for.
|
|
66
|
+
* @param out Directory to save backup.
|
|
67
|
+
* @param destPath Destionation file name if given.
|
|
68
|
+
* @returns Path to the tar-package.
|
|
69
|
+
*/
|
|
70
|
+
run(sqlite: SqliteDbPath, out: DirectoryPath, destPath: DirectoryPath | undefined): Promise<TarFilePath>;
|
|
71
|
+
}
|