@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,290 @@
|
|
|
1
|
+
import knex from 'knex';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import utc from 'dayjs/plugin/utc';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import { log, Bookkeeper, AccountType } from '@tasenor/common';
|
|
7
|
+
import { Exporter } from './Exporter';
|
|
8
|
+
dayjs.extend(utc);
|
|
9
|
+
const VAT_IGNORE = 1;
|
|
10
|
+
const VAT_RECONCILED = 2;
|
|
11
|
+
const ACCOUNT_TYPES = Object.keys(AccountType);
|
|
12
|
+
// Helpers to convert nasty dates from original format.
|
|
13
|
+
function dateFromDb(date) {
|
|
14
|
+
const str = dayjs.utc(date).add(2, 'hours').format('YYYY-MM-DD');
|
|
15
|
+
return str;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A class implementing conversion from old legacy Tilitin Sqlite-format to Tasenor format.
|
|
19
|
+
*/
|
|
20
|
+
export class TilitinExporter extends Exporter {
|
|
21
|
+
/**
|
|
22
|
+
* Construct Knex configuration for the given file.
|
|
23
|
+
* @param path Path to the Sqlite-file.
|
|
24
|
+
* @returns Instantiated Knex database connection.
|
|
25
|
+
*/
|
|
26
|
+
database(path) {
|
|
27
|
+
return knex({
|
|
28
|
+
client: 'sqlite3',
|
|
29
|
+
connection: {
|
|
30
|
+
filename: path
|
|
31
|
+
},
|
|
32
|
+
useNullAsDefault: true
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read all accounts from the database and generate TSV-data.
|
|
37
|
+
* @param db Knex connection to use.
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
async getAccounts(db) {
|
|
41
|
+
const headings = {};
|
|
42
|
+
for (const heading of await db('coa_heading').select('*').orderBy('level')) {
|
|
43
|
+
headings[heading.number] = headings[heading.number] || [];
|
|
44
|
+
let tab = '';
|
|
45
|
+
for (let i = 0; i < heading.level; i++) {
|
|
46
|
+
tab += '_';
|
|
47
|
+
}
|
|
48
|
+
heading.text = tab + heading.text;
|
|
49
|
+
headings[heading.number].push(heading);
|
|
50
|
+
}
|
|
51
|
+
const lines = [['# number / title', 'text', 'type', 'code', 'data']];
|
|
52
|
+
for (const account of await db('account').select('*').orderBy('number')) {
|
|
53
|
+
if (headings[account.number]) {
|
|
54
|
+
for (const heading of headings[account.number]) {
|
|
55
|
+
lines.push([heading.text, '', '', '', '', '']);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const data = {};
|
|
59
|
+
if (account.flags) {
|
|
60
|
+
data.favourite = true;
|
|
61
|
+
}
|
|
62
|
+
lines.push([account.number, account.name, ACCOUNT_TYPES[account.type], account.vat_percentage || '', JSON.stringify(data)]);
|
|
63
|
+
}
|
|
64
|
+
log(`Found ${lines.length} lines of data for headings and accounts.`);
|
|
65
|
+
return lines;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read all periods from the database and generate TSV-data.
|
|
69
|
+
* @param db Knex connection to use.
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
async getPeriods(db) {
|
|
73
|
+
const lines = [['# start', 'end', 'flags']];
|
|
74
|
+
for (const period of await db('period').select('*').orderBy('start_date')) {
|
|
75
|
+
lines.push([dateFromDb(period.start_date), dateFromDb(period.end_date), period.locked ? 'LOCKED' : '']);
|
|
76
|
+
}
|
|
77
|
+
log(`Found ${lines.length} lines of data for periods.`);
|
|
78
|
+
return lines;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Read all entries and documents from the database and generate TSV-data.
|
|
82
|
+
* @param db Knex connection to use.
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
async getEntries(db) {
|
|
86
|
+
const lines = [['# number', 'date / account', 'amount', 'text', 'data']];
|
|
87
|
+
let n = 1;
|
|
88
|
+
for (const period of await db('period').select('*').orderBy('start_date')) {
|
|
89
|
+
lines.push([`Period ${n}`, '', '', '', '']);
|
|
90
|
+
for (const doc of await db('document').select('*').where({ period_id: period.id }).orderBy('period_id', 'number')) {
|
|
91
|
+
lines.push([doc.number, dateFromDb(doc.date), '', '', '']);
|
|
92
|
+
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')) {
|
|
93
|
+
const data = {};
|
|
94
|
+
if (entry.flags & VAT_IGNORE) {
|
|
95
|
+
data.VAT = { ignore: true };
|
|
96
|
+
}
|
|
97
|
+
if (entry.flags & VAT_RECONCILED) {
|
|
98
|
+
data.VAT = { ...(data.VAT || {}), reconciled: true };
|
|
99
|
+
}
|
|
100
|
+
lines.push(['', entry.number, entry.debit ? entry.amount : -entry.amount, entry.description, JSON.stringify(data)]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
n++;
|
|
104
|
+
}
|
|
105
|
+
log(`Found ${lines.length} lines of data for documents and entries.`);
|
|
106
|
+
return lines;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check if the given table exist.
|
|
110
|
+
* @param db
|
|
111
|
+
*/
|
|
112
|
+
async hasTable(db, table) {
|
|
113
|
+
let hasTable = true;
|
|
114
|
+
try {
|
|
115
|
+
await db(table).select('*').limit(1);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
hasTable = false;
|
|
119
|
+
}
|
|
120
|
+
return hasTable;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Read configuration information from database and construct compiled configuration.
|
|
124
|
+
* @param db Knex connection to use.
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
async getConfig(db) {
|
|
128
|
+
const conf = Bookkeeper.createConfig();
|
|
129
|
+
conf.language = 'fi';
|
|
130
|
+
conf.currency = 'EUR';
|
|
131
|
+
conf.scheme = 'FinnishLimitedCompanyComplete';
|
|
132
|
+
conf.schemeVersion = '1.0.0';
|
|
133
|
+
// Add VAT config if we have correct accounts.
|
|
134
|
+
if (await db('account').select('*').where({ number: '29391' }).first()) {
|
|
135
|
+
conf.VAT = {
|
|
136
|
+
salesAccount: '29391',
|
|
137
|
+
purchasesAccount: '29392',
|
|
138
|
+
receivableAccount: '1763',
|
|
139
|
+
payableAccount: '2939',
|
|
140
|
+
delayedReceivableAccount: '1845',
|
|
141
|
+
delayedPayableAccount: '2977',
|
|
142
|
+
statementTagTypes: []
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
for (const setting of await db('settings').select('name', 'business_id')) {
|
|
146
|
+
conf.companyName = setting.name;
|
|
147
|
+
conf.companyCode = setting.business_id;
|
|
148
|
+
}
|
|
149
|
+
if (await this.hasTable(db, 'fyffe_settings')) {
|
|
150
|
+
for (const setting of await db('fyffe_settings').select('*')) {
|
|
151
|
+
switch (setting.name) {
|
|
152
|
+
case 'income-statement-tag-types':
|
|
153
|
+
conf.FinnishIncomeStatementReport = { tagTypes: JSON.parse(setting.value) };
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
throw new Error(`Unable to parse setting '${setting.name}'`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (conf.VAT && conf.VAT.statementTagTypes && !conf.FinnishIncomeStatementReport) {
|
|
161
|
+
conf.FinnishIncomeStatementReport = {
|
|
162
|
+
tagTypes: conf.VAT.statementTagTypes
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return conf;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Read all tags from the database and generate TSV-data.
|
|
169
|
+
* @param db Knex connection to use.
|
|
170
|
+
* @param out Directory to write image files.
|
|
171
|
+
* @returns
|
|
172
|
+
*/
|
|
173
|
+
async getTags(db, out) {
|
|
174
|
+
const lines = [['# tag', 'name', 'mime', 'picture', 'type', 'order']];
|
|
175
|
+
const picDir = path.join(out, 'pictures');
|
|
176
|
+
if (!fs.existsSync(picDir)) {
|
|
177
|
+
fs.mkdirSync(picDir);
|
|
178
|
+
}
|
|
179
|
+
if (await this.hasTable(db, 'tags')) {
|
|
180
|
+
for (const tag of await db('tags').select('*').orderBy('order')) {
|
|
181
|
+
const ext = tag.mime.split('/')[1];
|
|
182
|
+
const file = `${tag.type}-${tag.order}.${ext}`;
|
|
183
|
+
fs.writeFileSync(path.join(picDir, file), tag.picture);
|
|
184
|
+
lines.push([tag.tag, tag.name, tag.mime, path.join('pictures', file), tag.type, tag.order]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
log(`Found ${lines.length} lines of data for tags.`);
|
|
188
|
+
return lines;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Read all report formats from the database and generate mapping from report IDs to report format.
|
|
192
|
+
* @param db Knex connection to use.
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
async getReports(db) {
|
|
196
|
+
const reports = {};
|
|
197
|
+
for (const report of await db('report_structure').select('*')) {
|
|
198
|
+
reports[report.id] = report.data;
|
|
199
|
+
}
|
|
200
|
+
log(`Found reports ${Object.keys(reports)}.`);
|
|
201
|
+
return reports;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Convert old report format to new.
|
|
205
|
+
* @param report
|
|
206
|
+
*/
|
|
207
|
+
convertReport(report) {
|
|
208
|
+
const lines = [['# accounts', 'title', 'flags']];
|
|
209
|
+
for (const line of report.trim().split('\n')) {
|
|
210
|
+
let entries;
|
|
211
|
+
if (line === '')
|
|
212
|
+
continue;
|
|
213
|
+
if (line === '-') {
|
|
214
|
+
entries = ['', '', ['BREAK']];
|
|
215
|
+
}
|
|
216
|
+
else if (line === '--') {
|
|
217
|
+
entries = ['', '', ['NEW_PAGE']];
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const parts = line.split(';');
|
|
221
|
+
const code = parts[0];
|
|
222
|
+
let tab = '';
|
|
223
|
+
for (let i = 0; i < parseInt(code[2]); i++) {
|
|
224
|
+
tab += '_';
|
|
225
|
+
}
|
|
226
|
+
let flags = [];
|
|
227
|
+
switch (code[0]) {
|
|
228
|
+
case 'H':
|
|
229
|
+
flags = ['HIDE_TOTAL', 'REQUIRED'];
|
|
230
|
+
break;
|
|
231
|
+
case 'G':
|
|
232
|
+
flags = ['HIDE_TOTAL'];
|
|
233
|
+
break;
|
|
234
|
+
case 'S':
|
|
235
|
+
flags = ['REQUIRED'];
|
|
236
|
+
break;
|
|
237
|
+
case 'D':
|
|
238
|
+
flags = ['DETAILS'];
|
|
239
|
+
break;
|
|
240
|
+
case 'T':
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
throw new Error(`Cannot parse letter ${code[0]} in report code ${code} of line ${line}.`);
|
|
244
|
+
}
|
|
245
|
+
switch (code[1]) {
|
|
246
|
+
case 'B':
|
|
247
|
+
flags.push('BOLD');
|
|
248
|
+
break;
|
|
249
|
+
case 'I':
|
|
250
|
+
flags.push('ITALIC');
|
|
251
|
+
break;
|
|
252
|
+
case 'P':
|
|
253
|
+
break;
|
|
254
|
+
default:
|
|
255
|
+
throw new Error(`Cannot parse letter ${code[1]} in report code ${code} of line ${line}.`);
|
|
256
|
+
}
|
|
257
|
+
if (parts.length === 4) {
|
|
258
|
+
entries = [`${parts[1]}-${parts[2]}`, tab + parts[3], flags];
|
|
259
|
+
}
|
|
260
|
+
else if (parts.length === 6) {
|
|
261
|
+
entries = [`${parts[1]}-${parts[2]} ${parts[3]}-${parts[4]}`, tab + parts[5], flags];
|
|
262
|
+
}
|
|
263
|
+
else if (parts.length === 8) {
|
|
264
|
+
entries = [`${parts[1]}-${parts[2]} ${parts[3]}-${parts[4]} ${parts[5]}-${parts[6]}`, tab + parts[7], flags];
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
throw new Error(`Unable to parse line ${line} since there are ${parts.length} parts.`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
lines.push([entries[0], entries[1], entries[2].join(' ')]);
|
|
271
|
+
}
|
|
272
|
+
return lines;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Run the full backup for the given legacy database.
|
|
276
|
+
* @param sqlite Path to the Sqlite database to create backup for.
|
|
277
|
+
* @param out Directory to save backup.
|
|
278
|
+
* @param destPath Destionation file name if given.
|
|
279
|
+
* @returns Path to the tar-package.
|
|
280
|
+
*/
|
|
281
|
+
async run(sqlite, out, destPath) {
|
|
282
|
+
if (!fs.existsSync(sqlite)) {
|
|
283
|
+
throw new Error(`Database ${out} does not exist.`);
|
|
284
|
+
}
|
|
285
|
+
const db = this.database(sqlite);
|
|
286
|
+
const conf = await this.dump(db, out);
|
|
287
|
+
return this.makeTar(conf, out, destPath);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=TilitinExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TilitinExporter.js","sourceRoot":"","sources":["../../../src/export/TilitinExporter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAClC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAA6I,MAAM,iBAAiB,CAAA;AACzM,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAEjB,MAAM,UAAU,GAAG,CAAC,CAAA;AACpB,MAAM,cAAc,GAAG,CAAC,CAAA;AACxB,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;AAE9C,uDAAuD;AACvD,SAAS,UAAU,CAAC,IAAe;IACjC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC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AAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/export/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ProcessFile } from '../process/ProcessFile';
|
|
2
|
+
import { ProcessHandler } from '../process/ProcessHandler';
|
|
3
|
+
import { ImportAction, ProcessConfig, Directions, ImportCSVOptions, ImportState, ImportStateText, ImportCustomOptions, TransactionImportOptions } from '@tasenor/common';
|
|
4
|
+
import { Process } from '../process/Process';
|
|
5
|
+
/**
|
|
6
|
+
* Utility class to provide tools for implementing any text file based process handler.
|
|
7
|
+
*/
|
|
8
|
+
export declare class TextFileProcessHandler extends ProcessHandler {
|
|
9
|
+
importOptions: TransactionImportOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Split the file to lines and keep line numbers with the lines. Mark state type as initial state.
|
|
12
|
+
* @param file
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
startingState(processFiles: ProcessFile[]): ImportStateText<'initial'>;
|
|
16
|
+
/**
|
|
17
|
+
* Check the state type is matching to 'complete'.
|
|
18
|
+
* @param state
|
|
19
|
+
*/
|
|
20
|
+
checkCompletion(state: ImportState): boolean | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* A hook to check alternative directions from initial state.
|
|
23
|
+
* @param state
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
needInputForSegmentation(state: ImportState, config: ProcessConfig): Promise<Directions | false>;
|
|
27
|
+
/**
|
|
28
|
+
* A hook to check alternative directions from segmented state.
|
|
29
|
+
* @param state
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
needInputForClassification(state: ImportState, config: ProcessConfig): Promise<Directions | false>;
|
|
33
|
+
/**
|
|
34
|
+
* A hook to check alternative directions from classified state.
|
|
35
|
+
* @param state
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
needInputForAnalysis(state: ImportState, config: ProcessConfig): Promise<Directions | false>;
|
|
39
|
+
/**
|
|
40
|
+
* A hook to check alternative directions from analyzed state.
|
|
41
|
+
* @param state
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
needInputForExecution(state: ImportState, config: ProcessConfig): Promise<Directions | false>;
|
|
45
|
+
/**
|
|
46
|
+
* Run steps in order 'segmentation', 'classification', 'analysis', 'execution'.
|
|
47
|
+
* @param state
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
getDirections(state: ImportState, config: ProcessConfig): Promise<Directions>;
|
|
51
|
+
/**
|
|
52
|
+
* Call subclass implementation for each action.
|
|
53
|
+
* @param action
|
|
54
|
+
* @param state
|
|
55
|
+
* @param files
|
|
56
|
+
*/
|
|
57
|
+
action(process: Process, action: ImportAction, state: ImportState, files: ProcessFile[]): Promise<ImportState>;
|
|
58
|
+
/**
|
|
59
|
+
* This function must implement gathering of each line together that forms together one import activity.
|
|
60
|
+
* @param state
|
|
61
|
+
* @param files
|
|
62
|
+
*/
|
|
63
|
+
segmentation(process: Process, state: ImportState, files: ProcessFile[], config: ProcessConfig): Promise<ImportState>;
|
|
64
|
+
/**
|
|
65
|
+
* This function must implement gathering of each line together that forms together one import activity.
|
|
66
|
+
* @param state
|
|
67
|
+
* @param files
|
|
68
|
+
*/
|
|
69
|
+
classification(process: Process, state: ImportState, files: ProcessFile[], config: ProcessConfig): Promise<ImportState>;
|
|
70
|
+
/**
|
|
71
|
+
* This function must implement conversion from classified data to the actual executable operations.
|
|
72
|
+
* @param state
|
|
73
|
+
* @param files
|
|
74
|
+
*/
|
|
75
|
+
analysis(process: Process, state: ImportState, files: ProcessFile[], config: ProcessConfig): Promise<ImportState>;
|
|
76
|
+
/**
|
|
77
|
+
* This function must implement applying the result in practice.
|
|
78
|
+
* @param state
|
|
79
|
+
* @param files
|
|
80
|
+
*/
|
|
81
|
+
execution(process: Process, state: ImportState, files: ProcessFile[], config: ProcessConfig): Promise<ImportState>;
|
|
82
|
+
/**
|
|
83
|
+
* Parse a single line of CSV.
|
|
84
|
+
* @param line
|
|
85
|
+
* @param options
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
parseCsvLine(line: string, options?: ImportCSVOptions): Promise<string[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Go through each file and each line and add CSV interpretation of the content to each line.
|
|
91
|
+
* @param state
|
|
92
|
+
* @param options
|
|
93
|
+
* @returns The original state that has been modified by adding CSV parsed field `columns`.
|
|
94
|
+
*/
|
|
95
|
+
parseCSV(state: ImportStateText<'initial'>, options?: ImportCSVOptions): Promise<ImportStateText<'segmented'>>;
|
|
96
|
+
/**
|
|
97
|
+
* Handler for pure custom handler.
|
|
98
|
+
*/
|
|
99
|
+
parseCustom(state: ImportStateText<'initial'>, options: ImportCustomOptions): Promise<ImportStateText<'segmented'>>;
|
|
100
|
+
/**
|
|
101
|
+
* Split a string to fixed length fields given as name and length mapping.
|
|
102
|
+
*/
|
|
103
|
+
parseFixedLength(src: string, offsets: Record<string, number>, conversions: Record<string, (string: any) => string>): {};
|
|
104
|
+
}
|