@tasenor/common-plugins 1.13.14 → 1.13.15

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @tasenor/common-plugins@1.13.13 build /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
2
+ > @tasenor/common-plugins@1.13.14 build /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
3
3
  > rm -fr dist && tsc
4
4
 
@@ -1,8 +1,8 @@
1
1
 
2
- > @tasenor/common-plugins@1.13.13 ci /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
2
+ > @tasenor/common-plugins@1.13.14 ci /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
3
3
  > pnpm run lint
4
4
 
5
5
 
6
- > @tasenor/common-plugins@1.13.13 lint /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
6
+ > @tasenor/common-plugins@1.13.14 lint /home/ci/tasenor-qa/tasenor-bookkeeper/packages/tasenor-common-plugins
7
7
  > eslint 'src/**/*.{ts,tsx}' 'data/**/*.mjs'
8
8
 
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ToolPlugin } from '@tasenor/common-ui';
3
2
  import { ShortDate, ID } from '@tasenor/common';
4
3
  declare class DocumentCleaner extends ToolPlugin {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ToolPlugin } from '@tasenor/common-ui';
3
2
  declare class GitBackup extends ToolPlugin {
4
3
  busy: boolean;
@@ -0,0 +1,12 @@
1
+ import { DirectoryPath, NO_SEGMENT, SegmentId, TextFileLine } from '@tasenor/common';
2
+ import { ProcessFile, TransactionImportHandler } from '@tasenor/common-node';
3
+ /**
4
+ * Import implementation for S-Pankki CSV format.
5
+ */
6
+ export declare class SPankkiHandler extends TransactionImportHandler {
7
+ constructor();
8
+ get path(): DirectoryPath;
9
+ canHandle(file: ProcessFile): boolean;
10
+ segmentId(line: TextFileLine): SegmentId | typeof NO_SEGMENT;
11
+ time(line: TextFileLine): Date | undefined;
12
+ }
@@ -0,0 +1,42 @@
1
+ import { NO_SEGMENT } from '@tasenor/common';
2
+ import { TransactionImportHandler } from '@tasenor/common-node';
3
+ /**
4
+ * Import implementation for S-Pankki CSV format.
5
+ */
6
+ export class SPankkiHandler extends TransactionImportHandler {
7
+ constructor() {
8
+ super('SPankkiImport');
9
+ this.importOptions = {
10
+ parser: 'csv',
11
+ numericFields: ['Summa'],
12
+ requiredFields: ['Saajan nimi', 'Maksupäivä'],
13
+ insignificantFields: ['Saajan BIC-tunnus', 'Arkistointitunnus', 'Kirjauspäivä'],
14
+ textField: 'Viesti',
15
+ totalAmountField: 'Summa',
16
+ csv: {
17
+ trimLines: true,
18
+ cutFromBeginning: 0,
19
+ useFirstLineHeadings: true,
20
+ columnSeparator: ';'
21
+ }
22
+ };
23
+ }
24
+ get path() {
25
+ return __dirname;
26
+ }
27
+ canHandle(file) {
28
+ return file.firstLineMatch(/^Kirjauspäivä;Maksupäivä;Summa;Tapahtumalaji;Maksaja;Saajan nimi;Saajan tilinumero;Saajan BIC-tunnus;Viitenumero;Viesti;Arkistointitunnus$/);
29
+ }
30
+ segmentId(line) {
31
+ return line.columns ? this.hash(line) : NO_SEGMENT;
32
+ }
33
+ time(line) {
34
+ const match = /(\d+)\.(\d+)\.(\d+)/.exec(line.columns['Maksupäivä']);
35
+ if (match) {
36
+ const stamp = match[3] + '-' + match[2] + '-' + match[1] + 'T12:00:00.000Z';
37
+ return new Date(stamp);
38
+ }
39
+ return undefined;
40
+ }
41
+ }
42
+ //# sourceMappingURL=SPankkiHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SPankkiHandler.js","sourceRoot":"","sources":["../../../src/SPankkiImport/backend/SPankkiHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAA2B,MAAM,iBAAiB,CAAA;AACpF,O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CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import { ImportPlugin } from '@tasenor/common-node';
2
+ declare class SPankkiImportPlugin extends ImportPlugin {
3
+ constructor();
4
+ }
5
+ export default SPankkiImportPlugin;
@@ -0,0 +1,18 @@
1
+ import { ImportPlugin } from '@tasenor/common-node';
2
+ import { SPankkiHandler } from './SPankkiHandler';
3
+ class SPankkiImportPlugin extends ImportPlugin {
4
+ constructor() {
5
+ super(new SPankkiHandler());
6
+ this.code = 'SPankkiImport';
7
+ this.title = 'Import for S-Pankki';
8
+ this.version = '1.0.0';
9
+ 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>';
10
+ this.releaseDate = '2024-05-14';
11
+ this.use = 'backend';
12
+ this.type = 'import';
13
+ this.description = 'Import plugin for importing transaction data in CSV format provided by S-Pankki bank.';
14
+ this.languages = this.getLanguages();
15
+ }
16
+ }
17
+ export default SPankkiImportPlugin;
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SPankkiImport/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,mBAAoB,SAAQ,YAAY;IAE5C;QACE,KAAK,CAAC,IAAI,cAAc,EAAE,CAAC,CAAA;QAE3B,IAAI,CAAC,IAAI,GAAG,eAA6B,CAAA;QACzC,IAAI,CAAC,KAAK,GAAG,qBAAqB,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAkB,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,6NAA6N,CAAA;QACzO,IAAI,CAAC,WAAW,GAAG,YAAY,CAAA;QAC/B,IAAI,CAAC,GAAG,GAAG,SAAS,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,uFAAuF,CAAA;QAE1G,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;IACtC,CAAC;CAEF;AAED,eAAe,mBAAmB,CAAA"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ToolPlugin } from '@tasenor/common-ui';
3
2
  import { DatabaseModel, TagModel } from '@tasenor/common';
4
3
  /**
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ToolPlugin } from '@tasenor/common-ui';
3
2
  declare class VAT extends ToolPlugin {
4
3
  showVatTable: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tasenor/common-plugins",
3
- "version": "1.13.14",
3
+ "version": "1.13.15",
4
4
  "description": "Shared common plugins of Tasenor project",
5
5
  "repository": "git@github.com:dataplugoy/tasenor-bookkeeper.git",
6
6
  "author": "Tommi Ronkainen <tommi.ronkainen@gmail.com>",
@@ -13,9 +13,9 @@
13
13
  "dayjs": "1.10.8",
14
14
  "sprintf-js": "^1.1.2",
15
15
  "tsx": "^4.7.0",
16
- "@tasenor/common": "1.13.14",
17
- "@tasenor/common-node": "1.13.14",
18
- "@tasenor/common-ui": "1.13.14"
16
+ "@tasenor/common": "1.13.15",
17
+ "@tasenor/common-node": "1.13.15",
18
+ "@tasenor/common-ui": "1.13.15"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@mui/icons-material": "^5.14.1",
@@ -31,8 +31,8 @@
31
31
  "react-i18next": "^14.0.5",
32
32
  "react-router-dom": "^6.14.1",
33
33
  "typescript": "^5.1.6",
34
- "@tasenor/config": "1.13.14",
35
- "eslint-config-tasenor": "0.0.0"
34
+ "eslint-config-tasenor": "0.0.0",
35
+ "@tasenor/config": "1.13.15"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@mui/icons-material": "^5.14.1",
@@ -0,0 +1,48 @@
1
+ import { DirectoryPath, NO_SEGMENT, SegmentId, TextFileLine } from '@tasenor/common'
2
+ import { ProcessFile, TransactionImportHandler } from '@tasenor/common-node'
3
+
4
+ /**
5
+ * Import implementation for S-Pankki CSV format.
6
+ */
7
+ export class SPankkiHandler extends TransactionImportHandler {
8
+
9
+ constructor() {
10
+ super('SPankkiImport')
11
+
12
+ this.importOptions = {
13
+ parser: 'csv',
14
+ numericFields: ['Summa'],
15
+ requiredFields: ['Saajan nimi', 'Maksupäivä'],
16
+ insignificantFields: ['Saajan BIC-tunnus', 'Arkistointitunnus', 'Kirjauspäivä'],
17
+ textField: 'Viesti',
18
+ totalAmountField: 'Summa',
19
+ csv: {
20
+ trimLines: true,
21
+ cutFromBeginning: 0,
22
+ useFirstLineHeadings: true,
23
+ columnSeparator: ';'
24
+ }
25
+ }
26
+ }
27
+
28
+ get path(): DirectoryPath {
29
+ return __dirname as DirectoryPath
30
+ }
31
+
32
+ canHandle(file: ProcessFile): boolean {
33
+ return file.firstLineMatch(/^Kirjauspäivä;Maksupäivä;Summa;Tapahtumalaji;Maksaja;Saajan nimi;Saajan tilinumero;Saajan BIC-tunnus;Viitenumero;Viesti;Arkistointitunnus$/)
34
+ }
35
+
36
+ segmentId(line: TextFileLine): SegmentId | typeof NO_SEGMENT {
37
+ return line.columns ? this.hash(line) : NO_SEGMENT
38
+ }
39
+
40
+ time(line: TextFileLine): Date | undefined {
41
+ const match = /(\d+)\.(\d+)\.(\d+)/.exec(line.columns['Maksupäivä'])
42
+ if (match) {
43
+ const stamp = match[3] + '-' + match[2] + '-' + match[1] + 'T12:00:00.000Z'
44
+ return new Date(stamp)
45
+ }
46
+ return undefined
47
+ }
48
+ }
@@ -0,0 +1,24 @@
1
+ import { ImportPlugin } from '@tasenor/common-node'
2
+ import { PluginCode, Version } from '@tasenor/common'
3
+ import { SPankkiHandler } from './SPankkiHandler'
4
+
5
+ class SPankkiImportPlugin extends ImportPlugin {
6
+
7
+ constructor() {
8
+ super(new SPankkiHandler())
9
+
10
+ this.code = 'SPankkiImport' as PluginCode
11
+ this.title = 'Import for S-Pankki'
12
+ this.version = '1.0.0' 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 = '2024-05-14'
15
+ this.use = 'backend'
16
+ this.type = 'import'
17
+ this.description = 'Import plugin for importing transaction data in CSV format provided by S-Pankki bank.'
18
+
19
+ this.languages = this.getLanguages()
20
+ }
21
+
22
+ }
23
+
24
+ export default SPankkiImportPlugin
@@ -0,0 +1,4 @@
1
+ {
2
+ "rules": [
3
+ ]
4
+ }