@tasenor/common-plugins 1.9.16

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.
Files changed (114) hide show
  1. package/.eslintrc.js +4 -0
  2. package/.turbo/turbo-fix.log +4 -0
  3. package/.turbo/turbo-lint.log +4 -0
  4. package/.turbo/turbo-version.log +5 -0
  5. package/LICENSE +21 -0
  6. package/README.md +15 -0
  7. package/data/FinnishBalanceSheetReport.mjs +9 -0
  8. package/data/FinnishBalanceSheetReportInvestment.mjs +11 -0
  9. package/data/FinnishBalanceSheetReportLite.mjs +9 -0
  10. package/data/FinnishIncomeStatementReport.mjs +9 -0
  11. package/data/FinnishIncomeStatementReportInvestment.mjs +11 -0
  12. package/data/FinnishIncomeStatementReportLite.mjs +9 -0
  13. package/data/FinnishInvestmentCompany.mjs +5 -0
  14. package/data/FinnishLimitedCompanyComplete.mjs +5 -0
  15. package/data/FinnishLimitedCompanyLite.mjs +9 -0
  16. package/data/IncomeAndExpenses.mjs +64 -0
  17. package/data/README.md +8 -0
  18. package/data/VATFinland.mjs +22 -0
  19. package/data/bin/build_all +11 -0
  20. package/data/lib/utils.mjs +314 -0
  21. package/data/src/Assets Tree - Definitions.tsv +101 -0
  22. package/data/src/Expense Tree - Definitions.tsv +99 -0
  23. package/data/src/Finland VAT - Definitions.tsv +22 -0
  24. package/data/src/FinnishBalanceSheetReport - balance-sheet-detailed-fi.tsv +215 -0
  25. package/data/src/FinnishBalanceSheetReport - balance-sheet-fi.tsv +93 -0
  26. package/data/src/FinnishBalanceSheetReportInvestment - balance-sheet-detailed-fi.tsv +100 -0
  27. package/data/src/FinnishBalanceSheetReportInvestment - balance-sheet-fi.tsv +52 -0
  28. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-en.tsv +21 -0
  29. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-fi.tsv +21 -0
  30. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-lite-en.tsv +21 -0
  31. package/data/src/FinnishBalanceSheetReportLite - balance-sheet-lite-fi.tsv +21 -0
  32. package/data/src/FinnishIncomeStatementReport - income-statement-detailed-fi.tsv +118 -0
  33. package/data/src/FinnishIncomeStatementReport - income-statement-fi.tsv +45 -0
  34. package/data/src/FinnishIncomeStatementReportInvestment - income-statement-detailed-fi.tsv +96 -0
  35. package/data/src/FinnishIncomeStatementReportInvestment - income-statement-fi.tsv +39 -0
  36. package/data/src/FinnishIncomeStatementReportLite - income-statement-lite-en.tsv +23 -0
  37. package/data/src/FinnishIncomeStatementReportLite - income-statement-lite-fi.tsv +23 -0
  38. package/data/src/FinnishInvestmentCompany - fi-EUR.tsv +722 -0
  39. package/data/src/FinnishLimitedCompanyComplete - fi-EUR.tsv +1086 -0
  40. package/data/src/FinnishLimitedCompanyLite - en-EUR.tsv +97 -0
  41. package/data/src/FinnishLimitedCompanyLite - fi-EUR.tsv +99 -0
  42. package/data/src/Income Tree - Definitions.tsv +60 -0
  43. package/data/src/Tax Types - Definitions.tsv +11 -0
  44. package/package.json +51 -0
  45. package/src/CoinAPI/backend/index.ts +102 -0
  46. package/src/CoinbaseImport/backend/CoinbaseHandler.ts +35 -0
  47. package/src/CoinbaseImport/backend/index.ts +24 -0
  48. package/src/CoinbaseImport/backend/rules.json +64 -0
  49. package/src/DocumentCleaner/ui/index.tsx +165 -0
  50. package/src/Euro/ui/index.tsx +27 -0
  51. package/src/Finnish/ui/finnish.json +341 -0
  52. package/src/Finnish/ui/index.tsx +54 -0
  53. package/src/FinnishBalanceSheetReport/backend/balance-sheet-detailed-fi.tsv +215 -0
  54. package/src/FinnishBalanceSheetReport/backend/balance-sheet-fi.tsv +93 -0
  55. package/src/FinnishBalanceSheetReport/backend/index.ts +107 -0
  56. package/src/FinnishBalanceSheetReportInvestment/backend/balance-sheet-investment-detailed-fi.tsv +100 -0
  57. package/src/FinnishBalanceSheetReportInvestment/backend/balance-sheet-investment-fi.tsv +52 -0
  58. package/src/FinnishBalanceSheetReportInvestment/backend/index.ts +107 -0
  59. package/src/FinnishBalanceSheetReportLite/backend/balance-sheet-lite-en.tsv +21 -0
  60. package/src/FinnishBalanceSheetReportLite/backend/balance-sheet-lite-fi.tsv +21 -0
  61. package/src/FinnishBalanceSheetReportLite/backend/index.ts +121 -0
  62. package/src/FinnishIncomeStatementReport/backend/income-statement-detailed-fi.tsv +118 -0
  63. package/src/FinnishIncomeStatementReport/backend/income-statement-fi.tsv +45 -0
  64. package/src/FinnishIncomeStatementReport/backend/index.ts +212 -0
  65. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-detailed-fi.tsv +118 -0
  66. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-fi.tsv +45 -0
  67. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-investment-detailed-fi.tsv +96 -0
  68. package/src/FinnishIncomeStatementReportInvestment/backend/income-statement-investment-fi.tsv +39 -0
  69. package/src/FinnishIncomeStatementReportInvestment/backend/index.ts +212 -0
  70. package/src/FinnishIncomeStatementReportLite/backend/income-statement-lite-en.tsv +23 -0
  71. package/src/FinnishIncomeStatementReportLite/backend/income-statement-lite-fi.tsv +23 -0
  72. package/src/FinnishIncomeStatementReportLite/backend/index.ts +210 -0
  73. package/src/FinnishInvestmentCompany/backend/fi-EUR.tsv +722 -0
  74. package/src/FinnishInvestmentCompany/backend/index.ts +46 -0
  75. package/src/FinnishInvestmentCompany/ui/index.tsx +26 -0
  76. package/src/FinnishLimitedCompanyComplete/backend/fi-EUR.tsv +1086 -0
  77. package/src/FinnishLimitedCompanyComplete/backend/index.ts +46 -0
  78. package/src/FinnishLimitedCompanyComplete/ui/index.tsx +26 -0
  79. package/src/FinnishLimitedCompanyLite/backend/en-EUR.tsv +97 -0
  80. package/src/FinnishLimitedCompanyLite/backend/fi-EUR.tsv +99 -0
  81. package/src/FinnishLimitedCompanyLite/backend/index.ts +53 -0
  82. package/src/FinnishLimitedCompanyLite/ui/index.tsx +28 -0
  83. package/src/GitBackup/backend/index.ts +109 -0
  84. package/src/GitBackup/ui/index.tsx +127 -0
  85. package/src/IncomeAndExpenses/backend/assetCodes.json +126 -0
  86. package/src/IncomeAndExpenses/backend/expense.json +190 -0
  87. package/src/IncomeAndExpenses/backend/income.json +120 -0
  88. package/src/IncomeAndExpenses/backend/index.ts +354 -0
  89. package/src/IncomeAndExpenses/backend/taxTypes.json +12 -0
  90. package/src/JournalReport/backend/index.ts +157 -0
  91. package/src/KrakenImport/backend/KrakenHandler.ts +88 -0
  92. package/src/KrakenImport/backend/index.ts +24 -0
  93. package/src/KrakenImport/backend/rules.json +52 -0
  94. package/src/LedgerReport/backend/index.ts +161 -0
  95. package/src/LynxImport/backend/LynxHandler.ts +389 -0
  96. package/src/LynxImport/backend/index.ts +24 -0
  97. package/src/LynxImport/backend/rules.json +412 -0
  98. package/src/NordeaImport/backend/NordeaHandler.ts +44 -0
  99. package/src/NordeaImport/backend/index.ts +24 -0
  100. package/src/NordeaImport/backend/rules.json +4 -0
  101. package/src/NordnetImport/backend/NordnetHandler.ts +78 -0
  102. package/src/NordnetImport/backend/index.ts +24 -0
  103. package/src/NordnetImport/backend/rules.json +271 -0
  104. package/src/Rand/ui/index.tsx +27 -0
  105. package/src/RapidAPI/backend/index.ts +133 -0
  106. package/src/TITOImport/backend/TITOHandler.ts +268 -0
  107. package/src/TITOImport/backend/index.ts +24 -0
  108. package/src/TITOImport/backend/rules.json +4 -0
  109. package/src/TagEditor/ui/index.tsx +510 -0
  110. package/src/USDollar/ui/index.tsx +27 -0
  111. package/src/VAT/ui/index.tsx +572 -0
  112. package/src/VATFinland/backend/index.ts +22 -0
  113. package/src/VATFinland/backend/vat.json +23 -0
  114. package/tsconfig.json +13 -0
@@ -0,0 +1,412 @@
1
+ {
2
+ "rules": [
3
+ {
4
+ "name": "Deposit Correction",
5
+ "filter": "Type == 'Deposits & Withdrawals' and Subtype == 'Adjustment' and Amount >= 0",
6
+ "result": [
7
+ {
8
+ "reason": "'correction'",
9
+ "type": "'currency'",
10
+ "asset": "Currency",
11
+ "amount": "Amount",
12
+ "data": {
13
+ "text": "Description"
14
+ }
15
+ },
16
+ {
17
+ "reason": "'correction'",
18
+ "type": "'statement'",
19
+ "asset": "'INCOME_CORRECTION_DEPOSIT'",
20
+ "amount": "-Amount",
21
+ "data": {
22
+ "text": "Description"
23
+ }
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ "name": "Withdrawal Correction",
29
+ "filter": "Type == 'Deposits & Withdrawals' and Subtype == 'Adjustment' and Amount < 0",
30
+ "result": [
31
+ {
32
+ "reason": "'correction'",
33
+ "type": "'currency'",
34
+ "asset": "Currency",
35
+ "amount": "Amount",
36
+ "data": {
37
+ "text": "Description"
38
+ }
39
+ },
40
+ {
41
+ "reason": "'correction'",
42
+ "type": "'statement'",
43
+ "asset": "'EXPENSE_CORRECTION_WITHDRAWAL'",
44
+ "amount": "-Amount",
45
+ "data": {
46
+ "text": "Description"
47
+ }
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ "name": "Deposit",
53
+ "filter": "Type == 'Deposits & Withdrawals' and Amount > 0",
54
+ "result": [
55
+ {
56
+ "reason": "'deposit'",
57
+ "type": "'currency'",
58
+ "asset": "Currency",
59
+ "amount": "Amount",
60
+ "data": {
61
+ "text": "Description"
62
+ }
63
+ },
64
+ {
65
+ "reason": "'deposit'",
66
+ "type": "'external'",
67
+ "asset": "Currency",
68
+ "amount": "-Amount",
69
+ "data": {
70
+ "text": "Description"
71
+ }
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "name": "Withdrawal",
77
+ "filter": "Type == 'Deposits & Withdrawals' and Amount < 0",
78
+ "result": [
79
+ {
80
+ "reason": "'withdrawal'",
81
+ "type": "'currency'",
82
+ "asset": "Currency",
83
+ "amount": "Amount",
84
+ "data": {
85
+ "text": "Description"
86
+ }
87
+ },
88
+ {
89
+ "reason": "'withdrawal'",
90
+ "type": "'external'",
91
+ "asset": "Currency",
92
+ "amount": "-Amount",
93
+ "data": {
94
+ "text": "Description"
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "name": "Interest Expenses",
101
+ "filter": "Type == 'Interest'",
102
+ "result": [
103
+ {
104
+ "reason": "'expense'",
105
+ "type": "'currency'",
106
+ "asset": "Currency",
107
+ "amount": "Amount",
108
+ "data": {
109
+ "text": "Description",
110
+ "notes": ["Currency", "Month", "Year"]
111
+ }
112
+ },
113
+ {
114
+ "reason": "'expense'",
115
+ "type": "'statement'",
116
+ "asset": "'INTEREST_EXPENSE'",
117
+ "amount": "-Amount",
118
+ "data": {
119
+ "text": "Description",
120
+ "notes": ["Currency", "Month", "Year"]
121
+ }
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ "name": "Forex",
127
+ "filter": "Type == 'Trades' and str($('Asset Category')) == 'Forex'",
128
+ "result": [
129
+ {
130
+ "reason": "'forex'",
131
+ "type": "'currency'",
132
+ "asset": "config.currency",
133
+ "amount": "Quantity",
134
+ "data": {
135
+ "rates": "rates(Currency, 1 / $('T. Price'))",
136
+ "notes": ["join(config.currency, '⟷', round(1 / $('T. Price'), 3), 'x', Currency)"]
137
+ }
138
+ },
139
+ {
140
+ "reason": "'forex'",
141
+ "type": "'currency'",
142
+ "asset": "Currency",
143
+ "amount": "null",
144
+ "data": {
145
+ "rates": "rates(Currency, 1 / $('T. Price'))",
146
+ "notes": ["join(config.currency, '⟷', round(1 / $('T. Price'), 3), 'x', Currency)"]
147
+ }
148
+ },
149
+ {
150
+ "reason": "'fee'",
151
+ "type": "'currency'",
152
+ "asset": "config.currency",
153
+ "amount": "-$('Comm in Currency')",
154
+ "data": {
155
+ "rates": "rates(Currency, 1 / $('T. Price'))",
156
+ "notes": ["join(config.currency, '⟷', round(1 / $('T. Price'), 3), 'x', Currency)"]
157
+ }
158
+ },
159
+ {
160
+ "if": "cents($('MTM in Currency')) > 0",
161
+ "reason": "'income'",
162
+ "type": "'statement'",
163
+ "asset": "'TRADE_PROFIT_CURRENCY'",
164
+ "data": {
165
+ "currency": "config.currency",
166
+ "currencyValue": "-$('MTM in Currency') * 100",
167
+ "rates": "rates(Currency, 1 / $('T. Price'))",
168
+ "notes": ["join(config.currency, '⟷', round(1 / $('T. Price'), 3), 'x', Currency)"]
169
+ }
170
+ },
171
+ {
172
+ "if": "cents($('MTM in Currency')) < 0",
173
+ "reason": "'expense'",
174
+ "type": "'statement'",
175
+ "asset": "'TRADE_LOSS_CURRENCY'",
176
+ "data": {
177
+ "currency": "config.currency",
178
+ "currencyValue": "-$('MTM in Currency') * 100",
179
+ "rates": "rates(Currency, 1 / $('T. Price'))"
180
+ }
181
+ }
182
+ ]
183
+ },
184
+ {
185
+ "name": "Stock Buy",
186
+ "filter": "Type == 'Trades' and str($('Asset Category')) == 'Stocks' and Quantity > 0",
187
+ "result": [
188
+ {
189
+ "reason": "'trade'",
190
+ "type": "'currency'",
191
+ "asset": "Currency",
192
+ "amount": "Proceeds"
193
+ },
194
+ {
195
+ "reason": "'trade'",
196
+ "type": "'stock'",
197
+ "asset": "Symbol",
198
+ "amount": "Quantity"
199
+ },
200
+ {
201
+ "if": "cents($('Comm/Fee'))",
202
+ "reason": "'fee'",
203
+ "type": "'currency'",
204
+ "asset": "Currency",
205
+ "amount": "-$('Comm/Fee')"
206
+ }
207
+ ]
208
+ },
209
+ {
210
+ "name": "Stock Sell",
211
+ "filter": "Type == 'Trades' and str($('Asset Category')) == 'Stocks' and Quantity <= 0",
212
+ "result": [
213
+ {
214
+ "reason": "'trade'",
215
+ "type": "'currency'",
216
+ "asset": "Currency",
217
+ "amount": "Proceeds"
218
+ },
219
+ {
220
+ "reason": "'trade'",
221
+ "type": "'stock'",
222
+ "asset": "Symbol",
223
+ "amount": "Quantity"
224
+ },
225
+ {
226
+ "if": "cents($('Comm/Fee'))",
227
+ "reason": "'fee'",
228
+ "type": "'currency'",
229
+ "asset": "Currency",
230
+ "amount": "-$('Comm/Fee')"
231
+ }
232
+ ]
233
+ },
234
+ {
235
+ "name": "Withholding Tax Correction",
236
+ "filter": "Type == 'Withholding Tax' and Subtype == 'Adjustment'",
237
+ "result": [
238
+ {
239
+ "reason": "'tax'",
240
+ "type": "'statement'",
241
+ "asset": "'WITHHOLDING_TAX'",
242
+ "data": {
243
+ "text": "Description",
244
+ "currency": "Currency",
245
+ "currencyValue": "-Amount * 100",
246
+ "notes": ["Ticker", "Date"]
247
+ }
248
+ },
249
+ {
250
+ "reason": "'correction'",
251
+ "type": "'statement'",
252
+ "asset": "'INCOME_CORRECTION_WITHHOLDING_TAX'",
253
+ "data": {
254
+ "text": "Description",
255
+ "currency": "Currency",
256
+ "currencyValue": "Amount * 100",
257
+ "notes": ["Ticker", "Date"]
258
+ }
259
+ }
260
+ ]
261
+ },
262
+ {
263
+ "name": "Withholding Tax",
264
+ "filter": "Type == 'Withholding Tax'",
265
+ "result": [
266
+ {
267
+ "reason": "'tax'",
268
+ "type": "'statement'",
269
+ "asset": "'WITHHOLDING_TAX'",
270
+ "data": {
271
+ "text": "Description",
272
+ "currency": "Currency",
273
+ "currencyValue": "-Amount * 100"
274
+ }
275
+ }
276
+ ]
277
+ },
278
+ {
279
+ "name": "Dividend",
280
+ "filter": "Type == 'Dividends'",
281
+ "result": [
282
+ {
283
+ "reason": "'dividend'",
284
+ "type": "'currency'",
285
+ "asset": "Currency",
286
+ "amount": "null",
287
+ "data": {
288
+ "notes": ["PerAsset ? times(round(Amount / PerAsset), PerAsset) : ''"],
289
+ "text": "Description"
290
+ }
291
+ },
292
+ {
293
+ "reason": "'income'",
294
+ "type": "'statement'",
295
+ "asset": "'LISTED_CASH_DIVIDEND'",
296
+ "data": {
297
+ "notes": ["PerAsset ? times(round(Amount / PerAsset), PerAsset) : ''"],
298
+ "text": "Description",
299
+ "currency": "Currency",
300
+ "currencyValue": "-Amount * 100",
301
+ "asset": "Ticker"
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "name": "Splits",
308
+ "filter": "Type == 'Corporate Actions' and Action == 'Split'",
309
+ "result": [
310
+ {
311
+ "reason": "'trade'",
312
+ "type": "'stock'",
313
+ "asset": "Ticker",
314
+ "amount": "Quantity",
315
+ "value": "Value * 100",
316
+ "data": {
317
+ "text": "Description",
318
+ "notes": ["'split'"]
319
+ }
320
+ }
321
+ ]
322
+ },
323
+ {
324
+ "name": "Renamings",
325
+ "filter": "Type == 'Corporate Actions' and Action == 'Renaming'",
326
+ "result": [
327
+ {
328
+ "reason": "'trade'",
329
+ "type": "'stock'",
330
+ "asset": "Quantity < 0 ? Ticker : TickerInText",
331
+ "amount": "Quantity",
332
+ "value": "Value * 100",
333
+ "data": {
334
+ "text": "Description",
335
+ "notes": ["'renaming'"]
336
+ }
337
+ }
338
+ ]
339
+ },
340
+ {
341
+ "name": "Spinoffs",
342
+ "filter": "Type == 'Corporate Actions' and Action == 'Spinoff'",
343
+ "result": [
344
+ {
345
+ "reason": "'trade'",
346
+ "type": "'stock'",
347
+ "asset": "Ticker",
348
+ "amount": "0",
349
+ "value": "0",
350
+ "data": {
351
+ "text": "Description",
352
+ "currency": "Currency",
353
+ "notes": ["'spinoff'"]
354
+ }
355
+ },
356
+ {
357
+ "reason": "'trade'",
358
+ "type": "'stock'",
359
+ "asset": "TickerInText",
360
+ "amount": "Quantity",
361
+ "value": "Value",
362
+ "data": {
363
+ "text": "Description",
364
+ "currency": "Currency",
365
+ "notes": ["'spinoff'"]
366
+ }
367
+ }
368
+ ]
369
+ },
370
+ {
371
+ "name": "Merge actions",
372
+ "filter": "Type == 'Corporate Actions' and Action == 'Merged'",
373
+ "result": [
374
+ {
375
+ "reason": "'trade'",
376
+ "type": "'stock'",
377
+ "asset": "TickerInText",
378
+ "amount": "Quantity",
379
+ "value": "Value * 100",
380
+ "data": {
381
+ "text": "Description",
382
+ "notes": ["'converted'"]
383
+ }
384
+ }
385
+ ]
386
+ },
387
+ {
388
+ "name": "Inactivity Fees",
389
+ "filter": "Type == 'Fees'",
390
+ "result": [
391
+ {
392
+ "reason": "'expense'",
393
+ "type": "'currency'",
394
+ "asset": "Currency",
395
+ "amount": "Amount",
396
+ "data": {
397
+ "text": "ucfirst(lower(Description))"
398
+ }
399
+ },
400
+ {
401
+ "reason": "'expense'",
402
+ "type": "'statement'",
403
+ "asset": "'STOCK_BROKER_INACTIVITY_FEE'",
404
+ "amount": "null",
405
+ "data": {
406
+ "text": "ucfirst(lower(Description))"
407
+ }
408
+ }
409
+ ]
410
+ }
411
+ ]
412
+ }
@@ -0,0 +1,44 @@
1
+ import { NO_SEGMENT, SegmentId, TextFileLine } from '@dataplug/tasenor-common'
2
+ import { ProcessFile, TransactionImportHandler } from '@dataplug/tasenor-common-node'
3
+
4
+ /**
5
+ * Import implementation for Nordea CSV format.
6
+ */
7
+ export class NordeaHandler extends TransactionImportHandler {
8
+
9
+ constructor() {
10
+ super('NordeaImport')
11
+
12
+ this.importOptions = {
13
+ parser: 'csv',
14
+ numericFields: ['Määrä'],
15
+ requiredFields: ['Viesti'],
16
+ insignificantFields: ['Arvopäivä', 'Maksupäivä', 'Maksajan viite', 'Kirjauspäivä', 'Tapahtuma', 'Kuitti', 'BIC'],
17
+ textField: 'Viesti',
18
+ totalAmountField: 'Määrä',
19
+ csv: {
20
+ trimLines: true,
21
+ cutFromBeginning: 2,
22
+ useFirstLineHeadings: true,
23
+ columnSeparator: '\t'
24
+ }
25
+ }
26
+ }
27
+
28
+ canHandle(file: ProcessFile): boolean {
29
+ return file.firstLineMatch(/^Tilinumero\tFI\d+$/) && file.thirdLineMatch(/^Kirjauspäivä\tArvopäivä\tMaksupäivä\tMäärä\tSaaja\/Maksaja\tTilinumero\tBIC\tTapahtuma\tViite\tMaksajan viite\tViesti\tKortinnumero\tKuitti$/)
30
+ }
31
+
32
+ segmentId(line: TextFileLine): SegmentId | typeof NO_SEGMENT {
33
+ return line.columns ? this.hash(line) : NO_SEGMENT
34
+ }
35
+
36
+ time(line: TextFileLine): Date | undefined {
37
+ const match = /(\d+)\.(\d+)\.(\d+)/.exec(line.columns['Maksupäivä'])
38
+ if (match) {
39
+ const stamp = match[3] + '-' + match[2] + '-' + match[1] + 'T12:00:00.000Z'
40
+ return new Date(stamp)
41
+ }
42
+ return undefined
43
+ }
44
+ }
@@ -0,0 +1,24 @@
1
+ import { ImportPlugin } from '@dataplug/tasenor-common-node'
2
+ import { PluginCode, Version } from '@dataplug/tasenor-common'
3
+ import { NordeaHandler } from './NordeaHandler'
4
+
5
+ class NordeaImportPlugin extends ImportPlugin {
6
+
7
+ constructor() {
8
+ super(new NordeaHandler())
9
+
10
+ this.code = 'NordeaImport' as PluginCode
11
+ this.title = 'Import for Nordea'
12
+ this.version = '1.0.27' as Version
13
+ this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M5 6.99h3V14h2V6.99h3L9 3zM14 10v7.01h-3L15 21l4-3.99h-3V10z"/></svg>'
14
+ this.releaseDate = '2022-10-24'
15
+ this.use = 'backend'
16
+ this.type = 'import'
17
+ this.description = 'Import plugin for importing transaction data in CSV format provided by Nordea bank.'
18
+
19
+ this.languages = this.getLanguages()
20
+ }
21
+
22
+ }
23
+
24
+ export default NordeaImportPlugin
@@ -0,0 +1,4 @@
1
+ {
2
+ "rules": [
3
+ ]
4
+ }
@@ -0,0 +1,78 @@
1
+ import { ImportStateText, NO_SEGMENT, SegmentId, TextFileLine } from '@dataplug/tasenor-common'
2
+ import { NotImplemented, Process, ProcessFile, TransactionImportHandler } from '@dataplug/tasenor-common-node'
3
+
4
+ /**
5
+ * Import implementation for Coinbase CSV format.
6
+ */
7
+ export class NordnetHandler extends TransactionImportHandler {
8
+
9
+ constructor() {
10
+ super('NordnetImport')
11
+ this.importOptions = {
12
+ parser: 'csv',
13
+ numericFields: ['Summa', 'Kurssi', 'Määrä', 'Kokonaiskulut'],
14
+ requiredFields: [],
15
+ textField: 'Tapahtumatyyppi',
16
+ totalAmountField: 'Summa',
17
+ csv: { useFirstLineHeadings: true, columnSeparator: '\t' }
18
+ }
19
+ }
20
+
21
+ canHandle(file: ProcessFile): boolean {
22
+ return file.firstLineMatch(/^\s*Id\tKirjausp.iv.\sKauppap.iv.\sMaksup.iv./)
23
+ }
24
+
25
+ segmentId(line: TextFileLine): SegmentId | typeof NO_SEGMENT {
26
+ if (['LAINAKORKO'].includes(line.columns.Tapahtumatyyppi)) {
27
+ return super.segmentId(line, ['Salkku', 'Summa', 'Saldo', 'Maksupäivä', 'Kauppapäivä', 'Kirjauspäivä', 'Valuutta', 'Vaihtokurssi'])
28
+ }
29
+ if (line.columns.Vahvistusnumero) {
30
+ return line.columns.Vahvistusnumero
31
+ }
32
+ throw new NotImplemented(`Importer does not yet recognize ${JSON.stringify(line.columns)}.`)
33
+ // return NO_SEGMENT
34
+ }
35
+
36
+ time(line: TextFileLine): Date | undefined {
37
+ return line.columns['Kirjauspäivä'] ? new Date(line.columns['Kirjauspäivä']) : undefined
38
+ }
39
+
40
+ /**
41
+ * Convert typical punctuations to parseable number and return numeric value.
42
+ * @param s
43
+ */
44
+ num(str: string): number {
45
+ return parseFloat(str.replace(',', '.').replace(/ /g, ''))
46
+ }
47
+
48
+ async segmentation(process: Process, state: ImportStateText<'initial'>, files: ProcessFile[]): Promise<ImportStateText<'segmented'>> {
49
+
50
+ const result = await this.segmentationCSV(process, state, files)
51
+
52
+ // Fix missing currencies.
53
+ for (const fileName of Object.keys(result.files)) {
54
+ const file = result.files[fileName]
55
+ for (let n = 0; n < file.lines.length; n++) {
56
+ const { columns } = file.lines[n]
57
+
58
+ if (columns.Valuutta === '') {
59
+ if (columns.Valuuttakurssi === '1' || columns.Vaihtokurssi === '1') {
60
+ columns.Valuutta = process.config.currency as string
61
+ }
62
+ if (columns.Tapahtumatyyppi === 'OSINKO') {
63
+ const match = / ([A-Z]{3})\/OSAKE$/.exec(columns.Tapahtumateksti)
64
+ if (match) {
65
+ columns.Valuutta = match[1]
66
+ }
67
+ }
68
+ }
69
+
70
+ if (columns.Kokonaiskulut && !columns['Kokonaiskulut Valuutta']) {
71
+ columns['Kokonaiskulut Valuutta'] = columns.Valuutta
72
+ }
73
+ }
74
+ }
75
+
76
+ return this.segmentationPostProcess(result)
77
+ }
78
+ }
@@ -0,0 +1,24 @@
1
+ import { ImportPlugin } from '@dataplug/tasenor-common-node'
2
+ import { PluginCode, Version } from '@dataplug/tasenor-common'
3
+ import { NordnetHandler } from './NordnetHandler'
4
+
5
+ class NordnetImportPlugin extends ImportPlugin {
6
+
7
+ constructor() {
8
+ super(new NordnetHandler())
9
+
10
+ this.code = 'NordnetImport' as PluginCode
11
+ this.title = 'Import for Nordnet'
12
+ this.version = '1.0.48' as Version
13
+ this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M5 6.99h3V14h2V6.99h3L9 3zM14 10v7.01h-3L15 21l4-3.99h-3V10z"/></svg>'
14
+ this.releaseDate = '2023-05-31'
15
+ this.use = 'backend'
16
+ this.type = 'import'
17
+ this.description = 'Import plugin for importing transaction data in CSV format provided by Nordnet.'
18
+
19
+ this.languages = this.getLanguages()
20
+ }
21
+
22
+ }
23
+
24
+ export default NordnetImportPlugin